telesignature 0.0.8 → 0.0.9

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
2
  SHA1:
3
- metadata.gz: 94668e3da3625dea16f5997838d09a3d4099e363
4
- data.tar.gz: f6e7c953d1163107308a736f203e901361e2a660
3
+ metadata.gz: b4d685b3286e9090b56d06ccc7040b47ecec774e
4
+ data.tar.gz: bf532e7f892442be91636e8b40b497535b7e51a8
5
5
  SHA512:
6
- metadata.gz: b54e7050d8940a7f609d73fa330dcb6982effadcb172acbf9cc435885476c09038ed07dd6467133591bbc366c9dfa86e25c5b8280f7e350cd3f2bddd29d51779
7
- data.tar.gz: 6a5e81993fbb982bd1db426bd4e75f8426a5c0c61ae68206b9102d852deecc186bfc6a2e3c017c89c266e6ba54e61695d43f934fed212e974808758462513819
6
+ metadata.gz: ed55a7f4b42e4c0643653580852bd30d6fec2ef1a551bb6fd21134e564f14f4aa415247ec28f53a014fc55c83fc11f78c80e2961a62339bf82ff27648944b5a0
7
+ data.tar.gz: d901773762bf412e78acafe9786d89bd95ad9f78e8525801455b09fae5f65b54a1f4f0639ebae2609e5c6b0fadc285bc419ff9e4fe000f9ff41aebcb29fa9326
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- telesignature (0.0.8)
4
+ telesignature (0.0.9)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -8,45 +8,6 @@ require 'mimic'
8
8
  require 'json'
9
9
  require 'securerandom'
10
10
 
11
- class StdHelpers
12
- class << self
13
- def standard_headers
14
- # scraped from TeleSign api response
15
- { 'date'=>Time.now.strftime("%a, %d %b %Y %H:%M:%S %z"),
16
- 'server'=>'Apache',
17
- 'allow'=>'GET,POST,HEAD',
18
- 'connection'=>'close',
19
- 'content-type'=>'application/json'}
20
- end
21
-
22
- def std_response_body reference_id, status_code = 'UNKNOWN'
23
- # scraped from TeleSign api response
24
- { 'reference_id' => reference_id,
25
- 'resource_uri' => "/v1/verify/#{reference_id}",
26
- 'sub_resource' => "sms",
27
- 'errors' => [],
28
- 'status' => {
29
- 'updated_on' => standard_updated_on,
30
- 'code' => 290,
31
- 'description' => 'Message in progress'
32
- },
33
- 'verify' => {
34
- 'code_state' => status_code,
35
- 'code_entered' => ''
36
- }
37
- }
38
- end
39
-
40
- def std_reference_id
41
- SecureRandom.uuid.gsub('-','').upcase
42
- end
43
-
44
- def standard_updated_on
45
- Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%6N")
46
- end
47
- end
48
- end
49
-
50
11
  Mimic.mimic port: (ENV['TELESIGN_PORT'].to_i || 11989), host: (ENV['TELESIGN_URL'] || 'localhost'), fork: false do
51
12
  # 'https://rest.telesign.com/v1/verify/sms'
52
13
  # params['phone_number']
@@ -76,7 +37,7 @@ Mimic.mimic port: (ENV['TELESIGN_PORT'].to_i || 11989), host: (ENV['TELESIGN_URL
76
37
  [http_status, headers, response_body.to_json]
77
38
  end
78
39
 
79
- # "https://rest.telesign.com/v1/verify/%s" % @expected_ref_id
40
+ # 'https://rest.telesign.com/v1/verify/%s' % @expected_ref_id
80
41
  # params[:reference_id]
81
42
  # params[:verify_code]
82
43
  get '/v1/verify/:reference_id' do
@@ -96,25 +57,159 @@ Mimic.mimic port: (ENV['TELESIGN_PORT'].to_i || 11989), host: (ENV['TELESIGN_URL
96
57
  end
97
58
 
98
59
  # not using phoneid calls yet, but here are the stubs
99
- # # "https://rest.telesign.com/v1/phoneid/%s/%s"
60
+ # # 'https://rest.telesign.com/v1/phoneid/%s/%s'
100
61
 
101
- # # "/v1/phoneid/standard/%s" % phone_number
102
- # get '/v1/phoneid/standard/:phone_number' do
62
+ # '/v1/phoneid/standard/%s' % phone_number
63
+ get '/v1/phoneid/standard/:phone_number' do
64
+ http_status = 200
65
+ headers = StdHelpers.standard_headers
103
66
 
104
- # end
67
+ phone_type_hash = if params[:phone_number] =~ /111/
68
+ {'code' =>'1', 'description' =>'FIXED'}
69
+ elsif params[:phone_number] =~ /222/
70
+ {'code' =>'2', 'description' =>'MOBILE'}
71
+ elsif params[:phone_number] =~ /333/
72
+ {'code' =>'3', 'description' =>'PREPAID'}
73
+ elsif params[:phone_number] =~ /444/
74
+ {'code' =>'4', 'description' =>'TOLLFREE'}
75
+ elsif params[:phone_number] =~ /555/ # this could be problematic
76
+ {'code' =>'5', 'description' =>'VOIP'}
77
+ elsif params[:phone_number] =~ /666/
78
+ {'code' =>'6', 'description' =>'PAGER'}
79
+ elsif params[:phone_number] =~ /777/
80
+ {'code' =>'7', 'description' =>'PAYPHONE'}
81
+ elsif params[:phone_number] =~ /888/
82
+ {'code' =>'8', 'description' =>'INVALID'}
83
+ elsif params[:phone_number] =~ /999/
84
+ {'code' =>'9', 'description' =>'RESTRICTED'}
85
+ elsif params[:phone_number] =~ /101010/
86
+ {'code' =>'10', 'description' =>'PERSONAL'}
87
+ elsif params[:phone_number] =~ /110110/
88
+ {'code' =>'11', 'description' =>'VOICEMAIL'}
89
+ else
90
+ {'code' =>'20', 'description' =>'OTHER'}
91
+ end
92
+
93
+ response_body = StdHelpers.std_standard_body params[:phone_number], phone_type_hash
94
+
95
+ content_type :json
96
+ [http_status, headers, response_body.to_json]
97
+ end
105
98
 
106
- # # /v1/phoneid/score/%s" % phone_number
99
+ # # /v1/phoneid/score/%s' % phone_number
107
100
  # get '/v1/phoneid/score/:phone_number' do
108
101
 
109
102
  # end
110
103
 
111
- # # /v1/phoneid/contact/%s" % phone_number
104
+ # # /v1/phoneid/contact/%s' % phone_number
112
105
  # get '/v1/phoneid/contact/:phone_number' do
113
106
 
114
107
  # end
115
108
 
116
- # # /v1/phoneid/live/%s" % phone_number
109
+ # # /v1/phoneid/live/%s' % phone_number
117
110
  # get '/v1/phoneid/live/:phone_number' do
118
111
 
119
112
  # end
120
113
  end
114
+
115
+ BEGIN {
116
+ class StdHelpers
117
+ class << self
118
+ def standard_headers
119
+ # scraped from TeleSign api response
120
+ { 'date' =>Time.now.strftime('%a, %d %b %Y %H:%M:%S %z'),
121
+ 'server' =>'Apache',
122
+ 'allow' =>'GET,POST,HEAD',
123
+ 'connection' =>'close',
124
+ 'content-type' =>'application/json'}
125
+ end
126
+
127
+ def std_response_body reference_id, status_code = 'UNKNOWN'
128
+ # scraped from TeleSign api response
129
+ { 'reference_id' => reference_id,
130
+ 'resource_uri' => '/v1/verify/#{reference_id}',
131
+ 'sub_resource' => 'sms',
132
+ 'errors' => [],
133
+ 'status' => {
134
+ 'updated_on' => standard_updated_on,
135
+ 'code' => 290,
136
+ 'description' => 'Message in progress'
137
+ },
138
+ 'verify' => {
139
+ 'code_state' => status_code,
140
+ 'code_entered' => ''
141
+ }
142
+ }
143
+ end
144
+
145
+ def std_standard_body phone_number, phone_type_hash
146
+ simple_phone = phone_number[0]=='1' ? phone_number.slice(1..-1) : phone_number
147
+ { 'reference_id' => std_reference_id,
148
+ 'resource_uri' => nil,
149
+ 'sub_resource' => 'standard',
150
+ 'status' => {
151
+ 'updated_on' => standard_updated_on,
152
+ 'code' => 300,
153
+ 'description' => 'Transaction successfully completed'
154
+ },
155
+ 'errors' => [],
156
+ 'location' => {
157
+ 'city' => 'Reno',
158
+ 'state' => 'NV',
159
+ 'zip' => '89501',
160
+ 'metro_code' => '6720',
161
+ 'county' => '',
162
+ 'country' => {
163
+ 'name' => 'United States',
164
+ 'iso2' => 'US',
165
+ 'iso3' => 'USA'
166
+ },
167
+ 'coordinates' => {
168
+ 'latitude' => 39.52598,
169
+ 'longitude' => -119.80796
170
+ },
171
+ 'time_zone' => {
172
+ 'name' =>' America/Los_Angeles',
173
+ 'utc_offset_min' => '-8',
174
+ 'utc_offset_max' => '-8'
175
+ }
176
+ },
177
+ 'numbering' => {
178
+ 'original' => {
179
+ 'complete_phone_number' => '1'+simple_phone,
180
+ 'country_code' => '1',
181
+ 'phone_number' => simple_phone
182
+ },
183
+ 'cleansing' => {
184
+ 'call' => {
185
+ 'country_code' => '1',
186
+ 'phone_number' => simple_phone,
187
+ 'cleansed_code' => 100,
188
+ 'min_length' => 10,
189
+ 'max_length' => 10},
190
+ 'sms' => {
191
+ 'country_code' => '1',
192
+ 'phone_number' => simple_phone,
193
+ 'cleansed_code' => 100,
194
+ 'min_length' => 10,
195
+ 'max_length' => 10
196
+ }
197
+ }
198
+ },
199
+ 'phone_type' => phone_type_hash,
200
+ 'carrier' => {
201
+ 'name' => 'AT&T - PSTN'
202
+ }
203
+ }
204
+ end
205
+
206
+ def std_reference_id
207
+ SecureRandom.uuid.gsub('-','').upcase
208
+ end
209
+
210
+ def standard_updated_on
211
+ Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%6N')
212
+ end
213
+ end
214
+ end
215
+ }
@@ -1,3 +1,3 @@
1
1
  module Telesignature
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telesignature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Koch