Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- No longer require the user to download and process the fedex wsdl files! - Better expose the SOAP classes at the library boundary. - Simplify building out the request contents. - By default, have request objects constructed with entirely blank request contents to allow the user to modify any part of the request. - Add helper methods to optionally fill in request contents for common use cases.
- Loading branch information
Showing
39 changed files
with
22,363 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
require "bundler/gem_tasks" | ||
|
||
Dir.glob(File.expand_path("../tasks/*.rake", __FILE__)).each(&method(:import)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
require 'fedex_web_services' | ||
|
||
include FedexWebServices | ||
include FedexWebServices::Soap | ||
|
||
credentials = Api::Credentials.new( | ||
ENV.fetch('FEDEX_ACCOUNT'), | ||
ENV.fetch('FEDEX_METER'), | ||
ENV.fetch('FEDEX_AUTH_KEY'), | ||
ENV.fetch('FEDEX_SECURITY_CODE'), | ||
:test # or :production | ||
) | ||
api = Api.new(credentials) | ||
|
||
service = Ship::ServiceType::FEDEX_2_DAY | ||
|
||
from = Ship::Party.new.tap do |shipper| | ||
shipper.contact = Ship::Contact.new.tap do |contact| | ||
contact.personName = "Joe Shmoe" | ||
contact.phoneNumber = "(123) 456 789" | ||
end | ||
|
||
shipper.address = Ship::Address.new.tap do |address| | ||
address.streetLines = [ "123 4th St" ] | ||
address.city = "San Luis Obispo" | ||
address.stateOrProvinceCode = "CA" | ||
address.postalCode = "93401" | ||
address.countryCode = "US" | ||
address.residential = true | ||
end | ||
end | ||
|
||
to = Ship::Party.new.tap do |recipient| | ||
recipient.contact = Ship::Contact.new.tap do |contact| | ||
contact.personName = "Ahwahnee Hotel" | ||
contact.phoneNumber = "(801) 559-5000" | ||
end | ||
recipient.address = Ship::Address.new.tap do |address| | ||
address.streetLines = [ "9006 Yosemite Lodge Drive" ] | ||
address.city = "Yosemite National Park" | ||
address.stateOrProvinceCode = "CA" | ||
address.postalCode = "95389" | ||
address.countryCode = "US" | ||
address.residential = true | ||
end | ||
end | ||
|
||
label_spec = Ship::LabelSpecification.new | ||
label_spec.labelFormatType = Ship::LabelFormatType::COMMON2D | ||
label_spec.imageType = Ship::ShippingDocumentImageType::PDF | ||
label_spec.labelStockType = Ship::ShippingDocumentStockType::PAPER_LETTER | ||
|
||
weights = [ 10, 55.34, 10.2 ].map do |weight| | ||
Ship::Weight.new.tap do |w| | ||
w.units = "LB" | ||
w.value = weight | ||
end | ||
end | ||
|
||
requests = ProcessShipmentRequest.shipment_requests(service, from, to, label_spec, weights) | ||
requests.each do |request| | ||
request.sender_paid!(credentials.account_number) | ||
request.list_rate! | ||
request.regular_pickup! | ||
end | ||
|
||
tracking_numbers = api.process_shipments(requests).map do |response| | ||
filename = "#{response.tracking_number}.pdf" | ||
File.write(filename, response.label) | ||
puts "Wrote #{filename}" | ||
response.tracking_number | ||
end | ||
|
||
tracking_numbers.each do |tracking_number| | ||
delete_request = DeleteShipmentRequest.new | ||
delete_request.delete_all_packages!(tracking_number, Ship::TrackingIdType::EXPRESS) | ||
api.delete_shipment(delete_request) | ||
puts "Deleted shipment #{tracking_number}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "fedex/version" | ||
require "rake" | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'fedex_web_services/version' | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "fedex-web-services" | ||
s.version = Fedex::VERSION | ||
s.authors = ["Brian Abreu"] | ||
s.email = ["brian@nut.com"] | ||
s.homepage = "https://github.com/brewski/fedex-web-services" | ||
s.summary = %q{Provies an interface to the FedEx web services API (version 10)} | ||
s.description = %q{Interfaces with the FedEx web services API to look up shipping rates, generate labels, and cancel shipments} | ||
s.license = 'MIT' | ||
Gem::Specification.new do |spec| | ||
spec.name = "fedex-web-services" | ||
spec.version = FedexWebServices::VERSION | ||
spec.authors = ["Brian Abreu"] | ||
spec.email = ["brian@nuts.com"] | ||
spec.description = %q{Interfaces with the FedEx web services API to look up shipping rates, generate labels, and cancel shipments} | ||
spec.summary = %q{Provides an interface to the FedEx web services API} | ||
spec.homepage = "https://github.com/brewski/fedex-web-services" | ||
spec.license = "MIT" | ||
|
||
s.rubyforge_project = "fedex-web-services" | ||
spec.files = `git ls-files`.split($/) | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
s.files = FileList[ "lib/**/*" ] | ||
s.test_files = [ ] | ||
s.executables = [ ] | ||
s.require_paths = ["lib"] | ||
spec.add_dependency "soap4r-ng", '~> 2.0' | ||
spec.required_ruby_version = '>= 2.0.0' | ||
|
||
s.add_dependency "soap4r-ng", '~> 2.0' | ||
s.required_ruby_version = '>= 1.9.0' | ||
# specify any dependencies here; for example: | ||
# s.add_development_dependency "rspec" | ||
# s.add_runtime_dependency "rest-client" | ||
spec.add_development_dependency "bundler", "~> 1.3" | ||
spec.add_development_dependency "rake" | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.