messagemedia_messages_sdk 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aef2e715371702201b6a82045b12fe6236a4abed
4
- data.tar.gz: d5e0e979766af4f86e67837289fc5877ccbc3445
3
+ metadata.gz: 64507452df46cd3053f21a48c11d2de7a73a1e75
4
+ data.tar.gz: bcef3fa3ac201bd1873b3114dd7a3294de9d7001
5
5
  SHA512:
6
- metadata.gz: f6485aee0b4ab324ee4c587194f7fabdafba9d88b2a803b9b6bb86aa7088dc1a2c1996d6596ef1d3e40953d8178db60e585079efdc3b73610135692f3b5fc3d6
7
- data.tar.gz: 17b11c77f4a7958c87c79f7d41254376cd3073368f761104b62319d17f043cc6f48382cc8ac00c48806967b0aee5e7dc1debbbcea17bc16036531e357110871e
6
+ metadata.gz: 208053caf2e5f80b12ccd4e8ca814dce587954e2d1a614036a6cb80a568814324da33c4806b16ea0ea671071338a05176e784c651e188d945e859e49693f0123
7
+ data.tar.gz: adea3750c6ea3f266bc46d7a3104417f8a9e7f6a08c17600dd594945f1150f6f16086716d93ab78d19cc4bf75db2314fc2c5bef496d54cf76dcdf7597e14abb2
data/README.md CHANGED
@@ -1,608 +1,108 @@
1
- # Getting started
1
+ # MessageMedia Messages Ruby SDK
2
+ [![Travis Build Status](https://api.travis-ci.org/messagemedia/messages-ruby-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/messages-ruby-sdk)
3
+ [![gem](https://img.shields.io/badge/gem-v1.1.0-red.svg)](https://rubygems.org/gems/messagemedia_messages_sdk)
2
4
 
3
5
  The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.
4
-
5
- ## How to Build
6
-
7
- This client library is a Ruby gem which can be compiled and used in your Ruby and Ruby on Rails project. This library requires a few gems from the RubyGems repository.
8
-
9
- 1. Open the command line interface or the terminal and navigate to the folder containing the source code.
10
- 2. Run ``` gem build message_media_messages.gemspec ``` to build the gem.
11
- 3. Once built, the gem can be installed on the current work environment using ``` gem install message_media_messages-1.0.0.gem ```
12
-
13
- ![Building Gem](https://apidocs.io/illustration/ruby?step=buildSDK&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages-Ruby&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
14
-
15
- ## How to Use
16
-
17
- The following section explains how to use the MessageMediaMessages Ruby Gem in a new Rails project using RubyMine™. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
18
-
19
- ### 1. Starting a new project
20
-
21
- Close any existing projects in RubyMine™ by selecting ``` File -> Close Project ```. Next, click on ``` Create New Project ``` to create a new project from scratch.
22
-
23
- ![Create a new project in RubyMine](https://apidocs.io/illustration/ruby?step=createNewProject0&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
24
-
25
- Next, provide ``` TestApp ``` as the project name, choose ``` Rails Application ``` as the project type, and click ``` OK ```.
26
-
27
- ![Create a new Rails Application in RubyMine - step 1](https://apidocs.io/illustration/ruby?step=createNewProject1&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
28
-
29
- In the next dialog make sure that correct *Ruby SDK* is being used (minimum 2.0.0) and click ``` OK ```.
30
-
31
- ![Create a new Rails Application in RubyMine - step 2](https://apidocs.io/illustration/ruby?step=createNewProject2&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
32
-
33
- This will create a new Rails Application project with an existing set of files and folder.
34
-
35
- ### 2. Add reference of the gem
36
-
37
- In order to use the MessageMediaMessages gem in the new project we must add a gem reference. Locate the ```Gemfile``` in the *Project Explorer* window under the ``` TestApp ``` project node. The file contains references to all gems being used in the project. Here, add the reference to the library gem by adding the following line: ``` gem 'message_media_messages', '~> 1.0.0' ```
38
-
39
- ![Add references of the Gemfile](https://apidocs.io/illustration/ruby?step=addReference&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
40
-
41
- ### 3. Adding a new Rails Controller
42
-
43
- Once the ``` TestApp ``` project is created, a folder named ``` controllers ``` will be visible in the *Project Explorer* under the following path: ``` TestApp > app > controllers ```. Right click on this folder and select ``` New -> Run Rails Generator... ```.
44
-
45
- ![Run Rails Generator on Controllers Folder](https://apidocs.io/illustration/ruby?step=addCode0&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
46
-
47
- Selecting the said option will popup a small window where the generator names are displayed. Here, select the ``` controller ``` template.
48
-
49
- ![Create a new Controller](https://apidocs.io/illustration/ruby?step=addCode1&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
50
-
51
- Next, a popup window will ask you for a Controller name and included Actions. For controller name provide ``` Hello ``` and include an action named ``` Index ``` and click ``` OK ```.
52
-
53
- ![Add a new Controller](https://apidocs.io/illustration/ruby?step=addCode2&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
54
-
55
- A new controller class anmed ``` HelloController ``` will be created in a file named ``` hello_controller.rb ``` containing a method named ``` Index ```. In this method, add code for initialization and a sample for its usage.
56
-
57
- ![Initialize the library](https://apidocs.io/illustration/ruby?step=addCode3&workspaceFolder=MessageMediaMessages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0)
58
-
59
- ## How to Test
60
-
61
- You can test the generated SDK and the server with automatically generated test
62
- cases as follows:
63
-
64
- 1. From terminal/cmd navigate to the root directory of the SDK.
65
- 2. Invoke: `bundle exec rake`
66
-
67
- ## Initialization
68
-
69
- ### Authentication
70
- In order to setup authentication and initialization of the API client, you need the following information.
71
-
72
- | Parameter | Description |
73
- |-----------|-------------|
74
- | basic_auth_user_name | The username to use with basic authentication |
75
- | basic_auth_password | The password to use with basic authentication |
76
-
77
-
78
-
79
- API client can be initialized as following.
80
-
81
- ```ruby
82
- # Configuration parameters and credentials
83
- basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
84
- basic_auth_password = 'basic_auth_password' # The password to use with basic authentication
85
-
86
- client = MessageMediaMessages::MessageMediaMessagesClient.new(
87
- basic_auth_user_name: basic_auth_user_name,
88
- basic_auth_password: basic_auth_password
89
- )
90
- ```
91
-
92
- The added initlization code can be debugged by putting a breakpoint in the ``` Index ``` method and running the project in debug mode by selecting ``` Run -> Debug 'Development: TestApp' ```.
93
-
94
- ![Debug the TestApp](https://apidocs.io/illustration/ruby?step=addCode4&workspaceFolder=Messages-Ruby&workspaceName=MessageMediaMessages&projectName=message_media_messages&gemName=message_media_messages&gemVer=1.0.0&initLine=client%2520%253D%2520MessageMediaMessagesClient.new%2528%2527basic_auth_user_name%2527%252C%2520%2527basic_auth_password%2527%2529)
95
-
96
-
97
-
98
- # Class Reference
99
-
100
- ## <a name="list_of_controllers"></a>List of Controllers
101
-
102
- * [MessagesController](#messages_controller)
103
- * [DeliveryReportsController](#delivery_reports_controller)
104
- * [RepliesController](#replies_controller)
105
-
106
- ## <a name="messages_controller"></a>![Class: ](https://apidocs.io/img/class.png ".MessagesController") MessagesController
107
-
108
- ### Get singleton instance
109
-
110
- The singleton instance of the ``` MessagesController ``` class can be accessed from the API Client.
111
-
112
- ```ruby
113
- messages = client.messages
114
- ```
115
-
116
- ### <a name="update_cancel_scheduled_message"></a>![Method: ](https://apidocs.io/img/method.png ".MessagesController.update_cancel_scheduled_message") update_cancel_scheduled_message
117
-
118
- > Cancel a scheduled message that has not yet been delivered.
119
- > A scheduled message can be cancelled by updating the status of a message from ```scheduled```
120
- > to ```cancelled```. This is done by submitting a PUT request to the messages endpoint using
121
- > the message ID as a parameter (the same endpoint used above to retrieve the status of a message).
122
- > The body of the request simply needs to contain a ```status``` property with the value set
123
- > to ```cancelled```.
124
- > ```json
125
- > {
126
- > "status": "cancelled"
127
- > }
128
- > ```
129
- > *Note: Only messages with a status of scheduled can be cancelled. If an invalid or non existent
130
- > message ID parameter is specified in the request, then a HTTP 404 Not Found response will be
131
- > returned*
132
-
133
-
134
- ```ruby
135
- def update_cancel_scheduled_message(message_id,
136
- body); end
137
- ```
138
-
139
- #### Parameters
140
-
141
- | Parameter | Tags | Description |
142
- |-----------|------|-------------|
143
- | message_id | ``` Required ``` | TODO: Add a parameter description |
144
- | body | ``` Required ``` | TODO: Add a parameter description |
145
-
146
-
147
- #### Example Usage
148
-
149
- ```ruby
150
- message_id = 'messageId'
151
- body = CancelScheduledMessageRequest.new
152
-
153
- result = messages.update_cancel_scheduled_message(message_id, body)
154
-
155
- ```
156
-
157
- #### Errors
158
-
159
- | Error Code | Error Description |
160
- |------------|-------------------|
161
- | 400 | TODO: Add an error description |
162
- | 404 | TODO: Add an error description |
163
-
164
-
165
-
166
- ### <a name="get_message_status"></a>![Method: ](https://apidocs.io/img/method.png ".MessagesController.get_message_status") get_message_status
167
-
168
- > Retrieve the current status of a message using the message ID returned in the send messages end point.
169
- > A successful request to the get message status endpoint will return a response body as follows:
170
- > ```json
171
- > {
172
- > "format": "SMS",
173
- > "content": "My first message!",
174
- > "metadata": {
175
- > "key1": "value1",
176
- > "key2": "value2"
177
- > },
178
- > "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
179
- > "callback_url": "https://my.callback.url.com",
180
- > "delivery_report": true,
181
- > "destination_number": "+61401760575",
182
- > "scheduled": "2016-11-03T11:49:02.807Z",
183
- > "source_number": "+61491570157",
184
- > "source_number_type": "INTERNATIONAL"
185
- > "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
186
- > "status": "enroute"
187
- > }
188
- > ```
189
- > The status property of the response indicates the current status of the message. See the Delivery
190
- > Reports section of this documentation for more information on message statues.
191
- > *Note: If an invalid or non existent message ID parameter is specified in the request, then
192
- > a HTTP 404 Not Found response will be returned*
193
-
194
-
195
- ```ruby
196
- def get_message_status(message_id); end
197
- ```
198
-
199
- #### Parameters
200
-
201
- | Parameter | Tags | Description |
202
- |-----------|------|-------------|
203
- | message_id | ``` Required ``` | TODO: Add a parameter description |
204
-
205
-
206
- #### Example Usage
207
-
208
- ```ruby
209
- message_id = 'messageId'
210
-
211
- result = messages.get_message_status(message_id)
212
-
213
- ```
214
-
215
- #### Errors
216
-
217
- | Error Code | Error Description |
218
- |------------|-------------------|
219
- | 404 | TODO: Add an error description |
220
-
221
-
222
-
223
- ### <a name="create_send_messages"></a>![Method: ](https://apidocs.io/img/method.png ".MessagesController.create_send_messages") create_send_messages
224
-
225
- > Submit one or more (up to 100 per request) SMS or text to voice messages for delivery.
226
- > The most basic message has the following structure:
227
- > ```json
228
- > {
229
- > "messages": [
230
- > {
231
- > "content": "My first message!",
232
- > "destination_number": "+61491570156"
233
- > }
234
- > ]
235
- > }
236
- > ```
237
- > More advanced delivery features can be specified by setting the following properties in a message:
238
- > - ```callback_url``` A URL can be included with each message to which Webhooks will be pushed to
239
- > via a HTTP POST request. Webhooks will be sent if and when the status of the message changes as
240
- > it is processed (if the delivery report property of the request is set to ```true```) and when replies
241
- > are received. Specifying a callback URL is optional.
242
- > - ```content``` The content of the message. This can be a Unicode string, up to 5,000 characters long.
243
- > Message content is required.
244
- > - ```delivery_report``` Delivery reports can be requested with each message. If delivery reports are requested, a webhook
245
- > will be submitted to the ```callback_url``` property specified for the message (or to the webhooks)
246
- > specified for the account every time the status of the message changes as it is processed. The
247
- > current status of the message can also be retrieved via the Delivery Reports endpoint of the
248
- > Messages API. Delivery reports are optional and by default will not be requested.
249
- > - ```destination_number``` The destination number the message should be delivered to. This should be specified in E.164
250
- > international format. For information on E.164, please refer to http://en.wikipedia.org/wiki/E.164.
251
- > A destination number is required.
252
- > - ```format``` The format specifies which format the message will be sent as, ```SMS``` (text message)
253
- > or ```TTS``` (text to speech). With ```TTS``` format, we will call the destination number and read out the
254
- > message using a computer generated voice. Specifying a format is optional, by default ```SMS``` will be used.
255
- > - ```source_number``` A source number may be specified for the message, this will be the number that
256
- > the message appears from on the handset. By default this feature is _not_ available and will be ignored
257
- > in the request. Please contact <support@messagemeda.com> for more information. Specifying a source
258
- > number is optional and a by default a source number will be assigned to the message.
259
- > - ```source_number_type``` If a source number is specified, the type of source number may also be
260
- > specified. This is recommended when using a source address type that is not an internationally
261
- > formatted number, available options are ```INTERNATIONAL```, ```ALPHANUMERIC``` or ```SHORTCODE```. Specifying a
262
- > source number type is only valid when the ```source_number``` parameter is specified and is optional.
263
- > If a source number is specified and no source number type is specified, the source number type will be
264
- > inferred from the source number, however this may be inaccurate.
265
- > - ```scheduled``` A message can be scheduled for delivery in the future by setting the scheduled property.
266
- > The scheduled property expects a date time specified in ISO 8601 format. The scheduled time must be
267
- > provided in UTC and is optional. If no scheduled property is set, the message will be delivered immediately.
268
- > - ```message_expiry_timestamp``` A message expiry timestamp can be provided to specify the latest time
269
- > at which the message should be delivered. If the message cannot be delivered before the specified
270
- > message expiry timestamp elapses, the message will be discarded. Specifying a message expiry
271
- > timestamp is optional.
272
- > - ```metadata``` Metadata can be included with the message which will then be included with any delivery
273
- > reports or replies matched to the message. This can be used to create powerful two-way messaging
274
- > applications without having to store persistent data in the application. Up to 10 key / value metadata data
275
- > pairs can be specified in a message. Each key can be up to 100 characters long, and each value up to
276
- > 256 characters long. Specifying metadata for a message is optional.
277
- > The response body of a successful POST request to the messages endpoint will include a ```messages```
278
- > property which contains a list of all messages submitted. The list of messages submitted will
279
- > reflect the list of messages included in the request, but each message will also contain two new
280
- > properties, ```message_id``` and ```status```. The returned message ID will be a 36 character UUID
281
- > which can be used to check the status of the message via the Get Message Status endpoint. The status
282
- > of the message which reflect the status of the message at submission time which will always be
283
- > ```queued```. See the Delivery Reports section of this documentation for more information on message
284
- > statues.
285
- > *Note: when sending multiple messages in a request, all messages must be valid for the request to be successful.
286
- > If any messages in the request are invalid, no messages will be sent.*
287
-
288
-
289
- ```ruby
290
- def create_send_messages(body); end
291
- ```
292
-
293
- #### Parameters
294
-
295
- | Parameter | Tags | Description |
296
- |-----------|------|-------------|
297
- | body | ``` Required ``` | TODO: Add a parameter description |
298
-
299
-
300
- #### Example Usage
301
-
302
- ```ruby
303
- body_value = "{ \"messages\": [ { \"callback_url\": \"https://my.callback.url.com\", \"content\": \"My first message\", \"destination_number\": \"+61491570156\", \"delivery_report\": true, \"format\": \"SMS\", \"message_expiry_timestamp\": \"2016-11-03T11:49:02.807Z\", \"metadata\": { \"key1\": \"value1\", \"key2\": \"value2\" }, \"scheduled\": \"2016-11-03T11:49:02.807Z\", \"source_number\": \"+61491570157\", \"source_number_type\": \"INTERNATIONAL\" }, { \"callback_url\": \"https://my.callback.url.com\", \"content\": \"My second message\", \"destination_number\": \"+61491570158\", \"delivery_report\": true, \"format\": \"SMS\", \"message_expiry_timestamp\": \"2016-11-03T11:49:02.807Z\", \"metadata\": { \"key1\": \"value1\", \"key2\": \"value2\" }, \"scheduled\": \"2016-11-03T11:49:02.807Z\", \"source_number\": \"+61491570159\", \"source_number_type\": \"INTERNATIONAL\" } ]}";
304
- body = JSON.parse(body_value);
305
-
306
- result = messages.create_send_messages(body)
307
-
308
- ```
309
-
310
- #### Errors
311
-
312
- | Error Code | Error Description |
313
- |------------|-------------------|
314
- | 400 | TODO: Add an error description |
315
-
316
-
317
-
318
- [Back to List of Controllers](#list_of_controllers)
319
-
320
- ## <a name="delivery_reports_controller"></a>![Class: ](https://apidocs.io/img/class.png ".DeliveryReportsController") DeliveryReportsController
321
-
322
- ### Get singleton instance
323
-
324
- The singleton instance of the ``` DeliveryReportsController ``` class can be accessed from the API Client.
325
-
326
- ```ruby
327
- deliveryReports = client.delivery_reports
328
- ```
329
-
330
- ### <a name="get_check_delivery_reports"></a>![Method: ](https://apidocs.io/img/method.png ".DeliveryReportsController.get_check_delivery_reports") get_check_delivery_reports
331
-
332
- > Check for any delivery reports that have been received.
333
- > Delivery reports are a notification of the change in status of a message as it is being processed.
334
- > Each request to the check delivery reports endpoint will return any delivery reports received that
335
- > have not yet been confirmed using the confirm delivery reports endpoint. A response from the check
336
- > delivery reports endpoint will have the following structure:
337
- > ```json
338
- > {
339
- > "delivery_reports": [
340
- > {
341
- > "callback_url": "https://my.callback.url.com",
342
- > "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043",
343
- > "source_number": "+61491570157",
344
- > "date_received": "2017-05-20T06:30:37.642Z",
345
- > "status": "enroute",
346
- > "delay": 0,
347
- > "submitted_date": "2017-05-20T06:30:37.639Z",
348
- > "original_text": "My first message!",
349
- > "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba",
350
- > "vendor_account_id": {
351
- > "vendor_id": "MessageMedia",
352
- > "account_id": "MyAccount"
353
- > },
354
- > "metadata": {
355
- > "key1": "value1",
356
- > "key2": "value2"
357
- > }
358
- > },
359
- > {
360
- > "callback_url": "https://my.callback.url.com",
361
- > "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b",
362
- > "source_number": "+61491570158",
363
- > "date_received": "2017-05-21T01:46:42.579Z",
364
- > "status": "enroute",
365
- > "delay": 0,
366
- > "submitted_date": "2017-05-21T01:46:42.574Z",
367
- > "original_text": "My second message!",
368
- > "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281",
369
- > "vendor_account_id": {
370
- > "vendor_id": "MessageMedia",
371
- > "account_id": "MyAccount"
372
- > },
373
- > "metadata": {
374
- > "key1": "value1",
375
- > "key2": "value2"
376
- > }
377
- > }
378
- > ]
379
- > }
380
- > ```
381
- > Each delivery report will contain details about the message, including any metadata specified
382
- > and the new status of the message (as each delivery report indicates a change in status of a
383
- > message) and the timestamp at which the status changed. Every delivery report will have a
384
- > unique delivery report ID for use with the confirm delivery reports endpoint.
385
- > *Note: The source number and destination number properties in a delivery report are the inverse of
386
- > those specified in the message that the delivery report relates to. The source number of the
387
- > delivery report is the destination number of the original message.*
388
- > Subsequent requests to the check delivery reports endpoint will return the same delivery reports
389
- > and a maximum of 100 delivery reports will be returned in each request. Applications should use the
390
- > confirm delivery reports endpoint in the following pattern so that delivery reports that have been
391
- > processed are no longer returned in subsequent check delivery reports requests.
392
- > 1. Call check delivery reports endpoint
393
- > 2. Process each delivery report
394
- > 3. Confirm all processed delivery reports using the confirm delivery reports endpoint
395
- > *Note: It is recommended to use the Webhooks feature to receive reply messages rather than
396
- > polling the check delivery reports endpoint.*
397
-
398
-
399
- ```ruby
400
- def get_check_delivery_reports; end
401
- ```
402
-
403
- #### Example Usage
404
-
405
- ```ruby
406
-
407
- result = deliveryReports.get_check_delivery_reports()
408
-
409
- ```
410
-
411
-
412
- ### <a name="create_confirm_delivery_reports_as_received"></a>![Method: ](https://apidocs.io/img/method.png ".DeliveryReportsController.create_confirm_delivery_reports_as_received") create_confirm_delivery_reports_as_received
413
-
414
- > Mark a delivery report as confirmed so it is no longer return in check delivery reports requests.
415
- > The confirm delivery reports endpoint is intended to be used in conjunction with the check delivery
416
- > reports endpoint to allow for robust processing of delivery reports. Once one or more delivery
417
- > reports have been processed, they can then be confirmed using the confirm delivery reports endpoint so they
418
- > are no longer returned in subsequent check delivery reports requests.
419
- > The confirm delivery reports endpoint takes a list of delivery report IDs as follows:
420
- > ```json
421
- > {
422
- > "delivery_report_ids": [
423
- > "011dcead-6988-4ad6-a1c7-6b6c68ea628d",
424
- > "3487b3fa-6586-4979-a233-2d1b095c7718",
425
- > "ba28e94b-c83d-4759-98e7-ff9c7edb87a1"
426
- > ]
427
- > }
428
- > ```
429
- > Up to 100 delivery reports can be confirmed in a single confirm delivery reports request.
430
-
431
-
432
- ```ruby
433
- def create_confirm_delivery_reports_as_received(body); end
434
- ```
435
-
436
- #### Parameters
437
-
438
- | Parameter | Tags | Description |
439
- |-----------|------|-------------|
440
- | body | ``` Required ``` | TODO: Add a parameter description |
441
-
442
-
443
- #### Example Usage
444
-
445
- ```ruby
446
- body_value = "{ \"delivery_report_ids\": [ \"011dcead-6988-4ad6-a1c7-6b6c68ea628d\", \"3487b3fa-6586-4979-a233-2d1b095c7718\", \"ba28e94b-c83d-4759-98e7-ff9c7edb87a1\" ]}";
447
- body = JSON.parse(body_value);
448
-
449
- result = deliveryReports.create_confirm_delivery_reports_as_received(body)
450
-
451
- ```
452
-
453
- #### Errors
454
-
455
- | Error Code | Error Description |
456
- |------------|-------------------|
457
- | 400 | TODO: Add an error description |
458
-
459
-
460
-
461
- [Back to List of Controllers](#list_of_controllers)
462
-
463
- ## <a name="replies_controller"></a>![Class: ](https://apidocs.io/img/class.png ".RepliesController") RepliesController
464
-
465
- ### Get singleton instance
466
-
467
- The singleton instance of the ``` RepliesController ``` class can be accessed from the API Client.
468
-
469
- ```ruby
470
- replies = client.replies
471
- ```
472
-
473
- ### <a name="create_confirm_replies_as_received"></a>![Method: ](https://apidocs.io/img/method.png ".RepliesController.create_confirm_replies_as_received") create_confirm_replies_as_received
474
-
475
- > Mark a reply message as confirmed so it is no longer returned in check replies requests.
476
- > The confirm replies endpoint is intended to be used in conjunction with the check replies endpoint
477
- > to allow for robust processing of reply messages. Once one or more reply messages have been processed
478
- > they can then be confirmed using the confirm replies endpoint so they are no longer returned in
479
- > subsequent check replies requests.
480
- > The confirm replies endpoint takes a list of reply IDs as follows:
481
- > ```json
482
- > {
483
- > "reply_ids": [
484
- > "011dcead-6988-4ad6-a1c7-6b6c68ea628d",
485
- > "3487b3fa-6586-4979-a233-2d1b095c7718",
486
- > "ba28e94b-c83d-4759-98e7-ff9c7edb87a1"
487
- > ]
488
- > }
489
- > ```
490
- > Up to 100 replies can be confirmed in a single confirm replies request.
491
-
492
-
493
- ```ruby
494
- def create_confirm_replies_as_received(body); end
495
- ```
496
-
497
- #### Parameters
498
-
499
- | Parameter | Tags | Description |
500
- |-----------|------|-------------|
501
- | body | ``` Required ``` | TODO: Add a parameter description |
502
-
503
-
504
- #### Example Usage
505
-
506
- ```ruby
507
- body_value = "{ \"reply_ids\": [ \"011dcead-6988-4ad6-a1c7-6b6c68ea628d\", \"3487b3fa-6586-4979-a233-2d1b095c7718\", \"ba28e94b-c83d-4759-98e7-ff9c7edb87a1\" ]}";
508
- body = JSON.parse(body_value);
509
-
510
- result = replies.create_confirm_replies_as_received(body)
511
-
512
- ```
513
-
514
- #### Errors
515
-
516
- | Error Code | Error Description |
517
- |------------|-------------------|
518
- | 400 | TODO: Add an error description |
519
-
520
-
521
-
522
- ### <a name="get_check_replies"></a>![Method: ](https://apidocs.io/img/method.png ".RepliesController.get_check_replies") get_check_replies
523
-
524
- > Check for any replies that have been received.
525
- > Replies are messages that have been sent from a handset in response to a message sent by an
526
- > application or messages that have been sent from a handset to a inbound number associated with
527
- > an account, known as a dedicated inbound number (contact <support@messagemedia.com> for more
528
- > information on dedicated inbound numbers).
529
- > Each request to the check replies endpoint will return any replies received that have not yet
530
- > been confirmed using the confirm replies endpoint. A response from the check replies endpoint
531
- > will have the following structure:
532
- > ```json
533
- > {
534
- > "replies": [
535
- > {
536
- > "metadata": {
537
- > "key1": "value1",
538
- > "key2": "value2"
539
- > },
540
- > "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
541
- > "reply_id": "a175e797-2b54-468b-9850-41a3eab32f74",
542
- > "date_received": "2016-12-07T08:43:00.850Z",
543
- > "callback_url": "https://my.callback.url.com",
544
- > "destination_number": "+61491570156",
545
- > "source_number": "+61491570157",
546
- > "vendor_account_id": {
547
- > "vendor_id": "MessageMedia",
548
- > "account_id": "MyAccount"
549
- > },
550
- > "content": "My first reply!"
551
- > },
552
- > {
553
- > "metadata": {
554
- > "key1": "value1",
555
- > "key2": "value2"
556
- > },
557
- > "message_id": "8f2f5927-2e16-4f1c-bd43-47dbe2a77ae4",
558
- > "reply_id": "3d8d53d8-01d3-45dd-8cfa-4dfc81600f7f",
559
- > "date_received": "2016-12-07T08:43:00.850Z",
560
- > "callback_url": "https://my.callback.url.com",
561
- > "destination_number": "+61491570157",
562
- > "source_number": "+61491570158",
563
- > "vendor_account_id": {
564
- > "vendor_id": "MessageMedia",
565
- > "account_id": "MyAccount"
566
- > },
567
- > "content": "My second reply!"
568
- > }
569
- > ]
570
- > }
571
- > ```
572
- > Each reply will contain details about the reply message, as well as details of the message the reply was sent
573
- > in response to, including any metadata specified. Every reply will have a reply ID to be used with the
574
- > confirm replies endpoint.
575
- > *Note: The source number and destination number properties in a reply are the inverse of those
576
- > specified in the message the reply is in response to. The source number of the reply message is the
577
- > same as the destination number of the original message, and the destination number of the reply
578
- > message is the same as the source number of the original message. If a source number
579
- > wasn't specified in the original message, then the destination number property will not be present
580
- > in the reply message.*
581
- > Subsequent requests to the check replies endpoint will return the same reply messages and a maximum
582
- > of 100 replies will be returned in each request. Applications should use the confirm replies endpoint
583
- > in the following pattern so that replies that have been processed are no longer returned in
584
- > subsequent check replies requests.
585
- > 1. Call check replies endpoint
586
- > 2. Process each reply message
587
- > 3. Confirm all processed reply messages using the confirm replies endpoint
588
- > *Note: It is recommended to use the Webhooks feature to receive reply messages rather than polling
589
- > the check replies endpoint.*
590
-
591
-
592
- ```ruby
593
- def get_check_replies; end
594
- ```
595
-
596
- #### Example Usage
597
-
598
- ```ruby
599
-
600
- result = replies.get_check_replies()
601
-
602
- ```
603
-
604
-
605
- [Back to List of Controllers](#list_of_controllers)
606
-
607
-
608
-
6
+
7
+ ![Alt Text](https://media.giphy.com/media/l0Exov2QmxF5Xwjkc/giphy.gif)
8
+
9
+ ## ⭐️ Install via .gem file
10
+ * Download [messagemedia_messages_sdk-1.0.0.gem](https://github.com/messagemedia/messages-ruby-sdk/releases/download/v1.0.0/messagemedia_messages_sdk-1.0.0.gem)
11
+ run `gem install messagemedia_messages_sdk-1.0.0.gem`
12
+
13
+ ## 🎬 Get Started
14
+ It's easy to get started. Simply enter the API Key and secret you obtained from the [MessageMedia Developers Portal](https://developers.messagemedia.com) into the code snippet below and a mobile number you wish to send to.
15
+
16
+ ### 🚀 Send an SMS
17
+ * Destination numbers (`destination_number`) should be in the [E.164](http://en.wikipedia.org/wiki/E.164) format. For example, `+61491570156`.
18
+ ```ruby
19
+ require 'message_media_messages'
20
+
21
+ # Configuration parameters and credentials
22
+ basic_auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
23
+ basic_auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
24
+
25
+ client = MessageMediaMessages::MessageMediaMessagesClient.new(
26
+ basic_auth_user_name: basic_auth_user_name,
27
+ basic_auth_password: basic_auth_password
28
+ )
29
+
30
+ messages = client.messages
31
+ body_value = '{
32
+ "messages":[
33
+ {
34
+ "content":"My first message",
35
+ "destination_number":"YOUR_MOBILE_NUMBER"
36
+ }
37
+ ]
38
+ }';
39
+
40
+ body = JSON.parse(body_value);
41
+
42
+ result = messages.create_send_messages(body)
43
+ ```
44
+
45
+ ### 🕓 Get Status of a Message
46
+ You can get a messsage ID from a sent message by looking at the `message_id` from the response of the above example.
47
+ ```ruby
48
+ require 'message_media_messages'
49
+
50
+ # Configuration parameters and credentials
51
+ basic_auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
52
+ basic_auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
53
+
54
+ client = MessageMediaMessages::MessageMediaMessagesClient.new(
55
+ basic_auth_user_name: basic_auth_user_name,
56
+ basic_auth_password: basic_auth_password
57
+ )
58
+
59
+ messages = client.messages
60
+ message_id = 'YOUR_MESSAGE_ID'
61
+
62
+ result = messages.get_message_status(message_id)
63
+ print result
64
+ ```
65
+
66
+ ### 💬 Get replies to a message
67
+ You can check for replies that are sent to your messages
68
+ ```ruby
69
+ require 'message_media_messages'
70
+
71
+ # Configuration parameters and credentials
72
+ basic_auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
73
+ basic_auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
74
+
75
+ client = MessageMediaMessages::MessageMediaMessagesClient.new(
76
+ basic_auth_user_name: basic_auth_user_name,
77
+ basic_auth_password: basic_auth_password
78
+ )
79
+
80
+ replies = client.replies
81
+
82
+ result = replies.get_check_replies()
83
+ ```
84
+
85
+ ### Check Delivery Reports
86
+ This endpoint allows you to check for delivery reports to inbound and outbound messages.
87
+ ```ruby
88
+ require 'message_media_messages'
89
+
90
+ # Configuration parameters and credentials
91
+ basic_auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
92
+ basic_auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
93
+
94
+ client = MessageMediaMessages::MessageMediaMessagesClient.new(
95
+ basic_auth_user_name: basic_auth_user_name,
96
+ basic_auth_password: basic_auth_password
97
+ )
98
+
99
+ deliveryReports = client.delivery_reports
100
+
101
+ result = deliveryReports.get_check_delivery_reports()
102
+ ```
103
+
104
+ ## 📕 Documentation
105
+ The Ruby SDK Documentation can be viewed [here](DOCUMENTATION.md)
106
+
107
+ ## 😕 Got Stuck?
108
+ Please contact developer support at developers@messagemedia.com or check out the developer portal at [developers.messagemedia.com](https://developers.messagemedia.com/)