diff --git a/docs/schedule.md b/docs/schedule.md index 077dbeb..800fd9f 100644 --- a/docs/schedule.md +++ b/docs/schedule.md @@ -8,6 +8,7 @@ - [searchAvailableTimes](#searchavailabletimes) - [getFacilities](#getfacilities) - [getFacilityGroups](#getfacilitygroups) +- [getFacilitiesByFacilityGroupID](#getfacilitiesbyfacilitygroupid) ## Overview @@ -213,7 +214,7 @@ Search available times of users, organizations and facilities. | timeRanges | Array\ | Yes | The list of search time ranges. | | timeRanges[].start | String | Yes | The start datetime of the time range. The format is RFC3339. (e.g. `2020-01-01T00:00:00Z`) | | timeRanges[].end | String | Yes | The end datetime of the time range. The format is RFC3339. (e.g. `2020-01-01T00:00:00Z`) | -| timeInterval | number | Yes | The search time interval. | +| timeInterval | Number | Yes | The search time interval. | | attendees | Array\ | Conditionally
Required | The list of attendees. Required if `facilities` is not specified. | | attendees[].type | String | Yes | The attendee type. Possible values are `ORGANIZATION`, `USER`. | | attendees[].id | Number or String | Conditionally
Required | The ID of the attendee. Required if `attendees[].code` is not specified. | @@ -269,3 +270,23 @@ See the example response in the `Reference`. #### Reference - https://developer.cybozu.io/hc/ja/articles/360017481472#step1 + +### getFacilitiesByFacilityGroupID + +Get facilities belonging to the specified facility group. + +#### Parameters + +| Name | Type | Required | Description | +| ------ | :--------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ | +| id | Number or String | Yes | The facility group ID. | +| limit | Number | | The number of facilities to retrieve.
Must be between `1` and `1000`.
If nothing is specified, it will default to `100`. | +| offset | Number | | The number of retrievals that will be skipped.
Must be between `0` and `2147483647`. If nothing is specified, it will default to `0`. | + +#### Returns + +See the example response in the `Reference`. + +#### Reference + +- https://developer.cybozu.io/hc/ja/articles/360017481472#step2 diff --git a/src/client/ScheduleClient.ts b/src/client/ScheduleClient.ts index b0b777e..27591ac 100644 --- a/src/client/ScheduleClient.ts +++ b/src/client/ScheduleClient.ts @@ -241,4 +241,24 @@ export class ScheduleClient { const path = buildPath({ endpointName: "schedule/facilityGroups" }); return this.client.get(path, params ?? {}); } + + public getFacilitiesByFacilityGroupID(params: { + id: string | number; + limit?: number; + offset?: number; + }): Promise<{ + facilities: Array<{ + id: string; + name: string; + code: string; + notes: string; + facilityGroup: string; + }>; + }> { + const { id, ...rest } = params; + const path = buildPath({ + endpointName: `schedule/facilityGroups/${id}/facilities`, + }); + return this.client.get(path, rest as Record); + } } diff --git a/src/client/__tests__/ScheduleClient.test.ts b/src/client/__tests__/ScheduleClient.test.ts index bc89872..397dea0 100644 --- a/src/client/__tests__/ScheduleClient.test.ts +++ b/src/client/__tests__/ScheduleClient.test.ts @@ -325,4 +325,29 @@ describe("ScheduleClient", () => { expect(mockClient.getLogs()[0].params).toEqual(params); }); }); + + describe("getFacilitiesByFacilityGroupID", () => { + const params = { + id: 1, + limit: 100, + offset: 0, + }; + beforeEach(async () => { + await scheduleClient.getFacilitiesByFacilityGroupID(params); + }); + it("should pass the path to the http client", () => { + expect(mockClient.getLogs()[0].path).toBe( + "/api/v1/schedule/facilityGroups/1/facilities" + ); + }); + it("should send a get request", () => { + expect(mockClient.getLogs()[0].method).toBe("get"); + }); + it("should pass limit and offset as a param to the http client", () => { + expect(mockClient.getLogs()[0].params).toEqual({ + limit: 100, + offset: 0, + }); + }); + }); });