Skip to content

Commit bde58c0

Browse files
committed
added readme about adding an api call to the sdk
1 parent 1cdbdaa commit bde58c0

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,35 @@ npm link ../../keeperapi
3939
```
4040

4141
from your client folder
42+
43+
How to add an api command to this sdk:
44+
45+
Prerequisites:
46+
- Have the keeperapp-protobuf repo alongside this repo (eg: /home/keeper-sdk-javascript and /home/keeperapp-protobuf)
47+
- Make sure that the protobuf that you want is in the branch of the keeperapp-protobuf project you have loaded
48+
- In the update-proto:cjs and update-proto:es6 commands in keeperapi/package.json, ensure that the proto files from keeperapp-protobuf that you want are listed there
49+
50+
Steps:
51+
1. Navigate to the keeperapi folder in your terminal (eg: /home/keeper-sdk-javascript/keeperapi)
52+
2. Run command ```npm run update-proto:cjs``` then command ```npm run update-proto:es6```
53+
3. Open the file ```keeperapi/src/restMessages.ts```
54+
4. There are 4 messages we handle with each of their differences:
55+
a. createInMessage - This expects data to be sent
56+
b. createOutMessage - This expects data to be received
57+
c. createMessage - This expects data to be sent and received
58+
d. createActionMessage - This expects no data sent or received, just make the call
59+
60+
5. In the file, you will see various examples of each of those 4 messages being used. Their typical layout is as follows:
61+
a. createInMessage: export const name = (data: requestType): RestInMessage<requestType> =>
62+
createInMessage(data, 'api/call', requestType)
63+
b. createOutMessage: export const name = (): RestOutMessage<responseType> =>
64+
createOutMessage('api/call', responseType)
65+
c. createMessage: export const name = (data: requestType): RestMessage<requestType, responseType> =>
66+
createMessage(data, 'api/call', requestType, responseType)
67+
d. createActionMessage: export const name = (): RestActionMessage => createActionMessage('api/call')
68+
69+
6. From the examples, here are the variables and where you can get them:
70+
- name: This is from the api url mostly. This can be named whatever as long as it makes sense
71+
- requestType: This will be given from the loaded protobuf
72+
- responseType: Same with requestType
73+
- 'api/call': This is the path of the api url in string form. This needs to be a string

0 commit comments

Comments
 (0)