smartystreets_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTk5YTNiMGExYzA2NDNkYjU0MzlmMjJjNjdhZmE2YzYyYWM3MDQ1Yg==
5
- data.tar.gz: !binary |-
6
- NmQ4N2EwN2Y2OWRkMmFmZjA1NjYxYmZlYWI0NmEzNDJjMDMxNGMzOA==
2
+ SHA1:
3
+ metadata.gz: 5eac32d0c64820a518428462dfc6230c8da99476
4
+ data.tar.gz: a705c27f1258504bdfca8c7e67d3f5210791e1ba
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OThkOTNiZGI5OTRmNWM5MGNjOGVjNTE3YzNlZDJkNmFkNzE3NjQzZGZkYTcz
10
- YzE1YzI5OTJjNzNkYzEwNjE5NWUyNTllODZmZDE1YTM2OTMxYWI1ZWZhY2Y4
11
- YjM3NDhjZTIzMGVhMmViOTllZjAyM2IyY2QyYmY2MDk5NzNjN2Q=
12
- data.tar.gz: !binary |-
13
- ZTBiMGE1ODAxZWVkYjI0ZGYwN2ZhYzJhYTFkMjkwYTljZDI4YWIxMWZkMmYy
14
- NGNlMjI2OWVmMDFjZmM3NTJhZGE1Y2IxOTRiNDgyMzE5OTExZGZkN2I5NDAz
15
- ZjRmZDg1YmZiNWIxMTAyOWUxOTY2ZDgwMGNhMzkwYWUyZWUyNmM=
6
+ metadata.gz: 1d1c51600c5138adf770913fbc8570bd7be68d00c17176bc75941abe2f1a1b2a1e05f996e17c42ffe146ab70115f4f0bb32f649304eac91a36b5e2ba8c7dd240
7
+ data.tar.gz: 749190b8c9e1c0188c069180917b6749802344adb06c07ed828dece3186243f5ca19f98e5c414bbe69e019b421585a29e53048f1a55cf8c7baf7bd7690d82bda
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.2.1
5
4
  before_install: gem install bundler -v 1.11.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## [0.1.1] - 2016-12-21
5
+ ### Changed
6
+ - Raise a `SevereApiError` when an API exception happens
7
+ - Fix the error handling sequence so that error responses are not JSON parsed.
8
+ - Drop the support for Ruby 1.9
9
+
10
+ ## [0.1.0] - 2016-06-20
11
+ ### Added
12
+ - US Street Address API
@@ -0,0 +1,7 @@
1
+ module SmartyStreetsApi::Exceptions
2
+ class SevereApiError < StandardError
3
+ def initialize(message)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -13,17 +13,17 @@ class SmartyStreetsApi::UsStreetAddress
13
13
 
14
14
  response = Net::HTTP.get_response(uri)
15
15
 
16
+ raise_error!(response.code) if severe_error?(response.code)
17
+
16
18
  parse(response)
17
19
  end
18
20
 
19
21
  private
20
22
 
21
23
  def self.parse(response)
22
- parsed_response = JSON.parse(response.body)
23
-
24
- raise_error!(parsed_response) if severe_error?(response.code)
24
+ json_response = JSON.parse(response.body)
25
25
 
26
- parse_response(parsed_response)
26
+ parse_response(json_response)
27
27
  end
28
28
 
29
29
  def self.parse_response(response)
@@ -51,20 +51,22 @@ class SmartyStreetsApi::UsStreetAddress
51
51
  end
52
52
 
53
53
  def self.raise_error!(response_status_code)
54
- case response_status_code
54
+ reason = case response_status_code
55
55
  when 401
56
- raise "SmartyStreets - Unauthorized"
56
+ "Unauthorized"
57
57
  when 402
58
- raise "SmartyStreets - Payment Required"
58
+ "Payment Required"
59
59
  when 413
60
- raise "SmartyStreets - Request Entity Too Large"
60
+ "Request Entity Too Large"
61
61
  when 400
62
- raise "SmartyStreets - Bad Request (Malformed Payload)"
62
+ "Bad Request (Malformed Payload)"
63
63
  when 429
64
- raise "SmartyStreets - Too Many Requests"
64
+ "Too Many Requests"
65
65
  else
66
- raise "SmartyStreets - Unknown error"
66
+ "Unknown error: #{response_status_code}"
67
67
  end
68
+
69
+ raise SmartyStreetsApi::Exceptions::SevereApiError.new(reason)
68
70
  end
69
71
 
70
72
  def self.host
@@ -1,3 +1,3 @@
1
1
  module SmartyStreetsApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -37,5 +37,6 @@ module SmartyStreetsApi
37
37
  end
38
38
 
39
39
  require "smartystreets_api/monkey_patches"
40
+ require "smartystreets_api/exceptions"
40
41
  require "smartystreets_api/decorators/us_format"
41
42
  require "smartystreets_api/us_street_address"
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/florrain/smartystreets_api"
15
15
  spec.license = "MIT"
16
16
 
17
+ spec.required_ruby_version = '~> 2.0'
18
+
17
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
20
  spec.require_paths = ["lib"]
19
21
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartystreets_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - florrain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: vcr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.0.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.0.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.21.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.21.0
83
83
  description: A simple and dependency free API GEM for https://smartystreets.com/,
@@ -88,9 +88,10 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - .gitignore
92
- - .rspec
93
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CHANGELOG.md
94
95
  - CODE_OF_CONDUCT.md
95
96
  - Gemfile
96
97
  - LICENSE.txt
@@ -98,6 +99,7 @@ files:
98
99
  - Rakefile
99
100
  - lib/smartystreets_api.rb
100
101
  - lib/smartystreets_api/decorators/us_format.rb
102
+ - lib/smartystreets_api/exceptions.rb
101
103
  - lib/smartystreets_api/monkey_patches.rb
102
104
  - lib/smartystreets_api/us_street_address.rb
103
105
  - lib/smartystreets_api/version.rb
@@ -112,12 +114,12 @@ require_paths:
112
114
  - lib
113
115
  required_ruby_version: !ruby/object:Gem::Requirement
114
116
  requirements:
115
- - - ! '>='
117
+ - - "~>"
116
118
  - !ruby/object:Gem::Version
117
- version: '0'
119
+ version: '2.0'
118
120
  required_rubygems_version: !ruby/object:Gem::Requirement
119
121
  requirements:
120
- - - ! '>='
122
+ - - ">="
121
123
  - !ruby/object:Gem::Version
122
124
  version: '0'
123
125
  requirements: []