endicia_ruby 0.2.3 → 0.2.4

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
- SHA1:
3
- metadata.gz: 5fb91179ab61ca85d2be358f857dc75087705833
4
- data.tar.gz: 553918dd580eb1b3f718bbe57d507a4bd3058bb1
2
+ SHA256:
3
+ metadata.gz: 2cdc079607f4c753f5db554c3053a7a6a236562ec2dd90629a69c1dc298a9747
4
+ data.tar.gz: 85c06e55fe903f27b7e9aa7af859a8473cf452f98f4f50627f402785e28d0875
5
5
  SHA512:
6
- metadata.gz: 2e269c9314fdfecdbdffe9a7e320ca09e9dec3d3cf5145441c244884740591474fa791e195665184a6e378cd3fc1d3f72789bd1eb06dabc7c3500f945f7b1277
7
- data.tar.gz: 825622ba69c2c9184ec65aad7d4fbec2b93305068076883386fbbb6cf0585bb870e2df96e8e34384bccbddbba2f2bf0fc890f5fb5e4ac3cc657cb9b63f590afa
6
+ metadata.gz: 379a20445062689aec87ba460a7674cd5c6fbd0d6ce7b1ae2ff2dbb362c713a24fee21d44f5f4c19ba1b709c311d4489e433189ed79b3954031a19458bd05004
7
+ data.tar.gz: 868de66b68e2d7733af244a91f7b6c334491d0dcc71834681f801cfe27489c0a40f638c9283ecbfe66d4a69542f4496e133b633af936c91949e6313a24aa8baa
@@ -32,7 +32,8 @@ module Endicia
32
32
  elsif k == 'Label'
33
33
  # when customs form is included in xml, Endicia returns the image in a different format
34
34
  k = "image"
35
- v = v["Image"]["__content__"]
35
+ # There can be one or many <Image> elements in <Label>. MultiXml parses multiples into an array.
36
+ v = [v["Image"]].flatten.first["__content__"]
36
37
  end
37
38
  setter = :"#{k.tableize.singularize}="
38
39
  send(setter, v) if !k['xmlns'] && respond_to?(setter)
@@ -1,3 +1,3 @@
1
1
  module Endicia
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -29,6 +29,7 @@ describe Endicia::LabelResponse do
29
29
  )
30
30
  }
31
31
  let(:expected_image_value) { Faker::Lorem.sentence }
32
+ let(:different_image_value) { "a throwaway addendum" }
32
33
  let(:image_key) { "Base64LabelImage" }
33
34
  let(:image_value) { expected_image_value }
34
35
 
@@ -68,19 +69,43 @@ describe Endicia::LabelResponse do
68
69
  end
69
70
 
70
71
  context "for customs form case" do
71
- let(:image_key) { "Label" }
72
- let(:image_value) {
73
- {
74
- "Image" => {
75
- "__content__" => expected_image_value
72
+ context "when there is only one Image part" do
73
+ let(:image_key) { "Label" }
74
+ let(:image_value) {
75
+ {
76
+ "Image" => {
77
+ "__content__" => expected_image_value
78
+ }
76
79
  }
77
80
  }
78
- }
79
- it "translates Base64LabelImage to 'image'" do
80
- expect(response.image).to eq(expected_image_value)
81
+
82
+ it "translates Base64LabelImage to 'image'" do
83
+ expect(response.image).to eq(expected_image_value)
84
+ end
85
+ end
86
+
87
+ context "when there are multiple Image parts" do
88
+ let(:image_key) { "Label" }
89
+ let(:image_value) {
90
+ {
91
+ "Image" => [
92
+ {
93
+ "__content__" => expected_image_value
94
+ },
95
+ {
96
+ "__content__" => different_image_value
97
+ },
98
+ ],
99
+ }
100
+ }
101
+
102
+ it "translates the first Image part to 'image'" do
103
+ expect(response.image).to eq(expected_image_value)
104
+ end
81
105
  end
82
106
  end
83
107
  end
108
+
84
109
  describe "#label_generated?" do
85
110
  let(:status) { nil }
86
111
  subject(:label_response) { described_class.new(OpenStruct.new(body: "<foo></foo>", LabelRequestResponse: {"Status" => status})) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: endicia_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Dean
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-30 00:00:00.000000000 Z
12
+ date: 2018-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.4.5
205
+ rubygems_version: 2.7.4
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Wrapper around Endicia's APIs