phone_number_validation 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48223b3c9772aa65d633fa6806ded769023e8947
4
- data.tar.gz: 47aee733854886a90ea1e4b0ea7285ccbf40571a
3
+ metadata.gz: 19282847637452cd54d3bb938a59c882b9b5797a
4
+ data.tar.gz: 75aa8528dcd6c831d1d881d8d5a46a8d4f51be1b
5
5
  SHA512:
6
- metadata.gz: 2c4448518ff7c11de478f6ebb9a3fd5335717164497bc6251ff95dd95e85467b7b5e566ed06b1a54c5a17794e3ad5ea1c9723267491c76a13e865b81f7dc76cd
7
- data.tar.gz: 3dea520f7f561d2a8a72d10b63b4d31dfd04d23930b10f4121a207354445502be9c056227c9f8af9d21ef98096a7b58969a9d98deaea728d214d1fc9ec408299
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
@@ -0,0 +1,15 @@
1
+ require "phone_number_validation/version"
2
+
3
+ module NumverifyLayer
4
+
5
+ class CountriesException < Exception
6
+
7
+ attr_accessor :error
8
+
9
+ def initialize(error)
10
+ self.error = error
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ require "phone_number_validation/version"
2
+
3
+ module NumverifyLayer
4
+
5
+ class CountriesOptions
6
+
7
+ include Hashable
8
+
9
+ attr_accessor :access_key
10
+
11
+ def initialize()
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ require "hashable"
2
+
3
+ module NumverifyLayer
4
+
5
+ class CountriesRequest
6
+
7
+ include Hashable
8
+
9
+ attr_accessor :query
10
+
11
+ def initialize(query = {})
12
+ self.query = query;
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ require "phone_number_validation/version"
2
+
3
+ module NumverifyLayer
4
+
5
+ class CountriesResponse
6
+
7
+ ERROR_EXPR = 'error'
8
+
9
+ def bar
10
+ ERROR_EXPR
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -1,3 +1,3 @@
1
1
  module NumverifyLayer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.1
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