nexmo_api_specification 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d58ff0a85fd19af6b0a974e150263243b7a19a1
4
+ data.tar.gz: f2f92f490dc1910d2c08c01a46e8ba362ea3f7c1
5
+ SHA512:
6
+ metadata.gz: 818c25089d9e658542d40190679b6b96f4ee1e3db2f2c2dd529bb2e23eeea9dc06e6eb5b072bbd5726141867e23545c01301b52625ed00fea682f91b9bf0a85d
7
+ data.tar.gz: 0325d43b77283bcd34d423f3d43b4608754408a5696a41963c3d2d1715fd93ecb75ed9730382e2bcf2dcfcc8d9f981fdaf35afca8d8cfc48b243e64aadaa39f4
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nexmo_api_specification.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Nexmo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # API Specifications
2
+
3
+ Provides Open API Specification 3 definitions for Nexmo APIs.
4
+
5
+ These definitions provide a single point of truth that can be used end-to-end can we used to:
6
+
7
+ - **Planning** Shared during product discussions for planning API functionality
8
+ - **Implementation** Inform engineering during development
9
+ - **Testing** As the basis for testing or mocking API endpoints
10
+ - **Documentation** For producing thorough and interactive documentation
11
+ - **Tooling** To generate server stubs and client SDKs.
12
+
13
+ ## Definitions
14
+
15
+ | API | Definition owner | Contributors |
16
+ | --- | ---------------- | ------------ |
17
+ | SMS | - | Adam Butler |
18
+ | Voice | - | - |
19
+ | Verify | - | - |
20
+ | Number Insight | - | - |
21
+ | Conversation | Neil Stratford | Adam Butler |
22
+ | Olympus | Hugh Hopkins |
23
+ | Account | - | - |
24
+ | Messages | - | - |
25
+ | Messages | - | - |
26
+ | Numbers | - | - |
27
+ | Application | - | - |
28
+ | Conversion | - | - |
29
+
30
+ ## Resources
31
+
32
+ - [What is OpenAPI?](https://swagger.io/docs/specification/about/)
33
+ - [A Visual Guide to What's New in Swagger 3.0](https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/)
34
+ - [OAS3 Documentation](https://swagger.io/docs/specification/basic-structure/)
35
+ - [OAS3 Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md)
36
+ - [OAS3 Examples](https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v3.0)
37
+
38
+ ## Tools
39
+
40
+ - [Swagger Editor](http://editor.swagger.io/) - Can be used to edit OAS3 definitions, provides live reloading Swagger UI.
41
+ - [Swagger 2.0 to OAS3 converter](https://openapi-converter.herokuapp.com/) - Unofficial converter that can be used to convert existing Swagger 2.0 definitions to OAS3 definitions.
42
+ - [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) - A template-driven engine to generate documentation, API clients and server stubs in different languages by parsing OAS3 definitions.
43
+ - [Swagger Parser](https://github.com/swagger-api/swagger-parser) - Standalone library for parsing OAS3 definitions from Java
44
+ - [Nexmo Developer](https://github.com/Nexmo/nexmo-developer) - Nexmo Developer has it's own OAS3 definition parser and API reference UI.
45
+
46
+ ## Contributing
47
+
48
+ Contributions are welcome, please follow [GitHub Flow](https://guides.github.com/introduction/flow/index.html)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/conversation.yml ADDED
@@ -0,0 +1,369 @@
1
+ openapi: 3.0.0
2
+ servers:
3
+ - url: 'https://api.nexmo.com/beta'
4
+ info:
5
+ version: 1.0.0
6
+ title: Conversation API
7
+ description: >-
8
+ The Nexmo Conversation API enables you to build conversation features where communication can take place across multiple mediums including IP Messaging, PSTN Voice, SMS and WebRTC Audio and Video. The context of the conversations is maintained though each communication event taking place within a conversation, no matter the medium.
9
+ security:
10
+ - bearerAuth: []
11
+ paths:
12
+ /conversations:
13
+ post:
14
+ security:
15
+ - bearerAuth: []
16
+ x-group: conversation
17
+ summary: Create a conversation
18
+ parameters:
19
+ - name: name
20
+ in: query
21
+ description: Conversation name, must be unique but will auto-generated if you do not provide it.
22
+ required: false
23
+ schema:
24
+ type: string
25
+ - name: display_name
26
+ in: query
27
+ description: A personal name of your choosing.
28
+ required: false
29
+ schema:
30
+ type: string
31
+ responses:
32
+ '200':
33
+ description: conversations response
34
+ content:
35
+ application/json:
36
+ schema:
37
+ type: object
38
+ $ref: '#/components/schemas/Conversation'
39
+ '401':
40
+ $ref: '#/components/responses/UnauthorizedError'
41
+ /conversations/{id}:
42
+ get:
43
+ x-group: conversation
44
+ summary: Retrieve a conversation
45
+ parameters:
46
+ - name: id
47
+ in: path
48
+ description: ID of the conversation
49
+ required: true
50
+ schema:
51
+ type: string
52
+ responses:
53
+ '200':
54
+ description: conversations response
55
+ content:
56
+ application/json:
57
+ schema:
58
+ type: array
59
+ items:
60
+ $ref: '#/components/schemas/ConversationFull'
61
+ /conversations/{id}/members:
62
+ get:
63
+ x-group: member
64
+ summary: Retrieve members of a conversation
65
+ parameters:
66
+ - name: id
67
+ in: path
68
+ description: ID of the conversation
69
+ required: true
70
+ schema:
71
+ type: string
72
+ responses:
73
+ '200':
74
+ description: members response
75
+ content:
76
+ application/json:
77
+ schema:
78
+ type: array
79
+ items:
80
+ $ref: '#/components/schemas/Member'
81
+ post:
82
+ x-group: member
83
+ summary: Add a user to a conversation
84
+ parameters:
85
+ - name: id
86
+ in: path
87
+ description: tags to filter by
88
+ required: true
89
+ schema:
90
+ type: string
91
+ responses:
92
+ '200':
93
+ description: members response
94
+ content:
95
+ application/json:
96
+ schema:
97
+ type: object
98
+ $ref: '#/components/schemas/MemberFull'
99
+ /users:
100
+ get:
101
+ x-group: user
102
+ summary: Retrieve all users
103
+ responses:
104
+ '200':
105
+ description: users response
106
+ content:
107
+ application/json:
108
+ schema:
109
+ type: array
110
+ items:
111
+ $ref: '#/components/schemas/UserFull'
112
+ post:
113
+ x-group: user
114
+ summary: Create a user
115
+ parameters:
116
+ - name: name
117
+ in: query
118
+ description: The users name
119
+ example: Dillon
120
+ required: false
121
+ schema:
122
+ type: string
123
+ responses:
124
+ '200':
125
+ description: users response
126
+ content:
127
+ application/json:
128
+ schema:
129
+ $ref: '#/components/schemas/User'
130
+ /users/{id}:
131
+ get:
132
+ x-group: user
133
+ summary: Retrive a user
134
+ parameters:
135
+ - name: id
136
+ in: path
137
+ description: The users ID
138
+ required: true
139
+ schema:
140
+ type: string
141
+ responses:
142
+ '200':
143
+ description: user response
144
+ content:
145
+ application/json:
146
+ schema:
147
+ $ref: '#/components/schemas/UserShow'
148
+ components:
149
+ securitySchemes:
150
+ bearerAuth:
151
+ type: http
152
+ scheme: bearer
153
+ bearerFormat: JWT
154
+ responses:
155
+ UnauthorizedError:
156
+ description: Access token is missing or invalid
157
+ content:
158
+ application/json:
159
+ schema:
160
+ type: object
161
+ required:
162
+ - code
163
+ - description
164
+ properties:
165
+ code:
166
+ type: 'string'
167
+ example: 'system:error:invalid-token'
168
+ description:
169
+ type: string
170
+ example: 'the token was rejected'
171
+ schemas:
172
+ CreatedTimestamp:
173
+ properties:
174
+ created:
175
+ example: "2020-01-01T12:00:00.000Z"
176
+ type: string
177
+ description: The time the conversation was created
178
+ JoinedTimestamp:
179
+ properties:
180
+ joined:
181
+ example: "2020-01-01T12:00:00.000Z"
182
+ type: string
183
+ Link:
184
+ properties:
185
+ self:
186
+ type: object
187
+ allOf:
188
+ - $ref: '#/components/schemas/Self'
189
+ Self:
190
+ properties:
191
+ href:
192
+ example: "http://conversation.local/v1/conversations/CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
193
+ type: string
194
+ Embedded:
195
+ properties:
196
+ legs:
197
+ type: object
198
+ allOf:
199
+ - $ref: '#/components/schemas/Leg'
200
+ Leg:
201
+ properties:
202
+ _links:
203
+ type: array
204
+ example: []
205
+ Channel:
206
+ properties:
207
+ type:
208
+ type: string
209
+ example: app
210
+ MemberFull:
211
+ properties:
212
+ id:
213
+ example: "MEM-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
214
+ type: string
215
+ user_id:
216
+ example: "USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
217
+ type: string
218
+ state:
219
+ example: "JOINED"
220
+ type: string
221
+ timestamp:
222
+ type: object
223
+ allOf:
224
+ - $ref: '#/components/schemas/JoinedTimestamp'
225
+ channel:
226
+ type: object
227
+ allOf:
228
+ - $ref: '#/components/schemas/Channel'
229
+ href:
230
+ example: 'http://conversation.local/v1/conversations/CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab/MEM-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
231
+ type: string
232
+ Member:
233
+ properties:
234
+ user_id:
235
+ example: "USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
236
+ type: string
237
+ name:
238
+ example: "MEM-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
239
+ type: string
240
+ user_name:
241
+ example: "Dillon"
242
+ type: string
243
+ state:
244
+ example: "JOINED"
245
+ type: string
246
+ ConversationFull:
247
+ properties:
248
+ uuid:
249
+ example: "CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
250
+ type: string
251
+ description: >-
252
+ Unique identifier for the conversation
253
+ name:
254
+ example: "nexmo-chat"
255
+ type: string
256
+ description: >-
257
+ The name of the conversation
258
+ display_name:
259
+ example: "Nexmo Chat"
260
+ type: string
261
+ description: >-
262
+ The display name of the conversation
263
+ timestamp:
264
+ type: object
265
+ items:
266
+ $ref: '#/components/schemas/CreatedTimestamp'
267
+ sequence_number:
268
+ example: 0
269
+ type: integer
270
+ numbers:
271
+ example: {}
272
+ type: string
273
+ properties:
274
+ example: {}
275
+ type: string
276
+ members:
277
+ example: []
278
+ type: array
279
+ api_key:
280
+ example: "abcd1234"
281
+ type: string
282
+ description: The API Key of the owner of the conversation
283
+ _links:
284
+ example:
285
+ type: object
286
+ allOf:
287
+ - $ref: '#/components/schemas/Link'
288
+ _embedded:
289
+ type: object
290
+ allOf:
291
+ - $ref: '#/components/schemas/Embedded'
292
+ Conversation:
293
+ type: object
294
+ required:
295
+ - id
296
+ - href
297
+ properties:
298
+ id:
299
+ type: string
300
+ example: 'CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
301
+ href:
302
+ type: string
303
+ example: 'http://conversation.local/v1/conversations/CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
304
+ UserShow:
305
+ type: object
306
+ required:
307
+ - name
308
+ - id
309
+ - href
310
+ properties:
311
+ id:
312
+ type: string
313
+ example: 'USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
314
+ href:
315
+ type: string
316
+ example: 'http://conversation.local/v1/users/USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
317
+ name:
318
+ type: string
319
+ example: 'Dillon'
320
+ channels:
321
+ type: object
322
+ example: {}
323
+ User:
324
+ type: object
325
+ required:
326
+ - name
327
+ - id
328
+ - href
329
+ properties:
330
+ id:
331
+ type: string
332
+ example: 'USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
333
+ href:
334
+ type: string
335
+ example: 'http://conversation.local/v1/users/USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
336
+ UserFull:
337
+ type: object
338
+ required:
339
+ - name
340
+ - id
341
+ - href
342
+ properties:
343
+ name:
344
+ type: string
345
+ example: 'Dillon'
346
+ id:
347
+ type: string
348
+ example: 'USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
349
+ href:
350
+ type: string
351
+ example: 'http://conversation.local/v1/users/USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab'
352
+ x-groups:
353
+ conversation:
354
+ name: "Conversation"
355
+ order: 1
356
+ description: >-
357
+ A conversation is a shared core component that Nexmo APIs rely on. Conversations happen over multiple mediums and and can have associated Users through Memberships.
358
+ schema:
359
+ $ref: '#/components/schemas/ConversationFull'
360
+ user:
361
+ name: "User"
362
+ order: 2
363
+ description: >-
364
+ The concept of a user exists in Nexmo APIs, you can associate one with a user in your own application if you choose. A user can have multiple memberships to conversations and can communicate with other users through various different mediums.
365
+ member:
366
+ name: "Member"
367
+ order: 3
368
+ description: >-
369
+ Memberships connect users with conversations. Each membership has one conversation and one user however a user can have many memberships to conversations just as conversations can have many members.
@@ -0,0 +1,313 @@
1
+ # API Design Guidelines
2
+
3
+ - [Names and Formats](#names-and-formats)
4
+ - [Response Structure](#response-structure)
5
+ - [Behaviour](#behaviour)
6
+ - [API Spec](#api-spec)
7
+ - [Versioning](#versioning)
8
+
9
+ Names and Formats
10
+ -----------------
11
+
12
+ ### Convention
13
+ - Have parameters / properties in lower case with underscores.
14
+ - Have identifiers following the format: type_id. (message_id, recording_id, etc)
15
+ - Use distinguishers only when the name is non-intuitive or conflicts with another name. (`count` instead of `message_count` because message should be intuitive, but `carrier_network` if there's also a roaming network)
16
+ - Limit parameter / property names to a single underscore.
17
+ - Reuse parameter / property names. (`from` instead of `msisdn`)
18
+
19
+ #### Examples
20
+ - `machine_detection`
21
+ - `call_id`
22
+ - `conference_id`
23
+
24
+ ### Objects retrieved via webhooks by the API (*Discussion Required*)
25
+ Objects retrieved via webhooks by the API are in camelCase.
26
+
27
+ #### For example:
28
+ Nexmo Call Control Objects (NCCO) examples:
29
+ - `eventUrl`
30
+ - `musicOnHold`
31
+ - `beepOnStart`
32
+
33
+ ### Decimal precision
34
+ All values returned by Nexmo shall have the same decimal precision. Suggested is 4 decimal point to match pricing. For example: `credit-limit: "0.0000"`.
35
+
36
+ ### Generic Naming
37
+ The following parameters are included for all APIs:
38
+
39
+ #### `identifier`
40
+
41
+ A string that identifies a specific communication device or endpoint. Can be an:
42
+ - E.164 number
43
+ - sip address
44
+ - The UUID of a web rtc client
45
+ - ...
46
+
47
+ An API may restrict which types of identifiers are accepted. For example, Number Insight will only accept an E.164 number for the 'identifier' parameter.
48
+
49
+ #### `to`
50
+
51
+ The identifier of a message or conversation recipient. This represents either:
52
+ - The app sending an outbound message
53
+ - The user contacting the app with an inbound messages
54
+
55
+ #### `from`
56
+
57
+ The identifier of a message sender or the initiator of a conversation. This represents either:
58
+ - The app sending an outbound message
59
+ - The user contacting the app with an inbound messages
60
+
61
+ #### `reference`
62
+
63
+ The reference associating this request with the customer's internal data systems.
64
+
65
+ #### `<description>_url`
66
+
67
+ A url that is necessary for communication. For example, `callback_url`.
68
+
69
+ #### `<description>_method`
70
+
71
+ send the callback using either GET or POST.
72
+
73
+ #### `ttl`
74
+
75
+ Total time to live is the time during which this request is valid.
76
+
77
+ #### `<description>_id`
78
+
79
+ The unique identifier assigned by Nexmo for your request.
80
+
81
+ #### `mccmnc`
82
+
83
+ the country and carrier code for the carrier who handled your request.
84
+
85
+ #### `language`
86
+
87
+ The language used for the communication in https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. For example, en-US.
88
+
89
+ #### `count`
90
+
91
+ The number of parts your message was divided into in order to be sent correctly.
92
+
93
+ #### `total`
94
+
95
+ The amount of objects found as a result of a search request.
96
+
97
+ #### `direction`
98
+
99
+ Set to true if the communication is inbound.
100
+
101
+ #### `start`
102
+
103
+ The time the communication started in https://en.wikipedia.org/wiki/ISO_8601 format.
104
+
105
+ #### `end`
106
+
107
+ The time the communication ended in https://en.wikipedia.org/wiki/ISO_8601 format.
108
+
109
+ #### `duration`
110
+
111
+ The duration of the call in seconds.
112
+
113
+ #### `index`
114
+
115
+ The index of this message in relation to count.
116
+
117
+ #### `balance`
118
+
119
+ The amount of money left in your Nexmo account.
120
+
121
+ #### `rate`
122
+
123
+ The price for each request. This is per request for text based messages, or per second for voice.
124
+
125
+ #### `cost`
126
+
127
+ The total cost that is the result of the request.
128
+
129
+
130
+ Response Structure
131
+ ---------------
132
+ ### Data Structure
133
+ - Each API defines a single data structure and set of properties (resource). This must be coherent with the other APIs.
134
+ - The data structure must be uniform regardless of the context. An SMS record is always the same, a number is always the same.
135
+ - Data structures can be used as properties of other responses.
136
+ - In each context properties that are always unknown may be omitted. For example: a request to sending an SMS never contains DLR data.
137
+ - Properties that are potentially unknown should be included, but without a value. For example, if the Cloud Communications Platform cannot call the phone number defined in a request from Call API, the return properties will not have a valid `call_start` and `call_end`.
138
+
139
+ #### Example Response
140
+ (common data structure for 'number')
141
+
142
+ ```json
143
+ {
144
+ "call_id": "abcd1234",
145
+ "start_time": "123456789",
146
+ "end_time": "123456799",
147
+ "to": {
148
+ "type": "e.164",
149
+ "address": "+14445556767"
150
+ },
151
+ "from": {
152
+ "type": "sip",
153
+ "address": "user@example.com"
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### HTTP Status Codes
159
+ API must express the general status of the request using HTTP status codes. Specific errors can be expressed in the response body.
160
+
161
+ #### Success: 2XX
162
+
163
+ ##### 200: OK
164
+ Generic, and used when no more specific code is relevant. For example: `GET /plots/p123`, or `PUT /plots/p123?overthrow=true`
165
+
166
+ ##### 201: Created
167
+ Used when a new resource has been created. Should (per HTTP spec) contain a `Location` header with the URI for the created resource. Avoiding any body here forces the client to only ever get the resource data from the URI.
168
+ For example: `POST /plots?overthrow=true&date=tomorrow` => `Location: /plots/p124`
169
+
170
+ ##### 202: Accepted
171
+ Acknowledges the request has been received, but not that the process has been completed. Used for asynchronous tasks. Response body should include some kind of status, and a way to poll for status.
172
+ Should avoid this in favor of creating a 'workflow' resource for anything complex.
173
+
174
+ #### 204: No Content
175
+ Generally used on a successful DELETE. As the resource has been deleted there is no body.
176
+
177
+ #### Client errors: 4XX
178
+
179
+ ##### 400: Bad Request
180
+ Generic, like a 200 used in most cases when the request is incorrect and no more specific code applies. More details should be available (specific error, and human description) in the response body.
181
+
182
+ ##### 401: Unauthorized
183
+ Request is missing API authorization credentials, or those credentials are invalid.
184
+
185
+ ##### 403: Forbidden
186
+ The authenticated user can not make this request. This is not an authentication issue, this is an authorization issue (could be due to low balance, scope of the auth token used, etc).
187
+
188
+ ##### 404: Not Found
189
+ The resource could not be found. If the URI format is correct with the exception of the resource ID, the body should include the same structured error response as any other API error.
190
+ For example: `GET /plans/p125`
191
+
192
+ ##### 409: Conflict
193
+ The request could not be completed due to a conflict with the current state of the resource. The resource exists; however, the action could not be taken. The response MUST contain contain a description of the conflict.
194
+ For example: `PUT /calls/123/talk`
195
+
196
+ ##### 410: Gone
197
+ The requested resource is no longer available at the server. This condition is expected to be considered permanent. Used when the URI is formatted correctly, but the subresource is no long available.
198
+ For example: `PUT /calls/123/talk`
199
+
200
+ ##### 429: Too Many Requests
201
+ Not in the official spec (rather a part of RFC 6585), response used when request is rate-limited. Used enough to be well understood.
202
+
203
+ #### Server Errors(5XX)
204
+
205
+ ##### 500: Internal Server Error
206
+ Generic, like a 200 used in most cases when no more specific code applies. More details should be available (specific error, and human description) in the response body.
207
+
208
+ ### Error Messages
209
+ Any non 200 response body should follow a standard format. This should be consistent for all products, as an error may be product specific (invalid parameters) or global in nature (invalid authorization). The [HTTP Problem draft][http_problem], specifically the [JSON Object][http-problem-object] provide a familiar format used by other APIs that provides a set of standard properties while allowing additional properties when needed for a particular error condition.
210
+
211
+ Stealing the the examples from the draft:
212
+ ```
213
+ HTTP/1.1 403 Forbidden
214
+ Content-Type: application/problem+json
215
+ Content-Language: en
216
+ {
217
+ "type": "https://example.com/Error#out-of-credit",
218
+ "detail": "Your current balance is 30, but that costs 50.",
219
+ "instance": "/account/12345/msgs/abc",
220
+ "balance": 30,
221
+ "accounts": ["/account/12345",
222
+ "/account/67890"]
223
+ }
224
+ ```
225
+ ```
226
+ HTTP/1.1 400 Bad Request
227
+ Content-Type: application/problem+json
228
+ Content-Language: en
229
+ {
230
+ "type": "https://example.net/validation-error",
231
+ "title": "Your request parameters didn't validate.",
232
+ "invalid_parameters": [ {
233
+ "name": "age",
234
+ "reason": "must be a positive integer"
235
+ },
236
+ {
237
+ "name": "color",
238
+ "reason": "must be 'green', 'red' or 'blue'"}
239
+ ]
240
+ }
241
+ ```
242
+
243
+ Following REST patterns, `type` is both the identifier for the specific error (URI) and a link to human readable documentation about the problem.
244
+ `type`, `title`, `status`, `detail`, and `instance` [are the standard properties][http-problem-properties], as the example shows additional properties can be added if relevant to the error.
245
+ Note that this means a single response can not contain both a success and a failure (or even two failures that are significant enough to require two different high level problems).
246
+
247
+ ### Collection and Links
248
+ - [HAL-JSON][hal] provides a consistent format supported by consumer and provider tooling. [Current Draft][hal-draft]
249
+ - Allows resources to be embedded using an `_embedded` property (with a distinguishing key).
250
+ - Collections are simply resources that embed a set of resources of the same type.
251
+ - Collections are not limited to a fixed set of properties (can create collection specific properties like 'queuedCalls' to provide a count of a subset).
252
+ - Related resources will be referenced under a `_links` property.
253
+ - There will always be a `_links.self` to the current resource.
254
+ - Paging will use `_links`.
255
+
256
+
257
+ Behavior
258
+ --------
259
+ - Updating resources will fail if required parameters are not set.
260
+ - Unsent optional parameters will not be overwritten with default values.
261
+ - Response for a POST or GET will be the same resource.
262
+ - All APIs that allow updating a resource will also allow fetching a resource.
263
+
264
+ ### REST
265
+ All new API's shall adhere to the principles of REST (http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm). In doing so the following shall apply:
266
+
267
+ - Separate things into logical Collections e.g. members
268
+ - Collections are the collective term for Resources e.g. member
269
+ - Resources are nouns not verbs
270
+ - Collections are plurals
271
+ - Use HTTP methods to map CRUD actions on Resources i.e. POST creates a new Resources in a Collection, DELETE removes a Resource, GET lists Resources and PUT changes a Resource
272
+
273
+ #### Examples
274
+ - `GET members/` - lists all the resources of the collection members
275
+ - `GET members/bob` - lists the details of bob who is a resources of the collection members
276
+ - `POST members/harry` - create a new member called Harry
277
+ - `PUT members/harry/phone` - update Harry's phone number
278
+ - `DELETE members/steve` - remove the member Steve from the collection
279
+
280
+ ### Pagination
281
+ - There shall be a way to page through collections without additional filters.
282
+ - There shall be a way to page through collections with filters.
283
+ - Paging shall use a standard set of hal+json `_links`
284
+ - `self` (current page, required)
285
+ - `next` (next page, optional)
286
+ - `prev` (previous page, optional)
287
+ - `first` (first page, required)
288
+ - `last` (last page, required)
289
+ - Paging `_links` will include filters.
290
+
291
+
292
+ API specs
293
+ ---------
294
+ Every API shall be described using the [OpenAPI Specification][oai].
295
+
296
+
297
+ Versioning
298
+ ----------
299
+ Nexmo APIs will support versioning. The version is given in the URI.
300
+
301
+ ### Deprecation
302
+ When the decision has been taken to deprecate an API:
303
+ - There will be a 1 year grace period between the announcement and the moment when API is deactivated.
304
+ - Warning emails will be sent to the API at regular intervals before the deprecation time
305
+ - A guide will be supplied to customers explaining how to migrate to the replacement API with the initial deprecation notice.
306
+
307
+
308
+ [hal]: http://stateless.co/hal_specification.html
309
+ [hal-draft]: https://tools.ietf.org/html/draft-kelly-json-hal-07
310
+ [oai]: https://github.com/OAI/OpenAPI-Specification
311
+ [http-problem-properties]: https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-02#section-3.1
312
+ [http-problem]: https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-02
313
+ [http-problem-object]: https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-02#section-3
@@ -0,0 +1,7 @@
1
+ # Nexmo API Design Guidelines
2
+
3
+ - Define common aspects of API design to output a consistent interface.
4
+ - Expose those guidelines to provide:
5
+ - a process of adopting new guidelines.
6
+ - open communication around defining guidelines.
7
+ - an easily accessed history of changes.
@@ -0,0 +1,8 @@
1
+ module NexmoApiSpecification
2
+ module Definition
3
+ def self.load(definition)
4
+ raise 'Definition does not exist' unless File.exist? "#{definition}.yml"
5
+ File.read "#{definition}.yml"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module NexmoApiSpecification
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'nexmo_api_specification/version'
2
+
3
+ module NexmoApiSpecification
4
+ require 'nexmo_api_specification/definition'
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'nexmo_api_specification/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'nexmo_api_specification'
9
+ spec.version = NexmoApiSpecification::VERSION
10
+ spec.authors = ['Adam Butler']
11
+ spec.email = ['adam.butler@nexmo.com']
12
+
13
+ spec.summary = 'Provides Open API Spec 3 definitions for Nexmo APIs'
14
+ spec.homepage = 'https://github.com/nexmo/api-specification'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.13'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ end
data/sms.yml ADDED
@@ -0,0 +1,213 @@
1
+ openapi: 3.0.0
2
+ servers:
3
+ - url: 'https://rest.nexmo.com'
4
+ info:
5
+ title: SMS API
6
+ version: v1.0.0
7
+ description:
8
+ With the Nexmo SMS API you can send SMS from your account and lookup messages both messages that you've sent as well as messages sent to your virtual numbers.
9
+ paths:
10
+ '/sms/{format}':
11
+ post:
12
+ x-group: sms
13
+ summary: Send an SMS
14
+ description: Send an outbound SMS from your Nexmo account
15
+ parameters:
16
+ - name: format
17
+ description: The format of the response
18
+ required: true
19
+ in: path
20
+ example: json
21
+ type: string
22
+ enum:
23
+ - json
24
+ - xml
25
+ default: json
26
+ - name: api_key
27
+ description: Your API key
28
+ required: true
29
+ in: query
30
+ example: abcd1234
31
+ schema:
32
+ type: string
33
+ minLength: 8
34
+ maxLength: 8
35
+ - name: api_secret
36
+ description: Your API secret. Required unless `sig` is provided
37
+ required: false
38
+ in: query
39
+ example: abcdef0123456789
40
+ schema:
41
+ type: string
42
+ minLength: 16
43
+ maxLength: 16
44
+ - name: sig
45
+ description: The hash of the request parameters in alphabetical order, a timestamp and the signature secret. See [Signing Requests](/concepts/guides/signing-messages) for more details.
46
+ required: false
47
+ in: query
48
+ schema:
49
+ type: string
50
+ minLength: 16
51
+ maxLength: 16
52
+ responses:
53
+ '200':
54
+ description: Success
55
+ content:
56
+ '*/*':
57
+ schema:
58
+ $ref: '#/components/schemas/SMS'
59
+ requestBody:
60
+ content:
61
+ application/x-www-form-urlencoded:
62
+ schema:
63
+ type: object
64
+ properties:
65
+ from:
66
+ description: The name or number the message should be sent from. Alphanumeric senderID's are not supported in all countries, see [Global Messaging](/messaging/sms/guides/global-messaging#country-specific-features) for more details.
67
+ type: string
68
+ example: 'Acme Inc'
69
+ required: true
70
+ to:
71
+ description: The number that the message should be sent to
72
+ type: string
73
+ minLength: 11
74
+ maxLength: 12
75
+ pattern: '\d{11,12}'
76
+ example: 447700900000
77
+ required: true
78
+ text:
79
+ description: The body of the message being sent
80
+ type: string
81
+ example: Hello World!
82
+ ttl:
83
+ description: '**Advanced**: The duration in milliseconds the delivery of an SMS will be attempted.§§ By default Nexmo attempt delivery for 72 hours, however the maximum effective value depends on the operator and is typically 24 - 48 hours. We recommend this value should be kept at its default or at least 30 minutes.'
84
+ type: integer
85
+ example: 900000
86
+ default: 259200000
87
+ minimum: 20000
88
+ maximum: 604800000
89
+ status-report-req:
90
+ description: '**Advanced**: Boolean indicating if you like to receive a [Delivery Receipt](/messaging/sms/building-blocks/receive-a-delivery-receipt).'
91
+ type: boolean
92
+ example: 'false'
93
+ default: 'true'
94
+ callback:
95
+ description: '**Advanced**: The webhook endpoint the delivery receipt for this sms is sent to. This parameter overrides the webhook endpoint you set in Dashboard.'
96
+ type: string
97
+ example: 'https://example.com/sms-dlr'
98
+ message-class:
99
+ description: '**Advanced**: The Data Coding Scheme value of the message'
100
+ type: integer
101
+ enum:
102
+ - 0
103
+ - 1
104
+ - 2
105
+ - 3
106
+ type:
107
+ description: '**Advanced**: The format of the message body'
108
+ type: string
109
+ enum:
110
+ - text
111
+ - binary
112
+ - wappush
113
+ - unicode
114
+ - vcal
115
+ - vard
116
+ example: text
117
+ default: text
118
+ vcard:
119
+ description: '**Advanced**: A business card in [vCard format](https://en.wikipedia.org/wiki/VCard). Depends on `type` parameter having the value `vcard`.'
120
+ type: vcard
121
+ vcal:
122
+ description: '**Advanced**: A calendar event in [vCal format](https://en.wikipedia.org/wiki/VCal). Depends on `type` parameter having the value `vcal`.'
123
+ type: vcal
124
+ body:
125
+ description: '**Advanced**: Hex encoded binary data. Depends on `type` parameter having the value `binary`.'
126
+ type: string
127
+ example: 0011223344556677
128
+ udh:
129
+ description: '**Advanced**: Your custom Hex encoded [User Data Header](https://en.wikipedia.org/wiki/User_Data_Header). Depends on `type` parameter having the value `binary`.'
130
+ type: string
131
+ example: 06050415811581
132
+ protocol-id:
133
+ description: '**Advanced**: The value of the [protocol identifier](https://en.wikipedia.org/wiki/GSM_03.40#Protocol_Identifier) to use. Ensure that the value is aligned with `udh`.'
134
+ type: integer
135
+ example: 127
136
+ title:
137
+ description: '**Advanced**: The title for a wappush SMS. Depends on `type` parameter having the value `wappush`.'
138
+ type: string
139
+ example: Welcome
140
+ url:
141
+ description: '**Advanced**: The URL of your website. Depends on `type` parameter having the value `wappush`.'
142
+ type: string
143
+ example: https://example.com
144
+ validity:
145
+ description: '**Advanced**: The availability for an SMS in milliseconds. Depends on `type` parameter having the value `wappush`.'
146
+ type: string
147
+ example: https://example.com
148
+
149
+ components:
150
+ schemas:
151
+ Error:
152
+ type: object
153
+ properties:
154
+ message-count:
155
+ type: integer
156
+ description: The amount of messages in the request
157
+ example: 1
158
+ messages:
159
+ $ref: '#/components/schemas/ErrorMessage'
160
+ ErrorMessage:
161
+ type: object
162
+ properties:
163
+ status:
164
+ type: string
165
+ description: The error status of the message
166
+ example: '2'
167
+ error-text:
168
+ type: string
169
+ description: The description of the error
170
+ example: 'Missing to param'
171
+ SMS:
172
+ type: object
173
+ properties:
174
+ message-count:
175
+ type: integer
176
+ description: The amount of messages in the request
177
+ example: 1
178
+ messages:
179
+ $ref: '#/components/schemas/Message'
180
+ Message:
181
+ type: object
182
+ properties:
183
+ to:
184
+ type: string
185
+ description: The number the message was sent to
186
+ example: '447700900000'
187
+ message-id:
188
+ type: string
189
+ description: The ID of the message
190
+ example: 0A0000000123ABCD1
191
+ status:
192
+ type: string
193
+ description: The status of the message
194
+ example: '0'
195
+ remaining-balance:
196
+ type: string
197
+ description: Your remaining balance
198
+ example: '3.14159265'
199
+ message-price:
200
+ type: string
201
+ description: The cost of the message
202
+ example: '0.03330000'
203
+ network:
204
+ type: string
205
+ description: The ID of the network of the recipient
206
+ example: '12345'
207
+ x-groups:
208
+ sms:
209
+ name: "SMS"
210
+ order: 1
211
+ description: The SMS object contains information about the request and details of the message information.
212
+ schema:
213
+ $ref: '#/components/schemas/SMS'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nexmo_api_specification
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Butler
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - adam.butler@nexmo.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - conversation.yml
69
+ - guidelines/GUIDELINES.md
70
+ - guidelines/README.md
71
+ - lib/nexmo_api_specification.rb
72
+ - lib/nexmo_api_specification/definition.rb
73
+ - lib/nexmo_api_specification/version.rb
74
+ - nexmo_api_specification.gemspec
75
+ - sms.yml
76
+ homepage: https://github.com/nexmo/api-specification
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Provides Open API Spec 3 definitions for Nexmo APIs
100
+ test_files: []