Skip to content

Commit 665699b

Browse files
committed
Merge branch 'release/1.35.0'
2 parents 2460f2f + 06c6f92 commit 665699b

File tree

13 files changed

+473
-40
lines changed

13 files changed

+473
-40
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,41 @@ channelApeClient.locations().getSLA(locationId)
826826
});
827827
```
828828

829+
### Update location SLA information
830+
```typescript
831+
const LocationSLAUpdate: LocationSLA = {
832+
createdAt: '2018-04-24T14:02:34.703Z',
833+
fulfillmentSLAHours: '1',
834+
locationId: '1',
835+
operatingDays: [
836+
{
837+
createdAt: '2018-04-24T14:02:34.703Z',
838+
day: 'T',
839+
end: '10:00',
840+
fulfillmentCutoffTime: '09:30',
841+
id: '23',
842+
open: '08:00',
843+
updatedAt: '2018-04-24T14:02:34.703Z'
844+
},
845+
{
846+
createdAt: '2018-04-24T14:02:34.703Z',
847+
day: 'W',
848+
end: '10:00',
849+
fulfillmentCutoffTime: '09:50',
850+
id: '24',
851+
open: '08:00',
852+
updatedAt: '2018-04-24T14:02:34.703Z'
853+
}
854+
],
855+
updatedAt: '2018-04-24T14:02:34.703Z'
856+
};
857+
const locationId: string = '1';
858+
channelApeClient.locations().updateSla(locationId, sla)
859+
.then((locationSLA: LocationSLA) => {
860+
// Do what you need with the locations update
861+
});
862+
```
863+
829864
### Get location closures
830865
```typescript
831866
const locationId: string = '1';
@@ -835,6 +870,24 @@ channelApeClient.locations().getClosures(locationId)
835870
});
836871
```
837872

873+
### Update location closures
874+
```typescript
875+
const closesDates: LocationClosureRequest = {
876+
closedDays: [
877+
'2021/02/01',
878+
'2021/03/01',
879+
'2021/04/01',
880+
'2021/05/01',
881+
'2021/06/01'
882+
]
883+
};
884+
const locationId: string = '1';
885+
channelApeClient.locations().updateClosures(locationId, closedDates)
886+
.then((locationClosures: LocationClosedDay[]) => {
887+
// Do what you need with the locations closures update
888+
});
889+
```
890+
838891
### Steps
839892

840893
#### Get step by ID
@@ -853,4 +906,11 @@ channelapeClient.plays().get(playId)
853906
.then((play: Play) => {
854907
// do what you need to do with play data here
855908
});
909+
```
910+
#### Get All Plays
911+
```typescript
912+
channelapeClient.plays().get()
913+
.then((plays: Play[]) => {
914+
// do what you need to do with all play data here
915+
});
856916
```

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "channelape-sdk",
3-
"version": "1.34.1",
3+
"version": "1.35.0",
44
"description": "A client for interacting with ChannelApe's API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ export { default as InvitationResponse } from './businesses/model/InvitationResp
102102
export { default as SupplierCreateRequest } from './suppliers/model/SupplierCreateRequest';
103103
export { default as PlaySettings } from './suppliers/model/PlaySettings';
104104
export { default as Play } from './plays/service/PlaysService';
105+
export { default as LocationClosureRequest } from './locations/model/LocationClosureRequest';
106+
export { default as LocationSLAUpdateRequest } from './locations/model/LocationSLAUpdateRequest';
107+
export { default as LocationSLAOperatingDayUpdateRequest }
108+
from './locations/model/LocationSLAOperatingDayUpdateRequest';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default interface LocationClosureRequest {
2+
closedDays: string[];
3+
}

src/locations/model/LocationSLA.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ChannelApeApiError from '../../../src/model/ChannelApeApiError';
12
import LocationSLAOperatingDay from './LocationSLAOperatingDay';
23

34
export default interface LocationSLA {
@@ -6,4 +7,5 @@ export default interface LocationSLA {
67
locationId: string;
78
operatingDays: LocationSLAOperatingDay[];
89
updatedAt: Date;
10+
errors: ChannelApeApiError[];
911
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default interface LocationSLAOperatingDayUpdateRequest {
2+
day: string;
3+
end: string;
4+
fulfillmentCutoffTime: string;
5+
open: string;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import LocationSLAOperatingDayUpdateRequest from './LocationSLAOperatingDayUpdateRequest';
2+
3+
export default interface LocationSLAUpdateRequest {
4+
fulfillmentSLAHours?: string;
5+
operatingDays: LocationSLAOperatingDayUpdateRequest[];
6+
}

src/locations/service/LocationsService.ts

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import LocationUpdateRequest from './../model/LocationUpdateRequest';
1212
import LocationSLA from '../model/LocationSLA';
1313
import LocationClosureResponse from '../model/LocationClosureResponse';
1414
import LocationClosedDay from '../model/LocationClosedDay';
15+
import LocationSLAOperatingDay from '../model/LocationSLAOperatingDay';
16+
import LocationClosureRequest from '../model/LocationClosureRequest';
17+
import LocationSLAUpdateRequest from '../model/LocationSLAUpdateRequest';
1518

1619
export default class LocationsService extends RestService {
1720

@@ -44,7 +47,22 @@ export default class LocationsService extends RestService {
4447
});
4548
return deferred.promise as any;
4649
}
47-
50+
public updateSla(locationId: string, sla: LocationSLAUpdateRequest): Promise<LocationSLA> {
51+
return new Promise((resolve) => {
52+
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}/sla`;
53+
const options = {
54+
data: sla
55+
};
56+
this.client.put(requestUrl, options, (error, response, body) => {
57+
const requestResponse: RequestCallbackParams = {
58+
error,
59+
response,
60+
body
61+
};
62+
resolve(this.mapLocationSLAResponse(requestUrl, requestResponse, this.EXPECTED_GET_OR_UPDATE_STATUS));
63+
});
64+
});
65+
}
4866
public get(locationId: string): Promise<Location> {
4967
const deferred = Q.defer<Location>();
5068
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}`;
@@ -68,13 +86,34 @@ export default class LocationsService extends RestService {
6886
}
6987

7088
public getSla(locationId: string): Promise<LocationSLA> {
71-
const deferred = Q.defer<LocationSLA>();
72-
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}/sla`;
73-
this.client.get(requestUrl, {}, (error, response, body) =>
74-
this.mapResponseToPromise(requestUrl, deferred, error, response, body, this.EXPECTED_GET_OR_UPDATE_STATUS));
75-
return deferred.promise as any;
89+
return new Promise((resolve) => {
90+
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}/sla`;
91+
this.client.get(requestUrl, {}, (error, response, body) => {
92+
const requestResponse: RequestCallbackParams = {
93+
error,
94+
response,
95+
body
96+
};
97+
resolve(this.mapLocationSLAResponse(requestUrl, requestResponse, this.EXPECTED_GET_OR_UPDATE_STATUS));
98+
});
99+
});
100+
}
101+
public updateClosures(locationId: string, closedDates: LocationClosureRequest): Promise<LocationClosedDay []> {
102+
return new Promise((resolve) => {
103+
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}/closures`;
104+
const options = {
105+
data: closedDates
106+
};
107+
this.client.put(requestUrl, options, (error, response, body) => {
108+
const requestResponse: RequestCallbackParams = {
109+
error,
110+
response,
111+
body
112+
};
113+
resolve(this.mapLocationClosuresResponse(requestUrl, requestResponse, this.EXPECTED_GET_OR_UPDATE_STATUS));
114+
});
115+
});
76116
}
77-
78117
public getClosures(locationId: string): Promise<LocationClosedDay[]> {
79118
return new Promise((resolve) => {
80119
const requestUrl = `/${Version.V1}${Resource.LOCATIONS}/${locationId}/closures`;
@@ -108,7 +147,25 @@ export default class LocationsService extends RestService {
108147
}
109148
});
110149
}
111-
150+
private mapLocationSLAResponse(
151+
requestUrl: string,
152+
requestCallbackParams: RequestCallbackParams,
153+
expectedStatusCode: number
154+
): Promise<LocationSLA> {
155+
return new Promise((resolve, reject) => {
156+
if (requestCallbackParams.error) {
157+
reject(requestCallbackParams.error);
158+
} else if (requestCallbackParams.response.status === expectedStatusCode) {
159+
const data: LocationSLA = requestCallbackParams.body as LocationSLA;
160+
resolve(this.formatLocationSLA(data));
161+
} else {
162+
const channelApeErrorResponse =
163+
GenerateApiError(requestUrl, requestCallbackParams.response, requestCallbackParams.body,
164+
this.EXPECTED_GET_OR_UPDATE_STATUS);
165+
reject(channelApeErrorResponse);
166+
}
167+
});
168+
}
112169
private mapLocationClosuresResponse(
113170
requestUrl: string,
114171
requestCallbackParams: RequestCallbackParams,
@@ -140,4 +197,16 @@ export default class LocationsService extends RestService {
140197
locationClosedDay.updatedAt = new Date(locationClosedDay.updatedAt);
141198
return locationClosedDay as LocationClosedDay;
142199
}
200+
private formatLocationSLA(locationSla: LocationSLA): LocationSLA {
201+
locationSla.createdAt = new Date(locationSla.createdAt);
202+
locationSla.updatedAt = new Date(locationSla.updatedAt);
203+
locationSla.operatingDays = locationSla.operatingDays.map(operatingDay =>
204+
this.locationSLAOperatingDay(operatingDay));
205+
return locationSla as LocationSLA;
206+
}
207+
private locationSLAOperatingDay(locationSLAOperatingDay: LocationSLAOperatingDay): LocationSLAOperatingDay {
208+
locationSLAOperatingDay.createdAt = new Date(locationSLAOperatingDay.createdAt);
209+
locationSLAOperatingDay.updatedAt = new Date(locationSLAOperatingDay.updatedAt);
210+
return locationSLAOperatingDay as LocationSLAOperatingDay;
211+
}
143212
}

src/plays/model/Play.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export default interface Play {
44
createdAt: Date;
55
id: string;
66
name: string;
7-
steps: Step[];
7+
steps?: Step[];
88
updatedAt: Date;
99
}

0 commit comments

Comments
 (0)