vonage 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +190 -0
  3. data/README.md +191 -0
  4. data/lib/vonage.rb +29 -0
  5. data/lib/vonage/abstract_authentication.rb +9 -0
  6. data/lib/vonage/account.rb +61 -0
  7. data/lib/vonage/alerts.rb +72 -0
  8. data/lib/vonage/applications.rb +148 -0
  9. data/lib/vonage/applications/list_response.rb +11 -0
  10. data/lib/vonage/authentication_error.rb +6 -0
  11. data/lib/vonage/basic.rb +13 -0
  12. data/lib/vonage/bearer_token.rb +14 -0
  13. data/lib/vonage/client.rb +134 -0
  14. data/lib/vonage/client_error.rb +6 -0
  15. data/lib/vonage/config.rb +208 -0
  16. data/lib/vonage/conversations.rb +210 -0
  17. data/lib/vonage/conversations/events.rb +73 -0
  18. data/lib/vonage/conversations/legs.rb +30 -0
  19. data/lib/vonage/conversations/members.rb +104 -0
  20. data/lib/vonage/conversations/users.rb +93 -0
  21. data/lib/vonage/conversions.rb +19 -0
  22. data/lib/vonage/entity.rb +51 -0
  23. data/lib/vonage/error.rb +6 -0
  24. data/lib/vonage/errors.rb +51 -0
  25. data/lib/vonage/files.rb +26 -0
  26. data/lib/vonage/form_data.rb +11 -0
  27. data/lib/vonage/gsm7.rb +13 -0
  28. data/lib/vonage/http.rb +43 -0
  29. data/lib/vonage/json.rb +17 -0
  30. data/lib/vonage/jwt.rb +43 -0
  31. data/lib/vonage/key_secret_params.rb +20 -0
  32. data/lib/vonage/keys.rb +51 -0
  33. data/lib/vonage/logger.rb +60 -0
  34. data/lib/vonage/messages.rb +25 -0
  35. data/lib/vonage/namespace.rb +118 -0
  36. data/lib/vonage/number_insight.rb +140 -0
  37. data/lib/vonage/numbers.rb +196 -0
  38. data/lib/vonage/numbers/list_response.rb +11 -0
  39. data/lib/vonage/numbers/response.rb +8 -0
  40. data/lib/vonage/params.rb +27 -0
  41. data/lib/vonage/pricing.rb +30 -0
  42. data/lib/vonage/pricing_types.rb +18 -0
  43. data/lib/vonage/redact.rb +37 -0
  44. data/lib/vonage/response.rb +25 -0
  45. data/lib/vonage/secrets.rb +85 -0
  46. data/lib/vonage/secrets/list_response.rb +11 -0
  47. data/lib/vonage/server_error.rb +6 -0
  48. data/lib/vonage/signature.rb +53 -0
  49. data/lib/vonage/sms.rb +121 -0
  50. data/lib/vonage/tfa.rb +14 -0
  51. data/lib/vonage/user_agent.rb +16 -0
  52. data/lib/vonage/verify.rb +253 -0
  53. data/lib/vonage/version.rb +5 -0
  54. data/lib/vonage/voice.rb +250 -0
  55. data/lib/vonage/voice/dtmf.rb +26 -0
  56. data/lib/vonage/voice/list_response.rb +11 -0
  57. data/lib/vonage/voice/stream.rb +44 -0
  58. data/lib/vonage/voice/talk.rb +48 -0
  59. data/vonage.gemspec +26 -0
  60. metadata +155 -0
@@ -0,0 +1,72 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Alerts < Namespace
6
+ extend T::Sig
7
+ self.host = :rest_host
8
+
9
+ # Request the list of phone numbers opted out from your campaign.
10
+ #
11
+ # @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/subscription
12
+ #
13
+ # @return [Response]
14
+ #
15
+ sig { returns(Vonage::Response) }
16
+ def list
17
+ request('/sc/us/alert/opt-in/query/json')
18
+ end
19
+
20
+ # Remove a phone number from the opt-out list.
21
+ #
22
+ # @option params [required, String] :msisdn
23
+ # The phone number to resubscribe to your campaign and remove from the opt-out list.
24
+ #
25
+ # @param [Hash] params
26
+ #
27
+ # @return [Response]
28
+ #
29
+ # @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/subscription
30
+ #
31
+ sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
32
+ def remove(params)
33
+ request('/sc/us/alert/opt-in/manage/json', params: params, type: Post)
34
+ end
35
+
36
+ alias_method :resubscribe, :remove
37
+
38
+ # Send an alert to your user.
39
+ #
40
+ # @option params [required, String] :to
41
+ # The single phone number to send pin to.
42
+ # Mobile number in US format and one recipient per request.
43
+ #
44
+ # @option params [Integer] :status_report_req
45
+ # Set to 1 to receive a delivery receipt.
46
+ # To receive the delivery receipt, you have to configure a webhook endpoint in Dashboard.
47
+ #
48
+ # @option params [String] :client_ref
49
+ # A 40 character reference string for your internal reporting.
50
+ #
51
+ # @option params [Integer] :template
52
+ # If you have multiple templates, this is the index of the template to call.
53
+ # The default template starts is 0, each Event Based Alert campaign can have up to 6 templates.
54
+ # If you have one template only it is the default. That is, template=0.
55
+ # If you create a request with template=1 the API call will default, template=0 instead.
56
+ # After you add a valid campaign alert for 2FA, the request will call template 1 instead of template 0.
57
+ #
58
+ # @option params [String] :type
59
+ # Default value is `text`. Possible values are: `text` for plain text SMS or `unicode` only use this when your SMS must contain special characters.
60
+ #
61
+ # @param [Hash] params
62
+ #
63
+ # @return [Response]
64
+ #
65
+ # @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/sending
66
+ #
67
+ sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
68
+ def send(params)
69
+ request('/sc/us/alert/json', params: params, type: Post)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,148 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Applications < Namespace
6
+ extend T::Sig
7
+ self.authentication = Basic
8
+
9
+ self.request_body = JSON
10
+
11
+ self.request_headers['Content-Type'] = 'application/json'
12
+
13
+ # Create an application.
14
+ #
15
+ # @example
16
+ # params = {
17
+ # name: 'Example App',
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
+ # }
32
+ # }
33
+ #
34
+ # response = client.applications.create(params)
35
+ #
36
+ # @option params [required, String] :name
37
+ # Application name.
38
+ #
39
+ # @option params [Hash] :keys
40
+ # - **:public_key** (String) Public key
41
+ #
42
+ # @option params [Hash] :capabilities
43
+ # Your application can use multiple products.
44
+ # This contains the configuration for each product.
45
+ # This replaces the application `type` from version 1 of the Application API.
46
+ #
47
+ # @param [Hash] params
48
+ #
49
+ # @return [Response]
50
+ #
51
+ # @see https://developer.nexmo.com/api/application.v2#createApplication
52
+ #
53
+ sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
54
+ def create(params)
55
+ request('/v2/applications', params: params, type: Post)
56
+ end
57
+
58
+ # List available applications.
59
+ #
60
+ # @example
61
+ # response = client.applications.list
62
+ # response.each do |item|
63
+ # puts "#{item.id} #{item.name}"
64
+ # end
65
+ #
66
+ # @option params [Integer] :page_size
67
+ # The number of applications per page.
68
+ #
69
+ # @option params [Integer] :page
70
+ # The current page number (starts at 1).
71
+ #
72
+ # @param [Hash] params
73
+ #
74
+ # @return [ListResponse]
75
+ #
76
+ # @see https://developer.nexmo.com/api/application.v2#listApplication
77
+ #
78
+ sig { params(params: T.nilable(T::Hash[Symbol, Integer])).returns(Vonage::Response) }
79
+ def list(params = nil)
80
+ request('/v2/applications', params: params, response_class: ListResponse)
81
+ end
82
+
83
+ # Get an application.
84
+ #
85
+ # @example
86
+ # response = client.applications.get(id)
87
+ #
88
+ # @param [String] id
89
+ #
90
+ # @return [Response]
91
+ #
92
+ # @see https://developer.nexmo.com/api/application.v2#getApplication
93
+ #
94
+ sig { params(id: String).returns(Vonage::Response) }
95
+ def get(id)
96
+ request('/v2/applications/' + id)
97
+ end
98
+
99
+ # Update an application.
100
+ #
101
+ # @example
102
+ # response = client.applications.update(id, answer_method: 'POST')
103
+ #
104
+ # @option params [required, String] :name
105
+ # Application name.
106
+ #
107
+ # @option params [Hash] :keys
108
+ # - **:public_key** (String) Public key
109
+ #
110
+ # @option params [Hash] :capabilities
111
+ # Your application can use multiple products.
112
+ # This contains the configuration for each product.
113
+ # This replaces the application `type` from version 1 of the Application API.
114
+ #
115
+ # @param [String] id
116
+ # @param [Hash] params
117
+ #
118
+ # @return [Response]
119
+ #
120
+ # @see https://developer.nexmo.com/api/application.v2#updateApplication
121
+ #
122
+ sig { params(
123
+ id: String,
124
+ params: T::Hash[Symbol, T.untyped]
125
+ ).returns(Vonage::Response) }
126
+ def update(id, params)
127
+ request('/v2/applications/' + id, params: params, type: Put)
128
+ end
129
+
130
+ # Delete an application.
131
+ #
132
+ # @example
133
+ # response = client.applications.delete(id)
134
+ #
135
+ # @note Deleting an application cannot be undone.
136
+ #
137
+ # @param [String] id
138
+ #
139
+ # @return [Response]
140
+ #
141
+ # @see https://developer.nexmo.com/api/application.v2#deleteApplication
142
+ #
143
+ sig { params(id: String).returns(Vonage::Response) }
144
+ def delete(id)
145
+ request('/v2/applications/' + id, type: Delete)
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,11 @@
1
+ # typed: ignore
2
+
3
+ class Vonage::Applications::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.applications.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ # typed: strong
2
+
3
+ module Vonage
4
+ class AuthenticationError < ClientError
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # typed: ignore
2
+
3
+ module Vonage
4
+ class Basic < AbstractAuthentication
5
+ def update(object)
6
+ return unless object.is_a?(Net::HTTPRequest)
7
+
8
+ object.basic_auth(@config.api_key, @config.api_secret)
9
+ end
10
+ end
11
+
12
+ private_constant :Basic
13
+ end
@@ -0,0 +1,14 @@
1
+ # typed: ignore
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class BearerToken < AbstractAuthentication
6
+ def update(object)
7
+ return unless object.is_a?(Net::HTTPRequest)
8
+
9
+ object['Authorization'] = 'Bearer ' + @config.token
10
+ end
11
+ end
12
+
13
+ private_constant :BearerToken
14
+ end
@@ -0,0 +1,134 @@
1
+ # typed: strict
2
+
3
+ module Vonage
4
+ class Client
5
+ extend T::Sig
6
+
7
+ sig { returns(Vonage::Config) }
8
+ attr_reader :config
9
+
10
+ sig { params(options: T.nilable(T::Hash[Symbol, T.untyped])).void }
11
+ def initialize(options = nil)
12
+ @config = T.let(Vonage.config.merge(options), Vonage::Config)
13
+ end
14
+
15
+ # @return [Signature]
16
+ #
17
+ sig { returns(T.nilable(Vonage::Signature)) }
18
+ def signature
19
+ @signature ||= T.let(Signature.new(config), T.nilable(Vonage::Signature))
20
+ end
21
+
22
+ # @return [Account]
23
+ #
24
+ sig { returns(T.nilable(Vonage::Account)) }
25
+ def account
26
+ @account ||= T.let(Account.new(config), T.nilable(Vonage::Account))
27
+ end
28
+
29
+ # @return [Alerts]
30
+ #
31
+ sig { returns(T.nilable(Vonage::Alerts)) }
32
+ def alerts
33
+ @alerts ||= T.let(Alerts.new(config), T.nilable(Vonage::Alerts))
34
+ end
35
+
36
+ # @return [Applications]
37
+ #
38
+ sig { returns(T.nilable(Vonage::Applications)) }
39
+ def applications
40
+ @applications ||= T.let(Applications.new(config), T.nilable(Vonage::Applications))
41
+ end
42
+
43
+ # @return [Conversations]
44
+ #
45
+ sig { returns(T.nilable(Vonage::Conversations)) }
46
+ def conversations
47
+ @conversations ||= T.let(Conversations.new(config), T.nilable(Vonage::Conversations))
48
+ end
49
+
50
+ # @return [Conversions]
51
+ #
52
+ sig { returns(T.nilable(Vonage::Conversions)) }
53
+ def conversions
54
+ @conversions ||= T.let(Conversions.new(config), T.nilable(Vonage::Conversions))
55
+ end
56
+
57
+ # @return [Files]
58
+ #
59
+ sig { returns(T.nilable(Vonage::Files)) }
60
+ def files
61
+ @files ||= T.let(Files.new(config), T.nilable(Vonage::Files))
62
+ end
63
+
64
+ # @return [Messages]
65
+ #
66
+ sig { returns(T.nilable(Vonage::Messages)) }
67
+ def messages
68
+ @messages ||= T.let(Messages.new(config), T.nilable(Vonage::Messages))
69
+ end
70
+
71
+ # @return [NumberInsight]
72
+ #
73
+ sig { returns(T.nilable(Vonage::NumberInsight)) }
74
+ def number_insight
75
+ @number_insight ||= T.let(NumberInsight.new(config), T.nilable(Vonage::NumberInsight))
76
+ end
77
+
78
+ # @return [Numbers]
79
+ #
80
+ sig { returns(T.nilable(Vonage::Numbers)) }
81
+ def numbers
82
+ @numbers ||= T.let(Numbers.new(config), T.nilable(Vonage::Numbers))
83
+ end
84
+
85
+ # @return [PricingTypes]
86
+ #
87
+ sig { returns(T.nilable(Vonage::PricingTypes)) }
88
+ def pricing
89
+ @pricing ||= T.let(PricingTypes.new(config), T.nilable(Vonage::PricingTypes))
90
+ end
91
+
92
+ # @return [Redact]
93
+ #
94
+ sig { returns(T.nilable(Vonage::Redact)) }
95
+ def redact
96
+ @redact ||= T.let(Redact.new(config), T.nilable(Vonage::Redact))
97
+ end
98
+
99
+ # @return [Secrets]
100
+ #
101
+ sig { returns(T.nilable(Vonage::Secrets)) }
102
+ def secrets
103
+ @secrets ||= T.let(Secrets.new(config), T.nilable(Vonage::Secrets))
104
+ end
105
+
106
+ # @return [SMS]
107
+ #
108
+ sig { returns(T.nilable(Vonage::SMS)) }
109
+ def sms
110
+ @sms ||= T.let(SMS.new(config), T.nilable(Vonage::SMS))
111
+ end
112
+
113
+ # @return [TFA]
114
+ #
115
+ sig { returns(T.nilable(Vonage::TFA)) }
116
+ def tfa
117
+ @tfa ||= T.let(TFA.new(config), T.nilable(Vonage::TFA))
118
+ end
119
+
120
+ # @return [Verify]
121
+ #
122
+ sig { returns(T.nilable(Vonage::Verify)) }
123
+ def verify
124
+ @verify ||= T.let(Verify.new(config), T.nilable(Vonage::Verify))
125
+ end
126
+
127
+ # @return [Voice]
128
+ #
129
+ sig { returns(T.nilable(Vonage::Voice)) }
130
+ def voice
131
+ @voice ||= T.let(Voice.new(config), T.nilable(Vonage::Voice))
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,6 @@
1
+ # typed: strong
2
+
3
+ module Vonage
4
+ class ClientError < Error
5
+ end
6
+ end
@@ -0,0 +1,208 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+ require 'logger'
4
+
5
+ module Vonage
6
+ class Config
7
+ extend T::Sig
8
+
9
+ sig { void }
10
+ def initialize
11
+ self.api_host = 'api.nexmo.com'
12
+ self.api_key = T.let(ENV['VONAGE_API_KEY'], T.nilable(String))
13
+ self.api_secret = T.let(ENV['VONAGE_API_SECRET'], T.nilable(String))
14
+ self.application_id = ENV['VONAGE_APPLICATION_ID']
15
+ self.logger = (defined?(::Rails.logger) && ::Rails.logger) || Vonage::Logger.new(nil)
16
+ self.private_key = ENV['VONAGE_PRIVATE_KEY_PATH'] ? File.read(T.must(ENV['VONAGE_PRIVATE_KEY_PATH'])) : ENV['VONAGE_PRIVATE_KEY']
17
+ self.rest_host = 'rest.nexmo.com'
18
+ self.signature_secret = ENV['VONAGE_SIGNATURE_SECRET']
19
+ self.signature_method = ENV['VONAGE_SIGNATURE_METHOD'] || 'md5hash'
20
+ self.token = T.let(nil, T.nilable(String))
21
+ end
22
+
23
+ # Merges the config with the given options hash.
24
+ #
25
+ # @return [Vonage::Config]
26
+ #
27
+ sig { params(options: T.nilable(T::Hash[Symbol, T.untyped])).returns(Vonage::Config) }
28
+ def merge(options)
29
+ return self if options.nil? || options.empty?
30
+
31
+ options.each_with_object(dup) do |(name, value), config|
32
+ config.write_attribute(name, value)
33
+ end
34
+ end
35
+
36
+ sig { returns(String) }
37
+ attr_accessor :api_host
38
+
39
+ # Returns the value of attribute api_key.
40
+ #
41
+ # @return [String]
42
+ #
43
+ # @raise [AuthenticationError]
44
+ #
45
+ sig { returns(T.nilable(String)) }
46
+ def api_key
47
+ @api_key = T.let(@api_key, T.nilable(String))
48
+ unless @api_key
49
+ raise AuthenticationError.new('No API key provided. ' \
50
+ 'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \
51
+ 'or email support@nexmo.com if you have any questions.')
52
+ end
53
+
54
+ @api_key
55
+ end
56
+
57
+ sig { params(api_key: T.nilable(String)).returns(T.nilable(String)) }
58
+ attr_writer :api_key
59
+
60
+ # Returns the value of attribute api_secret.
61
+ #
62
+ # @return [String]
63
+ #
64
+ # @raise [AuthenticationError]
65
+ #
66
+ sig { returns(T.nilable(String)) }
67
+ def api_secret
68
+ @api_secret = T.let(@api_secret, T.nilable(String))
69
+ unless @api_secret
70
+ raise AuthenticationError.new('No API secret provided. ' \
71
+ 'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \
72
+ 'or email support@nexmo.com if you have any questions.')
73
+ end
74
+
75
+ @api_secret
76
+ end
77
+
78
+ sig { params(api_secret: T.nilable(String)).returns(T.nilable(String)) }
79
+ attr_writer :api_secret
80
+
81
+ # Returns the value of attribute application_id.
82
+ #
83
+ # @return [String]
84
+ #
85
+ # @raise [AuthenticationError]
86
+ #
87
+ sig { returns(T.nilable(String)) }
88
+ def application_id
89
+ @application_id = T.let(@application_id, T.nilable(String))
90
+ unless @application_id
91
+ raise AuthenticationError.new('No application_id provided. ' \
92
+ 'Either provide an application_id, or set an auth token. ' \
93
+ 'You can add new applications from the Vonage dashboard. ' \
94
+ 'See https://developer.nexmo.com/concepts/guides/applications for details, ' \
95
+ 'or email support@nexmo.com if you have any questions.')
96
+ end
97
+
98
+ @application_id
99
+ end
100
+
101
+ sig { params(application_id: T.nilable(String)).returns(T.nilable(String)) }
102
+ attr_writer :application_id
103
+
104
+ sig { returns(T.nilable(String)) }
105
+ attr_accessor :app_name
106
+
107
+ sig { returns(T.nilable(String)) }
108
+ attr_accessor :app_version
109
+
110
+ # Returns the value of attribute http.
111
+ #
112
+ # @return [Vonage::HTTP::Options]
113
+ #
114
+ sig { returns(T.nilable(Vonage::HTTP::Options)) }
115
+ attr_reader :http
116
+
117
+ sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.nilable(Vonage::HTTP::Options)) }
118
+ def http=(hash)
119
+ @http = T.let(nil, T.nilable(Vonage::HTTP::Options))
120
+ @http = Vonage::HTTP::Options.new(hash)
121
+ end
122
+
123
+ # Returns the value of attribute logger.
124
+ #
125
+ # @return [Vonage::Logger]
126
+ #
127
+ sig { returns(T.nilable(Vonage::Logger)) }
128
+ attr_reader :logger
129
+
130
+ # @return [Vonage::Logger]
131
+ #
132
+ sig { params(logger: T.nilable(T.any(::Logger, Vonage::Logger))).returns(T.nilable(Vonage::Logger)) }
133
+ def logger=(logger)
134
+ @logger = T.let(Logger.new(logger), T.nilable(Vonage::Logger))
135
+ end
136
+
137
+ # Returns the value of attribute private_key.
138
+ #
139
+ # @return [String]
140
+ #
141
+ # @raise [AuthenticationError]
142
+ #
143
+ sig { returns(T.nilable(String)) }
144
+ def private_key
145
+ @private_key = T.let(@private_key, T.nilable(String))
146
+ unless @private_key
147
+ raise AuthenticationError.new('No private_key provided. ' \
148
+ 'Either provide a private_key, or set an auth token. ' \
149
+ 'You can add new applications from the Vonage dashboard. ' \
150
+ 'See https://developer.nexmo.com/concepts/guides/applications for details, ' \
151
+ 'or email support@nexmo.com if you have any questions.')
152
+ end
153
+
154
+ @private_key
155
+ end
156
+
157
+ sig { params(private_key: T.nilable(String)).returns(T.nilable(String)) }
158
+ attr_writer :private_key
159
+
160
+ sig { returns(String) }
161
+ attr_accessor :rest_host
162
+
163
+ # Returns the value of attribute signature_secret.
164
+ #
165
+ # @return [String]
166
+ #
167
+ # @raise [AuthenticationError]
168
+ #
169
+ sig { returns(T.nilable(String)) }
170
+ def signature_secret
171
+ @signature_secret = T.let(@signature_secret, T.nilable(String))
172
+ unless @signature_secret
173
+ raise AuthenticationError.new('No signature_secret provided. ' \
174
+ 'You can find your signature secret in the Vonage dashboard. ' \
175
+ 'See https://developer.nexmo.com/concepts/guides/signing-messages for details, ' \
176
+ 'or email support@nexmo.com if you have any questions.')
177
+ end
178
+
179
+ @signature_secret
180
+ end
181
+
182
+ sig { params(signature_secret: T.nilable(String)).returns(T.nilable(String)) }
183
+ attr_writer :signature_secret
184
+
185
+ sig { returns(String) }
186
+ attr_accessor :signature_method
187
+
188
+ # Returns the value of attribute token, or a temporary short lived token.
189
+ #
190
+ # @return [String]
191
+ #
192
+ sig { returns(T.nilable(String)) }
193
+ def token
194
+ @token = T.let(nil, T.nilable(String))
195
+ @token || JWT.generate({application_id: application_id}, T.must(private_key))
196
+ end
197
+
198
+ sig { params(token: T.nilable(String)).returns(T.nilable(String)) }
199
+ attr_writer :token
200
+
201
+ protected
202
+
203
+ sig { params(name: Symbol, value: T.nilable(T.untyped)).void }
204
+ def write_attribute(name, value)
205
+ public_send(:"#{name}=", value)
206
+ end
207
+ end
208
+ end