File tree 5 files changed +59
-13
lines changed
5 files changed +59
-13
lines changed Original file line number Diff line number Diff line change 1
1
# Presence
2
2
3
3
- [ getPresenceByUserID] ( #getpresencebyuserid )
4
+ - [ getPresenceByUserCode] ( #getpresencebyusercode )
4
5
5
6
## Overview
6
7
@@ -38,3 +39,21 @@ See the example response in the `Reference`.
38
39
#### Reference
39
40
40
41
- https://developer.cybozu.io/hc/ja/articles/360026939891#step1
42
+
43
+ ### getPresenceByUserCode
44
+
45
+ Get the presence information specified by the code of the user.
46
+
47
+ #### Parameters
48
+
49
+ | Name | Type | Required | Description |
50
+ | ---- | :----: | :------: | --------------------- |
51
+ | code | String | Yes | The code of the user. |
52
+
53
+ #### Returns
54
+
55
+ See the example response in the ` Reference ` .
56
+
57
+ #### Reference
58
+
59
+ - https://developer.cybozu.io/hc/ja/articles/360026939891#step2
Original file line number Diff line number Diff line change 1
1
import { HttpClient } from "../http" ;
2
+ import { Presence } from "./types" ;
2
3
import { buildPath } from "../url" ;
3
4
4
5
export class PresenceClient {
@@ -10,21 +11,15 @@ export class PresenceClient {
10
11
11
12
public getPresenceByUserID ( params : {
12
13
id : string | number ;
13
- } ) : Promise < {
14
- user : {
15
- id : string ;
16
- name : string ;
17
- code : string ;
18
- } ;
19
- updatedAt : string ;
20
- notes : string ;
21
- status : {
22
- name : string ;
23
- code : string ;
24
- } ;
25
- } > {
14
+ } ) : Promise < Presence > {
26
15
const { id } = params ;
27
16
const path = buildPath ( { endpointName : `presence/users/${ id } ` } ) ;
28
17
return this . client . get ( path , { } ) ;
29
18
}
19
+
20
+ public getPresenceByUserCode ( params : { code : string } ) : Promise < Presence > {
21
+ const { code } = params ;
22
+ const path = buildPath ( { endpointName : `presence/users/code/${ code } ` } ) ;
23
+ return this . client . get ( path , { } ) ;
24
+ }
30
25
}
Original file line number Diff line number Diff line change @@ -35,4 +35,22 @@ describe("PresenceClient", () => {
35
35
expect ( mockClient . getLogs ( ) [ 0 ] . params ) . toEqual ( { } ) ;
36
36
} ) ;
37
37
} ) ;
38
+
39
+ describe ( "getPresenceByUserCode" , ( ) => {
40
+ const params = { code : "cybozu" } ;
41
+ beforeEach ( async ( ) => {
42
+ await presenceClient . getPresenceByUserCode ( params ) ;
43
+ } ) ;
44
+ it ( "should pass the path to the http client" , ( ) => {
45
+ expect ( mockClient . getLogs ( ) [ 0 ] . path ) . toBe (
46
+ "/api/v1/presence/users/code/cybozu"
47
+ ) ;
48
+ } ) ;
49
+ it ( "should send a get request" , ( ) => {
50
+ expect ( mockClient . getLogs ( ) [ 0 ] . method ) . toBe ( "get" ) ;
51
+ } ) ;
52
+ it ( "should pass an empty object as a param to the http client" , ( ) => {
53
+ expect ( mockClient . getLogs ( ) [ 0 ] . params ) . toEqual ( { } ) ;
54
+ } ) ;
55
+ } ) ;
38
56
} ) ;
Original file line number Diff line number Diff line change 1
1
export * from "./schedule" ;
2
2
export * from "./workflow" ;
3
+ export * from "./presence" ;
Original file line number Diff line number Diff line change
1
+ export type Presence = {
2
+ user : {
3
+ id : string ;
4
+ name : string ;
5
+ code : string ;
6
+ } ;
7
+ updatedAt : string ;
8
+ notes : string ;
9
+ status : {
10
+ name : string ;
11
+ code : string ;
12
+ } ;
13
+ } ;
You can’t perform that action at this time.
0 commit comments