-
Notifications
You must be signed in to change notification settings - Fork 1
/
locations.ts
97 lines (76 loc) · 2.39 KB
/
locations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Node, PlatformClient } from "./platformClient";
import { Maybe, Scalars } from "./graph";
import * as Graph from "./graph";
import { getLocationsQuery } from "./locations/graph";
class Address extends Node<Graph.Address> {
city: Maybe<Scalars["String"]>;
line1: Maybe<Scalars["String"]>;
line2: Maybe<Scalars["String"]>;
state: Maybe<Scalars["String"]>;
province: Maybe<Scalars["String"]>;
zip: Maybe<Scalars["String"]>;
country: Maybe<Scalars["String"]>;
}
class Location extends Node<Graph.Location> {
/** The location's address */
address: Graph.Address;
/** Whether or not the location allows booking online */
allowOnlineBooking: Scalars["Boolean"];
/** Whether or not the location allows rescheduling online */
allowOnlineRescheduling: Scalars["Boolean"];
/** The location's arrival instructions */
arrivalInstructions: Scalars["String"];
/** The location's logo */
avatar: Maybe<Scalars["String"]>;
/** Name of the business */
businessName: Scalars["String"];
/** The ID of an object */
id: Scalars["ID"];
/** Location external id */
externalId: Maybe<Scalars["String"]>;
insertedAt: Scalars["DateTime"];
/** The location's name */
name: Scalars["String"];
/** The location's name */
phoneNumber: Maybe<Scalars["String"]>;
/** The location's timezone */
tz: Scalars["Tz"];
/**
* Indicates that the location is a remote location, and that appointments for
* this location are carried out remotely.
*/
isRemote: Scalars["Boolean"];
coordinates: Maybe<{
latitude: Scalars["Float"];
longitude: Scalars["Float"];
}>;
social: Graph.LocationSocialAccounts;
updatedAt: Scalars["DateTime"];
/**
* @internal
*/
constructor(platformClient: PlatformClient, location: Graph.Location) {
super(platformClient, location);
this.address = new Address(platformClient, location.address);
}
}
class Locations {
/**
* @internal
*/
constructor(private platformClient: PlatformClient) {}
/**
* List locations for the business
*
* @async
* @returns Promise containing a list of Locations
* @todo Pagination
*/
async list(): Promise<Array<Location>> {
const response = await this.platformClient.request(getLocationsQuery);
return response.locations.edges.map(
(edge: Graph.LocationEdge) => new Location(this.platformClient, edge.node)
);
}
}
export { Locations, Location };