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 +5 -5
- data/lib/endicia_ruby/label_response.rb +2 -1
- data/lib/endicia_ruby/version.rb +1 -1
- data/spec/label_response_spec.rb +33 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2cdc079607f4c753f5db554c3053a7a6a236562ec2dd90629a69c1dc298a9747
|
4
|
+
data.tar.gz: 85c06e55fe903f27b7e9aa7af859a8473cf452f98f4f50627f402785e28d0875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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)
|
data/lib/endicia_ruby/version.rb
CHANGED
data/spec/label_response_spec.rb
CHANGED
@@ -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
|
-
|
72
|
-
|
73
|
-
{
|
74
|
-
|
75
|
-
"
|
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
|
-
|
80
|
-
|
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.
|
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:
|
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
|
205
|
+
rubygems_version: 2.7.4
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Wrapper around Endicia's APIs
|