Method: McFedex::Base#initialize

Defined in:
lib/mc-fedex.rb

#initialize(options = {}) ⇒ Base

Initializes the Fedex::Base class, setting defaults where necessary.

fedex = Fedex::Base.new(options = {})

Example:

fedex = Fedex::Base.new(:auth_key       => AUTH_KEY,
                        :security_code  => SECURITY_CODE
                        :account_number => ACCOUNT_NUMBER,
                        :meter_number   => METER_NUMBER)

Required options for new

:auth_key       - Your Fedex Authorization Key
:security_code  - Your Fedex Security Code
:account_number - Your Fedex Account Number
:meter_number   - Your Fedex Meter Number

Additional options

:dropoff_type       - One of Fedex::DropoffTypes.  Defaults to DropoffTypes::REGULAR_PICKUP
:packaging_type     - One of Fedex::PackagingTypes.  Defaults to PackagingTypes::YOUR_PACKAGING
:label_type         - One of Fedex::LabelFormatTypes.  Defaults to LabelFormatTypes::COMMON2D.  You'll only need to change this
                      if you're generating completely custom labels with a format of your own design.  If printing to Fedex stock
                      leave this alone.
:label_image_type   - One of Fedex::LabelSpecificationImageTypes.  Defaults to LabelSpecificationImageTypes::PDF.
:rate_request_type  - One of Fedex::RateRequestTypes.  Defaults to RateRequestTypes::ACCOUNT
:payment            - One of Fedex::PaymentTypes.  Defaults to PaymentTypes::SENDER
:units              - One of Fedex::WeightUnits.  Defaults to WeightUnits::LB
:currency           - One of Fedex::CurrencyTypes.  Defaults to CurrencyTypes::USD
:debug              - Enable or disable debug (wiredump) output.  Defaults to false.


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mc-fedex.rb', line 60

def initialize(options = {})
  check_required_options(:base, options)

  @auth_key           = options[:auth_key]
  @security_code      = options[:security_code]
  @account_number     = options[:account_number]
  @meter_number       = options[:meter_number]

  @wsdl_path          = options[:wsdl_path]
  @use_smart_post     = options[:use_smart_post]
  @smart_post_hub     = options[:smart_post_hub]

  @dropoff_type       = options[:dropoff_type]      || DropoffTypes::REGULAR_PICKUP
  @packaging_type     = options[:packaging_type]    || PackagingTypes::YOUR_PACKAGING
  @label_type         = options[:label_type]        || LabelFormatTypes::COMMON2D
  @label_image_type   = options[:label_image_type]  || LabelSpecificationImageTypes::PDF
  @rate_request_type  = options[:rate_request_type] || RateRequestTypes::LIST
  @payment_type       = options[:payment]           || PaymentTypes::SENDER
  @units              = options[:units]             || WeightUnits::LB
  @currency           = options[:currency]          || 'USD'
  @debug              = options[:debug]             || false
end