File tree 3 files changed +60
-0
lines changed
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1
1
# Base
2
2
3
3
- [ getUsers] ( #getusers )
4
+ - [ getOrganizations] ( #getorganizations )
4
5
5
6
## Overview
6
7
@@ -40,3 +41,23 @@ See the example response in the `Reference`.
40
41
#### Reference
41
42
42
43
- https://developer.cybozu.io/hc/ja/articles/360018124651#step1
44
+
45
+ ### getOrganizations
46
+
47
+ Get organizations specified by conditions.
48
+
49
+ #### Parameters
50
+
51
+ | Name | Type | Required | Description |
52
+ | ------ | :----: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------ |
53
+ | limit | Number | | The number of organizations to retrieve.<br />Must be between ` 1 ` and ` 1000 ` .<br />If nothing is specified, it will default to ` 100 ` . |
54
+ | 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 ` . |
55
+ | name | String | | The name for searching organizations. |
56
+
57
+ #### Returns
58
+
59
+ See the example response in the ` Reference ` .
60
+
61
+ #### Reference
62
+
63
+ - https://developer.cybozu.io/hc/ja/articles/360017843172#step1
Original file line number Diff line number Diff line change @@ -18,8 +18,27 @@ export class BaseClient {
18
18
name : string ;
19
19
code : string ;
20
20
} > ;
21
+ hasNext : boolean ;
21
22
} > {
22
23
const path = buildPath ( { endpointName : "base/users" } ) ;
23
24
return this . client . get ( path , params ?? { } ) ;
24
25
}
26
+
27
+ public getOrganizations ( params ?: {
28
+ limit ?: number ;
29
+ offset ?: number ;
30
+ name ?: string ;
31
+ } ) : Promise < {
32
+ organizations : Array < {
33
+ id : string ;
34
+ name : string ;
35
+ code : string ;
36
+ parentOrganization : string ;
37
+ childOrganizations : Array < { id : string } > ;
38
+ } > ;
39
+ hasNext : boolean ;
40
+ } > {
41
+ const path = buildPath ( { endpointName : "base/organizations" } ) ;
42
+ return this . client . get ( path , params ?? { } ) ;
43
+ }
25
44
}
Original file line number Diff line number Diff line change @@ -39,4 +39,24 @@ describe("BaseClient", () => {
39
39
expect ( mockClient . getLogs ( ) [ 0 ] . params ) . toEqual ( params ) ;
40
40
} ) ;
41
41
} ) ;
42
+
43
+ describe ( "getOrganizations" , ( ) => {
44
+ const params = {
45
+ limit : 100 ,
46
+ offset : 0 ,
47
+ name : "test" ,
48
+ } ;
49
+ beforeEach ( async ( ) => {
50
+ await baseClient . getOrganizations ( params ) ;
51
+ } ) ;
52
+ it ( "should pass the path to the http client" , ( ) => {
53
+ expect ( mockClient . getLogs ( ) [ 0 ] . path ) . toBe ( "/api/v1/base/organizations" ) ;
54
+ } ) ;
55
+ it ( "should send a get request" , ( ) => {
56
+ expect ( mockClient . getLogs ( ) [ 0 ] . method ) . toBe ( "get" ) ;
57
+ } ) ;
58
+ it ( "should pass params as a param to the http client" , ( ) => {
59
+ expect ( mockClient . getLogs ( ) [ 0 ] . params ) . toEqual ( params ) ;
60
+ } ) ;
61
+ } ) ;
42
62
} ) ;
You can’t perform that action at this time.
0 commit comments