easypost 3.0.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +22 -0
- data/CHANGELOG +44 -3
- data/README.md +2 -1
- data/VERSION +1 -1
- data/easypost.gemspec +24 -20
- data/lib/easypost.rb +109 -118
- data/lib/easypost/address.rb +47 -47
- data/lib/easypost/batch.rb +34 -38
- data/lib/easypost/carrier_account.rb +3 -6
- data/lib/easypost/carrier_type.rb +2 -0
- data/lib/easypost/customs_info.rb +3 -2
- data/lib/easypost/customs_item.rb +3 -2
- data/lib/easypost/error.rb +25 -33
- data/lib/easypost/event.rb +3 -6
- data/lib/easypost/insurance.rb +1 -3
- data/lib/easypost/item.rb +4 -8
- data/lib/easypost/object.rb +111 -113
- data/lib/easypost/order.rb +20 -18
- data/lib/easypost/parcel.rb +1 -3
- data/lib/easypost/pickup.rb +19 -18
- data/lib/easypost/pickup_rate.rb +1 -3
- data/lib/easypost/postage_label.rb +1 -3
- data/lib/easypost/print_job.rb +1 -5
- data/lib/easypost/printer.rb +18 -22
- data/lib/easypost/rate.rb +1 -3
- data/lib/easypost/refund.rb +1 -3
- data/lib/easypost/report.rb +22 -24
- data/lib/easypost/resource.rb +58 -60
- data/lib/easypost/scan_form.rb +4 -6
- data/lib/easypost/shipment.rb +90 -92
- data/lib/easypost/tracker.rb +10 -12
- data/lib/easypost/user.rb +33 -37
- data/lib/easypost/util.rb +99 -136
- data/lib/easypost/webhook.rb +22 -21
- metadata +35 -62
- data/circle.yml +0 -3
- data/spec/address_spec.rb +0 -81
- data/spec/batch_spec.rb +0 -48
- data/spec/carrier_account_spec.rb +0 -121
- data/spec/insurance_spec.rb +0 -69
- data/spec/item_spec.rb +0 -105
- data/spec/order_spec.rb +0 -58
- data/spec/pickup_spec.rb +0 -83
- data/spec/report_spec.rb +0 -59
- data/spec/scan_form_spec.rb +0 -46
- data/spec/shipment_spec.rb +0 -144
- data/spec/spec_helper.rb +0 -10
- data/spec/support/constant.rb +0 -106
- data/spec/tracker_spec.rb +0 -94
- data/spec/user_spec.rb +0 -88
- data/spec/webhook_spec.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db8276b780ceb6bde1e8b72185385da6458cb152babd4bccf3b1f75e5da4af93
|
4
|
+
data.tar.gz: 103f3173ab91f5521204aee15694a31a7bb61875a955967049342ca250f04813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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-
|
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
|
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
|
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
|
-
[
|
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
|
+
3.3.0
|
data/easypost.gemspec
CHANGED
@@ -1,27 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require "easypost/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
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
|
17
|
-
|
18
|
-
|
19
|
-
spec.
|
20
|
-
spec.
|
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.
|
23
|
-
spec.
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
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
|
2
|
-
require
|
3
|
-
require
|
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
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
|
36
|
-
|
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
|
-
|
40
|
-
|
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
|
-
|
42
|
+
@api_key = api_key
|
51
43
|
end
|
52
44
|
|
53
45
|
def self.api_key
|
54
|
-
|
46
|
+
@api_key
|
55
47
|
end
|
56
48
|
|
57
49
|
def self.api_base=(api_base)
|
58
|
-
|
50
|
+
@api_base = api_base
|
59
51
|
end
|
60
52
|
|
61
53
|
def self.api_base
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.api_version=(version)
|
66
|
-
@@api_version = version
|
54
|
+
@api_base
|
67
55
|
end
|
68
56
|
|
69
|
-
def self.
|
70
|
-
|
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
|
-
|
79
|
+
http_config.merge!(http_config_params)
|
84
80
|
end
|
85
81
|
|
86
|
-
def self.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
102
|
-
|
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
|
-
|
107
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
150
|
-
end
|
131
|
+
response = client.request(request)
|
151
132
|
|
152
|
-
|
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
|
-
|
155
|
-
|
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
|
data/lib/easypost/address.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
|
2
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
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
|