easypost 2.1.1 → 2.1.2

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
  SHA1:
3
- metadata.gz: 1d1cc5a734e2706f3cbeba923df0240405b0e0df
4
- data.tar.gz: fe44d1b81b62583f286e045e385cbdeab0818581
3
+ metadata.gz: ffecde59165d8726bc3c8df04460ace5510db641
4
+ data.tar.gz: 305d583c4003b61f47ac2d9a98fc1d562c40a988
5
5
  SHA512:
6
- metadata.gz: 4afc2b2702cf588aed58d28413cd6b31ea74ce1ca08a8e1527f1ebc71f7299ca596af96bdc2020542c625fd1809d99d144becff5d26c80a1688d73374ea8c9fc
7
- data.tar.gz: d5f90684e2740529028f2e32431c882f939db7ea788849d6e0054865078a2dfb4d9dcdeb74010ad99a1576ca068a64bf797bb0fa5d4387c029c8095634d39156
6
+ metadata.gz: 647172542d948f1a4d731b05033cb82ad42f71fae98448f88f353d6cb37cb5a45bd26119f0a31bbe396d6cd5c991f76bc84503a040c83c0111f3ceba1928be13
7
+ data.tar.gz: 6ac4b06bd97be38e839bd9a346e51ab3adfc072658516a4959256cbb2954a35bcd25cb6ffe607d71bfd77faaf78f4c967092bd52d85f82ba9302bc377e9f13d8
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ === 2.1.2 2015-04-29
2
+
3
+ * EasyPost::Errors now correctly parse field errors and error codes.
4
+
5
+
1
6
  === 2.1.1 2015-04-15
2
7
 
3
8
  * CarrierAccount will now correctly save in-place modifications to credentials
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -5,6 +5,8 @@ module EasyPost
5
5
  attr_reader :http_body
6
6
  attr_reader :json_body
7
7
  attr_reader :param
8
+ attr_reader :code
9
+ attr_reader :errors
8
10
 
9
11
  def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
10
12
  @message = message
@@ -12,18 +14,26 @@ module EasyPost
12
14
  @http_body = http_body
13
15
  @json_body = json_body
14
16
 
15
- begin
16
- @param = @json_body[:error][:param]
17
- rescue
18
- @param = nil
19
- end
17
+ @param = @json_body.fetch(:error, {}).fetch(:param, nil)
18
+ @code = @json_body.fetch(:error, {}).fetch(:code, nil)
19
+ @errors = @json_body.fetch(:error, {}).fetch(:errors, nil)
20
20
 
21
21
  super(message)
22
22
  end
23
23
 
24
24
  def to_s
25
- status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
26
- "#{status_string}#{@message}"
25
+ s = "#{@code} (#{@http_status}): #{@message}";
26
+ if @errors
27
+ s += "\nField errors:\n"
28
+ @errors.each do |field_error|
29
+ field_error.each do |k, v|
30
+ s += " #{k}: #{v}\n"
31
+ end
32
+ s += "\n"
33
+ end
34
+ end
35
+ s
27
36
  end
28
37
  end
29
38
  end
39
+
@@ -1,3 +1,3 @@
1
1
  module EasyPost
2
- VERSION = File.open(File.expand_path("../../../VERSION", __FILE__)).read()
2
+ VERSION = File.open(File.expand_path("../../../VERSION", __FILE__)).read().strip
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Bateman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client