phone_number_validation 0.1.1 → 0.2.0
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 +4 -4
- data/README.md +41 -0
- data/lib/phone_number_validation/countries/countries_exception.rb +15 -0
- data/lib/phone_number_validation/countries/countries_options.rb +16 -0
- data/lib/phone_number_validation/countries/countries_request.rb +16 -0
- data/lib/phone_number_validation/countries/countries_response.rb +15 -0
- data/lib/phone_number_validation/version.rb +1 -1
- data/lib/phone_number_validation.rb +40 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19282847637452cd54d3bb938a59c882b9b5797a
|
4
|
+
data.tar.gz: 75aa8528dcd6c831d1d881d8d5a46a8d4f51be1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ec31287c90a17286ed46aeffcbdba3b1c9e3f75e7d8081aa51c2e80d1ae2b06542354deb576611445d07b07e680ced654e71f708cb4d6fe583c83d32abdd3d
|
7
|
+
data.tar.gz: e76c9a02d10a96a49ecd8d5da001987670b656aed171ee1f826b51cbb21c8aec92e9d0512aa63503f36346f3db2507526fbccdf1fa36cfa52eef11084172f805
|
data/README.md
CHANGED
@@ -129,6 +129,47 @@ If we pass the number ```+14158586273``` as the query argument above, we get the
|
|
129
129
|
}
|
130
130
|
|
131
131
|
```
|
132
|
+
|
133
|
+
## Countries
|
134
|
+
Returns the list of Supported Countries.
|
135
|
+
|
136
|
+
###### Define Query
|
137
|
+
|
138
|
+
For this endpoint, we dont pass any primary argument, just the control options, so we define an options object.
|
139
|
+
There are currently no options for the ```countries``` endpoint, so we could omit it, however we use it with an empty options object here to stay aligned with the standard for the library.
|
140
|
+
|
141
|
+
```
|
142
|
+
options = NumverifyLayer::CountriesOptions.new()
|
143
|
+
|
144
|
+
```
|
145
|
+
|
146
|
+
###### Call Client
|
147
|
+
We then place the actual call to the API, passing in the email we wish to check and the options we defined above.
|
148
|
+
|
149
|
+
```
|
150
|
+
response = @client.countries([options] )
|
151
|
+
|
152
|
+
```
|
153
|
+
|
154
|
+
###### Response
|
155
|
+
```
|
156
|
+
{
|
157
|
+
"AF": {
|
158
|
+
"country_name": "Afghanistan",
|
159
|
+
"dialling_code": "+93"
|
160
|
+
},
|
161
|
+
"AL": {
|
162
|
+
"country_name": "Albania",
|
163
|
+
"dialling_code": "+355"
|
164
|
+
},
|
165
|
+
"DZ": {
|
166
|
+
"country_name": "Algeria",
|
167
|
+
"dialling_code": "+213"
|
168
|
+
},
|
169
|
+
...
|
170
|
+
}
|
171
|
+
```
|
172
|
+
|
132
173
|
---
|
133
174
|
|
134
175
|
## Example Application
|
@@ -5,7 +5,10 @@ require "phone_number_validation/validate/validate_options"
|
|
5
5
|
require "phone_number_validation/validate/validate_request"
|
6
6
|
require "phone_number_validation/validate/validate_response"
|
7
7
|
require "phone_number_validation/validate/validate_exception"
|
8
|
-
|
8
|
+
require "phone_number_validation/countries/countries_options"
|
9
|
+
require "phone_number_validation/countries/countries_request"
|
10
|
+
require "phone_number_validation/countries/countries_response"
|
11
|
+
require "phone_number_validation/countries/countries_exception"
|
9
12
|
|
10
13
|
module NumverifyLayer
|
11
14
|
|
@@ -68,6 +71,42 @@ module NumverifyLayer
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
74
|
+
def countries(options = {})
|
75
|
+
|
76
|
+
# Create a shallow copy so we don't manipulate the original reference
|
77
|
+
q = options.dup
|
78
|
+
|
79
|
+
# Populate the Query
|
80
|
+
q.access_key = @access_key
|
81
|
+
|
82
|
+
# We then create the Request
|
83
|
+
req = NumverifyLayer::CountriesRequest.new(q)
|
84
|
+
|
85
|
+
# We create a Hash of the request so we can send it via HTTP
|
86
|
+
req_dto = req.to_dh
|
87
|
+
|
88
|
+
begin
|
89
|
+
|
90
|
+
# We make the actual request
|
91
|
+
res = self.class.get('/countries', req_dto)
|
92
|
+
|
93
|
+
# We ensure that we tap the response so we can use the results
|
94
|
+
res.inspect
|
95
|
+
|
96
|
+
if (res[NumverifyLayer::CountriesResponse::ERROR_EXPR])
|
97
|
+
raise NumverifyLayer::CountriesException.new res[NumverifyLayer::CountriesResponse::ERROR_EXPR]
|
98
|
+
end
|
99
|
+
|
100
|
+
# We just return the parsed binary response
|
101
|
+
return res.parsed_response
|
102
|
+
|
103
|
+
rescue => e
|
104
|
+
puts e.inspect
|
105
|
+
return
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
71
110
|
end
|
72
111
|
|
73
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phone_number_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Andreas Moelgaard
|
@@ -127,6 +127,10 @@ files:
|
|
127
127
|
- bin/setup
|
128
128
|
- example/example_validate.rb
|
129
129
|
- lib/phone_number_validation.rb
|
130
|
+
- lib/phone_number_validation/countries/countries_exception.rb
|
131
|
+
- lib/phone_number_validation/countries/countries_options.rb
|
132
|
+
- lib/phone_number_validation/countries/countries_request.rb
|
133
|
+
- lib/phone_number_validation/countries/countries_response.rb
|
130
134
|
- lib/phone_number_validation/validate/validate_exception.rb
|
131
135
|
- lib/phone_number_validation/validate/validate_options.rb
|
132
136
|
- lib/phone_number_validation/validate/validate_request.rb
|