Skip to content

Commit

Permalink
feat: schedule.getFacilities (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
miyajan authored Jul 8, 2020
1 parent c8bd788 commit 63ed823
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [updateEvent](#updateevent)
- [deleteEvent](#deleteevent)
- [searchAvailableTimes](#searchavailabletimes)
- [getFacilities](#getfacilities)

## Overview

Expand Down Expand Up @@ -228,3 +229,23 @@ See the example response in the `Reference`.
#### Reference

- https://developer.cybozu.io/hc/ja/articles/360018417771#step1

### getFacilities

Get facilities by specifying conditions.

#### Parameters

| Name | Type | Required | Description |
| ------ | :----: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
| 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`. |
| 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`. |
| name | String | | The facility name. |

#### Returns

See the example response in the `Reference`.

#### Reference

- https://developer.cybozu.io/hc/ja/articles/360017764211#step1
18 changes: 18 additions & 0 deletions src/client/ScheduleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,22 @@ export class ScheduleClient {
const path = buildPath({ endpointName: "schedule/searchAvailableTimes" });
return this.client.post(path, params);
}

public getFacilities(params: {
limit?: number;
offset?: number;
name?: string;
}): Promise<{
facilities: Array<{
id: string;
name: string;
code: string;
notes: string;
facilityGroup: string;
}>;
hasNext: boolean;
}> {
const path = buildPath({ endpointName: "schedule/facilities" });
return this.client.get(path, params);
}
}
20 changes: 20 additions & 0 deletions src/client/__tests__/ScheduleClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,24 @@ describe("ScheduleClient", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});

describe("getFacilities", () => {
const params = {
limit: 100,
offset: 0,
name: "Facility",
};
beforeEach(async () => {
await scheduleClient.getFacilities(params);
});
it("should pass the path to the http client", () => {
expect(mockClient.getLogs()[0].path).toBe("/api/v1/schedule/facilities");
});
it("should send a get request", () => {
expect(mockClient.getLogs()[0].method).toBe("get");
});
it("should pass params as a param to the http client", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});
});

0 comments on commit 63ed823

Please sign in to comment.