stamps 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -83,22 +83,30 @@ module Stamps
83
83
 
84
84
  # Maps :rate to AddOns map
85
85
  def add_ons=(addons)
86
- self[:AddOns] = AddOnsArray.new(:add_on_v4 => addons[:add_on_v4])
86
+ self[:AddOns] = AddOnsArray.new(:add_on_v4 => addons[:add_on_v4],
87
+ :add_on_v5 => addons[:add_on_v5])
87
88
  end
88
89
  end
89
90
 
90
91
  class AddOnsArray < Hashie::Trash
91
92
  property :AddOnV4, :from => :add_on_v4
93
+ property :AddOnV5, :from => :add_on_v5
94
+
92
95
  def add_on_v4=(vals)
93
96
  return unless vals
94
- self[:AddOnV4] = vals.map{ |value| AddOnV4.new(value).to_hash }
97
+ self[:AddOnV4] = vals.map{ |value| AddOn.new(value).to_hash }
98
+ end
99
+
100
+ def add_on_v5=(vals)
101
+ return unless vals
102
+ self[:AddOnV5] = vals.map{ |value| AddOn.new(value).to_hash }
95
103
  end
96
104
  end
97
105
 
98
- class AddOnV4 < Hashie::Trash
106
+ class AddOn < Hashie::Trash
99
107
  property :Amount, :from => :amount
100
108
  property :AddOnType, :from => :add_on_type
101
- property :ProhibitedWithAnyOf, :from => :prohibited_with
109
+ property :ProhibitedWithAnyOf, :from => :prohibited_with_any_of
102
110
  property :MissingData, :from => :missing_data
103
111
  def prohibited_with_any_of; end
104
112
  def prohibited_with_any_of=(vals); end
@@ -117,8 +125,8 @@ module Stamps
117
125
  property :SampleOnly, :from => :sample
118
126
  property :ImageType, :from => :image_type
119
127
  property :EltronPrinterDPIType, :from => :label_resolution
120
- property :memo , :from => :memo
121
- property :recipient_email, :from => :recipient_email
128
+ property :memo
129
+ property :recipient_email
122
130
  property :deliveryNotification, :from => :notify
123
131
  property :shipmentNotificationCC, :from => :notify_crates
124
132
  property :shipmentNotificationFromCompany, :from => :notify_from_company
@@ -1,3 +1,3 @@
1
1
  module Stamps
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -6,7 +6,7 @@ class MappingTest < Test::Unit::TestCase
6
6
  context 'a new instance' do
7
7
 
8
8
  setup do
9
- @rate = Stamps::Mapping::Rate.new({
9
+ @params = {
10
10
  :from_zip_code => '45440',
11
11
  :to_zip_code => '45458',
12
12
  :weight_oz => '7.8',
@@ -18,7 +18,8 @@ class MappingTest < Test::Unit::TestCase
18
18
  { :amount => '0.19', :type => 'US-A-DC' }
19
19
  ]
20
20
  }
21
- })
21
+ }
22
+ @rate = Stamps::Mapping::Rate.new(@params)
22
23
  end
23
24
 
24
25
  should 'map :to property fields' do
@@ -29,5 +30,40 @@ class MappingTest < Test::Unit::TestCase
29
30
  assert_equal @rate.to_hash['ServiceType'], 'US-PM'
30
31
  end
31
32
 
33
+ context 'with add_ons' do
34
+ setup do
35
+ @add_ons = [
36
+ { add_on_type: "US-A-DC" },
37
+ { amount: '3.3', add_on_type: "US-A-SC" }
38
+ ]
39
+ @expected = [
40
+ { "AddOnType" => "US-A-DC" },
41
+ { "Amount" => "3.3", "AddOnType" => "US-A-SC" }
42
+ ]
43
+ end
44
+
45
+ context 'a rate with add_on_v4 add-ons' do
46
+ setup do
47
+ @params[:add_ons] = { add_on_v4: @add_ons}
48
+ @rate = Stamps::Mapping::Rate.new(@params)
49
+ end
50
+
51
+ should 'map add_ons to AddOnsV4' do
52
+ assert_equal @rate.to_hash['AddOns'], { "AddOnV4" => @expected }
53
+ end
54
+ end
55
+
56
+ context 'a rate with add_on_v5 add-ons' do
57
+ setup do
58
+ @params[:add_ons] = { add_on_v5: @add_ons}
59
+ @rate = Stamps::Mapping::Rate.new(@params)
60
+ end
61
+
62
+ should 'map add_ons to AddOnsV5' do
63
+ assert_equal @rate.to_hash['AddOns'], { "AddOnV5" => @expected }
64
+ end
65
+ end
66
+ end
32
67
  end
68
+
33
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stamps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-26 00:00:00.000000000 Z
12
+ date: 2014-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simplecov