Skip to content

Commit 63ed823

Browse files
authored
feat: schedule.getFacilities (#37)
1 parent c8bd788 commit 63ed823

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

docs/schedule.md

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [updateEvent](#updateevent)
77
- [deleteEvent](#deleteevent)
88
- [searchAvailableTimes](#searchavailabletimes)
9+
- [getFacilities](#getfacilities)
910

1011
## Overview
1112

@@ -228,3 +229,23 @@ See the example response in the `Reference`.
228229
#### Reference
229230

230231
- https://developer.cybozu.io/hc/ja/articles/360018417771#step1
232+
233+
### getFacilities
234+
235+
Get facilities by specifying conditions.
236+
237+
#### Parameters
238+
239+
| Name | Type | Required | Description |
240+
| ------ | :----: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
241+
| limit | number | | The number of facilities to retrieve.<br />Must be between `1` and `1000`.<br />If nothing is specified, it will default to `100`. |
242+
| offset | Number | | The number of retrievals that will be skipped.<br />Must be between `0` and `2147483647`. If nothing is specified, it will default to `0`. |
243+
| name | String | | The facility name. |
244+
245+
#### Returns
246+
247+
See the example response in the `Reference`.
248+
249+
#### Reference
250+
251+
- https://developer.cybozu.io/hc/ja/articles/360017764211#step1

src/client/ScheduleClient.ts

+18
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,22 @@ export class ScheduleClient {
203203
const path = buildPath({ endpointName: "schedule/searchAvailableTimes" });
204204
return this.client.post(path, params);
205205
}
206+
207+
public getFacilities(params: {
208+
limit?: number;
209+
offset?: number;
210+
name?: string;
211+
}): Promise<{
212+
facilities: Array<{
213+
id: string;
214+
name: string;
215+
code: string;
216+
notes: string;
217+
facilityGroup: string;
218+
}>;
219+
hasNext: boolean;
220+
}> {
221+
const path = buildPath({ endpointName: "schedule/facilities" });
222+
return this.client.get(path, params);
223+
}
206224
}

src/client/__tests__/ScheduleClient.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,24 @@ describe("ScheduleClient", () => {
284284
expect(mockClient.getLogs()[0].params).toEqual(params);
285285
});
286286
});
287+
288+
describe("getFacilities", () => {
289+
const params = {
290+
limit: 100,
291+
offset: 0,
292+
name: "Facility",
293+
};
294+
beforeEach(async () => {
295+
await scheduleClient.getFacilities(params);
296+
});
297+
it("should pass the path to the http client", () => {
298+
expect(mockClient.getLogs()[0].path).toBe("/api/v1/schedule/facilities");
299+
});
300+
it("should send a get request", () => {
301+
expect(mockClient.getLogs()[0].method).toBe("get");
302+
});
303+
it("should pass params as a param to the http client", () => {
304+
expect(mockClient.getLogs()[0].params).toEqual(params);
305+
});
306+
});
287307
});

0 commit comments

Comments
 (0)