nexmo 7.0.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -6
- data/lib/nexmo.rb +1 -1
- data/lib/nexmo/abstract_authentication.rb +0 -2
- data/lib/nexmo/applications.rb +24 -4
- data/lib/nexmo/client.rb +40 -19
- data/lib/nexmo/config.rb +42 -9
- data/lib/nexmo/conversations.rb +24 -1
- data/lib/nexmo/conversations/events.rb +1 -1
- data/lib/nexmo/conversations/legs.rb +1 -1
- data/lib/nexmo/conversations/members.rb +1 -1
- data/lib/nexmo/conversations/users.rb +1 -1
- data/lib/nexmo/conversions.rb +4 -1
- data/lib/nexmo/entity.rb +2 -2
- data/lib/nexmo/errors.rb +6 -1
- data/lib/nexmo/files.rb +7 -3
- data/lib/nexmo/gsm7.rb +0 -2
- data/lib/nexmo/http.rb +12 -4
- data/lib/nexmo/json.rb +4 -1
- data/lib/nexmo/jwt.rb +11 -12
- data/lib/nexmo/key_secret_params.rb +9 -3
- data/lib/nexmo/keys.rb +24 -3
- data/lib/nexmo/logger.rb +14 -5
- data/lib/nexmo/messages.rb +6 -1
- data/lib/nexmo/number_insight.rb +1 -1
- data/lib/nexmo/numbers.rb +1 -1
- data/lib/nexmo/pricing.rb +1 -1
- data/lib/nexmo/pricing_types.rb +1 -1
- data/lib/nexmo/redact.rb +4 -1
- data/lib/nexmo/response.rb +1 -1
- data/lib/nexmo/secrets.rb +1 -1
- data/lib/nexmo/signature.rb +1 -1
- data/lib/nexmo/sms.rb +1 -1
- data/lib/nexmo/tfa.rb +1 -1
- data/lib/nexmo/verify.rb +66 -3
- data/lib/nexmo/version.rb +1 -1
- data/lib/nexmo/voice.rb +1 -1
- data/lib/nexmo/voice/dtmf.rb +1 -1
- data/lib/nexmo/voice/stream.rb +1 -1
- data/lib/nexmo/voice/talk.rb +1 -1
- data/nexmo.gemspec +13 -1
- metadata +29 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 447ff8e3327707d746fe73ec09ea76c18bc42a7dbfe90a3ce149428503a647e4
|
4
|
+
data.tar.gz: 54695afb4d4d5cd4a8198ed96eea0cb96667ac837c3eeff62cf1693d7d67f055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a65424751d0d892fdfbfe76c3536aac6d048779af3cadcaa11b12acd67d460411de36cfd17ea546131e6d0a4360be16f379573f077cec7654a860d6a3ceed6
|
7
|
+
data.tar.gz: 0dfe4f3086fa2ddaf88784d9af0e8ed87aaf363d496feed3be993d24058699d61ae093cfedadaf7852f336e8385e00db08f4d51504260f8f8eadcab63bdf1f13
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# Nexmo Client Library for Ruby
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![Coverage Status](https://github.com/nexmo/nexmo-ruby/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Nexmo/nexmo-ruby/badge.svg?branch=coveralls)](https://coveralls.io/github/Nexmo/nexmo-ruby?branch=master)
|
4
4
|
|
5
5
|
<img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />
|
6
6
|
|
7
|
+
|<p align="left">:exclamation: This SDK and Ruby gem have moved! It is now [`vonage`](https://rubygems.org/gems/vonage), located at [vonage/vonage-ruby-sdk](https://github.com/vonage/vonage-ruby-sdk). <br /><br /> We will support this repository for 12 months, ending October 2021, with any needed bug or security fixes for the last release of v7.2.1. New features will be released under `vonage`, so to take advantage of those please make sure to switch to `vonage` as soon as possible so you don't miss out!</p> |
|
8
|
+
|-----------------------------------------|
|
9
|
+
|
7
10
|
This is the Ruby client library for Nexmo's API. To use it you'll
|
8
11
|
need a Nexmo account. Sign up [for free at nexmo.com][signup].
|
9
12
|
|
@@ -15,6 +18,8 @@ need a Nexmo account. Sign up [for free at nexmo.com][signup].
|
|
15
18
|
* [JWT authentication](#jwt-authentication)
|
16
19
|
* [Webhook signatures](#webhook-signatures)
|
17
20
|
* [Documentation](#documentation)
|
21
|
+
* [Frequently Asked Questions](#frequently-asked-questions)
|
22
|
+
* [Supported APIs](#supported-apis)
|
18
23
|
* [License](#license)
|
19
24
|
|
20
25
|
|
@@ -112,18 +117,19 @@ the token option. For example:
|
|
112
117
|
```ruby
|
113
118
|
claims = {
|
114
119
|
application_id: application_id,
|
120
|
+
private_key: 'path/to/private.key',
|
115
121
|
nbf: 1483315200,
|
116
|
-
|
117
|
-
iat: 1483228800
|
122
|
+
ttl: 800
|
118
123
|
}
|
119
124
|
|
120
|
-
|
121
|
-
|
122
|
-
token = Nexmo::JWT.generate(claims, private_key)
|
125
|
+
token = Nexmo::JWT.generate(claims)
|
123
126
|
|
124
127
|
client = Nexmo::Client.new(token: token)
|
125
128
|
````
|
126
129
|
|
130
|
+
Documentation for the Nexmo Ruby JWT generator gem can be found at
|
131
|
+
[https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby](https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby).
|
132
|
+
The documentation outlines all the possible parameters you can use to customize and build a token with.
|
127
133
|
|
128
134
|
## Webhook signatures
|
129
135
|
|
@@ -154,6 +160,31 @@ Nexmo Ruby code examples: https://github.com/Nexmo/nexmo-ruby-code-snippets
|
|
154
160
|
|
155
161
|
Nexmo API reference: https://developer.nexmo.com/api
|
156
162
|
|
163
|
+
## Frequently Asked Questions
|
164
|
+
|
165
|
+
## Supported APIs
|
166
|
+
|
167
|
+
The following is a list of Vonage APIs and whether the Ruby SDK provides support for them:
|
168
|
+
|
169
|
+
| API | API Release Status | Supported?
|
170
|
+
|----------|:---------:|:-------------:|
|
171
|
+
| Account API | General Availability |✅|
|
172
|
+
| Alerts API | General Availability |✅|
|
173
|
+
| Application API | General Availability |✅|
|
174
|
+
| Audit API | Beta |❌|
|
175
|
+
| Conversation API | Beta |❌|
|
176
|
+
| Dispatch API | Beta |❌|
|
177
|
+
| External Accounts API | Beta |❌|
|
178
|
+
| Media API | Beta | ❌|
|
179
|
+
| Messages API | Beta |❌|
|
180
|
+
| Number Insight API | General Availability |✅|
|
181
|
+
| Number Management API | General Availability |✅|
|
182
|
+
| Pricing API | General Availability |✅|
|
183
|
+
| Redact API | Developer Preview |✅|
|
184
|
+
| Reports API | Beta |❌|
|
185
|
+
| SMS API | General Availability |✅|
|
186
|
+
| Verify API | General Availability |✅|
|
187
|
+
| Voice API | General Availability |✅|
|
157
188
|
|
158
189
|
## License
|
159
190
|
|
data/lib/nexmo.rb
CHANGED
data/lib/nexmo/applications.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Nexmo
|
5
5
|
class Applications < Namespace
|
6
|
+
extend T::Sig
|
6
7
|
self.authentication = Basic
|
7
8
|
|
8
9
|
self.request_body = JSON
|
@@ -14,9 +15,20 @@ module Nexmo
|
|
14
15
|
# @example
|
15
16
|
# params = {
|
16
17
|
# name: 'Example App',
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# capabilities: {
|
19
|
+
# 'messages': {
|
20
|
+
# 'webhooks': {
|
21
|
+
# 'inbound_url': {
|
22
|
+
# 'address': 'https://example.com/webhooks/inbound',
|
23
|
+
# 'http_method': 'POST'
|
24
|
+
# },
|
25
|
+
# 'status_url': {
|
26
|
+
# 'address': 'https://example.com/webhooks/status',
|
27
|
+
# 'http_method': 'POST'
|
28
|
+
# }
|
29
|
+
# }
|
30
|
+
# }
|
31
|
+
# }
|
20
32
|
# }
|
21
33
|
#
|
22
34
|
# response = client.applications.create(params)
|
@@ -38,6 +50,7 @@ module Nexmo
|
|
38
50
|
#
|
39
51
|
# @see https://developer.nexmo.com/api/application.v2#createApplication
|
40
52
|
#
|
53
|
+
sig { params(params: T::Hash[Symbol, T.untyped]).returns(Nexmo::Response) }
|
41
54
|
def create(params)
|
42
55
|
request('/v2/applications', params: params, type: Post)
|
43
56
|
end
|
@@ -62,6 +75,7 @@ module Nexmo
|
|
62
75
|
#
|
63
76
|
# @see https://developer.nexmo.com/api/application.v2#listApplication
|
64
77
|
#
|
78
|
+
sig { params(params: T.nilable(T::Hash[Symbol, Integer])).returns(Nexmo::Response) }
|
65
79
|
def list(params = nil)
|
66
80
|
request('/v2/applications', params: params, response_class: ListResponse)
|
67
81
|
end
|
@@ -77,6 +91,7 @@ module Nexmo
|
|
77
91
|
#
|
78
92
|
# @see https://developer.nexmo.com/api/application.v2#getApplication
|
79
93
|
#
|
94
|
+
sig { params(id: String).returns(Nexmo::Response) }
|
80
95
|
def get(id)
|
81
96
|
request('/v2/applications/' + id)
|
82
97
|
end
|
@@ -104,6 +119,10 @@ module Nexmo
|
|
104
119
|
#
|
105
120
|
# @see https://developer.nexmo.com/api/application.v2#updateApplication
|
106
121
|
#
|
122
|
+
sig { params(
|
123
|
+
id: String,
|
124
|
+
params: T::Hash[Symbol, T.untyped]
|
125
|
+
).returns(Nexmo::Response) }
|
107
126
|
def update(id, params)
|
108
127
|
request('/v2/applications/' + id, params: params, type: Put)
|
109
128
|
end
|
@@ -121,6 +140,7 @@ module Nexmo
|
|
121
140
|
#
|
122
141
|
# @see https://developer.nexmo.com/api/application.v2#deleteApplication
|
123
142
|
#
|
143
|
+
sig { params(id: String).returns(Nexmo::Response) }
|
124
144
|
def delete(id)
|
125
145
|
request('/v2/applications/' + id, type: Delete)
|
126
146
|
end
|
data/lib/nexmo/client.rb
CHANGED
@@ -1,113 +1,134 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
|
3
3
|
module Nexmo
|
4
4
|
class Client
|
5
|
+
extend T::Sig
|
6
|
+
|
7
|
+
sig { returns(Nexmo::Config) }
|
5
8
|
attr_reader :config
|
6
9
|
|
10
|
+
sig { params(options: T.nilable(T::Hash[Symbol, T.untyped])).void }
|
7
11
|
def initialize(options = nil)
|
8
|
-
@config = Nexmo.config.merge(options)
|
12
|
+
@config = T.let(Nexmo.config.merge(options), Nexmo::Config)
|
9
13
|
end
|
10
14
|
|
11
15
|
# @return [Signature]
|
12
16
|
#
|
17
|
+
sig { returns(T.nilable(Nexmo::Signature)) }
|
13
18
|
def signature
|
14
|
-
@signature ||= Signature.new(config)
|
19
|
+
@signature ||= T.let(Signature.new(config), T.nilable(Nexmo::Signature))
|
15
20
|
end
|
16
21
|
|
17
22
|
# @return [Account]
|
18
23
|
#
|
24
|
+
sig { returns(T.nilable(Nexmo::Account)) }
|
19
25
|
def account
|
20
|
-
@account ||= Account.new(config)
|
26
|
+
@account ||= T.let(Account.new(config), T.nilable(Nexmo::Account))
|
21
27
|
end
|
22
28
|
|
23
29
|
# @return [Alerts]
|
24
30
|
#
|
31
|
+
sig { returns(T.nilable(Nexmo::Alerts)) }
|
25
32
|
def alerts
|
26
|
-
@alerts ||= Alerts.new(config)
|
33
|
+
@alerts ||= T.let(Alerts.new(config), T.nilable(Nexmo::Alerts))
|
27
34
|
end
|
28
35
|
|
29
36
|
# @return [Applications]
|
30
37
|
#
|
38
|
+
sig { returns(T.nilable(Nexmo::Applications)) }
|
31
39
|
def applications
|
32
|
-
@applications ||= Applications.new(config)
|
40
|
+
@applications ||= T.let(Applications.new(config), T.nilable(Nexmo::Applications))
|
33
41
|
end
|
34
42
|
|
35
43
|
# @return [Conversations]
|
36
44
|
#
|
45
|
+
sig { returns(T.nilable(Nexmo::Conversations)) }
|
37
46
|
def conversations
|
38
|
-
@conversations ||= Conversations.new(config)
|
47
|
+
@conversations ||= T.let(Conversations.new(config), T.nilable(Nexmo::Conversations))
|
39
48
|
end
|
40
49
|
|
41
50
|
# @return [Conversions]
|
42
51
|
#
|
52
|
+
sig { returns(T.nilable(Nexmo::Conversions)) }
|
43
53
|
def conversions
|
44
|
-
@conversions ||= Conversions.new(config)
|
54
|
+
@conversions ||= T.let(Conversions.new(config), T.nilable(Nexmo::Conversions))
|
45
55
|
end
|
46
56
|
|
47
57
|
# @return [Files]
|
48
58
|
#
|
59
|
+
sig { returns(T.nilable(Nexmo::Files)) }
|
49
60
|
def files
|
50
|
-
@files ||= Files.new(config)
|
61
|
+
@files ||= T.let(Files.new(config), T.nilable(Nexmo::Files))
|
51
62
|
end
|
52
63
|
|
53
64
|
# @return [Messages]
|
54
65
|
#
|
66
|
+
sig { returns(T.nilable(Nexmo::Messages)) }
|
55
67
|
def messages
|
56
|
-
@messages ||= Messages.new(config)
|
68
|
+
@messages ||= T.let(Messages.new(config), T.nilable(Nexmo::Messages))
|
57
69
|
end
|
58
70
|
|
59
71
|
# @return [NumberInsight]
|
60
72
|
#
|
73
|
+
sig { returns(T.nilable(Nexmo::NumberInsight)) }
|
61
74
|
def number_insight
|
62
|
-
@number_insight ||= NumberInsight.new(config)
|
75
|
+
@number_insight ||= T.let(NumberInsight.new(config), T.nilable(Nexmo::NumberInsight))
|
63
76
|
end
|
64
77
|
|
65
78
|
# @return [Numbers]
|
66
79
|
#
|
80
|
+
sig { returns(T.nilable(Nexmo::Numbers)) }
|
67
81
|
def numbers
|
68
|
-
@numbers ||= Numbers.new(config)
|
82
|
+
@numbers ||= T.let(Numbers.new(config), T.nilable(Nexmo::Numbers))
|
69
83
|
end
|
70
84
|
|
71
85
|
# @return [PricingTypes]
|
72
86
|
#
|
87
|
+
sig { returns(T.nilable(Nexmo::PricingTypes)) }
|
73
88
|
def pricing
|
74
|
-
@pricing ||= PricingTypes.new(config)
|
89
|
+
@pricing ||= T.let(PricingTypes.new(config), T.nilable(Nexmo::PricingTypes))
|
75
90
|
end
|
76
91
|
|
77
92
|
# @return [Redact]
|
78
93
|
#
|
94
|
+
sig { returns(T.nilable(Nexmo::Redact)) }
|
79
95
|
def redact
|
80
|
-
@redact ||= Redact.new(config)
|
96
|
+
@redact ||= T.let(Redact.new(config), T.nilable(Nexmo::Redact))
|
81
97
|
end
|
82
98
|
|
83
99
|
# @return [Secrets]
|
84
100
|
#
|
101
|
+
sig { returns(T.nilable(Nexmo::Secrets)) }
|
85
102
|
def secrets
|
86
|
-
@secrets ||= Secrets.new(config)
|
103
|
+
@secrets ||= T.let(Secrets.new(config), T.nilable(Nexmo::Secrets))
|
87
104
|
end
|
88
105
|
|
89
106
|
# @return [SMS]
|
90
107
|
#
|
108
|
+
sig { returns(T.nilable(Nexmo::SMS)) }
|
91
109
|
def sms
|
92
|
-
@sms ||= SMS.new(config)
|
110
|
+
@sms ||= T.let(SMS.new(config), T.nilable(Nexmo::SMS))
|
93
111
|
end
|
94
112
|
|
95
113
|
# @return [TFA]
|
96
114
|
#
|
115
|
+
sig { returns(T.nilable(Nexmo::TFA)) }
|
97
116
|
def tfa
|
98
|
-
@tfa ||= TFA.new(config)
|
117
|
+
@tfa ||= T.let(TFA.new(config), T.nilable(Nexmo::TFA))
|
99
118
|
end
|
100
119
|
|
101
120
|
# @return [Verify]
|
102
121
|
#
|
122
|
+
sig { returns(T.nilable(Nexmo::Verify)) }
|
103
123
|
def verify
|
104
|
-
@verify ||= Verify.new(config)
|
124
|
+
@verify ||= T.let(Verify.new(config), T.nilable(Nexmo::Verify))
|
105
125
|
end
|
106
126
|
|
107
127
|
# @return [Voice]
|
108
128
|
#
|
129
|
+
sig { returns(T.nilable(Nexmo::Voice)) }
|
109
130
|
def voice
|
110
|
-
@voice ||= Voice.new(config)
|
131
|
+
@voice ||= T.let(Voice.new(config), T.nilable(Nexmo::Voice))
|
111
132
|
end
|
112
133
|
end
|
113
134
|
end
|
data/lib/nexmo/config.rb
CHANGED
@@ -1,26 +1,30 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: true
|
2
2
|
# frozen_string_literal: true
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module Nexmo
|
6
6
|
class Config
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { void }
|
7
10
|
def initialize
|
8
11
|
self.api_host = 'api.nexmo.com'
|
9
|
-
self.api_key = ENV['NEXMO_API_KEY']
|
10
|
-
self.api_secret = ENV['NEXMO_API_SECRET']
|
12
|
+
self.api_key = T.let(ENV['NEXMO_API_KEY'], T.nilable(String))
|
13
|
+
self.api_secret = T.let(ENV['NEXMO_API_SECRET'], T.nilable(String))
|
11
14
|
self.application_id = ENV['NEXMO_APPLICATION_ID']
|
12
|
-
self.logger = (defined?(Rails.logger) && Rails.logger) || ::Logger.new(nil)
|
13
|
-
self.private_key = ENV['NEXMO_PRIVATE_KEY_PATH'] ? File.read(ENV['NEXMO_PRIVATE_KEY_PATH']) : ENV['NEXMO_PRIVATE_KEY']
|
15
|
+
self.logger = (defined?(::Rails.logger) && ::Rails.logger) || Nexmo::Logger.new(nil)
|
16
|
+
self.private_key = ENV['NEXMO_PRIVATE_KEY_PATH'] ? File.read(T.must(ENV['NEXMO_PRIVATE_KEY_PATH'])) : ENV['NEXMO_PRIVATE_KEY']
|
14
17
|
self.rest_host = 'rest.nexmo.com'
|
15
18
|
self.signature_secret = ENV['NEXMO_SIGNATURE_SECRET']
|
16
19
|
self.signature_method = ENV['NEXMO_SIGNATURE_METHOD'] || 'md5hash'
|
17
|
-
self.token = nil
|
20
|
+
self.token = T.let(nil, T.nilable(String))
|
18
21
|
end
|
19
22
|
|
20
23
|
# Merges the config with the given options hash.
|
21
24
|
#
|
22
25
|
# @return [Nexmo::Config]
|
23
26
|
#
|
27
|
+
sig { params(options: T.nilable(T::Hash[Symbol, T.untyped])).returns(Nexmo::Config) }
|
24
28
|
def merge(options)
|
25
29
|
return self if options.nil? || options.empty?
|
26
30
|
|
@@ -29,6 +33,7 @@ module Nexmo
|
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
36
|
+
sig { returns(String) }
|
32
37
|
attr_accessor :api_host
|
33
38
|
|
34
39
|
# Returns the value of attribute api_key.
|
@@ -37,7 +42,9 @@ module Nexmo
|
|
37
42
|
#
|
38
43
|
# @raise [AuthenticationError]
|
39
44
|
#
|
45
|
+
sig { returns(T.nilable(String)) }
|
40
46
|
def api_key
|
47
|
+
@api_key = T.let(@api_key, T.nilable(String))
|
41
48
|
unless @api_key
|
42
49
|
raise AuthenticationError.new('No API key provided. ' \
|
43
50
|
'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \
|
@@ -47,6 +54,7 @@ module Nexmo
|
|
47
54
|
@api_key
|
48
55
|
end
|
49
56
|
|
57
|
+
sig { params(api_key: T.nilable(String)).returns(T.nilable(String)) }
|
50
58
|
attr_writer :api_key
|
51
59
|
|
52
60
|
# Returns the value of attribute api_secret.
|
@@ -55,7 +63,9 @@ module Nexmo
|
|
55
63
|
#
|
56
64
|
# @raise [AuthenticationError]
|
57
65
|
#
|
66
|
+
sig { returns(T.nilable(String)) }
|
58
67
|
def api_secret
|
68
|
+
@api_secret = T.let(@api_secret, T.nilable(String))
|
59
69
|
unless @api_secret
|
60
70
|
raise AuthenticationError.new('No API secret provided. ' \
|
61
71
|
'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \
|
@@ -65,6 +75,7 @@ module Nexmo
|
|
65
75
|
@api_secret
|
66
76
|
end
|
67
77
|
|
78
|
+
sig { params(api_secret: T.nilable(String)).returns(T.nilable(String)) }
|
68
79
|
attr_writer :api_secret
|
69
80
|
|
70
81
|
# Returns the value of attribute application_id.
|
@@ -73,7 +84,9 @@ module Nexmo
|
|
73
84
|
#
|
74
85
|
# @raise [AuthenticationError]
|
75
86
|
#
|
87
|
+
sig { returns(T.nilable(String)) }
|
76
88
|
def application_id
|
89
|
+
@application_id = T.let(@application_id, T.nilable(String))
|
77
90
|
unless @application_id
|
78
91
|
raise AuthenticationError.new('No application_id provided. ' \
|
79
92
|
'Either provide an application_id, or set an auth token. ' \
|
@@ -85,32 +98,40 @@ module Nexmo
|
|
85
98
|
@application_id
|
86
99
|
end
|
87
100
|
|
101
|
+
sig { params(application_id: T.nilable(String)).returns(T.nilable(String)) }
|
88
102
|
attr_writer :application_id
|
89
103
|
|
104
|
+
sig { returns(T.nilable(String)) }
|
90
105
|
attr_accessor :app_name
|
91
106
|
|
107
|
+
sig { returns(T.nilable(String)) }
|
92
108
|
attr_accessor :app_version
|
93
109
|
|
94
110
|
# Returns the value of attribute http.
|
95
111
|
#
|
96
112
|
# @return [Nexmo::HTTP::Options]
|
97
113
|
#
|
114
|
+
sig { returns(T.nilable(Nexmo::HTTP::Options)) }
|
98
115
|
attr_reader :http
|
99
116
|
|
117
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.nilable(Nexmo::HTTP::Options)) }
|
100
118
|
def http=(hash)
|
101
|
-
@http = HTTP::Options
|
119
|
+
@http = T.let(nil, T.nilable(Nexmo::HTTP::Options))
|
120
|
+
@http = Nexmo::HTTP::Options.new(hash)
|
102
121
|
end
|
103
122
|
|
104
123
|
# Returns the value of attribute logger.
|
105
124
|
#
|
106
125
|
# @return [Nexmo::Logger]
|
107
126
|
#
|
127
|
+
sig { returns(T.nilable(Nexmo::Logger)) }
|
108
128
|
attr_reader :logger
|
109
129
|
|
110
130
|
# @return [Nexmo::Logger]
|
111
131
|
#
|
132
|
+
sig { params(logger: T.nilable(T.any(::Logger, Nexmo::Logger))).returns(T.nilable(Nexmo::Logger)) }
|
112
133
|
def logger=(logger)
|
113
|
-
@logger = Logger.new(logger)
|
134
|
+
@logger = T.let(Logger.new(logger), T.nilable(Nexmo::Logger))
|
114
135
|
end
|
115
136
|
|
116
137
|
# Returns the value of attribute private_key.
|
@@ -119,7 +140,9 @@ module Nexmo
|
|
119
140
|
#
|
120
141
|
# @raise [AuthenticationError]
|
121
142
|
#
|
143
|
+
sig { returns(T.nilable(String)) }
|
122
144
|
def private_key
|
145
|
+
@private_key = T.let(@private_key, T.nilable(String))
|
123
146
|
unless @private_key
|
124
147
|
raise AuthenticationError.new('No private_key provided. ' \
|
125
148
|
'Either provide a private_key, or set an auth token. ' \
|
@@ -131,8 +154,10 @@ module Nexmo
|
|
131
154
|
@private_key
|
132
155
|
end
|
133
156
|
|
157
|
+
sig { params(private_key: T.nilable(String)).returns(T.nilable(String)) }
|
134
158
|
attr_writer :private_key
|
135
159
|
|
160
|
+
sig { returns(String) }
|
136
161
|
attr_accessor :rest_host
|
137
162
|
|
138
163
|
# Returns the value of attribute signature_secret.
|
@@ -141,7 +166,9 @@ module Nexmo
|
|
141
166
|
#
|
142
167
|
# @raise [AuthenticationError]
|
143
168
|
#
|
169
|
+
sig { returns(T.nilable(String)) }
|
144
170
|
def signature_secret
|
171
|
+
@signature_secret = T.let(@signature_secret, T.nilable(String))
|
145
172
|
unless @signature_secret
|
146
173
|
raise AuthenticationError.new('No signature_secret provided. ' \
|
147
174
|
'You can find your signature secret in the Nexmo dashboard. ' \
|
@@ -152,22 +179,28 @@ module Nexmo
|
|
152
179
|
@signature_secret
|
153
180
|
end
|
154
181
|
|
182
|
+
sig { params(signature_secret: T.nilable(String)).returns(T.nilable(String)) }
|
155
183
|
attr_writer :signature_secret
|
156
184
|
|
185
|
+
sig { returns(String) }
|
157
186
|
attr_accessor :signature_method
|
158
187
|
|
159
188
|
# Returns the value of attribute token, or a temporary short lived token.
|
160
189
|
#
|
161
190
|
# @return [String]
|
162
191
|
#
|
192
|
+
sig { returns(T.nilable(String)) }
|
163
193
|
def token
|
164
|
-
@token
|
194
|
+
@token = T.let(nil, T.nilable(String))
|
195
|
+
@token || JWT.generate({application_id: application_id}, T.must(private_key))
|
165
196
|
end
|
166
197
|
|
198
|
+
sig { params(token: T.nilable(String)).returns(T.nilable(String)) }
|
167
199
|
attr_writer :token
|
168
200
|
|
169
201
|
protected
|
170
202
|
|
203
|
+
sig { params(name: Symbol, value: T.nilable(T.untyped)).void }
|
171
204
|
def write_attribute(name, value)
|
172
205
|
public_send(:"#{name}=", value)
|
173
206
|
end
|