loqate 0.11.1 → 0.12.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
  SHA256:
3
- metadata.gz: 1d8b2153d2e4dc1f2a54ed028b256f531e8faf42061b31b359e58295617b942f
4
- data.tar.gz: ea65ed9dc5b6e0ff70359781ac5e447c98aa5bb1edc261ebb0b2e929644a9011
3
+ metadata.gz: d37f55f57ac91abcb2a381c0389d908114db9c330bdf07379d5ada10a2dea85c
4
+ data.tar.gz: efde49b8e5cd34031450c7f8043c389d66e509a575bb73cdf0386286246fb903
5
5
  SHA512:
6
- metadata.gz: ce3ea4757fb605b795bdeb136f1cba611b1adc6240aab59863ee7e032d5df0ae97fe1f91bf48abc0ea1668a014d3f5ce387b3bc40b8297b566607c58a4036540
7
- data.tar.gz: ed9f75aa997bc9f3ec7fc11f86610f2e479dd2cc224183ea9a7ca5bfba56437ca73e21da59d26ab53224eac3c1b17dd87aae70dab21ea05dc2eeb4cbde018c75
6
+ metadata.gz: f3fe6bde75397bbaeea6ec97fb764ad0a23c62c3c83f045f42d40962cc8c12686e7534195a502ee48d5f480261e7329d1213c32d8b304b16ce5f49433e7eb8bf
7
+ data.tar.gz: 850e514eada88d53af951c7a14929a41ef73673ff79ad4d25fc8a47fd05ebf9c6bcca2ca29623d45f311655110c775e87d99fdb24a7b9fe060d906183724e9e6
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.7.1
1
+ ruby 3.0.1
data/.travis.yml CHANGED
@@ -7,6 +7,7 @@ rvm:
7
7
  - 2.5
8
8
  - 2.6
9
9
  - 2.7
10
+ - 3.0
10
11
 
11
12
  before_install: gem install bundler -v 2.1.4
12
13
 
data/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ 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.12.0] - 2021-04-26
8
+ ## Changed
9
+ - Set the gem development Ruby version to Ruby `3.0.1`
10
+ - Ensured compatibility with Ruby `3.0`
11
+ - Updated the API client to handle internal Loqate errors such as `502`:
12
+ ```
13
+ JSON::ParserError (767: unexpected token at '<html><head>)
14
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
15
+ <title>502 Server Error</title>
16
+ </head>
17
+ <body text=#000000 bgcolor=#ffffff>
18
+ <h1>Error: Server Error</h1>
19
+ <h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
20
+ <h2></h2>
21
+ </body></html>
22
+ ```
23
+
7
24
  ## [0.11.1] - 2021-04-26
8
25
  ## Fixed
9
26
  - Fixed the allowed values of the enum `Phone::PhoneNumberValidation::IsValid` by adding `Maybe` as a valid value.
@@ -134,6 +151,7 @@ and will always return `false`.
134
151
  - Initial core functionality
135
152
  - Codebase maintenance tools
136
153
 
154
+ [0.12.0]: https://github.com/wilsonsilva/loqate/compare/v0.11.1...v0.12.0
137
155
  [0.11.1]: https://github.com/wilsonsilva/loqate/compare/v0.11.0...v0.11.1
138
156
  [0.11.0]: https://github.com/wilsonsilva/loqate/compare/v0.10.4...v0.11.0
139
157
  [0.10.4]: https://github.com/wilsonsilva/loqate/compare/v0.10.3...v0.10.4
@@ -15,6 +15,19 @@ module Loqate
15
15
  @items = items
16
16
  end
17
17
 
18
+ def self.error(status:)
19
+ new(
20
+ [
21
+ {
22
+ 'Error' => '-2',
23
+ 'Description' => 'Something went wrong - please try again later',
24
+ 'Resolution' => 'Try again later',
25
+ 'Cause' => "Server returned response with #{status}"
26
+ }
27
+ ]
28
+ )
29
+ end
30
+
18
31
  # Whether the response contains errors
19
32
  #
20
33
  # @return [Boolean] true if the response has errors and false otherwise
data/lib/loqate/client.rb CHANGED
@@ -38,8 +38,12 @@ module Loqate
38
38
 
39
39
  response = HTTP.headers(headers).get(configuration.host + endpoint, params: formatted_params)
40
40
 
41
- body = JSON.parse(response.body)
42
- APIResult.new(body.fetch('Items'))
41
+ if response.status.success?
42
+ body = JSON.parse(response.body)
43
+ APIResult.new(body.fetch('Items'))
44
+ else
45
+ APIResult.error(status: response.status)
46
+ end
43
47
  end
44
48
 
45
49
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loqate
4
- VERSION = '0.11.1'
4
+ VERSION = '0.12.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loqate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilson Silva
@@ -394,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
394
394
  - !ruby/object:Gem::Version
395
395
  version: '0'
396
396
  requirements: []
397
- rubygems_version: 3.1.2
397
+ rubygems_version: 3.2.15
398
398
  signing_key:
399
399
  specification_version: 4
400
400
  summary: API client for GBG Loqate