fedex 2.2.0 → 2.2.1

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.
data/Readme.md CHANGED
@@ -147,24 +147,30 @@ label = fedex.label(:filename => "my_dir/example_epl2.pcx",
147
147
  :shipping_details => shipping_details,
148
148
  :label_specification => example_spec)
149
149
  ```
150
+ ### ** Storing a label on Amazon S3 with Paperclip **
150
151
 
151
- ### ** Tracking a shipment **
152
-
153
- To track a shipment:
152
+ This is useful when you need to store the labels for later use, and are hosting your application on [Heroku](http://www.heroku.com/) as they do not allow writing to the filesystem, save the `tmp` directory. With [Paperclip](https://github.com/thoughtbot/paperclip/) setup up on a shipment model:
154
153
 
155
154
  ```ruby
156
- tracking_info = fedex.track(:tracking_number => "1234567890123")
157
-
158
- tracking_info.tracking_number
159
- # => "1234567890123"
155
+ label = fedex.label(:filename => "tmp/example_label.pdf",
156
+ :shipper=>shipper,
157
+ :recipient => recipient,
158
+ :packages => packages,
159
+ :service_type => "FEDEX_GROUND",
160
+ :shipping_details => shipping_details,
161
+ :label_specification => example_spec)
162
+ ```
160
163
 
161
- tracking_info.status
162
- # => "Delivered"
164
+ Then attach the label to your Paperclip model:
163
165
 
164
- tracking_info.events.first.description
165
- # => "On FedEx vehicle for delivery"
166
+ ```ruby
167
+ shipment.fedex_label = label.file_name
168
+ shipment.save!
166
169
  ```
167
170
 
171
+ Documentation for setting up Paperclip with Amazon S3 can be found in the Paperclip [README](https://github.com/thoughtbot/paperclip/#storage).
172
+
173
+
168
174
  ### ** Tracking a shipment **
169
175
 
170
176
  To track a shipment:
@@ -221,6 +227,9 @@ Fedex::Shipment::DROP_OFF_TYPES
221
227
  - [parndt](https://github.com/parndt) (Philip Arndt)
222
228
  - [mmell](https://github.com/mmell) (Michael Mell)
223
229
  - [jordanbyron](https://github.com/jordanbyron) (Jordan Byron)
230
+ - [GermanC4](https://github.com/GermanC4) (German Garcia)
231
+ - [janders223] (https://github.com/janders223) (Jim Anders)
232
+ - [jlambert121] (https://github.com/jlambert121) (Justin Lambert)
224
233
 
225
234
  # Copyright/License:
226
235
  Copyright 2011 [Jazmin Schroeder](http://jazminschroeder.com)
@@ -14,7 +14,7 @@ module Fedex
14
14
  @options[:format] = label_details[:format]
15
15
  @options[:tracking_number] = package_details[:tracking_ids][:tracking_number]
16
16
  @options[:file_name] = label_details[:file_name]
17
-
17
+
18
18
  @image = Base64.decode64(options[:parts][:image]) if has_image?
19
19
 
20
20
  if file_name = @options[:file_name]
@@ -30,6 +30,10 @@ module Fedex
30
30
  options[:format]
31
31
  end
32
32
 
33
+ def file_name
34
+ options[:file_name]
35
+ end
36
+
33
37
  def tracking_number
34
38
  options[:tracking_number]
35
39
  end
@@ -182,6 +182,51 @@ module Fedex
182
182
  end
183
183
  }
184
184
  end
185
+ if package[:special_services_requested] && package[:special_services_requested][:special_service_types]
186
+ xml.SpecialServicesRequested{
187
+ if package[:special_services_requested][:special_service_types].is_a? Array
188
+ package[:special_services_requested][:special_service_types].each do |type|
189
+ xml.SpecialServiceTypes type
190
+ end
191
+ else
192
+ xml.SpecialServiceTypes package[:special_services_requested][:special_service_types]
193
+ end
194
+ # Handle COD Options
195
+ if package[:special_services_requested][:cod_detail]
196
+ xml.CodDetail{
197
+ xml.CodCollectionAmount{
198
+ xml.Currency package[:special_services_requested][:cod_detail][:cod_collection_amount][:currency]
199
+ xml.Amount package[:special_services_requested][:cod_detail][:cod_collection_amount][:amount]
200
+ }
201
+ if package[:special_services_requested][:cod_detail][:add_transportation_charges]
202
+ xml.AddTransportationCharges package[:special_services_requested][:cod_detail][:add_transportation_charges]
203
+ end
204
+ xml.CollectionType package[:special_services_requested][:cod_detail][:collection_type]
205
+ xml.CodRecipient {
206
+ add_shipper(xml)
207
+ }
208
+ if package[:special_services_requested][:cod_detail][:reference_indicator]
209
+ xml.ReferenceIndicator package[:special_services_requested][:cod_detail][:reference_indicator]
210
+ end
211
+ }
212
+ end
213
+ # DangerousGoodsDetail goes here
214
+ if package[:special_services_requested][:dry_ice_weight]
215
+ xml.DryIceWeight{
216
+ xml.Units package[:special_services_requested][:dry_ice_weight][:units]
217
+ xml.Value package[:special_services_requested][:dry_ice_weight][:value]
218
+ }
219
+ end
220
+ if package[:special_services_requested][:signature_option_detail]
221
+ xml.SignatureOptionDetail{
222
+ xml.OptionType package[:special_services_requested][:signature_option_detail][:signature_option_type]
223
+ }
224
+ end
225
+ if package[:special_services_requested][:priority_alert_detail]
226
+ xml.PriorityAlertDetail package[:special_services_requested][:priority_alert_detail]
227
+ end
228
+ }
229
+ end
185
230
  }
186
231
  end
187
232
  end
@@ -59,7 +59,9 @@ module Fedex
59
59
  # Add the label specification
60
60
  def add_label_specification(xml)
61
61
  xml.LabelSpecification {
62
- hash_to_xml(xml, @label_specification)
62
+ xml.LabelFormatType @label_specification[:label_format_type]
63
+ xml.ImageType @label_specification[:image_type]
64
+ xml.LabelStockType @label_specification[:label_stock_type]
63
65
  }
64
66
  end
65
67
 
@@ -1,3 +1,3 @@
1
1
  module Fedex
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -21,48 +21,52 @@ module Fedex
21
21
  let(:shipping_options) do
22
22
  { :packaging_type => "YOUR_PACKAGING", :drop_off_type => "REGULAR_PICKUP" }
23
23
  end
24
-
24
+
25
25
  let(:label_specification) do
26
26
  { :label_format_type => 'COMMON2D',
27
27
  :image_type => 'PNG',
28
28
  }
29
- end
30
-
29
+ end
30
+
31
31
  let(:filename) {
32
32
  require 'tmpdir'
33
33
  File.join(Dir.tmpdir, "label#{rand(15000)}.pdf")
34
34
  }
35
-
35
+
36
36
  let(:options) do
37
- { :shipper => shipper,
37
+ { :shipper => shipper,
38
38
  :recipient => recipient,
39
- :packages => packages,
39
+ :packages => packages,
40
40
  :service_type => "FEDEX_GROUND",
41
41
  :label_specification => label_specification,
42
42
  :filename => filename
43
43
  }
44
44
  end
45
-
45
+
46
46
  describe "label", :vcr do
47
47
  before do
48
48
  @label = fedex.label(options)
49
49
  end
50
-
50
+
51
51
  it "should create a label" do
52
52
  File.should exist(filename)
53
53
  end
54
-
54
+
55
55
  it "should return tracking number" do
56
- @label.should respond_to('tracking_number')
56
+ @label.should respond_to('tracking_number')
57
57
  end
58
-
58
+
59
59
  it "should expose complete response" do
60
60
  @label.should respond_to('response_details')
61
- end
61
+ end
62
62
  after do
63
63
  require 'fileutils'
64
64
  FileUtils.rm_r(filename) if File.exist?(filename)
65
65
  end
66
+
67
+ it "should expose the file_name" do
68
+ @label.should respond_to('file_name')
69
+ end
66
70
  end
67
71
  end
68
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000Z
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70172992598000 !ruby/object:Gem::Requirement
16
+ requirement: &70200674635740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70172992598000
24
+ version_requirements: *70200674635740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70172992597500 !ruby/object:Gem::Requirement
27
+ requirement: &70200674635240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70172992597500
35
+ version_requirements: *70200674635240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70172992597040 !ruby/object:Gem::Requirement
38
+ requirement: &70200674634760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.9.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70172992597040
46
+ version_requirements: *70200674634760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: vcr
49
- requirement: &70172992596580 !ruby/object:Gem::Requirement
49
+ requirement: &70200674634280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70172992596580
57
+ version_requirements: *70200674634280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: fakeweb
60
- requirement: &70172992596200 !ruby/object:Gem::Requirement
60
+ requirement: &70200674633880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70172992596200
68
+ version_requirements: *70200674633880
69
69
  description: Provides an interface to Fedex Web Services(version 10) - shipping rates,
70
70
  generate labels and address validation
71
71
  email: