1.0.0-beta8 • Published 6 years ago

@parkmobile/client v1.0.0-beta8

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

parkmobile-client

A JavaScript client for ParkMobile's API.

Installation

yarn add @parkmobile/client

Getting Started

Create a Client

Create a new Parkmobile Client by passing a version, sourceAppKey, and optional cache

import ParkmobileClient, { VERSIONS } from '@parkmobile/client';

const client = Client({
  cache: undefined,
  version: VERSIONS.production,
  sourceAppKey: 'parkmobileWeb',
});

Subscribe to a Query

Create a query from one of the Parkmobile Models, like a Zone.

import { Zone } from '@parkmobile/client';
const startDate = new Date();
const endDate = new Date(startDate.getHours() + 3);
const centerPoint = {
  latitude: 33.775591,
  longitude: -84.392190,
};
const upperPoint = {
  latitude: 33.798561,
  longitude: -84.411599,
};
const lowerPoint = {
  latitude: 33.729035,
  longitude: -84.342527,
};

client.subscribe(Zone.queries.searchReservations({
  endDate,
  startDate,
  centerPoint,
  lowerPoint,
  upperPoint,
}), ({ data, error, pending }) => {
  if (pending) {
    return drawLoadingIndicator();
  }

  if (error) {
    return drawError(error);
  }

  return drawMarkers(data);
});