Skip to content

Commit 41ddc94

Browse files
committed
Generate SDK
1 parent c69e258 commit 41ddc94

34 files changed

+1970
-0
lines changed

.rubocop.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Metrics/ClassLength:
2+
Enabled: false
3+
4+
Metrics/MethodLength:
5+
Enabled: false
6+
7+
Metrics/BlockLength:
8+
Enabled: false
9+
10+
Metrics/ParameterLists:
11+
Enabled: false
12+
13+
Metrics/AbcSize:
14+
Enabled: false
15+
16+
Metrics/CyclomaticComplexity:
17+
Enabled: false
18+
19+
Metrics/PerceivedComplexity:
20+
Enabled: false
21+
22+
Lint/UnderscorePrefixedVariableName:
23+
Enabled: false
24+
25+
Naming/AccessorMethodName:
26+
Enabled: false
27+
28+
AllCops:
29+
Exclude:
30+
- './test/**/*'
31+
- './*'

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: ruby
2+
rvm:
3+
- 2.0.0
4+
- 2.1.10
5+
- 2.2.5
6+
- 2.3.1

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
3+
group :test do
4+
gem 'rake'
5+
end
6+
7+
gemspec

Jenkinsfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node {
2+
stage 'Checkout'
3+
checkout scm
4+
5+
stage 'Prepare'
6+
bat 'bundle install'
7+
8+
stage 'Test'
9+
bat 'bundle exec rake'
10+
}

README.md

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
# Getting started
2+
3+
TODO: Add a description
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_webhooks.gemspec ``` to build the gem.
11+
3. Once built, the gem can be installed on the current work environment using ``` gem install message_media_webhooks-1.0.0.gem ```
12+
13+
![Building Gem](https://apidocs.io/illustration/ruby?step=buildSDK&workspaceFolder=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks-Ruby&projectName=message_media_webhooks&gemName=message_media_webhooks&gemVer=1.0.0)
14+
15+
## How to Use
16+
17+
The following section explains how to use the MessageMediaWebhooks 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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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 MessageMediaWebhooks 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_webhooks', '~> 1.0.0' ```
38+
39+
![Add references of the Gemfile](https://apidocs.io/illustration/ruby?step=addReference&workspaceFolder=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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=MessageMediaWebhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&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 = MessageMediaWebhooks::MessageMediaWebhooksClient.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=Webhooks-Ruby&workspaceName=MessageMediaWebhooks&projectName=message_media_webhooks&gemName=message_media_webhooks&gemVer=1.0.0&initLine=client%2520%253D%2520MessageMediaWebhooksClient.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+
* [APIController](#api_controller)
103+
104+
## <a name="api_controller"></a>![Class: ](https://apidocs.io/img/class.png ".APIController") APIController
105+
106+
### Get singleton instance
107+
108+
The singleton instance of the ``` APIController ``` class can be accessed from the API Client.
109+
110+
```ruby
111+
client_controller = client.client
112+
```
113+
114+
### <a name="create"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.create") create
115+
116+
> This will create a webhook for the specified `events`
117+
> ### Parameters
118+
> **list of supported parameters in `template` according to the message type :**
119+
> you must escape the json for the template parameter. see example .
120+
> | Data | parameter name | DR| MO | MO MMS | Comment |
121+
> |:--|--|--|--|--|--|
122+
> | **service type** | $type| ``OK`` |`OK`| `OK`| |
123+
> | **Message ID** | $mtId, $messageId| `OK` |`OK`| `OK`| |
124+
> | **Delivery report ID** |$drId, $reportId | `OK` || | |
125+
> | **Reply ID**| $moId, $replyId| |`OK`| `OK`||
126+
> | **Account ID** | $accountId| `OK` |`OK`| `OK`||
127+
> | **Message Timestamp** | $submittedTimestamp| `OK` |`OK`| `OK`||
128+
> | **Provider Timestamp** | $receivedTimestamp| `OK` |`OK`| `OK`||
129+
> | **Message status** | $status| `OK` ||||
130+
> | **Status code** | $statusCode| `OK` ||||
131+
> | **External metadata** | $metadata.get('key')| `OK` |`OK`| `OK`||
132+
> | **Source address**| $sourceAddress| `OK` |`OK`| `OK`||
133+
> | **Destination address**| $destinationAddress| |`OK`| `OK`||
134+
> | **Message content**| $mtContent, $messageContent| `OK` |`OK`| `OK`||
135+
> | **Reply Content**| $moContent, $replyContent| |`OK`| `OK`||
136+
> | **Retry Count**| $retryCount| `OK` |`OK`| `OK`||
137+
> **list of allowed `events` :**
138+
> you can combine all the events whatever the message type.(at least one Event set otherwise the webhook won't be created)
139+
> + **events for SMS**
140+
> + `RECEIVED_SMS`
141+
> + `OPT_OUT_SMS`
142+
> + **events for MMS**
143+
> + `RECEIVED_MMS`
144+
> + **events for DR**
145+
> + `ENROUTE_DR`
146+
> + `EXPIRED_DR`
147+
> + `REJECTED_DR`
148+
> + `FAILED_DR`
149+
> + `DELIVERED_DR`
150+
> + `SUBMITTED_DR`
151+
> a **Response 400 is returned when** :
152+
> <ul>
153+
> <li>the `url` is not valid </li>
154+
> <li>the `events` is null/empty </li>
155+
> <li>the `encoding` is null </li>
156+
> <li>the `method` is null </li>
157+
> <li>the `headers` has a `ContentType` attribute </li>
158+
> </ul>
159+
160+
161+
```ruby
162+
def create(content_type,
163+
body); end
164+
```
165+
166+
#### Parameters
167+
168+
| Parameter | Tags | Description |
169+
|-----------|------|-------------|
170+
| content_type | ``` Required ``` | TODO: Add a parameter description |
171+
| body | ``` Required ``` | TODO: Add a parameter description |
172+
173+
174+
#### Example Usage
175+
176+
```ruby
177+
content_type = 'Content-Type'
178+
body = CreateRequest.new
179+
180+
result = client_controller.create(content_type, body)
181+
182+
```
183+
184+
#### Errors
185+
186+
| Error Code | Error Description |
187+
|------------|-------------------|
188+
| 400 | TODO: Add an error description |
189+
190+
191+
192+
### <a name="delete_delete_and_update_webhook"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.delete_delete_and_update_webhook") delete_delete_and_update_webhook
193+
194+
> This will delete the webhook wuth the give id.
195+
> a **Response 404 is returned when** :
196+
> <ul>
197+
> <li>there is no webhook with this `webhookId` </li>
198+
> </ul>
199+
200+
201+
```ruby
202+
def delete_delete_and_update_webhook(webhook_id); end
203+
```
204+
205+
#### Parameters
206+
207+
| Parameter | Tags | Description |
208+
|-----------|------|-------------|
209+
| webhook_id | ``` Required ``` | TODO: Add a parameter description |
210+
211+
212+
#### Example Usage
213+
214+
```ruby
215+
webhook_id = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad
216+
217+
client_controller.delete_delete_and_update_webhook(webhook_id)
218+
219+
```
220+
221+
#### Errors
222+
223+
| Error Code | Error Description |
224+
|------------|-------------------|
225+
| 404 | TODO: Add an error description |
226+
227+
228+
229+
### <a name="retrieve"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.retrieve") retrieve
230+
231+
> This will retrieve all webhooks for the account we're connected with.
232+
> a **Response 400 is returned when** :
233+
> <ul>
234+
> <li>the `page` query parameter is not valid </li>
235+
> <li>the `pageSize` query parameter is not valid </li>
236+
> </ul>
237+
238+
239+
```ruby
240+
def retrieve(page = nil,
241+
page_size = nil); end
242+
```
243+
244+
#### Parameters
245+
246+
| Parameter | Tags | Description |
247+
|-----------|------|-------------|
248+
| page | ``` Optional ``` | TODO: Add a parameter description |
249+
| page_size | ``` Optional ``` | TODO: Add a parameter description |
250+
251+
252+
#### Example Usage
253+
254+
```ruby
255+
page = '1'
256+
page_size = '10'
257+
258+
result = client_controller.retrieve(page, page_size)
259+
260+
```
261+
262+
#### Errors
263+
264+
| Error Code | Error Description |
265+
|------------|-------------------|
266+
| 400 | TODO: Add an error description |
267+
268+
269+
270+
### <a name="update"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.update") update
271+
272+
> This will update a webhook and returned the updated Webhook.
273+
> you can update all the attributes individually or together.
274+
> PS : the new value will override the previous one.
275+
> ### Parameters
276+
> + same parameters rules as create webhook apply
277+
> a **Response 404 is returned when** :
278+
> <ul>
279+
> <li>there is no webhook with this `webhookId` </li>
280+
> </ul>
281+
> a **Response 400 is returned when** :
282+
> <ul>
283+
> <li>all attributes are null </li>
284+
> <li>events array is empty </li>
285+
> <li>content-Type is set in the headers instead of using the `encoding` attribute </li>
286+
> </ul>
287+
288+
289+
```ruby
290+
def update(webhook_id,
291+
content_type,
292+
body); end
293+
```
294+
295+
#### Parameters
296+
297+
| Parameter | Tags | Description |
298+
|-----------|------|-------------|
299+
| webhook_id | ``` Required ``` | TODO: Add a parameter description |
300+
| content_type | ``` Required ``` | TODO: Add a parameter description |
301+
| body | ``` Required ``` | TODO: Add a parameter description |
302+
303+
304+
#### Example Usage
305+
306+
```ruby
307+
webhook_id = UUID.new
308+
content_type = 'Content-Type'
309+
body = UpdateRequest.new
310+
311+
client_controller.update(webhook_id, content_type, body)
312+
313+
```
314+
315+
#### Errors
316+
317+
| Error Code | Error Description |
318+
|------------|-------------------|
319+
| 404 | TODO: Add an error description |
320+
321+
322+
323+
[Back to List of Controllers](#list_of_controllers)
324+
325+
326+

0 commit comments

Comments
 (0)