telesign 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 671cb0c341029e000d0f044258feae187c404c96
4
- data.tar.gz: b0775ec9773690bfebaa7305fcbae024d9c7b44c
2
+ SHA256:
3
+ metadata.gz: 716a642e7718e75d8f1ec5c350774290c56066d7876d256dac4f46c0db9ec946
4
+ data.tar.gz: 2b12275befebfd6afc2e4e724534abb3297cd4ade5d317c80de9766f8f2b6a82
5
5
  SHA512:
6
- metadata.gz: 6120cd99c9365fed13091a82ead98010288526808e83405a1cb8f5fabbce0a4477b3c2f34b748d89360693e0681489ac3543c339519f775c8d7173e3ccbc5569
7
- data.tar.gz: 991559dcf89c7d7f2a9876fd5675daf8f283f9e3b8d4245867fe90d027e71ef542582699241beaaa9099c840e474ee85c7eb299c2888ef1c6232ea6ee1b07448
6
+ metadata.gz: 6f7ec05b6a558c1955254e55b298e07b9b80712c1b8bab22bc3f219c50eb90c141189c2a9275a51c12269ff78d15621f869cdd90f6532c4dbaf064b75ac948f0
7
+ data.tar.gz: e5ae107f2b6f381bfd6777e8fcafb8831a36609ae03c55d7e493c01ef61e1358f8b032dba6b90c10c8104ee9b235f52945e66381dc7fb8c69d5efb41df86e839
@@ -17,5 +17,10 @@ module Telesign
17
17
  self.post(PHONEID_RESOURCE % {:phone_number => phone_number},
18
18
  **params)
19
19
  end
20
+
21
+ private
22
+ def content_type
23
+ "application/json"
24
+ end
20
25
  end
21
26
  end
@@ -7,7 +7,7 @@ require 'securerandom'
7
7
  require 'net/http/persistent'
8
8
 
9
9
  module Telesign
10
- SDK_VERSION = '2.2.0'
10
+ SDK_VERSION = '2.2.1'
11
11
 
12
12
  # The TeleSign RestClient is a generic HTTP REST client that can be extended to make requests against any of
13
13
  # TeleSign's REST API endpoints.
@@ -85,7 +85,8 @@ module Telesign
85
85
  api_key,
86
86
  method_name,
87
87
  resource,
88
- url_encoded_fields,
88
+ content_type,
89
+ encoded_fields,
89
90
  date_rfc2616: nil,
90
91
  nonce: nil,
91
92
  user_agent: nil)
@@ -98,7 +99,7 @@ module Telesign
98
99
  nonce = SecureRandom.uuid
99
100
  end
100
101
 
101
- content_type = (%w[POST PUT].include? method_name) ? 'application/x-www-form-urlencoded' : ''
102
+ content_type = (%w[POST PUT].include? method_name) ? content_type : ''
102
103
 
103
104
  auth_method = 'HMAC-SHA256'
104
105
 
@@ -112,8 +113,8 @@ module Telesign
112
113
 
113
114
  string_to_sign << "\nx-ts-nonce:#{nonce}"
114
115
 
115
- if !content_type.empty? and !url_encoded_fields.empty?
116
- string_to_sign << "\n#{url_encoded_fields}"
116
+ if !content_type.empty? and !encoded_fields.empty?
117
+ string_to_sign << "\n#{encoded_fields}"
117
118
  end
118
119
 
119
120
  string_to_sign << "\n#{resource}"
@@ -191,25 +192,32 @@ module Telesign
191
192
 
192
193
  resource_uri = URI.parse("#{@rest_endpoint}#{resource}")
193
194
 
194
- url_encoded_fields = URI.encode_www_form(params, Encoding::UTF_8)
195
-
196
- headers = RestClient.generate_telesign_headers(@customer_id,
197
- @api_key,
198
- method_name,
199
- resource,
200
- url_encoded_fields,
201
- user_agent: @user_agent)
202
-
203
195
  request = method_function.new(resource_uri.request_uri)
204
196
 
205
197
  unless params.empty?
206
198
  if %w[POST PUT].include? method_name
207
- request.set_form_data(params)
199
+ if content_type == "application/x-www-form-urlencoded"
200
+ encoded_fields = URI.encode_www_form(params, Encoding::UTF_8)
201
+ request.set_form_data(params)
202
+ else
203
+ encoded_fields = params.to_json
204
+ request.body = encoded_fields
205
+ request.set_content_type("application/json")
206
+ end
208
207
  else
209
- resource_uri.query = url_encoded_fields
208
+ encoded_fields = []
209
+ resource_uri.query = URI.encode_www_form(params, Encoding::UTF_8)
210
210
  end
211
211
  end
212
212
 
213
+ headers = RestClient.generate_telesign_headers(@customer_id,
214
+ @api_key,
215
+ method_name,
216
+ resource,
217
+ content_type,
218
+ encoded_fields,
219
+ user_agent: @user_agent)
220
+
213
221
  headers.each do |k, v|
214
222
  request[k] = v
215
223
  end
@@ -218,5 +226,9 @@ module Telesign
218
226
 
219
227
  Response.new(http_response)
220
228
  end
229
+
230
+ def content_type
231
+ "application/x-www-form-urlencoded"
232
+ end
221
233
  end
222
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telesign
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TeleSign
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.6.12
165
+ rubygems_version: 2.7.6
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: TeleSign Ruby SDK