Skip to content

Commit

Permalink
Fixes per Fedex Tech Support (version, additional tags)
Browse files Browse the repository at this point in the history
  • Loading branch information
chip committed Jun 9, 2011
1 parent 2ff8ed0 commit f73935a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 55 deletions.
18 changes: 15 additions & 3 deletions lib/shippinglogic/fedex/request.rb
Expand Up @@ -41,8 +41,7 @@ def build_authentication(b)
end

b.TransactionDetail do
b.CustomerTransactionId 'Express International Basic Shipment'
# b.CustomerTransactionId 'Express US Basic Shipment'
b.CustomerTransactionId 'ProcessShipmentRequest_Condor_US_CA_ADG_IE'
end
end

Expand Down Expand Up @@ -91,8 +90,9 @@ def build_insured_value(b)
# A convenience method for building the package block in your XML request
def build_package(b)
b.PackageCount package_count
b.PackageDetail package_detail

b.RequestedPackages do
b.RequestedPackageLineItems do
b.SequenceNumber 1

b.Weight do
Expand All @@ -109,6 +109,18 @@ def build_package(b)
end
end

b.CustomerReferences do
b.CustomerReferenceType customer_reference_type
b.Value customer_reference_value
end

b.SpecialServicesRequested do
b.SpecialServiceTypes DANGEROUS_GOODS
b.DangerousGoodsDetail do
b.Accessibility ACCESSIBLE
end
end

if respond_to?(:signature) && signature
self.special_services_requested << "SIGNATURE_OPTION"
end
Expand Down
82 changes: 30 additions & 52 deletions lib/shippinglogic/fedex/ship.rb
Expand Up @@ -107,7 +107,7 @@ class Ship < Service
# The shipment result is an object of this class
class Shipment; attr_accessor :rate, :currency, :delivery_date, :tracking_number, :label, :barcode; end

VERSION = {:major => 6, :intermediate => 0, :minor => 0}
VERSION = {:major => 9, :intermediate => 0, :minor => 0}

# shipper options
attribute :shipper_name, :string
Expand Down Expand Up @@ -138,29 +138,38 @@ class Shipment; attr_accessor :rate, :currency, :delivery_date, :tracking_number
# label options
attribute :label_format, :string, :default => "COMMON2D"
attribute :label_file_type, :string, :default => "PDF"
attribute :label_stock_type, :string, :default => "PAPER_8.5X11_TOP_HALF_LABEL"
attribute :label_stock_type, :string, :default => "PAPER_7X4.75" #"PAPER_8.5X11_TOP_HALF_LABEL"

# packaging options
attribute :packaging_type, :string, :default => "YOUR_PACKAGING"
attribute :packaging_type, :string, :default => "YOUR_PACKAGING"
attribute :preferred_currency, :string, :default => "USD"
attribute :package_count, :integer, :default => 1
attribute :package_detail, :string, :default => "INDIVIDUAL_PACKAGES"
attribute :package_weight, :float
attribute :package_weight_units, :string, :default => "LB"
attribute :package_length, :integer
attribute :package_width, :integer
attribute :package_height, :integer
attribute :package_dimension_units, :string, :default => "IN"

# customer reference
attribute :customer_reference_type, :string, :default => 'CUSTOMER_REFERENCE'
attribute :customer_reference_value, :string, :default => 'TC001_01_PT1_ST01_PK01_SNDUS_RCPCA_POS'

# special services
attribute :special_service_types, :string, :default => 'DANGEROUS_GOODS'
attribute :accessibility, :string, :default => 'ACCESSIBLE'

# monetary options
attribute :currency_type, :string
attribute :insured_value, :decimal
attribute :payment_type, :string, :default => "SENDER"
attribute :payor_account_number, :string, :default => lambda { |shipment| shipment.base.account }
attribute :payor_country, :string
attribute :payor_country_code, :string, :default => 'US'

# delivery options
attribute :ship_time, :datetime, :default => lambda { |shipment| Time.now }
attribute :service_type, :string
attribute :service_type, :string, :default => "INTERNATIONAL_PRIORITY"
attribute :dropoff_type, :string, :default => "REGULAR_PICKUP"
attribute :special_services_requested, :array
attribute :signature, :string
Expand All @@ -169,6 +178,9 @@ class Shipment; attr_accessor :rate, :currency, :delivery_date, :tracking_number
attribute :just_validate, :boolean, :default => false
attribute :rate_request_types, :array, :default => ["ACCOUNT"]

# commercial invoice
attribute :terms_of_sale, :string, :default => "FOB_OR_FCA"

# customs options
attribute :payment_type, :string, :default => "SENDER"
attribute :document_content, :string, :default => "NON_DOCUMENTS"
Expand All @@ -191,8 +203,8 @@ def target
# Just building some XML to send off to FedEx using our various options
def build_request
@log = Logger.new('/tmp/fedex.log')
@log.info "build_request service_type = #{service_type}"

@log.info "inside build request"
b = builder
xml = b.tag!(just_validate ? "ValidateShipmentRequest" : "ProcessShipmentRequest", :xmlns => "http://fedex.com/ws/ship/v#{VERSION[:major]}") do
build_authentication(b)
Expand All @@ -202,8 +214,8 @@ def build_request
b.ShipTimestamp ship_time.xmlschema if ship_time
b.DropoffType dropoff_type if dropoff_type
b.ServiceType service_type if service_type
# b.ServiceType 'INTERNATIONAL_PRIORITY'
b.PackagingType packaging_type if packaging_type
b.PreferredCurrency preferred_currency if preferred_currency
build_insured_value(b)

b.Shipper do
Expand All @@ -220,47 +232,9 @@ def build_request
b.PaymentType payment_type if payment_type
b.Payor do
b.AccountNumber payor_account_number if payor_account_number
b.CountryCode payor_country if payor_country
b.CountryCode payor_country_code if payor_country_code
end
end

# Per Proprietary_Developer_Guide.pdf from FedEx
# <q0:CustomsClearanceDetail>
# <q0:DutiesPayment>
# <q0:PaymentType>SENDER</q0:PaymentType>
# <q0:Payor>
# <q0:AccountNumber>123456789</q0:AccountNumber>
# <q0:CountryCode>US</q0:CountryCode>
# </q0:Payor>
# </q0:DutiesPayment>
# <q0:DocumentContent>NON_DOCUMENTS</q0:DocumentContent>
# <q0:CustomsValue>
# <q0:Currency>USD</q0:Currency>
# <q0:Amount>100.00</q0:Amount>
# </q0:CustomsValue>
# <q0:Commodities>
# <q0:NumberOfPieces>1</q0:NumberOfPieces>
# <q0:Description>Technical Book</q0:Description>
# <q0:CountryOfManufacture>US</q0:CountryOfManufacture>
# <q0:Weight>
# <q0:Units>LB</q0:Units>
# <q0:Value>5</q0:Value>
# </q0:Weight>
# <q0:Quantity>1</q0:Quantity>
# <q0:QuantityUnits>EA</q0:QuantityUnits>
# <q0:UnitPrice>
# <q0:Currency>USD</q0:Currency>
# <q0:Amount>100.00</q0:Amount>
# </q0:UnitPrice>
# <q0:CustomsValue>
# <q0:Currency>USD</q0:Currency>
# <q0:Amount>100.00</q0:Amount>
# </q0:CustomsValue>
# </q0:Commodities>
# <q0:ExportDetail>
# <q0:ExportComplianceStatement>NO EEI 30.36</q0:ExportComplianceStatement>
# </q0:ExportDetail>
# </q0:CustomsClearanceDetail>

b.CustomsClearanceDetail do
b.DutiesPayment do
Expand All @@ -275,6 +249,9 @@ def build_request
b.Currency currency if currency
b.Amount item_amount if item_amount
end
b.CommercialInvoice do
b.TermsOfSale terms_of_sale if terms_of_sale
end
b.Commodities do
b.NumberOfPieces number_of_pieces if number_of_pieces
b.Description description if description
Expand All @@ -294,9 +271,9 @@ def build_request
b.Amount item_amount if item_amount
end
end
b.ExportDetail do
b.ExportComplianceStatement export_compliance_statement if export_compliance_statement
end
# b.ExportDetail do
# b.ExportComplianceStatement export_compliance_statement if export_compliance_statement
# end
end

b.LabelSpecification do
Expand All @@ -309,12 +286,13 @@ def build_request
build_package(b)
end
end
@log.info "shippinglogic xml\n" + xml
xml
end

# Making sense of the reponse and grabbing the information we need.
def parse_response(response)
@log = Logger.new('/tmp/fedex.log')
@log.info "parse_response = #{parse_response}"

details = response[:completed_shipment_detail]
rate_details = details[:shipment_rating][:shipment_rate_details]
rate = rate_details[:total_net_charge] || rate_details.first[:total_net_charge]
Expand Down

0 comments on commit f73935a

Please sign in to comment.