telesign 2.2.0 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/telesign/phoneid.rb +5 -0
- data/lib/telesign/rest.rb +31 -19
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14fe933bd033c1db40c1f993d6345d7c60a1ce40ac1aa769f35365d9793a3ec1
|
4
|
+
data.tar.gz: 2356df3c1a727c2f79847b78e8eb670e99400aac92ba6f40df38d42fd61edc88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e53412a5532e6d59ee5cb82e00edcd5646fdf60007d0f86857261f47e5e29dc3bb37aba1049bf2ef1fb1253efee63f2d43403111434b715f5e451eeec83077f9
|
7
|
+
data.tar.gz: 26c0497d23fb9cbf37887eebdfe8ee85acb24798ca13f20b167ab8e62095b091bbf4954497bbe07cbd8f7684fca41111fb1908b00873b90dba0f610e80d8f70f
|
data/lib/telesign/phoneid.rb
CHANGED
data/lib/telesign/rest.rb
CHANGED
@@ -7,7 +7,7 @@ require 'securerandom'
|
|
7
7
|
require 'net/http/persistent'
|
8
8
|
|
9
9
|
module Telesign
|
10
|
-
SDK_VERSION = '2.2.
|
10
|
+
SDK_VERSION = '2.2.4'
|
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.
|
@@ -18,7 +18,7 @@ module Telesign
|
|
18
18
|
# See https://developer.telesign.com for detailed API documentation.
|
19
19
|
class RestClient
|
20
20
|
|
21
|
-
|
21
|
+
@@user_agent = "TeleSignSDK/ruby-{#{SDK_VERSION} #{RUBY_DESCRIPTION} net/http/persistent"
|
22
22
|
|
23
23
|
# A simple HTTP Response object to abstract the underlying net/http library response.
|
24
24
|
|
@@ -85,7 +85,8 @@ module Telesign
|
|
85
85
|
api_key,
|
86
86
|
method_name,
|
87
87
|
resource,
|
88
|
-
|
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) ?
|
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 !
|
116
|
-
string_to_sign << "\n#{
|
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,24 +192,31 @@ module Telesign
|
|
191
192
|
|
192
193
|
resource_uri = URI.parse("#{@rest_endpoint}#{resource}")
|
193
194
|
|
194
|
-
|
195
|
+
encoded_fields = ''
|
196
|
+
if %w[POST PUT].include? method_name
|
197
|
+
request = method_function.new(resource_uri.request_uri)
|
198
|
+
if content_type == "application/x-www-form-urlencoded"
|
199
|
+
unless params.empty?
|
200
|
+
encoded_fields = URI.encode_www_form(params, Encoding::UTF_8)
|
201
|
+
request.set_form_data(params)
|
202
|
+
end
|
203
|
+
else
|
204
|
+
encoded_fields = params.to_json
|
205
|
+
request.body = encoded_fields
|
206
|
+
request.set_content_type("application/json")
|
207
|
+
end
|
208
|
+
else
|
209
|
+
resource_uri.query = URI.encode_www_form(params, Encoding::UTF_8)
|
210
|
+
request = method_function.new(resource_uri.request_uri)
|
211
|
+
end
|
195
212
|
|
196
213
|
headers = RestClient.generate_telesign_headers(@customer_id,
|
197
214
|
@api_key,
|
198
215
|
method_name,
|
199
216
|
resource,
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
request = method_function.new(resource_uri.request_uri)
|
204
|
-
|
205
|
-
unless params.empty?
|
206
|
-
if %w[POST PUT].include? method_name
|
207
|
-
request.set_form_data(params)
|
208
|
-
else
|
209
|
-
resource_uri.query = url_encoded_fields
|
210
|
-
end
|
211
|
-
end
|
217
|
+
content_type,
|
218
|
+
encoded_fields,
|
219
|
+
user_agent: @@user_agent)
|
212
220
|
|
213
221
|
headers.each do |k, v|
|
214
222
|
request[k] = v
|
@@ -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,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telesign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TeleSign
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-05-25 00:00:00.000000000 Z
|
@@ -14,22 +14,22 @@ dependencies:
|
|
14
14
|
name: net-http-persistent
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 3.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.0'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 3.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ homepage: http://rubygems.org/gems/telesign
|
|
146
146
|
licenses:
|
147
147
|
- MIT
|
148
148
|
metadata: {}
|
149
|
-
post_install_message:
|
149
|
+
post_install_message:
|
150
150
|
rdoc_options: []
|
151
151
|
require_paths:
|
152
152
|
- lib
|
@@ -161,9 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
|
165
|
-
|
166
|
-
signing_key:
|
164
|
+
rubygems_version: 3.2.28
|
165
|
+
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: TeleSign Ruby SDK
|
169
168
|
test_files: []
|