vonage 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +190 -0
- data/README.md +191 -0
- data/lib/vonage.rb +29 -0
- data/lib/vonage/abstract_authentication.rb +9 -0
- data/lib/vonage/account.rb +61 -0
- data/lib/vonage/alerts.rb +72 -0
- data/lib/vonage/applications.rb +148 -0
- data/lib/vonage/applications/list_response.rb +11 -0
- data/lib/vonage/authentication_error.rb +6 -0
- data/lib/vonage/basic.rb +13 -0
- data/lib/vonage/bearer_token.rb +14 -0
- data/lib/vonage/client.rb +134 -0
- data/lib/vonage/client_error.rb +6 -0
- data/lib/vonage/config.rb +208 -0
- data/lib/vonage/conversations.rb +210 -0
- data/lib/vonage/conversations/events.rb +73 -0
- data/lib/vonage/conversations/legs.rb +30 -0
- data/lib/vonage/conversations/members.rb +104 -0
- data/lib/vonage/conversations/users.rb +93 -0
- data/lib/vonage/conversions.rb +19 -0
- data/lib/vonage/entity.rb +51 -0
- data/lib/vonage/error.rb +6 -0
- data/lib/vonage/errors.rb +51 -0
- data/lib/vonage/files.rb +26 -0
- data/lib/vonage/form_data.rb +11 -0
- data/lib/vonage/gsm7.rb +13 -0
- data/lib/vonage/http.rb +43 -0
- data/lib/vonage/json.rb +17 -0
- data/lib/vonage/jwt.rb +43 -0
- data/lib/vonage/key_secret_params.rb +20 -0
- data/lib/vonage/keys.rb +51 -0
- data/lib/vonage/logger.rb +60 -0
- data/lib/vonage/messages.rb +25 -0
- data/lib/vonage/namespace.rb +118 -0
- data/lib/vonage/number_insight.rb +140 -0
- data/lib/vonage/numbers.rb +196 -0
- data/lib/vonage/numbers/list_response.rb +11 -0
- data/lib/vonage/numbers/response.rb +8 -0
- data/lib/vonage/params.rb +27 -0
- data/lib/vonage/pricing.rb +30 -0
- data/lib/vonage/pricing_types.rb +18 -0
- data/lib/vonage/redact.rb +37 -0
- data/lib/vonage/response.rb +25 -0
- data/lib/vonage/secrets.rb +85 -0
- data/lib/vonage/secrets/list_response.rb +11 -0
- data/lib/vonage/server_error.rb +6 -0
- data/lib/vonage/signature.rb +53 -0
- data/lib/vonage/sms.rb +121 -0
- data/lib/vonage/tfa.rb +14 -0
- data/lib/vonage/user_agent.rb +16 -0
- data/lib/vonage/verify.rb +253 -0
- data/lib/vonage/version.rb +5 -0
- data/lib/vonage/voice.rb +250 -0
- data/lib/vonage/voice/dtmf.rb +26 -0
- data/lib/vonage/voice/list_response.rb +11 -0
- data/lib/vonage/voice/stream.rb +44 -0
- data/lib/vonage/voice/talk.rb +48 -0
- data/vonage.gemspec +26 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e9290165780002d6158c32755f7f1cd8d1aaa76001d99e146b4f7e3b2a941b0b
|
4
|
+
data.tar.gz: 16ec9178b751f692f6e263889d5ecd85ab2da79fbd691fbe5f0fd2cfd8f4ccf2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 483502202f3872cc10e1dcfa17dacde39acfc31f2b0c6abfb5f5c0bb78ce7f2d16ef32b393a4ff7ad2a13c3f23b5cb9aa2318bf9786e422571404d8eabd3516b
|
7
|
+
data.tar.gz: 9e19e1170e37eec1e1e48eb39fad55a1c05f6e691974eccd575c6d47ae12d2d446ee4373dcea638b1f4e5ac9bb6de847a483856dff53c2b94f182750c76f4447
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,190 @@
|
|
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
|
+
Copyright 2020 Vonage
|
179
|
+
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
181
|
+
you may not use this file except in compliance with the License.
|
182
|
+
You may obtain a copy of the License at
|
183
|
+
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
185
|
+
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
189
|
+
See the License for the specific language governing permissions and
|
190
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
# Vonage Server SDK for Ruby
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/vonage.svg)](https://badge.fury.io/rb/vonage) [![Coverage Status](https://github.com/Vonage/vonage-ruby-sdk/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Vonage/vonage-ruby-sdk/badge.svg?branch=coveralls)](https://coveralls.io/github/Vonage/vonage-ruby-sdk?branch=master)
|
4
|
+
|
5
|
+
<img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />
|
6
|
+
|
7
|
+
This is the Ruby Server SDK for Vonage APIs. To use it you'll
|
8
|
+
need a Vonage account. Sign up [for free at vonage.com][signup].
|
9
|
+
|
10
|
+
* [Requirements](#requirements)
|
11
|
+
* [Installation](#installation)
|
12
|
+
* [Usage](#usage)
|
13
|
+
* [Logging](#logging)
|
14
|
+
* [Overriding the default hosts](#overriding-the-default-hosts)
|
15
|
+
* [JWT authentication](#jwt-authentication)
|
16
|
+
* [Webhook signatures](#webhook-signatures)
|
17
|
+
* [Documentation](#documentation)
|
18
|
+
* [Frequently Asked Questions](#frequently-asked-questions)
|
19
|
+
* [Supported APIs](#supported-apis)
|
20
|
+
* [License](#license)
|
21
|
+
|
22
|
+
|
23
|
+
## Requirements
|
24
|
+
|
25
|
+
Vonage Ruby supports MRI/CRuby (2.5 or newer), JRuby (9.2.x), and Truffleruby.
|
26
|
+
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
To install the Ruby Server SDK using Rubygems:
|
31
|
+
|
32
|
+
gem install vonage
|
33
|
+
|
34
|
+
Alternatively you can clone the repository:
|
35
|
+
|
36
|
+
git clone git@github.com:Vonage/vonage-ruby-sdk.git
|
37
|
+
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Begin by requiring the Vonage library:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'vonage'
|
45
|
+
```
|
46
|
+
|
47
|
+
Then construct a client object with your key and secret:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
client = Vonage::Client.new(api_key: 'YOUR-API-KEY', api_secret: 'YOUR-API-SECRET')
|
51
|
+
```
|
52
|
+
|
53
|
+
You can now use the client object to call Vonage APIs. For example, to send an SMS:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
client.sms.send(from: 'Ruby', to: '447700900000', text: 'Hello world')
|
57
|
+
```
|
58
|
+
|
59
|
+
For production you can specify the `VONAGE_API_KEY` and `VONAGE_API_SECRET`
|
60
|
+
environment variables instead of specifying the key and secret explicitly,
|
61
|
+
keeping your credentials out of source control.
|
62
|
+
|
63
|
+
|
64
|
+
## Logging
|
65
|
+
|
66
|
+
Use the logger option to specify a logger. For example:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'logger'
|
70
|
+
|
71
|
+
logger = Logger.new(STDOUT)
|
72
|
+
|
73
|
+
client = Vonage::Client.new(logger: logger)
|
74
|
+
```
|
75
|
+
|
76
|
+
By default the library sets the logger to `Rails.logger` if it is defined.
|
77
|
+
|
78
|
+
To disable logging set the logger to `nil`.
|
79
|
+
|
80
|
+
|
81
|
+
## Overriding the default hosts
|
82
|
+
|
83
|
+
To override the default hosts that the SDK uses for HTTP requests, you need to
|
84
|
+
specify the `api_host`, `rest_host` or both in the client configuration. For example:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
client = Vonage::Client.new(
|
88
|
+
api_host: 'api-sg-1.nexmo.com',
|
89
|
+
rest_host: 'rest-sg-1.nexmo.com'
|
90
|
+
)
|
91
|
+
```
|
92
|
+
|
93
|
+
By default the hosts are set to `api.nexmo.com` and `rest.nexmo.com`, respectively.
|
94
|
+
|
95
|
+
|
96
|
+
## JWT authentication
|
97
|
+
|
98
|
+
To call newer endpoints that support JWT authentication such as the Voice API you'll
|
99
|
+
also need to specify the `application_id` and `private_key` options. For example:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
client = Vonage::Client.new(application_id: application_id, private_key: private_key)
|
103
|
+
```
|
104
|
+
|
105
|
+
Both arguments should have string values corresponding to the `id` and `private_key`
|
106
|
+
values returned in a ["create an application"](https://developer.nexmo.com/api/application.v2#createApplication)
|
107
|
+
response. These credentials can be stored in a datastore, in environment variables,
|
108
|
+
on disk outside of source control, or in some kind of key management infrastructure.
|
109
|
+
|
110
|
+
By default the library generates a short lived JWT per request. To generate a long lived
|
111
|
+
JWT for multiple requests or to specify JWT claims directly use `Vonage::JWT.generate` and
|
112
|
+
the token option. For example:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
claims = {
|
116
|
+
application_id: application_id,
|
117
|
+
private_key: 'path/to/private.key',
|
118
|
+
nbf: 1483315200,
|
119
|
+
ttl: 800
|
120
|
+
}
|
121
|
+
|
122
|
+
token = Vonage::JWT.generate(claims)
|
123
|
+
|
124
|
+
client = Vonage::Client.new(token: token)
|
125
|
+
````
|
126
|
+
|
127
|
+
Documentation for the Vonage Ruby JWT generator gem can be found at
|
128
|
+
[https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby](https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby).
|
129
|
+
The documentation outlines all the possible parameters you can use to customize and build a token with.
|
130
|
+
|
131
|
+
## Webhook signatures
|
132
|
+
|
133
|
+
To check webhook signatures you'll also need to specify the `signature_secret` option. For example:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
client = Vonage::Client.new
|
137
|
+
client.config.signature_secret = 'secret'
|
138
|
+
client.config.signature_method = 'sha512'
|
139
|
+
|
140
|
+
if client.signature.check(request.GET)
|
141
|
+
# valid signature
|
142
|
+
else
|
143
|
+
# invalid signature
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
147
|
+
Alternatively you can set the `VONAGE_SIGNATURE_SECRET` environment variable.
|
148
|
+
|
149
|
+
Note: you'll need to contact support@nexmo.com to enable message signing on your account.
|
150
|
+
|
151
|
+
|
152
|
+
## Documentation
|
153
|
+
|
154
|
+
Vonage Ruby documentation: https://www.rubydoc.info/github/Vonage/vonage-ruby-sdk
|
155
|
+
|
156
|
+
Vonage Ruby code examples: https://github.com/Nexmo/nexmo-ruby-code-snippets
|
157
|
+
|
158
|
+
Vonage APIs API reference: https://developer.nexmo.com/api
|
159
|
+
|
160
|
+
## Frequently Asked Questions
|
161
|
+
|
162
|
+
## Supported APIs
|
163
|
+
|
164
|
+
The following is a list of Vonage APIs and whether the Ruby SDK provides support for them:
|
165
|
+
|
166
|
+
| API | API Release Status | Supported?
|
167
|
+
|----------|:---------:|:-------------:|
|
168
|
+
| Account API | General Availability |✅|
|
169
|
+
| Alerts API | General Availability |✅|
|
170
|
+
| Application API | General Availability |✅|
|
171
|
+
| Audit API | Beta |❌|
|
172
|
+
| Conversation API | Beta |❌|
|
173
|
+
| Dispatch API | Beta |❌|
|
174
|
+
| External Accounts API | Beta |❌|
|
175
|
+
| Media API | Beta | ❌|
|
176
|
+
| Messages API | Beta |❌|
|
177
|
+
| Number Insight API | General Availability |✅|
|
178
|
+
| Number Management API | General Availability |✅|
|
179
|
+
| Pricing API | General Availability |✅|
|
180
|
+
| Redact API | Developer Preview |✅|
|
181
|
+
| Reports API | Beta |❌|
|
182
|
+
| SMS API | General Availability |✅|
|
183
|
+
| Verify API | General Availability |✅|
|
184
|
+
| Voice API | General Availability |✅|
|
185
|
+
|
186
|
+
## License
|
187
|
+
|
188
|
+
This library is released under the [Apache 2.0 License][license]
|
189
|
+
|
190
|
+
[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library
|
191
|
+
[license]: LICENSE.txt
|
data/lib/vonage.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require 'zeitwerk'
|
4
|
+
require 'sorbet-runtime'
|
5
|
+
|
6
|
+
module Vonage
|
7
|
+
loader = Zeitwerk::Loader.new
|
8
|
+
loader.tag = File.basename(__FILE__, '.rb')
|
9
|
+
loader.inflector.inflect({
|
10
|
+
'dtmf' => 'DTMF',
|
11
|
+
'gsm7' => 'GSM7',
|
12
|
+
'http' => 'HTTP',
|
13
|
+
'json' => 'JSON',
|
14
|
+
'jwt' => 'JWT',
|
15
|
+
'sms' => 'SMS',
|
16
|
+
'tfa' => 'TFA',
|
17
|
+
'version' => 'VERSION',
|
18
|
+
})
|
19
|
+
loader.push_dir(__dir__)
|
20
|
+
loader.setup
|
21
|
+
|
22
|
+
def self.config
|
23
|
+
@config ||= Config.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.configure(&block)
|
27
|
+
block.call(config)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Account < Namespace
|
6
|
+
extend T::Sig
|
7
|
+
include Keys
|
8
|
+
|
9
|
+
self.host = :rest_host
|
10
|
+
|
11
|
+
# Retrieve your account balance.
|
12
|
+
#
|
13
|
+
# @return [Response]
|
14
|
+
#
|
15
|
+
# @see https://developer.nexmo.com/api/developer/account#get-balance
|
16
|
+
#
|
17
|
+
sig { returns(Vonage::Response) }
|
18
|
+
def balance
|
19
|
+
request('/account/get-balance')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Update the default callback URLs (where the webhooks are sent to) associated with your account.
|
23
|
+
#
|
24
|
+
# @note The URLs you provide must be valid and active. Vonage will check that they return a 200 OK response before the setting is saved.
|
25
|
+
#
|
26
|
+
# @option params [String] :mo_call_back_url
|
27
|
+
# The URL where Vonage will send a webhook when an SMS is received to a Vonage number that does not have SMS handling configured.
|
28
|
+
# Send an empty string to unset this value.
|
29
|
+
#
|
30
|
+
# @option params [String] :dr_call_back_url
|
31
|
+
# The URL where Vonage will send a webhook when an delivery receipt is received without a specific callback URL configured.
|
32
|
+
# Send an empty string to unset this value.
|
33
|
+
#
|
34
|
+
# @param [Hash] params
|
35
|
+
#
|
36
|
+
# @return [Response]
|
37
|
+
#
|
38
|
+
# @see https://developer.nexmo.com/api/developer/account#settings
|
39
|
+
#
|
40
|
+
sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
|
41
|
+
def update(params)
|
42
|
+
request('/account/settings', params: camelcase(params), type: Post)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Top-up your account balance.
|
46
|
+
#
|
47
|
+
# @option params [required, String] :trx
|
48
|
+
# The ID associated with your original auto-reload transaction.
|
49
|
+
#
|
50
|
+
# @param [Hash] params
|
51
|
+
#
|
52
|
+
# @return [Response]
|
53
|
+
#
|
54
|
+
# @see https://developer.nexmo.com/api/developer/account#top-up
|
55
|
+
#
|
56
|
+
sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
|
57
|
+
def topup(params)
|
58
|
+
request('/account/top-up', params: params, type: Post)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|