Skip to content

Commit 8b03c1d

Browse files
committed
feat: schedule.getFacilityGroups
1 parent 63ed823 commit 8b03c1d

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

docs/schedule.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Get facilities by specifying conditions.
238238

239239
| Name | Type | Required | Description |
240240
| ------ | :----: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
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`. |
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`. |
242242
| 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`. |
243243
| name | String | | The facility name. |
244244

@@ -249,3 +249,22 @@ See the example response in the `Reference`.
249249
#### Reference
250250

251251
- https://developer.cybozu.io/hc/ja/articles/360017764211#step1
252+
253+
### getFacilityGroups
254+
255+
Get facility groups by specifying conditions.
256+
257+
#### Parameters
258+
259+
| Name | Type | Required | Description |
260+
| ------ | :----: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
261+
| limit | Number | | The number of facility groups to retrieve.<br />Must be between `1` and `1000`.<br />If nothing is specified, it will default to `100`. |
262+
| 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`. |
263+
264+
#### Returns
265+
266+
See the example response in the `Reference`.
267+
268+
#### Reference
269+
270+
- https://developer.cybozu.io/hc/ja/articles/360017481472#step1

src/client/ScheduleClient.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class ScheduleClient {
204204
return this.client.post(path, params);
205205
}
206206

207-
public getFacilities(params: {
207+
public getFacilities(params?: {
208208
limit?: number;
209209
offset?: number;
210210
name?: string;
@@ -219,6 +219,26 @@ export class ScheduleClient {
219219
hasNext: boolean;
220220
}> {
221221
const path = buildPath({ endpointName: "schedule/facilities" });
222-
return this.client.get(path, params);
222+
return this.client.get(path, params ?? {});
223+
}
224+
225+
public getFacilityGroups(params?: {
226+
limit?: number;
227+
offset?: number;
228+
}): Promise<{
229+
facilityGroups: Array<{
230+
id: string;
231+
name: string;
232+
code: string;
233+
notes: string;
234+
parentFacilityGroup: string | null;
235+
childFacilityGroups: Array<{
236+
id: string;
237+
}>;
238+
}>;
239+
hasNext: boolean;
240+
}> {
241+
const path = buildPath({ endpointName: "schedule/facilityGroups" });
242+
return this.client.get(path, params ?? {});
223243
}
224244
}

src/client/__tests__/ScheduleClient.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,25 @@ describe("ScheduleClient", () => {
304304
expect(mockClient.getLogs()[0].params).toEqual(params);
305305
});
306306
});
307+
308+
describe("getFacilityGroups", () => {
309+
const params = {
310+
limit: 100,
311+
offset: 0,
312+
};
313+
beforeEach(async () => {
314+
await scheduleClient.getFacilityGroups(params);
315+
});
316+
it("should pass the path to the http client", () => {
317+
expect(mockClient.getLogs()[0].path).toBe(
318+
"/api/v1/schedule/facilityGroups"
319+
);
320+
});
321+
it("should send a get request", () => {
322+
expect(mockClient.getLogs()[0].method).toBe("get");
323+
});
324+
it("should pass params as a param to the http client", () => {
325+
expect(mockClient.getLogs()[0].params).toEqual(params);
326+
});
327+
});
307328
});

0 commit comments

Comments
 (0)