Class: Fedex::Shipment

Inherits:
Object
  • Object
show all
Defined in:
lib/fedex/shipment.rb

Direct Known Subclasses

Request::Document, Request::Label

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Shipment

In order to use Fedex rates API you must first apply for a developer(and later production keys), Visit / Fedex Developer Center for more information about how to obtain your keys. return a Fedex::Shipment object

Parameters:

  • key (String)
    • Fedex web service key

  • password (String)
    • Fedex password

  • account_number (String)
    • Fedex account_number

  • meter (String)
    • Fedex meter number

  • mode (String)
    • development/production


25
26
27
# File 'lib/fedex/shipment.rb', line 25

def initialize(options={})
  @credentials = Credentials.new(options)
end

Instance Method Details

#delete(options = {}) ⇒ Object

Parameters:

  • package_id, (Hash)

    A string with the tracking number to delete



87
88
89
# File 'lib/fedex/shipment.rb', line 87

def delete(options = {})
  Request::Delete.new(@credentials, options).process_request
end

#document(options = {}) ⇒ Object

Parameters:

  • shipper, (Hash)

    A hash containing the shipper information

  • recipient, (Hash)

    A hash containing the recipient information

  • packages, (Array)

    An array including a hash for each package being shipped

  • service_type, (String)

    A valid fedex service type, to view a complete list of services Fedex::Shipment::SERVICE_TYPES

  • customs_clearance, (Hash)

    A hash containing customs clearance specification

  • shipping_document, (Hash)

    A hash containing shipping document specification

  • filenames, (Array)

    A location where the label and shipment documents will be saved



82
83
84
# File 'lib/fedex/shipment.rb', line 82

def document(options = {})
  Request::Document.new(@credentials, options).process_request
end

#ground_close(options = {}) ⇒ Object

Parameters:

  • up_to_time, (Date)

    A time up to which shipments are to be closed

  • filename, (String)

    A location where the manifest (text file) will be saved



93
94
95
# File 'lib/fedex/shipment.rb', line 93

def ground_close(options = {})
  Request::GroundClose.new(@credentials, options).process_request
end

#label(options = {}) ⇒ Object

Parameters:

  • shipper, (Hash)

    A hash containing the shipper information

  • recipient, (Hash)

    A hash containing the recipient information

  • packages, (Array)

    An array including a hash for each package being shipped

  • service_type, (String)

    A valid fedex service type, to view a complete list of services Fedex::Shipment::SERVICE_TYPES

  • filename, (String)

    A location where the label will be saved

  • label_specification, (Hash)

    A hash containing the label printer settings



35
36
37
# File 'lib/fedex/shipment.rb', line 35

def label(options = {})
  Request::Label.new(@credentials, options).process_request
end

#pickup(options = {}) ⇒ Object

Parameters:

  • carrier_code, (String)

    A valid fedex carrier code, to view a complete list of carrier codes Fedex::Shipment::CARRIER_CODES

  • packages, (Hash)

    A hash containing the number of packages and their total weight

  • ready_timestamp, (DateTime)

    A timestamp that indicates what day and time the package will be available for pickup

  • close_time, (Time)

    The latest time that the business will be open to accept a pickup

  • pickup_location, (Hash)

    A hash containing the pickup location information



65
66
67
# File 'lib/fedex/shipment.rb', line 65

def pickup(options = {})
  Request::Pickup.new(@credentials, options).process_request
end

#pickup_availability(options = {}) ⇒ Object

Parameters:

  • country_code, (String)

    A string containing country code

  • state_code, (String)

    A string containing state code

  • postal_code, (String)

    A string containing postal code

  • carrier_code, (String)

    A string containing carrier code

  • request_type, (String)

    A string with request type

  • dispatch_date, (String)

    A string with dispatch date in YYYY-MM-DD format



102
103
104
# File 'lib/fedex/shipment.rb', line 102

def pickup_availability(options = {})
  Request::PickupAvailability.new(@credentials, options).process_request
end

#rate(options = {}) ⇒ Object

Parameters:

  • shipper, (Hash)

    A hash containing the shipper information

  • recipient, (Hash)

    A hash containing the recipient information

  • packages, (Array)

    An array including a hash for each package being shipped

  • service_type, (String)

    A valid fedex service type, to view a complete list of services Fedex::Shipment::SERVICE_TYPES



43
44
45
# File 'lib/fedex/shipment.rb', line 43

def rate(options = {})
  Request::Rate.new(@credentials, options).process_request
end

#service_availability(options = {}) ⇒ Object

param [Hash] origin, A hash containing origin information param [Hash] destination, A hash containing destination information param [date] ship_date, A string containing ship date in YYYY-MM-DD format param [String] carrier_code, A string containing carrier code



110
111
112
# File 'lib/fedex/shipment.rb', line 110

def service_availability(options = {})
  Request::ServiceAvailability.new(@credentials, options).process_request
end

#ship(options = {}) ⇒ Object

Parameters:

  • shipper, (Hash)

    A hash containing the shipper information

  • recipient, (Hash)

    A hash containing the recipient information

  • packages, (Array)

    An array including a hash for each package being shipped

  • service_type, (String)

    A valid fedex service type, to view a complete list of services Fedex::Shipment::SERVICE_TYPES



56
57
58
# File 'lib/fedex/shipment.rb', line 56

def ship(options = {})
  Request::Shipment.new(@credentials, options).process_request
end

#track(options = {}) ⇒ Object

Parameters:

  • package_id, (Hash)

    A string with the requested tracking number

  • package_type, (Hash)

    A string identifitying the type of tracking number used. Full list Fedex::Track::PACKAGE_IDENTIFIER_TYPES



71
72
73
# File 'lib/fedex/shipment.rb', line 71

def track(options = {})
  Request::TrackingInformation.new(@credentials, options).process_request
end

#validate_address(options = {}) ⇒ Object

Parameters:

  • address, (Hash)

    A hash containing the address information



48
49
50
# File 'lib/fedex/shipment.rb', line 48

def validate_address(options = {})
  Request::Address.new(@credentials, options).process_request
end