File tree 3 files changed +64
-0
lines changed
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 3
3
- [ getPresenceByUserID] ( #getpresencebyuserid )
4
4
- [ getPresenceByUserCode] ( #getpresencebyusercode )
5
5
- [ updatePresenceByUserID] ( #updatepresencebyuserid )
6
+ - [ updatePresenceByUserCode] ( #updatepresencebyusercode )
6
7
7
8
## Overview
8
9
@@ -79,3 +80,24 @@ See the example response in the `Reference`.
79
80
#### Reference
80
81
81
82
- https://developer.cybozu.io/hc/ja/articles/360026939911#step1
83
+
84
+ ### updatePresenceByUserCode
85
+
86
+ Update the presence information specified by the user code.
87
+
88
+ #### Parameters
89
+
90
+ | Name | Type | Required | Description |
91
+ | ----------- | :----: | :------: | -------------------------------------------- |
92
+ | code | String | Yes | The user code. |
93
+ | status | Object | | An object containing data of the status. |
94
+ | status.code | String | | The status code of the presence information. |
95
+ | notes | String | | The memo. |
96
+
97
+ #### Returns
98
+
99
+ See the example response in the ` Reference ` .
100
+
101
+ #### Reference
102
+
103
+ - https://developer.cybozu.io/hc/ja/articles/360026939911#step2
Original file line number Diff line number Diff line change @@ -35,4 +35,17 @@ export class PresenceClient {
35
35
const data = ( rest as unknown ) as Record < string , unknown > ;
36
36
return this . client . patch ( path , data ) ;
37
37
}
38
+
39
+ public updatePresenceByUserCode ( params : {
40
+ code : string ;
41
+ status ?: {
42
+ code ?: string ;
43
+ } ;
44
+ notes ?: string ;
45
+ } ) : Promise < Presence > {
46
+ const { code, ...rest } = params ;
47
+ const path = buildPath ( { endpointName : `presence/users/code/${ code } ` } ) ;
48
+ const data = ( rest as unknown ) as Record < string , unknown > ;
49
+ return this . client . patch ( path , data ) ;
50
+ }
38
51
}
Original file line number Diff line number Diff line change @@ -80,4 +80,33 @@ describe("PresenceClient", () => {
80
80
} ) ;
81
81
} ) ;
82
82
} ) ;
83
+
84
+ describe ( "updatePresenceByUserCode" , ( ) => {
85
+ const params = {
86
+ code : "cybozu" ,
87
+ status : {
88
+ code : "attend" ,
89
+ } ,
90
+ notes : "This is presence note." ,
91
+ } ;
92
+ beforeEach ( async ( ) => {
93
+ await presenceClient . updatePresenceByUserCode ( params ) ;
94
+ } ) ;
95
+ it ( "should pass the path to the http client" , ( ) => {
96
+ expect ( mockClient . getLogs ( ) [ 0 ] . path ) . toBe (
97
+ "/api/v1/presence/users/code/cybozu"
98
+ ) ;
99
+ } ) ;
100
+ it ( "should send a patch request" , ( ) => {
101
+ expect ( mockClient . getLogs ( ) [ 0 ] . method ) . toBe ( "patch" ) ;
102
+ } ) ;
103
+ it ( "should pass status and notes as a param to the http client" , ( ) => {
104
+ expect ( mockClient . getLogs ( ) [ 0 ] . params ) . toEqual ( {
105
+ status : {
106
+ code : "attend" ,
107
+ } ,
108
+ notes : "This is presence note." ,
109
+ } ) ;
110
+ } ) ;
111
+ } ) ;
83
112
} ) ;
You can’t perform that action at this time.
0 commit comments