temando 0.1.3 → 0.1.4

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.
@@ -5,19 +5,37 @@ module Temando::Api
5
5
  @anything = anything
6
6
  end
7
7
 
8
+ def weight_units
9
+ if @anything.weight < 9.5 then
10
+ 'Grams'
11
+ else
12
+ 'Kilograms'
13
+ end
14
+ end
15
+
16
+ def converted_weight
17
+ if weight_units == 'Grams' then
18
+ (@anything.weight * 1000).ceil
19
+ else
20
+ @anything.weight.ceil
21
+ end
22
+ end
23
+
8
24
  def build_xml(xml)
9
25
  xml.anything do
10
26
  xml.class_ @anything.shipping_class
11
27
  xml.packagingOptimisation(@anything.packaging_optimization.presence || "N")
12
28
  xml.subclass @anything.shipping_subclass
13
29
  xml.packaging @anything.shipping_packaging
30
+ xml.palletType @anything.pallet_type unless @anything.pallet_type.nil?
31
+ xml.palletNature @anything.pallet_nature unless @anything.pallet_nature.nil?
14
32
  xml.qualifierFreightGeneralFragile(@anything.fragile ? 'Y' : 'N')
15
33
  xml.distanceMeasurementType 'Centimetres'
16
- xml.weightMeasurementType 'Kilograms'
34
+ xml.weightMeasurementType weight_units
17
35
  xml.length((@anything.length.to_f * 100).ceil)
18
36
  xml.width((@anything.width.to_f * 100).ceil)
19
37
  xml.height((@anything.height.to_f * 100).ceil)
20
- xml.weight @anything.weight.ceil
38
+ xml.weight converted_weight
21
39
  xml.quantity @anything.quantity
22
40
  xml.description @anything.description
23
41
  end
@@ -2,6 +2,13 @@ module Temando
2
2
  module Item
3
3
  # A GeneralGood is a type of item that can be shipped by Temando.
4
4
  class GeneralGoods < Temando::Item::Base
5
+ attr_accessor :shipping_packaging, :pallet_type, :pallet_nature
6
+
7
+ def initialize(attributes={})
8
+ @shipping_packaging = 'Parcel'
9
+ super
10
+ end
11
+
5
12
  def shipping_class
6
13
  'General Goods'
7
14
  end
@@ -10,13 +17,9 @@ module Temando
10
17
  'Household Goods'
11
18
  end
12
19
 
13
- def shipping_packaging
14
- 'Parcel'
15
- end
16
-
17
20
  def fragile
18
21
  false
19
22
  end
20
23
  end
21
- end
24
+ end
22
25
  end
@@ -1,3 +1,3 @@
1
1
  module Temando
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -18,11 +18,11 @@
18
18
  <packaging>Parcel</packaging>
19
19
  <qualifierFreightGeneralFragile>N</qualifierFreightGeneralFragile>
20
20
  <distanceMeasurementType>Centimetres</distanceMeasurementType>
21
- <weightMeasurementType>Kilograms</weightMeasurementType>
21
+ <weightMeasurementType>Grams</weightMeasurementType>
22
22
  <length>10</length>
23
23
  <width>10</width>
24
24
  <height>10</height>
25
- <weight>1</weight>
25
+ <weight>1000</weight>
26
26
  <quantity>2</quantity>
27
27
  <description>Contains hats.</description>
28
28
  </anything>
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Temando::Api::Entities::Anything do
4
+ let(:item) { valid_temando_item(:description => 'Contains hats.', :quantity => 2) }
5
+
6
+ describe ".converted_weight" do
7
+ it "formats large weights as Kilograms" do
8
+ item.weight = 10.2
9
+ entity = Temando::Api::Entities::Anything.new(item)
10
+ entity.converted_weight.should == 11
11
+ entity.weight_units.should == 'Kilograms'
12
+ end
13
+
14
+ it "formats medium weights as Grams" do
15
+ item.weight = 9.2
16
+ entity = Temando::Api::Entities::Anything.new(item)
17
+ entity.converted_weight.should == 9200
18
+ entity.weight_units.should == 'Grams'
19
+ end
20
+
21
+ it "formats small weights as Grams" do
22
+ item.weight = 0.033
23
+ entity = Temando::Api::Entities::Anything.new(item)
24
+ entity.converted_weight.should == 33
25
+ entity.weight_units.should == 'Grams'
26
+ end
27
+ end
28
+ end
@@ -18,4 +18,38 @@ describe Temando::Item::GeneralGoods do
18
18
  valid_item.should_not be_valid
19
19
  end
20
20
  end
21
+
22
+ describe ".shipping_packaging" do
23
+ it 'defaults to "Parcel"' do
24
+ valid_item.shipping_packaging.should == 'Parcel'
25
+ end
26
+
27
+ it 'can be set and read' do
28
+ valid_item.shipping_packaging = 'Pallet'
29
+ valid_item.shipping_packaging.should == 'Pallet'
30
+ end
31
+ end
32
+
33
+ describe ".pallet_type" do
34
+ it 'defaults to nil' do
35
+ valid_item.pallet_type.should be_nil
36
+ end
37
+
38
+ it 'can be set and read' do
39
+ valid_item.pallet_type = 'Plain'
40
+ valid_item.pallet_type.should == 'Plain'
41
+ end
42
+ end
43
+
44
+ describe ".pallet_nature" do
45
+ it 'defaults to nil' do
46
+ valid_item.pallet_nature.should be_nil
47
+ end
48
+
49
+ it 'can be set and read' do
50
+ valid_item.pallet_nature = 'Not Required'
51
+ valid_item.pallet_nature.should == 'Not Required'
52
+ end
53
+ end
54
+
21
55
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_development_dependency 'rspec', '~> 2.11.0'
24
24
  gem.add_development_dependency 'faker'
25
+ gem.add_development_dependency 'rake'
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temando
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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: 2012-11-30 00:00:00.000000000 Z
12
+ date: 2012-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -107,6 +107,22 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
110
126
  description: Ruby API to Temando - an Australian transport fulfilment broker
111
127
  email:
112
128
  - jason@reinteractive.net
@@ -145,6 +161,7 @@ files:
145
161
  - spec/support/default_disable_remote.rb
146
162
  - spec/support/factories/item_factory.rb
147
163
  - spec/support/xml_fixtures.rb
164
+ - spec/units/api/entities/anything_spec.rb
148
165
  - spec/units/api/entities/quote_spec.rb
149
166
  - spec/units/api/get_quotes_by_request_spec.rb
150
167
  - spec/units/api/soap_client_spec.rb
@@ -186,6 +203,7 @@ test_files:
186
203
  - spec/support/default_disable_remote.rb
187
204
  - spec/support/factories/item_factory.rb
188
205
  - spec/support/xml_fixtures.rb
206
+ - spec/units/api/entities/anything_spec.rb
189
207
  - spec/units/api/entities/quote_spec.rb
190
208
  - spec/units/api/get_quotes_by_request_spec.rb
191
209
  - spec/units/api/soap_client_spec.rb