messagemedia_messages_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +608 -0
  4. data/lib/message_media_messages.rb +50 -0
  5. data/lib/message_media_messages/api_helper.rb +209 -0
  6. data/lib/message_media_messages/configuration.rb +29 -0
  7. data/lib/message_media_messages/controllers/base_controller.rb +57 -0
  8. data/lib/message_media_messages/controllers/delivery_reports_controller.rb +208 -0
  9. data/lib/message_media_messages/controllers/messages_controller.rb +336 -0
  10. data/lib/message_media_messages/controllers/replies_controller.rb +208 -0
  11. data/lib/message_media_messages/exceptions/api_exception.rb +18 -0
  12. data/lib/message_media_messages/http/auth/basic_auth.rb +20 -0
  13. data/lib/message_media_messages/http/faraday_client.rb +55 -0
  14. data/lib/message_media_messages/http/http_call_back.rb +22 -0
  15. data/lib/message_media_messages/http/http_client.rb +92 -0
  16. data/lib/message_media_messages/http/http_context.rb +18 -0
  17. data/lib/message_media_messages/http/http_method_enum.rb +11 -0
  18. data/lib/message_media_messages/http/http_request.rb +48 -0
  19. data/lib/message_media_messages/http/http_response.rb +21 -0
  20. data/lib/message_media_messages/message_media_messages_client.rb +39 -0
  21. data/lib/message_media_messages/models/base_model.rb +34 -0
  22. data/lib/message_media_messages/models/cancel_scheduled_message_request.rb +35 -0
  23. data/lib/message_media_messages/models/check_delivery_reports_response.rb +35 -0
  24. data/lib/message_media_messages/models/check_replies_response.rb +35 -0
  25. data/lib/message_media_messages/models/confirm_delivery_reports_as_received_request.rb +35 -0
  26. data/lib/message_media_messages/models/confirm_delivery_reports_as_received_request_11.rb +35 -0
  27. data/lib/message_media_messages/models/confirm_replies_as_received_request.rb +35 -0
  28. data/lib/message_media_messages/models/confirm_replies_as_received_request_8.rb +35 -0
  29. data/lib/message_media_messages/models/send_messages_request.rb +35 -0
  30. data/lib/message_media_messages/models/send_messages_response.rb +35 -0
  31. data/test/controllers/controller_test_base.rb +30 -0
  32. data/test/controllers/test_delivery_reports_controller.rb +131 -0
  33. data/test/controllers/test_messages_controller.rb +105 -0
  34. data/test/controllers/test_replies_controller.rb +132 -0
  35. data/test/http_response_catcher.rb +16 -0
  36. data/test/test_helper.rb +91 -0
  37. metadata +168 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aef2e715371702201b6a82045b12fe6236a4abed
4
+ data.tar.gz: d5e0e979766af4f86e67837289fc5877ccbc3445
5
+ SHA512:
6
+ metadata.gz: f6485aee0b4ab324ee4c587194f7fabdafba9d88b2a803b9b6bb86aa7088dc1a2c1996d6596ef1d3e40953d8178db60e585079efdc3b73610135692f3b5fc3d6
7
+ data.tar.gz: 17b11c77f4a7958c87c79f7d41254376cd3073368f761104b62319d17f043cc6f48382cc8ac00c48806967b0aee5e7dc1debbbcea17bc16036531e357110871e
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,608 @@
1
+ # Getting started
2
+
3
+ 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
+