fedex-web-services 1.1.51 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +113 -0
- data/Rakefile +3 -0
- data/examples/create_shipments.rb +81 -0
- data/fedex-web-services.gemspec +26 -0
- data/lib/fedex_web_services.rb +13 -0
- data/lib/fedex_web_services/api.rb +66 -0
- data/lib/fedex_web_services/close_smart_post_request.rb +23 -0
- data/lib/fedex_web_services/delete_shipment_request.rb +31 -0
- data/lib/fedex_web_services/process_shipment_request.rb +96 -0
- data/lib/fedex_web_services/process_shipment_response.rb +28 -0
- data/lib/fedex_web_services/railtie.rb +7 -0
- data/lib/fedex_web_services/request.rb +57 -0
- data/lib/fedex_web_services/response.rb +16 -0
- data/lib/fedex_web_services/soap.rb +6 -0
- data/lib/fedex_web_services/soap/CloseServiceDefinitions.rb +910 -0
- data/lib/fedex_web_services/soap/CloseServiceDefinitionsDriver.rb +93 -0
- data/lib/fedex_web_services/soap/CloseServiceDefinitionsMappingRegistry.rb +1201 -0
- data/lib/fedex_web_services/soap/RateServiceDefinitions.rb +4318 -0
- data/lib/fedex_web_services/soap/RateServiceDefinitionsDriver.rb +53 -0
- data/lib/fedex_web_services/soap/RateServiceDefinitionsMappingRegistry.rb +4655 -0
- data/lib/fedex_web_services/soap/ShipServiceDefinitions.rb +4911 -0
- data/lib/fedex_web_services/soap/ShipServiceDefinitionsDriver.rb +101 -0
- data/lib/fedex_web_services/soap/ShipServiceDefinitionsMappingRegistry.rb +5405 -0
- data/lib/fedex_web_services/version.rb +3 -0
- data/license.txt +7 -0
- data/tasks/generate_definitions.rake +23 -0
- data/tasks/test.rake +5 -0
- data/test/integration_test.rb +109 -0
- metadata +76 -34
- data/lib/fedex.rb +0 -2
- data/lib/fedex/version.rb +0 -3
- data/lib/fedex/web_services.rb +0 -10
- data/lib/fedex/web_services/definitions.rb +0 -46
- data/lib/fedex/web_services/request/base.rb +0 -69
- data/lib/fedex/web_services/request/delete_shipment.rb +0 -27
- data/lib/fedex/web_services/request/get_rates.rb +0 -61
- data/lib/fedex/web_services/request/process_shipment.rb +0 -76
- data/lib/fedex/web_services/service/base.rb +0 -72
- data/lib/fedex/web_services/service/rate.rb +0 -40
- data/lib/fedex/web_services/service/ship.rb +0 -85
- data/lib/generators/fedex/generate_definitions_generator.rb +0 -38
data/license.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Brian Abreu
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
task :generate_definitions do
|
2
|
+
require 'wsdl/soap/wsdl2ruby'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module_path = File.join(%w(lib fedex_web_services soap))
|
7
|
+
|
8
|
+
Dir.glob(File.expand_path("../../wsdl/*.wsdl", __FILE__)).each do |wsdl_file|
|
9
|
+
service = File.basename(wsdl_file).gsub(/^(.+?)Service.*wsdl/, "\\1")
|
10
|
+
|
11
|
+
worker = WSDL::SOAP::WSDL2Ruby.new
|
12
|
+
worker.basedir = FileUtils.mkdir_p(File.join(module_path)).first
|
13
|
+
worker.location = File.new(wsdl_file).path
|
14
|
+
worker.logger.level = Logger::WARN
|
15
|
+
worker.opt.update(
|
16
|
+
"module_path" => "FedexWebServices::Soap::#{service}",
|
17
|
+
"mapping_registry" => nil,
|
18
|
+
"driver" => nil,
|
19
|
+
"classdef" => nil
|
20
|
+
)
|
21
|
+
worker.run
|
22
|
+
end
|
23
|
+
end
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'fedex_web_services'
|
4
|
+
|
5
|
+
class IntegrationTest < MiniTest::Unit::TestCase
|
6
|
+
include FedexWebServices
|
7
|
+
|
8
|
+
@@logger = Logger.new($stderr)
|
9
|
+
|
10
|
+
def setup
|
11
|
+
credentials = %w(FEDEX_ACCOUNT FEDEX_METER FEDEX_AUTH_KEY FEDEX_SECURITY_CODE).map do |env_var|
|
12
|
+
ENV.fetch(env_var) { flunk("Missing environment variable #{env_var}") }
|
13
|
+
end
|
14
|
+
|
15
|
+
@credentials = Api::Credentials.new(*credentials, :test)
|
16
|
+
@api = Api.new(@credentials)
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
def run_request(api, method, request)
|
21
|
+
api.send(method, request)
|
22
|
+
rescue
|
23
|
+
err = $!
|
24
|
+
@@logger.error([ "FedEx Exception: #{err.message}", *err.backtrace ] * "\n ")
|
25
|
+
|
26
|
+
until ((err = err.cause).nil?)
|
27
|
+
@@logger.error([ "caused by: #{err.class.name} #{err}", *err.backtrace ] * "\n ")
|
28
|
+
end
|
29
|
+
|
30
|
+
if (api.wiredump)
|
31
|
+
@@logger.debug("FedEx SOAP debug output")
|
32
|
+
@@logger.debug(api.wiredump)
|
33
|
+
end
|
34
|
+
|
35
|
+
raise
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class ShipTest < IntegrationTest
|
40
|
+
include FedexWebServices::Soap
|
41
|
+
|
42
|
+
def test_process_shipment
|
43
|
+
service = Ship::ServiceType::FEDEX_2_DAY
|
44
|
+
|
45
|
+
from = Ship::Party.new.tap do |shipper|
|
46
|
+
shipper.contact = Ship::Contact.new.tap do |contact|
|
47
|
+
contact.personName = "Joe Shmoe"
|
48
|
+
contact.phoneNumber = "(123) 456 789"
|
49
|
+
end
|
50
|
+
|
51
|
+
shipper.address = Ship::Address.new.tap do |address|
|
52
|
+
address.streetLines = [ "123 4th St" ]
|
53
|
+
address.city = "San Luis Obispo"
|
54
|
+
address.stateOrProvinceCode = "CA"
|
55
|
+
address.postalCode = "93401"
|
56
|
+
address.countryCode = "US"
|
57
|
+
address.residential = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
to = Ship::Party.new.tap do |recipient|
|
62
|
+
recipient.contact = Ship::Contact.new.tap do |contact|
|
63
|
+
contact.personName = "Ahwahnee Hotel"
|
64
|
+
contact.phoneNumber = "(801) 559-5000"
|
65
|
+
end
|
66
|
+
recipient.address = Ship::Address.new.tap do |address|
|
67
|
+
address.streetLines = [ "9006 Yosemite Lodge Drive" ]
|
68
|
+
address.city = "Yosemite National Park"
|
69
|
+
address.stateOrProvinceCode = "CA"
|
70
|
+
address.postalCode = "95389"
|
71
|
+
address.countryCode = "US"
|
72
|
+
address.residential = true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
label_spec = Ship::LabelSpecification.new
|
77
|
+
label_spec.labelFormatType = Ship::LabelFormatType::COMMON2D
|
78
|
+
label_spec.imageType = Ship::ShippingDocumentImageType::PDF
|
79
|
+
label_spec.labelStockType = Ship::ShippingDocumentStockType::PAPER_LETTER
|
80
|
+
|
81
|
+
weights = [ 10, 55.34, 10.2 ].map do |weight|
|
82
|
+
Ship::Weight.new.tap do |w|
|
83
|
+
w.units = "LB"
|
84
|
+
w.value = weight
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
requests = ProcessShipmentRequest.shipment_requests(service, from, to, label_spec, weights)
|
89
|
+
requests.each do |request|
|
90
|
+
request.sender_paid!(@credentials.account_number)
|
91
|
+
request.list_rate!
|
92
|
+
request.regular_pickup!
|
93
|
+
request.customer_reference!("01234")
|
94
|
+
request.customer_invoice!("56789")
|
95
|
+
end
|
96
|
+
|
97
|
+
run_request(@api, :process_shipments, requests).each do |response|
|
98
|
+
delete_request = DeleteShipmentRequest.new
|
99
|
+
delete_request.delete_all_packages!(response.tracking_number, Ship::TrackingIdType::EXPRESS)
|
100
|
+
run_request(@api, :delete_shipment, delete_request)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class CloseTest < IntegrationTest
|
106
|
+
def test_smart_post_close
|
107
|
+
run_request(@api, :close_smart_post, CloseSmartPostRequest.new)
|
108
|
+
end
|
109
|
+
end
|
metadata
CHANGED
@@ -1,75 +1,117 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedex-web-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Abreu
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: soap4r-
|
14
|
+
name: soap4r-ng
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '2.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
28
53
|
- !ruby/object:Gem::Version
|
29
54
|
version: '0'
|
30
|
-
description: Interfaces with the FedEx web services API
|
31
|
-
generate labels, and cancel shipments
|
55
|
+
description: Interfaces with the FedEx SOAP web services API
|
32
56
|
email:
|
33
|
-
- brian@
|
57
|
+
- brian@nuts.com
|
34
58
|
executables: []
|
35
59
|
extensions: []
|
36
60
|
extra_rdoc_files: []
|
37
61
|
files:
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- lib/
|
47
|
-
- lib/
|
48
|
-
- lib/
|
49
|
-
- lib/
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- examples/create_shipments.rb
|
67
|
+
- fedex-web-services.gemspec
|
68
|
+
- lib/fedex_web_services.rb
|
69
|
+
- lib/fedex_web_services/api.rb
|
70
|
+
- lib/fedex_web_services/close_smart_post_request.rb
|
71
|
+
- lib/fedex_web_services/delete_shipment_request.rb
|
72
|
+
- lib/fedex_web_services/process_shipment_request.rb
|
73
|
+
- lib/fedex_web_services/process_shipment_response.rb
|
74
|
+
- lib/fedex_web_services/railtie.rb
|
75
|
+
- lib/fedex_web_services/request.rb
|
76
|
+
- lib/fedex_web_services/response.rb
|
77
|
+
- lib/fedex_web_services/soap.rb
|
78
|
+
- lib/fedex_web_services/soap/CloseServiceDefinitions.rb
|
79
|
+
- lib/fedex_web_services/soap/CloseServiceDefinitionsDriver.rb
|
80
|
+
- lib/fedex_web_services/soap/CloseServiceDefinitionsMappingRegistry.rb
|
81
|
+
- lib/fedex_web_services/soap/RateServiceDefinitions.rb
|
82
|
+
- lib/fedex_web_services/soap/RateServiceDefinitionsDriver.rb
|
83
|
+
- lib/fedex_web_services/soap/RateServiceDefinitionsMappingRegistry.rb
|
84
|
+
- lib/fedex_web_services/soap/ShipServiceDefinitions.rb
|
85
|
+
- lib/fedex_web_services/soap/ShipServiceDefinitionsDriver.rb
|
86
|
+
- lib/fedex_web_services/soap/ShipServiceDefinitionsMappingRegistry.rb
|
87
|
+
- lib/fedex_web_services/version.rb
|
88
|
+
- license.txt
|
89
|
+
- tasks/generate_definitions.rake
|
90
|
+
- tasks/test.rake
|
91
|
+
- test/integration_test.rb
|
50
92
|
homepage: https://github.com/brewski/fedex-web-services
|
51
93
|
licenses:
|
52
94
|
- MIT
|
95
|
+
metadata: {}
|
53
96
|
post_install_message:
|
54
97
|
rdoc_options: []
|
55
98
|
require_paths:
|
56
99
|
- lib
|
57
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
101
|
requirements:
|
60
|
-
- -
|
102
|
+
- - ">="
|
61
103
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
104
|
+
version: 2.0.0
|
63
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
106
|
requirements:
|
66
|
-
- -
|
107
|
+
- - ">="
|
67
108
|
- !ruby/object:Gem::Version
|
68
109
|
version: '0'
|
69
110
|
requirements: []
|
70
|
-
rubyforge_project:
|
71
|
-
rubygems_version:
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.3
|
72
113
|
signing_key:
|
73
|
-
specification_version:
|
74
|
-
summary:
|
75
|
-
test_files:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Provides an interface to the FedEx web services API
|
116
|
+
test_files:
|
117
|
+
- test/integration_test.rb
|
data/lib/fedex.rb
DELETED
data/lib/fedex/version.rb
DELETED
data/lib/fedex/web_services.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'fedex/web_services/definitions'
|
2
|
-
|
3
|
-
require 'fedex/web_services/request/base'
|
4
|
-
require 'fedex/web_services/request/process_shipment'
|
5
|
-
require 'fedex/web_services/request/delete_shipment'
|
6
|
-
require 'fedex/web_services/request/get_rates'
|
7
|
-
|
8
|
-
require 'fedex/web_services/service/base'
|
9
|
-
require 'fedex/web_services/service/ship'
|
10
|
-
require 'fedex/web_services/service/rate'
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Fedex
|
2
|
-
module WebServices
|
3
|
-
module Definitions
|
4
|
-
extend(self)
|
5
|
-
|
6
|
-
MODULE_PATH = File.join(%w(fedex web_services definitions))
|
7
|
-
|
8
|
-
def load_definitions(lib_dir)
|
9
|
-
$VERBOSE = $VERBOSE.tap do
|
10
|
-
$VERBOSE = nil
|
11
|
-
|
12
|
-
$:.unshift(lib_dir)
|
13
|
-
$:.unshift(File.join(lib_dir, MODULE_PATH))
|
14
|
-
Dir.glob(File.join(lib_dir, MODULE_PATH, "*DefinitionsDriver.rb")).each do |definition_file|
|
15
|
-
begin
|
16
|
-
require File.join(MODULE_PATH, File.basename(definition_file))
|
17
|
-
rescue Exception
|
18
|
-
raise "Error loading Fedex definition file #{definition_file}: #{$!.message}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
$:.shift
|
22
|
-
$:.shift
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def generate_definitions(lib_dir, *wsdl_files)
|
27
|
-
require 'wsdl/soap/wsdl2ruby'
|
28
|
-
require 'fileutils'
|
29
|
-
|
30
|
-
wsdl_files.each do |wsdl_file|
|
31
|
-
worker = WSDL::SOAP::WSDL2Ruby.new
|
32
|
-
worker.basedir = FileUtils.mkdir_p(File.join(Dir.new(lib_dir), MODULE_PATH)).first
|
33
|
-
worker.location = File.new(wsdl_file).path
|
34
|
-
worker.logger.level = Logger::WARN
|
35
|
-
worker.opt.update(
|
36
|
-
"module_path" => "Fedex::WebServices::Definitions",
|
37
|
-
"mapping_registry" => nil,
|
38
|
-
"driver" => nil,
|
39
|
-
"classdef" => nil
|
40
|
-
)
|
41
|
-
worker.run
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
module Fedex::WebServices
|
4
|
-
module Request
|
5
|
-
class Base
|
6
|
-
include Fedex::WebServices::Definitions
|
7
|
-
|
8
|
-
def initialize(service)
|
9
|
-
@service = service
|
10
|
-
end
|
11
|
-
|
12
|
-
def remote_method
|
13
|
-
raise "remote_method must be implemented by subclasses of Service"
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def web_authentication_detail
|
18
|
-
WebAuthenticationDetail.new.tap do |o|
|
19
|
-
o.userCredential = WebAuthenticationCredential.new.tap do |o|
|
20
|
-
o.key = @service.credentials.key
|
21
|
-
o.password = @service.credentials.password
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def client_detail
|
27
|
-
ClientDetail.new.tap do |o|
|
28
|
-
o.accountNumber = @service.credentials.account_number
|
29
|
-
o.meterNumber = @service.credentials.meter_number
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def version
|
34
|
-
VersionId.new.tap do |o|
|
35
|
-
o.serviceId = @service.service_id
|
36
|
-
o.major = 10
|
37
|
-
o.intermediate = 0
|
38
|
-
o.minor = 0
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
# return
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# ship_service = Fedex::WebServices::Service::Ship.new(creds)
|
48
|
-
# a = nil
|
49
|
-
# ship_service.delete_shipment('1234', 'GROUND') { |contents| a = contents }
|
50
|
-
#
|
51
|
-
# # req = FedExRequest.new(credentials).delete_shipment_request('794797411470', TrackingIdType::GROUND)
|
52
|
-
# req = FedExRequest.new(credentials).process_shipment
|
53
|
-
# ship_port = ShipPortType.new('https://wsbeta.fedex.com:443/web-services')
|
54
|
-
# ship_port.wiredump_dev = STDOUT
|
55
|
-
#
|
56
|
-
# begin
|
57
|
-
# # response = ship_port.deleteShipment(req)
|
58
|
-
# response = ship_port.processShipment(req)
|
59
|
-
# check_response(response)
|
60
|
-
# rescue Exception => root_exception
|
61
|
-
# begin
|
62
|
-
# err = RuntimeError.new(root_exception.detail.fault.details.validationFailureDetail.message * ",")
|
63
|
-
# err.set_backtrace([ "#{__FILE__}:#{__LINE__}", *root_exception.backtrace ])
|
64
|
-
# rescue
|
65
|
-
# raise root_exception.message
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# raise err
|
69
|
-
# end
|