vonage 7.11.0 → 7.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vonage/client.rb +7 -0
- data/lib/vonage/namespace.rb +1 -0
- data/lib/vonage/subaccounts/balance_transfers/list_response.rb +11 -0
- data/lib/vonage/subaccounts/credit_transfers/list_response.rb +11 -0
- data/lib/vonage/subaccounts/list_response.rb +15 -0
- data/lib/vonage/subaccounts.rb +203 -0
- data/lib/vonage/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42d5bfc879e0b399da415f92a0f65313c3aa3f22760945c7832996290e7cbebb
|
4
|
+
data.tar.gz: be7e53025cad9a1fa877d9749e82ff22fa4c6ec4cb2da63ecefef136269fc810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f033e6795e3d52bdef207656a7230925037b04dbdbd57bbdbce4cf74b91842cb9cfcd7e04b9061a5267210905d14b68961dc4daab26bf349dff0ece9a6e659
|
7
|
+
data.tar.gz: 43c52d578923fd7a5a7b04b243b040df2ba1cef5dd0c38c37007820207a5ab411a9976a0b42a2dff653b19d6e856ade248163a8856ac93c88dd49209d4cd6b4f
|
data/lib/vonage/client.rb
CHANGED
@@ -117,6 +117,13 @@ module Vonage
|
|
117
117
|
@sms ||= T.let(SMS.new(config), T.nilable(Vonage::SMS))
|
118
118
|
end
|
119
119
|
|
120
|
+
# @return [Subaccounts]
|
121
|
+
#
|
122
|
+
sig { returns(T.nilable(Vonage::Subaccounts)) }
|
123
|
+
def subaccounts
|
124
|
+
@subaccounts ||= T.let(Subaccounts.new(config), T.nilable(Vonage::Subaccounts))
|
125
|
+
end
|
126
|
+
|
120
127
|
# @return [TFA]
|
121
128
|
#
|
122
129
|
sig { returns(T.nilable(Vonage::TFA)) }
|
data/lib/vonage/namespace.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
class Vonage::Subaccounts::ListResponse < Vonage::Response
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def primary_account
|
7
|
+
@entity._embedded.primary_account
|
8
|
+
end
|
9
|
+
|
10
|
+
def each
|
11
|
+
return enum_for(:each) unless block_given?
|
12
|
+
|
13
|
+
@entity._embedded.subaccounts.each { |item| yield item }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Subaccounts < Namespace
|
6
|
+
self.authentication = Basic
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
# Retrieve list of subaccounts.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# response = client.subaccounts.list
|
14
|
+
#
|
15
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveSubaccountsList
|
16
|
+
#
|
17
|
+
def list
|
18
|
+
request("/accounts/#{@config.api_key}/subaccounts", response_class: ListResponse)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve a subaccount.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# response = client.subaccounts.find(subaccount_key: 'abc123')
|
25
|
+
#
|
26
|
+
# @option params [required, String] :subaccount_key
|
27
|
+
# The API key for the subaccount you want to retrieve
|
28
|
+
#
|
29
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveSubaccount
|
30
|
+
#
|
31
|
+
def find(subaccount_key:)
|
32
|
+
request("/accounts/#{@config.api_key}/subaccounts/#{subaccount_key}")
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a subaccount.
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# response = client.subaccounts.create(name: 'Foo')
|
39
|
+
#
|
40
|
+
# @option params [required, String] :name
|
41
|
+
# The name of the subaccount
|
42
|
+
#
|
43
|
+
# @option params [optional, String] :secret
|
44
|
+
# An account secret for use by the subaccount. Can be used in combination with your API key to authenticate your API requests.
|
45
|
+
# Requirements:
|
46
|
+
# - 8 characters and no more than 25
|
47
|
+
# - 1 lower-case letter
|
48
|
+
# - 1 capital letter
|
49
|
+
# - 1 digit
|
50
|
+
# - must be unique
|
51
|
+
#
|
52
|
+
# @option params [optional, Boolean] :use_primary_account_balance
|
53
|
+
# Whether the subaccount uses the primary account balance (true, the default) or has its own balance (false).
|
54
|
+
# Once set to `false` cannot be changed back to `true`
|
55
|
+
#
|
56
|
+
# @see https://developer.vonage.com/en/api/subaccounts#createSubAccount
|
57
|
+
#
|
58
|
+
def create(name:, **params)
|
59
|
+
request("/accounts/#{@config.api_key}/subaccounts", params: params.merge(name: name), type: Post)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Modify a subaccount.
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# response = client.subaccounts.update(name: 'Bar')
|
66
|
+
#
|
67
|
+
# @option params [required, String] :subaccount_key
|
68
|
+
# The API key for the subaccount you want to modify
|
69
|
+
#
|
70
|
+
# @option params [optional, String] :name
|
71
|
+
# The name of the subaccount
|
72
|
+
#
|
73
|
+
# @option params [optional, Boolean] :use_primary_account_balance
|
74
|
+
# Whether the subaccount uses the primary account balance (true, the default) or has its own balance (false).
|
75
|
+
# Once set to `false` cannot be changed back to `true`
|
76
|
+
#
|
77
|
+
# @option params [optional, String] :suspended
|
78
|
+
# Whether the subaccount is suspended (true) or not (false, the default)
|
79
|
+
#
|
80
|
+
# @see https://developer.vonage.com/en/api/subaccounts#modifySubaccount
|
81
|
+
#
|
82
|
+
def update(subaccount_key:, **params)
|
83
|
+
request("/accounts/#{@config.api_key}/subaccounts/#{subaccount_key}", params: params, type: Patch)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Retrieve list of credit transfers.
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# response = client.subaccounts.list_credit_transfers(start_date: "2023-06-15T15:53:50Z")
|
90
|
+
#
|
91
|
+
# @option params [optional, String] :start_date
|
92
|
+
# The ISO format datetime from which to list transfers. Example: 2019-03-02T16:34:49Z.
|
93
|
+
# Defaults to "1970-01-01T00:00:00Z" if omitted
|
94
|
+
#
|
95
|
+
# @option params [optional, String] :end_date
|
96
|
+
# The ISO format datetime to which to list transfers. Example: 2019-03-02T16:34:49Z.
|
97
|
+
# If absent then all transfers until now is returned.
|
98
|
+
#
|
99
|
+
# @option params [optional, String] :subaccount
|
100
|
+
# Subaccount to filter by.
|
101
|
+
#
|
102
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveCreditTransfers
|
103
|
+
#
|
104
|
+
def list_credit_transfers(start_date: "1970-01-01T00:00:00Z", **params)
|
105
|
+
path = "/accounts/#{@config.api_key}/credit-transfers?#{Params.encode(params.merge(start_date: start_date))}"
|
106
|
+
|
107
|
+
request(path, response_class: CreditTransfers::ListResponse)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Transfer credit.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# response = client.subaccounts.transfer_credit(from: 'abc123', to: 'def456', amount: 10.00)
|
114
|
+
#
|
115
|
+
# @option params [required, String] :from
|
116
|
+
# The API key of the account or subaccount to transfer credit from.
|
117
|
+
#
|
118
|
+
# @option params [required, String] :to
|
119
|
+
# The API key of the account or subaccount to transfer credit to.
|
120
|
+
#
|
121
|
+
# @option params [required, Number] :amount
|
122
|
+
# The amount to transfer
|
123
|
+
#
|
124
|
+
# @option params [optional, String] :reference
|
125
|
+
# A reference for the transfer.
|
126
|
+
#
|
127
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferCredit
|
128
|
+
#
|
129
|
+
def transfer_credit(from:, to:, amount:, **params)
|
130
|
+
request("/accounts/#{@config.api_key}/credit-transfers", params: params.merge(from: from, to: to, amount: amount), type: Post)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Retrieve list of balance transfers.
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# response = client.subaccounts.list_balance_transfers(start_date: "2023-06-15T15:53:50Z")
|
137
|
+
#
|
138
|
+
# @option params [optional, String] :start_date
|
139
|
+
# The ISO format datetime from which to list transfers. Example: 2019-03-02T16:34:49Z.
|
140
|
+
# Defaults to "1970-01-01T00:00:00Z" if omitted
|
141
|
+
#
|
142
|
+
# @option params [optional, String] :end_date
|
143
|
+
# The ISO format datetime to which to list transfers. Example: 2019-03-02T16:34:49Z.
|
144
|
+
# If absent then all transfers until now is returned.
|
145
|
+
#
|
146
|
+
# @option params [optional, String] :subaccount
|
147
|
+
# Subaccount to filter by.
|
148
|
+
#
|
149
|
+
# @see https://developer.vonage.com/en/api/subaccounts#retrieveBalanceTransfers
|
150
|
+
#
|
151
|
+
def list_balance_transfers(start_date: "1970-01-01T00:00:00Z", **params)
|
152
|
+
path = "/accounts/#{@config.api_key}/balance-transfers?#{Params.encode(params.merge(start_date: start_date))}"
|
153
|
+
|
154
|
+
request(path, response_class: BalanceTransfers::ListResponse)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Transfer balance.
|
158
|
+
#
|
159
|
+
# @example
|
160
|
+
# response = client.subaccounts.transfer_balance(from: 'abc123', to: 'def456', amount: 10.00)
|
161
|
+
#
|
162
|
+
# @option params [required, String] :from
|
163
|
+
# The API key of the account or subaccount to transfer balance from.
|
164
|
+
#
|
165
|
+
# @option params [required, String] :to
|
166
|
+
# The API key of the account or subaccount to transfer balance to.
|
167
|
+
#
|
168
|
+
# @option params [required, Number] :amount
|
169
|
+
# The amount to transfer
|
170
|
+
#
|
171
|
+
# @option params [optional, String] :reference
|
172
|
+
# A reference for the transfer.
|
173
|
+
#
|
174
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferBalance
|
175
|
+
#
|
176
|
+
def transfer_balance(from:, to:, amount:, **params)
|
177
|
+
request("/accounts/#{@config.api_key}/balance-transfers", params: params.merge(from: from, to: to, amount: amount), type: Post)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Transfer number.
|
181
|
+
#
|
182
|
+
# @example
|
183
|
+
# response = client.subaccounts.transfer_number(from: 'abc123', to: 'def456', number: 447900000000, country: 'GB')
|
184
|
+
#
|
185
|
+
# @option params [required, String] :from
|
186
|
+
# The API key of the account or subaccount to transfer the number from.
|
187
|
+
#
|
188
|
+
# @option params [required, String] :to
|
189
|
+
# The API key of the account or subaccount to transfer the number to.
|
190
|
+
#
|
191
|
+
# @option params [required, Number] :number
|
192
|
+
# The number to transfer
|
193
|
+
#
|
194
|
+
# @option params [required, String] :country
|
195
|
+
# An ISO-3166-1 alpha 2 code representing the country for the number, e.g. GB.
|
196
|
+
#
|
197
|
+
# @see https://developer.vonage.com/en/api/subaccounts#transferNumber
|
198
|
+
#
|
199
|
+
def transfer_number(from:, to:, number:, country:)
|
200
|
+
request("/accounts/#{@config.api_key}/transfer-number", params: {from: from, to: to, number: number, country: country}, type: Post)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
data/lib/vonage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vonage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vonage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vonage-jwt
|
@@ -149,6 +149,10 @@ files:
|
|
149
149
|
- lib/vonage/service_error.rb
|
150
150
|
- lib/vonage/signature.rb
|
151
151
|
- lib/vonage/sms.rb
|
152
|
+
- lib/vonage/subaccounts.rb
|
153
|
+
- lib/vonage/subaccounts/balance_transfers/list_response.rb
|
154
|
+
- lib/vonage/subaccounts/credit_transfers/list_response.rb
|
155
|
+
- lib/vonage/subaccounts/list_response.rb
|
152
156
|
- lib/vonage/tfa.rb
|
153
157
|
- lib/vonage/user_agent.rb
|
154
158
|
- lib/vonage/verify.rb
|