fedex-web-services 1.1.6 → 1.1.42
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fedex.rb +4 -0
- data/lib/fedex/railtie.rb +9 -0
- data/lib/fedex/tasks/fedex.rake +21 -0
- data/lib/fedex/version.rb +1 -1
- data/lib/fedex/web_services/request/base.rb +1 -1
- data/lib/fedex/web_services/request/get_rates.rb +1 -3
- data/lib/fedex/web_services/request/process_shipment.rb +1 -3
- data/lib/fedex/web_services/service/base.rb +1 -11
- data/lib/fedex/web_services/service/rate.rb +4 -8
- data/lib/fedex/web_services/service/ship.rb +1 -7
- metadata +8 -13
- data/lib/generators/fedex/generate_definitions_generator.rb +0 -38
data/lib/fedex.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :fedex do
|
2
|
+
desc "Generate the ruby definition files from the FedEx wsdl files"
|
3
|
+
task :generate_definitions do
|
4
|
+
wsdl_dir = ENV['WSDL_DIR']
|
5
|
+
if (!Dir.exist?(wsdl_dir || ""))
|
6
|
+
puts "Set the WSDL_DIR environment variable to location of the Fedex wsdl files"
|
7
|
+
else
|
8
|
+
Fedex::WebServices::Definitions.generate_definitions(
|
9
|
+
File.join(Rails.root, 'lib'),
|
10
|
+
*Dir.glob(File.join(ENV['WSDL_DIR'], '*.wsdl'))
|
11
|
+
)
|
12
|
+
|
13
|
+
File.open(File.join(Rails.root, 'config', 'initializers', 'fedex.rb'), "w") do |file|
|
14
|
+
file.puts "Fedex::WebServices::Definitions.load_definitions('lib')"
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "Added lib/fedex/web_services/definitions/"
|
18
|
+
puts "Added config/initializers/fedex.rb"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fedex/version.rb
CHANGED
@@ -45,9 +45,7 @@ module Fedex::WebServices
|
|
45
45
|
o.shippingChargesPayment = Payment.new.tap do |o|
|
46
46
|
o.paymentType = PaymentType::SENDER
|
47
47
|
o.payor = Payor.new.tap do |o|
|
48
|
-
o.
|
49
|
-
o.accountNumber = @service.credentials.account_number
|
50
|
-
end
|
48
|
+
o.accountNumber = @service.credentials.account_number
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
@@ -58,9 +58,7 @@ module Fedex::WebServices
|
|
58
58
|
o.shippingChargesPayment = Payment.new.tap do |o|
|
59
59
|
o.paymentType = PaymentType::SENDER
|
60
60
|
o.payor = Payor.new.tap do |o|
|
61
|
-
o.
|
62
|
-
o.accountNumber = @service.credentials.account_number
|
63
|
-
end
|
61
|
+
o.accountNumber = @service.credentials.account_number
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
@@ -10,7 +10,7 @@ module Fedex::WebServices
|
|
10
10
|
include Fedex::WebServices::Definitions
|
11
11
|
include Fedex::WebServices::Request
|
12
12
|
|
13
|
-
Credentials = Struct.new(
|
13
|
+
Credentials = Struct.new("Credentials",
|
14
14
|
:account_number, :meter_number, :key, :password, :environment
|
15
15
|
)
|
16
16
|
|
@@ -25,16 +25,6 @@ module Fedex::WebServices
|
|
25
25
|
raise "service_id must be implemented by subclasses of Service"
|
26
26
|
end
|
27
27
|
|
28
|
-
def service_version
|
29
|
-
raise "service_version must be implemented by subclasses of Service"
|
30
|
-
end
|
31
|
-
|
32
|
-
def service_url
|
33
|
-
(@credentials.environment.to_sym == :production) ?
|
34
|
-
'https://ws.fedex.com:443/web-services' :
|
35
|
-
'https://wsbeta.fedex.com:443/web-services'
|
36
|
-
end
|
37
|
-
|
38
28
|
protected
|
39
29
|
def port
|
40
30
|
raise "port must be implemented by subclasses of Service"
|
@@ -4,12 +4,12 @@ module Fedex::WebServices
|
|
4
4
|
module Service
|
5
5
|
class Rate < Base
|
6
6
|
|
7
|
-
def get_rates(service_type, rate_request_type,
|
7
|
+
def get_rates(service_type, rate_request_type, shipper, recipient, weight, &process_contents)
|
8
8
|
request = GetRates.new(self,
|
9
9
|
service_type,
|
10
10
|
rate_request_type,
|
11
|
-
|
12
|
-
|
11
|
+
shipper,
|
12
|
+
recipient,
|
13
13
|
weight
|
14
14
|
)
|
15
15
|
|
@@ -21,10 +21,6 @@ module Fedex::WebServices
|
|
21
21
|
:crs
|
22
22
|
end
|
23
23
|
|
24
|
-
def service_version
|
25
|
-
13
|
26
|
-
end
|
27
|
-
|
28
24
|
def self.rate_for(response, rate_request_type)
|
29
25
|
details = response.rateReplyDetails.first.ratedShipmentDetails.select do |detail|
|
30
26
|
detail.shipmentRateDetail.rateType == "PAYOR_#{rate_request_type}_PACKAGE"
|
@@ -37,7 +33,7 @@ module Fedex::WebServices
|
|
37
33
|
|
38
34
|
protected
|
39
35
|
def port
|
40
|
-
RatePortType.new(
|
36
|
+
RatePortType.new('https://wsbeta.fedex.com:443/web-services')
|
41
37
|
end
|
42
38
|
end
|
43
39
|
end
|
@@ -9,10 +9,6 @@ module Fedex::WebServices
|
|
9
9
|
:ship
|
10
10
|
end
|
11
11
|
|
12
|
-
def service_version
|
13
|
-
12
|
14
|
-
end
|
15
|
-
|
16
12
|
def process_shipment(service_type, shipper, recipient,
|
17
13
|
label_specification, package_weights, &process_contents)
|
18
14
|
|
@@ -76,13 +72,11 @@ module Fedex::WebServices
|
|
76
72
|
acc + BigDecimal.new(rate.netCharge.amount) :
|
77
73
|
acc
|
78
74
|
end
|
79
|
-
rescue
|
80
|
-
raise "Unable to extract rate information from response"
|
81
75
|
end
|
82
76
|
|
83
77
|
protected
|
84
78
|
def port
|
85
|
-
ShipPortType.new(
|
79
|
+
ShipPortType.new('https://wsbeta.fedex.com:443/web-services')
|
86
80
|
end
|
87
81
|
end
|
88
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedex-web-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.42
|
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-
|
12
|
+
date: 2012-04-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: soap4r-ruby19
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70234741411120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,12 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70234741411120
|
30
25
|
description: Interfaces with the FedEx web services API to look up shipping rates,
|
31
26
|
generate labels, and cancel shipments
|
32
27
|
email:
|
@@ -35,6 +30,8 @@ executables: []
|
|
35
30
|
extensions: []
|
36
31
|
extra_rdoc_files: []
|
37
32
|
files:
|
33
|
+
- lib/fedex/railtie.rb
|
34
|
+
- lib/fedex/tasks/fedex.rake
|
38
35
|
- lib/fedex/version.rb
|
39
36
|
- lib/fedex/web_services/definitions.rb
|
40
37
|
- lib/fedex/web_services/request/base.rb
|
@@ -46,10 +43,8 @@ files:
|
|
46
43
|
- lib/fedex/web_services/service/ship.rb
|
47
44
|
- lib/fedex/web_services.rb
|
48
45
|
- lib/fedex.rb
|
49
|
-
- lib/generators/fedex/generate_definitions_generator.rb
|
50
46
|
homepage: https://github.com/brewski/fedex-web-services
|
51
|
-
licenses:
|
52
|
-
- MIT
|
47
|
+
licenses: []
|
53
48
|
post_install_message:
|
54
49
|
rdoc_options: []
|
55
50
|
require_paths:
|
@@ -68,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
63
|
version: '0'
|
69
64
|
requirements: []
|
70
65
|
rubyforge_project: fedex-web-services
|
71
|
-
rubygems_version: 1.8.
|
66
|
+
rubygems_version: 1.8.10
|
72
67
|
signing_key:
|
73
68
|
specification_version: 3
|
74
69
|
summary: Provies an interface to the FedEx web services API (version 10)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Fedex
|
2
|
-
module Generators
|
3
|
-
class GenerateDefinitionsGenerator < ::Rails::Generators::Base
|
4
|
-
FEDEX_INITIALIZER_FILE = File.join(Rails.root, 'config', 'initializers', 'fedex.rb')
|
5
|
-
|
6
|
-
class_option :wsdl_dir,
|
7
|
-
default: File.join(%w(lib fedex web_services wsdl)),
|
8
|
-
type: :string,
|
9
|
-
desc: "directory where the fedex wsld files are stored"
|
10
|
-
|
11
|
-
|
12
|
-
class_option :skip_initializer,
|
13
|
-
default: false,
|
14
|
-
type: :boolean,
|
15
|
-
desc: "install a rails initializer to load the wsdl definitions"
|
16
|
-
|
17
|
-
desc "Generate the FedEx WebServices class definitions and create an initializer to load them"
|
18
|
-
|
19
|
-
def install
|
20
|
-
wsdl_dir = options[:wsdl_dir]
|
21
|
-
wsdl_files = Dir.glob(File.join(wsdl_dir, '*.wsdl'))
|
22
|
-
target_lib_dir = File.join(Rails.root, 'lib')
|
23
|
-
|
24
|
-
if (wsdl_files.empty?)
|
25
|
-
say("Could not find any wsdl files in #{wsdl_dir}", :red)
|
26
|
-
else
|
27
|
-
Fedex::WebServices::Definitions.generate_definitions(target_lib_dir, *wsdl_files)
|
28
|
-
say("Added #{File.join(target_lib_dir, Fedex::WebServices::Definitions::MODULE_PATH)}", :green)
|
29
|
-
|
30
|
-
unless (options[:skip_initializer])
|
31
|
-
create_file(FEDEX_INITIALIZER_FILE,
|
32
|
-
"Fedex::WebServices::Definitions.load_definitions('lib')")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|