1
1
# sipgate Integration Bridge Framework
2
2
3
- This is the sipgate Integration Bridge framework to integrate sipgate apps with external services. It provides a unified way to connect apps to any provider of external data management, like contacts or calendar events.
3
+ This is the sipgate Integration Bridge framework to integrate sipgate apps with external services. It provides a unified
4
+ way to connect apps to any provider of external data management, like contacts or calendar events.
5
+
6
+ ## Developing locally
7
+
8
+ To test your changes to the integration-bridge framework locally, follow these steps:
9
+
10
+ * Run ` npm run dev ` in sipgate-integration-bridge repo
11
+ * Run ` npm link @sipgate/integration-bridge ` in * -integration-bridge-repo
12
+ * Add the following to your ` tsconfig.json ` :
13
+ ``` json
14
+ {
15
+ "compilerOptions" : {
16
+ "paths" : {
17
+ "@sipgate/integration-bridge" : [" node_modules/@sipgate/integration-bridge/src" ]
18
+ }
19
+ }
20
+ }
21
+ ```
4
22
5
23
## Publishing a version
6
24
To publish a new framework version, simply create a new tag and push it:
7
25
```
26
+
8
27
npm version <minor|patch>
9
28
git push --follow-tags
29
+
10
30
```
11
31
This will automatically publish the package in the npm registry via the CI pipeline.
12
32
@@ -31,27 +51,27 @@ The minimum adapter implements the `getContacts` method:
31
51
const bridge = require (" @sipgate/integration-bridge" );
32
52
const fetch = require (" node-fetch" );
33
53
34
- const { ServerError } = bridge;
54
+ const {ServerError } = bridge;
35
55
36
56
const adapter = {
37
- getContacts: async ({ apiKey, apiUrl }) => {
38
- // Fetch contacts using apiUrl and apiKey
39
- const response = await fetch (` ${ apiUrl} /api/contacts` , {
40
- headers: { Authorization: ` Bearer ${ apiKey} ` },
41
- });
42
-
43
- if (response .status === 401 ) {
44
- throw new ServerError (401 , " Unauthorized" );
45
- }
46
-
47
- if (! response .ok ) {
48
- throw new ServerError (500 , " Could not fetch contacts" );
49
- }
50
-
51
- // TODO: Convert contacts to the structure below
52
- const contacts = await response .json ();
53
- return contacts;
54
- },
57
+ getContacts: async ({apiKey, apiUrl}) => {
58
+ // Fetch contacts using apiUrl and apiKey
59
+ const response = await fetch (` ${ apiUrl} /api/contacts` , {
60
+ headers: {Authorization: ` Bearer ${ apiKey} ` },
61
+ });
62
+
63
+ if (response .status === 401 ) {
64
+ throw new ServerError (401 , " Unauthorized" );
65
+ }
66
+
67
+ if (! response .ok ) {
68
+ throw new ServerError (500 , " Could not fetch contacts" );
69
+ }
70
+
71
+ // TODO: Convert contacts to the structure below
72
+ const contacts = await response .json ();
73
+ return contacts;
74
+ },
55
75
};
56
76
57
77
bridge .start (adapter);
@@ -61,21 +81,37 @@ Contacts are accepted in this format:
61
81
62
82
``` js
63
83
{
64
- id: " abc123" ,
65
- // Provide either the full name or first and last name, not both
66
- name: null , // or null
67
- firstName: " Walter" , // or null
68
- lastName: " Geoffrey" , // or null
69
- organization: " Rocket Science Inc." , // or null
70
- contactUrl: " http://myapp.com/contacts/abc123" , // or null
71
- avatarUrl: " http://myapp.com/avatar/abc123.png" , // or null
72
- email
: " [email protected] " ,
// or null
73
- phoneNumbers: [
74
- {
75
- label: " MOBILE" , // or "WORK" or "HOME"
76
- phoneNumber: " +4915799912345"
77
- }
78
- ]
84
+ id: " abc123" ,
85
+ // Provide either the full name or first and last name, not both
86
+ name
87
+ :
88
+ null , // or null
89
+ firstName
90
+ :
91
+ " Walter" , // or null
92
+ lastName
93
+ :
94
+ " Geoffrey" , // or null
95
+ organization
96
+ :
97
+ " Rocket Science Inc." , // or null
98
+ contactUrl
99
+ :
100
+ " http://myapp.com/contacts/abc123" , // or null
101
+ avatarUrl
102
+ :
103
+ " http://myapp.com/avatar/abc123.png" , // or null
104
+ email
105
+ :
106
+
107
+ phoneNumbers
108
+ :
109
+ [
110
+ {
111
+ label: " MOBILE" , // or "WORK" or "HOME"
112
+ phoneNumber: " +4915799912345"
113
+ }
114
+ ]
79
115
}
80
116
```
81
117
@@ -87,4 +123,5 @@ The sipgate Integration Bridge supports configuration through the following envi
87
123
- ` OAUTH2_IDENTIFIER ` : Name of the Integration to identify credentials in uppercase e. g. "MY_CRM"
88
124
- ` REDIS_URL ` : URL of a Redis instance to cache responses, otherwise memory cache will be used
89
125
- ` CACHE_DISABLED ` : Disable caching
90
- - ` CACHE_REFRESH_INTERVAL ` : Time a contact in cache is not refreshed (in seconds), only used if redis or memory cache is active
126
+ - ` CACHE_REFRESH_INTERVAL ` : Time a contact in cache is not refreshed (in seconds), only used if redis or memory cache is
127
+ active
0 commit comments