easypost 3.0.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +22 -0
  3. data/CHANGELOG +44 -3
  4. data/README.md +2 -1
  5. data/VERSION +1 -1
  6. data/easypost.gemspec +24 -20
  7. data/lib/easypost.rb +109 -118
  8. data/lib/easypost/address.rb +47 -47
  9. data/lib/easypost/batch.rb +34 -38
  10. data/lib/easypost/carrier_account.rb +3 -6
  11. data/lib/easypost/carrier_type.rb +2 -0
  12. data/lib/easypost/customs_info.rb +3 -2
  13. data/lib/easypost/customs_item.rb +3 -2
  14. data/lib/easypost/error.rb +25 -33
  15. data/lib/easypost/event.rb +3 -6
  16. data/lib/easypost/insurance.rb +1 -3
  17. data/lib/easypost/item.rb +4 -8
  18. data/lib/easypost/object.rb +111 -113
  19. data/lib/easypost/order.rb +20 -18
  20. data/lib/easypost/parcel.rb +1 -3
  21. data/lib/easypost/pickup.rb +19 -18
  22. data/lib/easypost/pickup_rate.rb +1 -3
  23. data/lib/easypost/postage_label.rb +1 -3
  24. data/lib/easypost/print_job.rb +1 -5
  25. data/lib/easypost/printer.rb +18 -22
  26. data/lib/easypost/rate.rb +1 -3
  27. data/lib/easypost/refund.rb +1 -3
  28. data/lib/easypost/report.rb +22 -24
  29. data/lib/easypost/resource.rb +58 -60
  30. data/lib/easypost/scan_form.rb +4 -6
  31. data/lib/easypost/shipment.rb +90 -92
  32. data/lib/easypost/tracker.rb +10 -12
  33. data/lib/easypost/user.rb +33 -37
  34. data/lib/easypost/util.rb +99 -136
  35. data/lib/easypost/webhook.rb +22 -21
  36. metadata +35 -62
  37. data/circle.yml +0 -3
  38. data/spec/address_spec.rb +0 -81
  39. data/spec/batch_spec.rb +0 -48
  40. data/spec/carrier_account_spec.rb +0 -121
  41. data/spec/insurance_spec.rb +0 -69
  42. data/spec/item_spec.rb +0 -105
  43. data/spec/order_spec.rb +0 -58
  44. data/spec/pickup_spec.rb +0 -83
  45. data/spec/report_spec.rb +0 -59
  46. data/spec/scan_form_spec.rb +0 -46
  47. data/spec/shipment_spec.rb +0 -144
  48. data/spec/spec_helper.rb +0 -10
  49. data/spec/support/constant.rb +0 -106
  50. data/spec/tracker_spec.rb +0 -94
  51. data/spec/user_spec.rb +0 -88
  52. data/spec/webhook_spec.rb +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6168d8faeaf5226b22bed0526e692acb11d0c29d8bcdc42d744c725112854792
4
- data.tar.gz: 6fc7826c1e0c958cee412cb9554268c0665ee7a11080ed1309d39f5fbceb9d65
3
+ metadata.gz: db8276b780ceb6bde1e8b72185385da6458cb152babd4bccf3b1f75e5da4af93
4
+ data.tar.gz: 103f3173ab91f5521204aee15694a31a7bb61875a955967049342ca250f04813
5
5
  SHA512:
6
- metadata.gz: 52832eace51fd93e54fdf6117b73beb5facdeb76f6df4a5a50fea512bc4983744cb09ba06e9ed204f91979fee7f902ca9814fbfd9b104075ed99f842bc088d70
7
- data.tar.gz: a5f572caca04940e794a8f363c48713159b8a946a82bc76a0465a4408d78ecb5b3419c4e32caa152e0f0e7b7071d67cbbb50dc858fc42dc01e4e0a14c5bf5391
6
+ metadata.gz: 3b4bff8f08265b7821605dec9ea8ee2b8de3261975dbe860ee33aa0746bfb2238c615d527a8db9b51716886845229437f535e8d41e541285e04cf97102120f20
7
+ data.tar.gz: e0828a81e8c006ba589fe899cff31d3fe67bbf6e77577c44224224bf818d4650ebe8c76fe6f014fd3d00330c4f9974d8f9dda5fe79ee90dadc45ceefb3cd6a10
@@ -0,0 +1,22 @@
1
+ name: 'CI'
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request: ~
7
+
8
+ jobs:
9
+ run-tests:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ rubyversion: ['2.4', '2.5', '2.6', '2.7', '3.0']
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: set up ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.rubyversion }}
20
+ bundler-cache: true
21
+ - name: run tests
22
+ run: bundle exec rspec
data/CHANGELOG CHANGED
@@ -1,18 +1,59 @@
1
+ === 3.3.0 2021-06-10
2
+
3
+ * Adds `SmartRate` functionality to the `Shipments` object (available by calling `get_smartrates` on a shipment)
4
+ * Fix bug where `EasyPost::CarrierAccount.types` was hitting the wrong endpoint
5
+
6
+ === 3.2.0 2021-01-14
7
+
8
+ * Replace Travis CI with Github Actions
9
+ * Add Ruby 3.0 to supported platforms (#110; thanks @maxwell)
10
+
11
+ === 3.1.5 2020-12-16
12
+
13
+ * Fix attribute lookup when manually constructing objects (#105; thanks @drewtempelmeyer)
14
+ * Flatten class names and clean up some other style issues
15
+ * Fix `EasyPost::Address.create_and_verify`, broken since 3.1.0 (#108; thanks @rajbirverma)
16
+
17
+ === 3.1.4 2020-09-29
18
+
19
+ * Don't modify params passed into Address#create (#78; thanks @TheRusskiy)
20
+ * Don't modify `carriers` and `services` parameters to `Shipment.lowest_rate` (#71 / #103, thanks @vladvinnikov and @jurisgalang)
21
+ * When constructing an easypost object, convert the key to a string (#102; thanks @Geesu)
22
+ * Expose the raw HTTP response as `#http_body` on `EasyPost::Error` objects (#101; thanks @Geesu)
23
+
24
+ === 3.1.3 2020-06-26
25
+
26
+ * Fix bug causing Authorization header to be included in User-Agent header. All users must upgrade.
27
+
28
+ === 3.1.2 2020-06-24
29
+
30
+ * Bad gem push. New version required.
31
+
32
+ === 3.1.1 2020-06-23
33
+
34
+ * Fix bug where EasyPost.http_config was invalid when not explicitly initialized.
35
+
36
+ === 3.1.0 2020-06-23
37
+
38
+ * Add Shipment Invoice and Refund Report
39
+ * Remove dependencies on `RestClient` and `MultiJson`
40
+ * Remove some deprecated endpoints
41
+
1
42
  === 3.0.1 2018-05-17
2
43
 
3
44
  * Enforce TLS certificate validity by default
4
45
 
5
- === 3.0.0 2018-02-09
46
+ === 3.0.0 2018-02-15
6
47
 
7
48
  * Require use of ruby ~> 2.0 and TLSv1.2
8
49
 
9
50
 
10
- === 2.7.3 2017-05-25
51
+ === 2.7.3 2018-02-05
11
52
 
12
53
  * Fix bug with introduced around certain JSON objects with IDs (thanks vladvinnikov!)
13
54
 
14
55
 
15
- === 2.7.2 2018-01-31
56
+ === 2.7.2 2018-02-01
16
57
 
17
58
  * Removed unused and unsupported code paths for Container model
18
59
  * Removed unused and unsupported code path for Stamp and Barcode methods on the Shipment model
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # EasyPost Ruby Client Library
2
2
 
3
- [<img src="https://circleci.com/gh/EasyPost/easypost-ruby.png?circle-token=80adb5236ed1fdce20810b055af79c63c3d5796b">](https://circleci.com/gh/EasyPost/easypost-ruby)
3
+ [![Build Status](https://github.com/EasyPost/easypost-ruby/workflows/CI/badge.svg)](https://github.com/EasyPost/easypost-ruby/actions?query=workflow%3ACI)
4
+ [![Gem Version](https://badge.fury.io/rb/easypost.svg)](https://badge.fury.io/rb/easypost)
4
5
 
5
6
 
6
7
  EasyPost is a simple shipping API. You can sign up for an account at https://easypost.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.1
1
+ 3.3.0
data/easypost.gemspec CHANGED
@@ -1,27 +1,31 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'easypost/version'
5
+ require "easypost/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'easypost'
8
- spec.version = EasyPost::VERSION
9
- spec.date = Time.now.strftime("%Y-%m-%d")
10
- spec.summary = 'EasyPost Ruby Client Library'
11
- spec.description = 'Client library for accessing the EasyPost shipping API via Ruby.'
12
- spec.authors = ['Sawyer Bateman']
13
- spec.email = 'contact@easypost.com'
14
- spec.homepage = 'https://www.easypost.com/docs'
8
+ spec.name = "easypost"
9
+ spec.version = EasyPost::VERSION
10
+ spec.licenses = ["MIT"]
11
+ spec.date = Time.now.strftime("%Y-%m-%d")
12
+ spec.summary = "EasyPost Ruby Client Library"
13
+ spec.description = "Client library for accessing the EasyPost shipping API via Ruby."
14
+ spec.authors = ["Jake Epstein", "Andrew Tribone", "James Brown"]
15
+ spec.email = "support@easypost.com"
16
+ spec.homepage = "https://www.easypost.com/docs"
15
17
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
- spec.required_ruby_version = '~> 2.0'
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+ spec.required_ruby_version = ">= 2.2"
21
25
 
22
- spec.add_dependency 'rest-client', '>= 1.7'
23
- spec.add_dependency 'multi_json', '>= 1.3.0'
24
- spec.add_development_dependency 'bundler', '~> 1.7'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 2.13'
26
+ spec.add_development_dependency "pry", "~> 0.13"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_development_dependency "rspec", "~> 3.9"
29
+ spec.add_development_dependency "webmock", "~> 3.8"
30
+ spec.add_development_dependency "vcr", "~> 5.1"
27
31
  end
data/lib/easypost.rb CHANGED
@@ -1,157 +1,148 @@
1
- require 'cgi'
2
- require 'set'
3
- require 'openssl'
4
- require 'rest_client'
5
- require 'multi_json'
1
+ require "base64"
2
+ require "cgi"
3
+ require "net/http"
6
4
 
7
5
  # Resources
8
- require 'easypost/version'
9
- require 'easypost/util'
10
- require 'easypost/object'
11
- require 'easypost/resource'
12
- require 'easypost/address'
13
- require 'easypost/parcel'
14
- require 'easypost/customs_item'
15
- require 'easypost/customs_info'
16
- require 'easypost/shipment'
17
- require 'easypost/rate'
18
- require 'easypost/postage_label'
19
- require 'easypost/scan_form'
20
- require 'easypost/refund'
21
- require 'easypost/insurance'
22
- require 'easypost/event'
23
- require 'easypost/batch'
24
- require 'easypost/tracker'
25
- require 'easypost/item'
26
- require 'easypost/order'
27
- require 'easypost/pickup'
28
- require 'easypost/pickup_rate'
29
- require 'easypost/printer'
30
- require 'easypost/print_job'
31
- require 'easypost/carrier_account'
32
- require 'easypost/user'
33
- require 'easypost/report'
34
- require 'easypost/webhook'
35
-
36
- require 'easypost/error'
6
+ require "easypost/version"
7
+ require "easypost/util"
8
+ require "easypost/object"
9
+ require "easypost/resource"
10
+ require "easypost/address"
11
+ require "easypost/parcel"
12
+ require "easypost/customs_item"
13
+ require "easypost/customs_info"
14
+ require "easypost/shipment"
15
+ require "easypost/rate"
16
+ require "easypost/postage_label"
17
+ require "easypost/scan_form"
18
+ require "easypost/refund"
19
+ require "easypost/insurance"
20
+ require "easypost/event"
21
+ require "easypost/batch"
22
+ require "easypost/tracker"
23
+ require "easypost/item"
24
+ require "easypost/order"
25
+ require "easypost/pickup"
26
+ require "easypost/pickup_rate"
27
+ require "easypost/printer"
28
+ require "easypost/print_job"
29
+ require "easypost/carrier_type"
30
+ require "easypost/carrier_account"
31
+ require "easypost/user"
32
+ require "easypost/report"
33
+ require "easypost/webhook"
34
+
35
+ require "easypost/error"
37
36
 
38
37
  module EasyPost
39
- @@api_key = nil
40
- @@api_base = 'https://api.easypost.com/v2'
41
- @@api_version = nil
42
- @@open_timeout = 30
43
- @@timeout = 60
44
-
45
- def self.api_url(url='')
46
- @@api_base + url
47
- end
38
+ @api_key = nil
39
+ @api_base = "https://api.easypost.com"
48
40
 
49
41
  def self.api_key=(api_key)
50
- @@api_key = api_key
42
+ @api_key = api_key
51
43
  end
52
44
 
53
45
  def self.api_key
54
- @@api_key
46
+ @api_key
55
47
  end
56
48
 
57
49
  def self.api_base=(api_base)
58
- @@api_base = api_base
50
+ @api_base = api_base
59
51
  end
60
52
 
61
53
  def self.api_base
62
- @@api_base
63
- end
64
-
65
- def self.api_version=(version)
66
- @@api_version = version
54
+ @api_base
67
55
  end
68
56
 
69
- def self.api_version
70
- @@api_version
71
- end
72
-
73
- def self.http_config
74
- @@http_config ||= {
57
+ def self.reset_http_config
58
+ @http_config = {
75
59
  timeout: 60,
76
60
  open_timeout: 30,
77
61
  verify_ssl: OpenSSL::SSL::VERIFY_PEER,
78
- ssl_version: :TLSv1_2,
79
62
  }
63
+
64
+ ruby_version = Gem::Version.new(RUBY_VERSION)
65
+ if ruby_version >= Gem::Version.new("2.5.0")
66
+ @http_config[:min_version] = OpenSSL::SSL::TLS1_2_VERSION
67
+ else
68
+ @http_config[:ssl_version] = :TLSv1_2
69
+ end
70
+
71
+ @http_config
72
+ end
73
+
74
+ def self.http_config
75
+ @http_config ||= reset_http_config
80
76
  end
81
77
 
82
78
  def self.http_config=(http_config_params)
83
- self.http_config.merge!(http_config_params)
79
+ http_config.merge!(http_config_params)
84
80
  end
85
81
 
86
- def self.request(method, url, api_key, params={}, headers={}, api_key_required=true)
87
- api_key ||= @@api_key
88
- if api_key_required
89
- raise Error.new('No API key provided.') unless api_key
90
- end
82
+ def self.make_client(uri)
83
+ client = if http_config[:proxy]
84
+ proxy_uri = URI(http_config[:proxy])
85
+ Net::HTTP.new(
86
+ uri.host,
87
+ uri.port,
88
+ proxy_uri.host,
89
+ proxy_uri.port,
90
+ proxy_uri.user,
91
+ proxy_uri.password
92
+ )
93
+ else
94
+ Net::HTTP.new(uri.host, uri.port)
95
+ end
96
+ client.use_ssl = true
97
+
98
+ http_config.each do |name, value|
99
+ # Discrepancies between RestClient and Net::HTTP.
100
+ if name == :verify_ssl
101
+ name = :verify_mode
102
+ elsif name == :timeout
103
+ name = :read_timeout
104
+ end
91
105
 
92
- params = Util.objects_to_ids(params)
93
- url = self.api_url(url)
94
- case method.to_s.downcase.to_sym
95
- when :get, :head, :delete
96
- # Make params into GET parameters
97
- if params && params.count > 0
98
- query_string = Util.flatten_params(params).collect{|key, value| "#{key}=#{Util.url_encode(value)}"}.join('&')
99
- url += "#{URI.parse(url).query ? '&' : '?'}#{query_string}"
106
+ # Handled in the creation of the client.
107
+ if name == :proxy
108
+ next
100
109
  end
101
- payload = nil
102
- else
103
- payload = Util.flatten_params(params).collect{|(key, value)| "#{key}=#{Util.url_encode(value)}"}.join('&')
110
+
111
+ client.send("#{name}=", value)
104
112
  end
105
113
 
106
- headers = {
107
- :user_agent => "EasyPost/v2 RubyClient/#{VERSION}",
108
- :authorization => "Bearer #{api_key}",
109
- :content_type => 'application/x-www-form-urlencoded'
110
- }.merge(headers)
111
-
112
- opts = http_config.merge(
113
- {
114
- :method => method,
115
- :url => url,
116
- :headers => headers,
117
- :payload => payload
118
- }
119
- )
114
+ client
115
+ end
120
116
 
121
- begin
122
- response = execute_request(opts)
123
- rescue RestClient::ExceptionWithResponse => e
124
- if response_code = e.http_code and response_body = e.http_body
125
- begin
126
- response_json = MultiJson.load(response_body, :symbolize_keys => true)
127
- rescue MultiJson::DecodeError
128
- raise Error.new("Invalid response from API, unable to decode.", response_code, response_body)
129
- end
130
- begin
131
- raise NoMethodError if response_json[:error][:message] == nil
132
- raise Error.new(response_json[:error][:message], response_code, response_body, response_json)
133
- rescue NoMethodError, TypeError
134
- raise Error.new(response_json[:error], response_code, response_body, response_json)
135
- end
136
- else
137
- raise Error.new(e.message)
138
- end
139
- rescue RestClient::Exception, Errno::ECONNREFUSED => e
140
- raise Error.new(e.message)
117
+ def self.make_request(method, path, api_key=nil, body=nil)
118
+ client = make_client(URI(@api_base))
119
+
120
+ request = Net::HTTP.const_get(method.capitalize).new(path)
121
+ if body
122
+ request.body = JSON.dump(EasyPost::Util.objects_to_ids(body))
141
123
  end
142
124
 
143
- begin
144
- response_json = MultiJson.load(response.body, :symbolize_keys => true)
145
- rescue MultiJson::DecodeError
146
- raise Error.new("Invalid response object from API, unable to decode.", response.code, response.body)
125
+ request["Content-Type"] = "application/json"
126
+ request["User-Agent"] = "EasyPost/v2 RubyClient/#{VERSION} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
127
+ if api_key = api_key || @api_key
128
+ request["Authorization"] = "Basic #{Base64.strict_encode64("#{api_key}:")}"
147
129
  end
148
130
 
149
- return [response_json, api_key]
150
- end
131
+ response = client.request(request)
151
132
 
152
- private
133
+ if (400..599).include? response.code.to_i
134
+ error = JSON.parse(response.body)["error"]
135
+ raise EasyPost::Error.new(error["message"], response.code.to_i, error["code"], error["errors"], response.body)
136
+ end
153
137
 
154
- def self.execute_request(opts)
155
- RestClient::Request.execute(opts)
138
+ if response["Content-Type"].include? "application/json"
139
+ JSON.parse(response.body)
140
+ else
141
+ response.body
142
+ end
143
+ rescue JSON::ParserError
144
+ raise RuntimeError.new(
145
+ "Invalid response object from API, unable to decode.\n#{response.body}"
146
+ )
156
147
  end
157
148
  end
@@ -1,58 +1,58 @@
1
- module EasyPost
2
- class Address < Resource
3
- attr_accessor :message # Backwards compatibility
4
-
5
- def self.create(params={}, api_key=nil)
6
- url = self.url
7
-
8
- if params[:verify] || params[:verify_strict]
9
- verify = params.delete(:verify) || []
10
- verify_strict = params.delete(:verify_strict) || []
11
-
12
- url += "?"
13
- verify.each do |verification|
14
- url += "verify[]=#{verification}&"
15
- end
16
- verify_strict.each do |verification|
17
- url += "verify_strict[]=#{verification}&"
18
- end
19
- end
1
+ class EasyPost::Address < EasyPost::Resource
2
+ attr_accessor :message # Backwards compatibility
20
3
 
21
- response, api_key = EasyPost.request(:post, url, api_key, {address: params})
22
- return Util.convert_to_easypost_object(response, api_key)
23
- end
4
+ def self.create(params={}, api_key=nil)
5
+ url = self.url
6
+
7
+ address = params.reject { |k,_| k == :verify || k == :verify_strict }
8
+
9
+ if params[:verify] || params[:verify_strict]
10
+ verify = params[:verify] || []
11
+ verify_strict = params[:verify_strict] || []
24
12
 
25
- def self.create_and_verify(params={}, carrier=nil, api_key=nil)
26
- wrapped_params = {}
27
- wrapped_params[self.class_name().to_sym] = params
28
- wrapped_params[:carrier] = carrier
29
- response, api_key = EasyPost.request(:post, url + '/create_and_verify', api_key, wrapped_params)
30
-
31
- if response.has_key?(:address)
32
- if response.has_key?(:message)
33
- response[:address][:message] = response[:message]
34
- end
35
- verified_address = EasyPost::Util::convert_to_easypost_object(response[:address], api_key)
36
- return verified_address
37
- else
38
- raise Error.new("Unable to verify address.")
13
+ url += "?"
14
+ verify.each do |verification|
15
+ url += "verify[]=#{verification}&"
16
+ end
17
+ verify_strict.each do |verification|
18
+ url += "verify_strict[]=#{verification}&"
39
19
  end
40
20
  end
41
21
 
42
- def verify(params={}, carrier=nil)
43
- begin
44
- response, api_key = EasyPost.request(:get, url + '/verify?carrier=' + String(carrier), @api_key, params)
45
- rescue
46
- raise Error.new("Unable to verify address.")
47
- end
22
+ response = EasyPost.make_request(:post, url, api_key, {address: address})
23
+ return EasyPost::Util.convert_to_easypost_object(response, api_key)
24
+ end
48
25
 
49
- if response.has_key?(:address)
50
- return EasyPost::Util::convert_to_easypost_object(response[:address], api_key)
51
- else
52
- raise Error.new("Unable to verify address.")
26
+ def self.create_and_verify(params={}, carrier=nil, api_key=nil)
27
+ wrapped_params = {}
28
+ wrapped_params[self.class_name().to_sym] = params
29
+ wrapped_params[:carrier] = carrier
30
+ response = EasyPost.make_request(:post, url + '/create_and_verify', api_key, wrapped_params)
31
+
32
+ if response.has_key?("address")
33
+ if response.has_key?("message")
34
+ response["address"]["message"] = response["message"]
53
35
  end
36
+ verified_address = EasyPost::Util::convert_to_easypost_object(response["address"], api_key)
37
+ return verified_address
38
+ else
39
+ raise EasyPost::Error.new("Unable to verify address.")
40
+ end
41
+ end
54
42
 
55
- return self
43
+ def verify(params={}, carrier=nil)
44
+ begin
45
+ response = EasyPost.make_request(:get, url + '/verify?carrier=' + String(carrier), @api_key, params)
46
+ rescue
47
+ raise EasyPost::Error.new("Unable to verify address.")
56
48
  end
49
+
50
+ if response.has_key?("address")
51
+ return EasyPost::Util::convert_to_easypost_object(response["address"], api_key)
52
+ else
53
+ raise EasyPost::Error.new("Unable to verify address.")
54
+ end
55
+
56
+ return self
57
57
  end
58
58
  end