loqate 0.3.0 → 0.4.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/.yardstick.yml +24 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE.md +21 -0
- data/README.md +49 -8
- data/ROADMAP.md +2 -2
- data/lib/loqate.rb +1 -0
- data/lib/loqate/address.rb +6 -42
- data/lib/loqate/client.rb +6 -1
- data/lib/loqate/gateway.rb +9 -0
- data/lib/loqate/phone_gateway.rb +82 -0
- data/lib/loqate/phone_number_validation.rb +67 -0
- data/lib/loqate/types.rb +9 -0
- data/lib/loqate/version.rb +1 -1
- data/loqate.gemspec +2 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1480f53219de60b29e6137f502c3b5c09af4fc0b9f8737a8248d2e71704b391a
|
4
|
+
data.tar.gz: 7842ed023231d338d31ede50f77e87e3ddcfcf78131754539bb55e3d9744722f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e65821f932b0e0c2c910e0e92c02c4ab68cbde159db6e50ae645931c0497d3b87f0f4b37ada680f56feadb6a1302b3ea6d118fd4fbfa7c828b8484ad68b1aaf
|
7
|
+
data.tar.gz: a56f36319aa424b4fb368defd2bb03b76770d66faec41ebe5ac6efe8f9ffaef5edee87595c437a6f85269a7841a083adfc3ff6872d59500996021d0452143bc3
|
data/.yardstick.yml
CHANGED
@@ -41,6 +41,18 @@ rules:
|
|
41
41
|
- Loqate::Gateway#config
|
42
42
|
- Loqate::Gateway#initialize
|
43
43
|
- Loqate::Gateway#address
|
44
|
+
- Loqate::Gateway#phone
|
45
|
+
- Loqate::PhoneGateway#initialize
|
46
|
+
- Loqate::PhoneNumberValidation#phone_number
|
47
|
+
- Loqate::PhoneNumberValidation#request_processed
|
48
|
+
- Loqate::PhoneNumberValidation#is_valid
|
49
|
+
- Loqate::PhoneNumberValidation#network_code
|
50
|
+
- Loqate::PhoneNumberValidation#network_name
|
51
|
+
- Loqate::PhoneNumberValidation#network_country
|
52
|
+
- Loqate::PhoneNumberValidation#national_format
|
53
|
+
- Loqate::PhoneNumberValidation#country_prefix
|
54
|
+
- Loqate::PhoneNumberValidation#number_type
|
55
|
+
- Loqate::PhoneNumberValidation#valid?
|
44
56
|
- Loqate::Result::Success#success?
|
45
57
|
- Loqate::Result::Success#failure?
|
46
58
|
- Loqate::Result::Failure#success?
|
@@ -67,6 +79,7 @@ rules:
|
|
67
79
|
- Loqate::Client#configuration
|
68
80
|
- Loqate::Client#authenticate_params
|
69
81
|
- Loqate::Client#format_params
|
82
|
+
- Loqate::Client#headers
|
70
83
|
- Loqate::DetailedAddress#==
|
71
84
|
- Loqate::Util.camelize
|
72
85
|
- Loqate::Util#camelize
|
@@ -74,6 +87,11 @@ rules:
|
|
74
87
|
- Loqate::Util#underscore
|
75
88
|
- Loqate::Error#attributes
|
76
89
|
- Loqate::Gateway#client
|
90
|
+
- Loqate::PhoneGateway#mapper
|
91
|
+
- Loqate::PhoneGateway#error_mapper
|
92
|
+
- Loqate::PhoneGateway#client
|
93
|
+
- Loqate::PhoneGateway#build_error_from
|
94
|
+
- Loqate::PhoneGateway#build_phone_validation_from
|
77
95
|
- Loqate::Result::Failure#error
|
78
96
|
Summary::Presence:
|
79
97
|
enabled: true
|
@@ -94,10 +112,16 @@ rules:
|
|
94
112
|
- Loqate::Client#configuration
|
95
113
|
- Loqate::Client#authenticate_params
|
96
114
|
- Loqate::Client#format_params
|
115
|
+
- Loqate::Client#headers
|
97
116
|
- Loqate::DetailedAddress#initialize
|
98
117
|
- Loqate::DetailedAddress#==
|
99
118
|
- Loqate::Error#attributes
|
100
119
|
- Loqate::Gateway#client
|
120
|
+
- Loqate::PhoneGateway#mapper
|
121
|
+
- Loqate::PhoneGateway#error_mapper
|
122
|
+
- Loqate::PhoneGateway#client
|
123
|
+
- Loqate::PhoneGateway#build_error_from
|
124
|
+
- Loqate::PhoneGateway#build_phone_validation_from
|
101
125
|
- Loqate::Result::Failure#error
|
102
126
|
Summary::Length:
|
103
127
|
enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.4.0] - 2018-11-14
|
8
|
+
### Changed
|
9
|
+
- Updated the gem `HTTP` to version `4.0.0`
|
10
|
+
- Added the header `Accept: application/json` to every request
|
11
|
+
- Simplified the Value Objects with Dry-Struct
|
12
|
+
|
13
|
+
## Added
|
14
|
+
- A License (MIT)
|
15
|
+
- Phone API
|
16
|
+
|
7
17
|
## [0.3.0] - 2018-11-10
|
8
18
|
### Changed
|
9
19
|
- `address.retrieve` and `address.find` return a single error, not an array with a single item
|
@@ -35,5 +45,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
35
45
|
- Initial core functionality
|
36
46
|
- Codebase maintenance tools
|
37
47
|
|
48
|
+
[0.4.0]: https://github.com/wilsonsilva/loqate/compare/v0.3.0...v0.4.0
|
38
49
|
[0.3.0]: https://github.com/wilsonsilva/loqate/compare/v0.2.0...v0.3.0
|
39
50
|
[0.2.0]: https://github.com/wilsonsilva/loqate/compare/v0.1.0...v0.2.0
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Wilson Silva
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -9,6 +9,22 @@
|
|
9
9
|
|
10
10
|
Client to address verification, postcode lookup, & data quality services from Loqate.
|
11
11
|
|
12
|
+
## Table of contents
|
13
|
+
- [Installation](#installation)
|
14
|
+
- [Usage](#usage)
|
15
|
+
- [Getting started](#getting-started)
|
16
|
+
- [Bang methods](#bang-methods)
|
17
|
+
- [Example of using non-bang method](#example-of-using-non-bang-method)
|
18
|
+
- [Example of using bang method](#example-of-using-bang-method)
|
19
|
+
- [Address API](#address-api)
|
20
|
+
- [Finding addresses](#finding-addresses)
|
21
|
+
- [Retrieving the details of an address](#retrieving-the-details-of-an-address)
|
22
|
+
- [Phone API](#phone-api)
|
23
|
+
- [Validating a phone number](#validating-a-phone-number)
|
24
|
+
- [Development](#development)
|
25
|
+
- [Contributing](#contributing)
|
26
|
+
- [License](#license)
|
27
|
+
|
12
28
|
## Installation
|
13
29
|
|
14
30
|
Add this line to your application's Gemfile:
|
@@ -38,7 +54,7 @@ To get started, initialize an API gateway with [your API key](https://account.lo
|
|
38
54
|
gateway = Loqate::Gateway.new(api_key: '<YOUR_API_KEY>')
|
39
55
|
```
|
40
56
|
|
41
|
-
### Bang
|
57
|
+
### Bang methods
|
42
58
|
|
43
59
|
Most methods have a bang and a non-bang version (e.g. `gateway.address.find` and `gateway.address.find!`).
|
44
60
|
The non-bang version will either return a `Loqate::Success` or an `Loqate::Failure`. The bang version will
|
@@ -88,21 +104,42 @@ selection.
|
|
88
104
|
#### Finding addresses
|
89
105
|
|
90
106
|
```ruby
|
91
|
-
|
107
|
+
addresses = gateway.address.find!(text: 'EC1Y 8AF', country: 'GB', limit: 5)
|
92
108
|
|
93
|
-
addresses = result.value
|
94
109
|
addresses.first.id # => 'GB|RM|B|8144611'
|
95
110
|
```
|
96
111
|
|
97
112
|
#### Retrieving the details of an address
|
98
113
|
|
99
114
|
```ruby
|
100
|
-
|
115
|
+
address = gateway.address.retrieve!(id: 'GB|RM|B|8144611')
|
116
|
+
|
117
|
+
address.city # 'London'
|
118
|
+
address.line1 # '148 Warner Road'
|
119
|
+
address.postal_code # 'E17 7EA'
|
120
|
+
```
|
121
|
+
|
122
|
+
### Phone API
|
101
123
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
124
|
+
The Phone API consists of a single API request:
|
125
|
+
[Validate](https://www.loqate.com/resources/support/apis/PhoneNumberValidation/Interactive/Validate/2.2/) which starts
|
126
|
+
a new phone number validation request.
|
127
|
+
|
128
|
+
#### Validating a phone number
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
phone_validation = gateway.phone.validate!(phone: '+447440029210', country: 'GB')
|
132
|
+
|
133
|
+
phone_validation.phone_number # => '+447440029210'
|
134
|
+
phone_validation.request_processed # => true
|
135
|
+
phone_validation.is_valid # => 'Yes' -> This is how Loqate defines validity
|
136
|
+
phone_validation.valid? # => true
|
137
|
+
phone_validation.network_code # => '26'
|
138
|
+
phone_validation.network_name # => 'Telefonica UK'
|
139
|
+
phone_validation.network_country # => 'GB'
|
140
|
+
phone_validation.national_format # => '07440 029210'
|
141
|
+
phone_validation.country_prefix # => 44
|
142
|
+
phone_validation.number_type # => 'Mobile'
|
106
143
|
```
|
107
144
|
|
108
145
|
## Development
|
@@ -131,3 +168,7 @@ rake yardstick_measure # Measure docs in lib/**/*.rb with yardstick
|
|
131
168
|
## Contributing
|
132
169
|
|
133
170
|
Bug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/loqate.
|
171
|
+
|
172
|
+
## License
|
173
|
+
|
174
|
+
See [LICENSE](https://github.com/wilsonsilva/loqate/blob/master/LICENSE).
|
data/ROADMAP.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
- [ ] Logging
|
8
8
|
- [x] Domain error handling
|
9
9
|
- [x] Configuration
|
10
|
-
- [
|
10
|
+
- [x] Unwrap request results
|
11
11
|
- [ ] Validate request parameters
|
12
12
|
- [ ] API/Service versioning
|
13
13
|
- [ ] Integration with RSpec
|
@@ -18,7 +18,7 @@
|
|
18
18
|
- [ ] Geocode
|
19
19
|
- [ ] Data Cleanse
|
20
20
|
- [ ] Email Verification
|
21
|
-
- [
|
21
|
+
- [x] Phone Verification
|
22
22
|
- [ ] Bank Verification
|
23
23
|
|
24
24
|
## Formats
|
data/lib/loqate.rb
CHANGED
data/lib/loqate/address.rb
CHANGED
@@ -1,71 +1,35 @@
|
|
1
1
|
module Loqate
|
2
2
|
# A result from the address find service.
|
3
|
-
class Address
|
3
|
+
class Address < Dry::Struct::Value
|
4
4
|
# An address ID or a container ID for further results
|
5
5
|
#
|
6
6
|
# @return [String]
|
7
7
|
#
|
8
|
-
|
8
|
+
attribute :id, Types::Strict::String
|
9
9
|
|
10
10
|
# If the Type is 'Address' then the ID can be passed to the Retrieve service.
|
11
11
|
# Any other ID should be passed as the Container to a further Find request to get more results.
|
12
12
|
#
|
13
13
|
# @return [String]
|
14
14
|
#
|
15
|
-
|
15
|
+
attribute :type, Types::Strict::String
|
16
16
|
|
17
17
|
# The name of the result
|
18
18
|
#
|
19
19
|
# @return [String]
|
20
20
|
#
|
21
|
-
|
21
|
+
attribute :text, Types::Strict::String
|
22
22
|
|
23
23
|
# A list of number ranges identifying the matched characters in the Text and Description
|
24
24
|
#
|
25
25
|
# @return [String]
|
26
26
|
#
|
27
|
-
|
27
|
+
attribute :highlight, Types::Strict::String
|
28
28
|
|
29
29
|
# Descriptive information about the result
|
30
30
|
#
|
31
31
|
# @return [String]
|
32
32
|
#
|
33
|
-
|
34
|
-
|
35
|
-
# Creates an address
|
36
|
-
#
|
37
|
-
# @param [String] id An address ID or a container ID for further results
|
38
|
-
# @param [String] type If the Type is 'Address' then the ID can be passed to the Retrieve service.
|
39
|
-
# Any other ID should be passed as the Container to a further Find request to get more results.
|
40
|
-
# @param [String] text The name of the result
|
41
|
-
# @param [String] highlight A list of number ranges identifying the matched characters in the Text and Description
|
42
|
-
# @param [String] description Descriptive information about the result
|
43
|
-
#
|
44
|
-
def initialize(id:, type:, text:, highlight:, description:)
|
45
|
-
@id = id
|
46
|
-
@type = type
|
47
|
-
@text = text
|
48
|
-
@highlight = highlight
|
49
|
-
@description = description
|
50
|
-
end
|
51
|
-
|
52
|
-
# @!visibility private
|
53
|
-
# @api private
|
54
|
-
def ==(other)
|
55
|
-
attributes == other.send(:attributes)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# @api private
|
61
|
-
def attributes
|
62
|
-
@attributes ||= {
|
63
|
-
id: id,
|
64
|
-
type: type,
|
65
|
-
text: text,
|
66
|
-
highlight: highlight,
|
67
|
-
description: description
|
68
|
-
}
|
69
|
-
end
|
33
|
+
attribute :description, Types::Strict::String
|
70
34
|
end
|
71
35
|
end
|
data/lib/loqate/client.rb
CHANGED
@@ -36,7 +36,7 @@ module Loqate
|
|
36
36
|
authenticated_params = authenticate_params(params)
|
37
37
|
formatted_params = format_params(authenticated_params)
|
38
38
|
|
39
|
-
response = HTTP.get(configuration.host + endpoint, params: formatted_params)
|
39
|
+
response = HTTP.headers(headers).get(configuration.host + endpoint, params: formatted_params)
|
40
40
|
|
41
41
|
body = JSON.parse(response.body)
|
42
42
|
APIResult.new(body.fetch('Items'))
|
@@ -56,5 +56,10 @@ module Loqate
|
|
56
56
|
def format_params(params)
|
57
57
|
params.transform_keys { |key| Util.camelize(key) }
|
58
58
|
end
|
59
|
+
|
60
|
+
# @api private
|
61
|
+
def headers
|
62
|
+
{ accept: 'application/json' }
|
63
|
+
end
|
59
64
|
end
|
60
65
|
end
|
data/lib/loqate/gateway.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'loqate/address_gateway'
|
2
|
+
require 'loqate/phone_gateway'
|
2
3
|
|
3
4
|
module Loqate
|
4
5
|
# Acts as a single point of entry for a defined group of API's.
|
@@ -31,6 +32,14 @@ module Loqate
|
|
31
32
|
@address ||= AddressGateway.new(client)
|
32
33
|
end
|
33
34
|
|
35
|
+
# Gateway to the Phone number API.
|
36
|
+
#
|
37
|
+
# @return [PhoneGateway] An instance of a phone gateway.
|
38
|
+
#
|
39
|
+
def phone
|
40
|
+
@phone ||= PhoneGateway.new(client)
|
41
|
+
end
|
42
|
+
|
34
43
|
private
|
35
44
|
|
36
45
|
# @api private
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'loqate/client'
|
2
|
+
require 'loqate/result'
|
3
|
+
require 'loqate/mappers/error_mapper'
|
4
|
+
require 'loqate/mappers/generic_mapper'
|
5
|
+
require 'loqate/phone_number_validation'
|
6
|
+
|
7
|
+
module Loqate
|
8
|
+
# Starts a new phone number validation request.
|
9
|
+
#
|
10
|
+
class PhoneGateway
|
11
|
+
VALIDATE_ENDPOINT = '/PhoneNumberValidation/Interactive/Validate/v2.20/json3.ws'.freeze
|
12
|
+
|
13
|
+
include Result::Mixin
|
14
|
+
|
15
|
+
# Creates a phone gateway
|
16
|
+
#
|
17
|
+
# @param [Client] client The client responsible for the HTTP interactions
|
18
|
+
#
|
19
|
+
def initialize(client)
|
20
|
+
@client = client
|
21
|
+
@mapper = Mappers::GenericMapper.new
|
22
|
+
@error_mapper = Mappers::ErrorMapper.new
|
23
|
+
end
|
24
|
+
|
25
|
+
# Validates phone numbers.
|
26
|
+
#
|
27
|
+
# @param [Hash] options The options to validate a phone number.
|
28
|
+
# @option options [String] :phone The mobile/cell phone number to verify. This must be in international format
|
29
|
+
# (+447528471411 or 447528471411) if no country code is provided or national format with a Country parameter
|
30
|
+
# provided (07528471411 and GB as the Country parameter).
|
31
|
+
# @option options [String] :country The ISO2 country code of the number you are trying to validate
|
32
|
+
# (if provided in national format).
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# phone_validation = phone_gateway.validate(phone: '447440019210', country: 'GB')
|
36
|
+
#
|
37
|
+
# @return [Result] A result wrapping a phone number validation
|
38
|
+
#
|
39
|
+
def validate(options)
|
40
|
+
response = client.get(VALIDATE_ENDPOINT, options)
|
41
|
+
|
42
|
+
response.errors? && build_error_from(response.items.first) || build_phone_validation_from(response.items.first)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Validates phone numbers.
|
46
|
+
#
|
47
|
+
# @param [Hash] options The options to validate a phone number.
|
48
|
+
# @option options [String] :phone The mobile/cell phone number to verify. This must be in international format
|
49
|
+
# (+447528471411 or 447528471411) if no country code is provided or national format with a Country parameter
|
50
|
+
# provided (07528471411 and GB as the Country parameter).
|
51
|
+
# @option options [String] :country The ISO2 country code of the number you are trying to validate
|
52
|
+
# (if provided in national format).
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# phone_validation = phone_gateway.validate(phone: '447440019210', country: 'GB')
|
56
|
+
#
|
57
|
+
# @raise [Error] If the result is not a success
|
58
|
+
#
|
59
|
+
# @return [PhoneNumberValidation> A phone number validation
|
60
|
+
#
|
61
|
+
def validate!(options)
|
62
|
+
unwrap_result_or_raise { validate(options) }
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
attr_reader :client, :mapper, :error_mapper
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
def build_error_from(item)
|
72
|
+
error = error_mapper.map_one(item)
|
73
|
+
Failure(error)
|
74
|
+
end
|
75
|
+
|
76
|
+
# @api private
|
77
|
+
def build_phone_validation_from(item)
|
78
|
+
phone_number_validation = mapper.map_one(item, PhoneNumberValidation)
|
79
|
+
Success(phone_number_validation)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Loqate
|
2
|
+
# Result of a phone number validation.
|
3
|
+
class PhoneNumberValidation < Dry::Struct::Value
|
4
|
+
IsValid = Types::Strict::String.enum('Yes', 'No', 'Unknown')
|
5
|
+
NumberType = Types::Strict::String.enum('Mobile', 'Landline', 'Voip', 'Unknown')
|
6
|
+
|
7
|
+
# The recipient phone number in international format.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
attribute :phone_number, Types::Strict::String
|
12
|
+
|
13
|
+
# Returns true if we managed to process the request on the network or false if the validation
|
14
|
+
# attempt was unsuccessful.
|
15
|
+
#
|
16
|
+
# @return [Boolean]
|
17
|
+
#
|
18
|
+
attribute :request_processed, Types::Strict::Bool
|
19
|
+
|
20
|
+
# Whether the number is valid or not (Unknown returned if validation wasn't possible).
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
attribute :is_valid, IsValid
|
25
|
+
|
26
|
+
# The current operator serving the supplied number.
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
#
|
30
|
+
attribute :network_code, Types::Strict::String
|
31
|
+
|
32
|
+
# The name of the current operator serving the supplied number.
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
#
|
36
|
+
attribute :network_name, Types::Strict::String
|
37
|
+
|
38
|
+
# The country code of the operator.
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
#
|
42
|
+
attribute :network_country, Types::Strict::String
|
43
|
+
|
44
|
+
# The domestic network format (useful for dialling from within the same country).
|
45
|
+
#
|
46
|
+
# @return [String]
|
47
|
+
#
|
48
|
+
attribute :national_format, Types::Strict::String
|
49
|
+
|
50
|
+
# The country prefix that must be prepended to the number when dialling internationally.
|
51
|
+
#
|
52
|
+
# @return [Integer]
|
53
|
+
#
|
54
|
+
attribute :country_prefix, Types::Coercible::Integer
|
55
|
+
|
56
|
+
# The type of number that was detected in the request (Mobile, Landline, VOIP or Unknown).
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
#
|
60
|
+
attribute :number_type, NumberType
|
61
|
+
|
62
|
+
# Whether the validation was successful or not.
|
63
|
+
def valid?
|
64
|
+
is_valid == 'Yes'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/loqate/types.rb
ADDED
data/lib/loqate/version.rb
CHANGED
data/loqate.gemspec
CHANGED
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
|
-
spec.add_runtime_dependency '
|
27
|
+
spec.add_runtime_dependency 'dry-struct', '~> 0.6.0'
|
28
|
+
spec.add_runtime_dependency 'http', '~> 4.0.0'
|
28
29
|
|
29
30
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
30
31
|
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loqate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilson Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-struct
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: http
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 4.0.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: 4.0.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -323,6 +337,7 @@ files:
|
|
323
337
|
- CHANGELOG.md
|
324
338
|
- Gemfile
|
325
339
|
- Guardfile
|
340
|
+
- LICENSE.md
|
326
341
|
- README.md
|
327
342
|
- ROADMAP.md
|
328
343
|
- Rakefile
|
@@ -339,7 +354,10 @@ files:
|
|
339
354
|
- lib/loqate/gateway.rb
|
340
355
|
- lib/loqate/mappers/error_mapper.rb
|
341
356
|
- lib/loqate/mappers/generic_mapper.rb
|
357
|
+
- lib/loqate/phone_gateway.rb
|
358
|
+
- lib/loqate/phone_number_validation.rb
|
342
359
|
- lib/loqate/result.rb
|
360
|
+
- lib/loqate/types.rb
|
343
361
|
- lib/loqate/util.rb
|
344
362
|
- lib/loqate/version.rb
|
345
363
|
- loqate.gemspec
|