Class: Fedex::WebServices::Request::GetRates

Inherits:
Base
  • Object
show all
Defined in:
lib/fedex/web_services/request/get_rates.rb

Constant Summary

Constants included from Definitions

Definitions::MODULE_PATH

Instance Method Summary collapse

Methods included from Definitions

#generate_definitions, #load_definitions

Constructor Details

#initialize(service, service_type, rate_request_type, from_address, to_address, weight) ⇒ GetRates

Returns a new instance of GetRates.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fedex/web_services/request/get_rates.rb', line 5

def initialize(service, service_type, rate_request_type, from_address, to_address, weight)

  super(service)

  @service_type = service_type
  @from_address = from_address
  @to_address = to_address
  @rate_request_type = rate_request_type
  @requested_package_line_items = [
    RequestedPackageLineItem.new.tap do |o|
      o.groupPackageCount = 1
      o.sequenceNumber = 1
      o.weight = weight
    end
  ]
end

Instance Method Details

#contentsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fedex/web_services/request/get_rates.rb', line 26

def contents
  RateRequest.new.tap do |o|
    o.webAuthenticationDetail = web_authentication_detail
    o.version                 = version
    o.clientDetail            = client_detail

    o.requestedShipment = RequestedShipment.new.tap do |o|
      o.shipTimestamp = Time.now.iso8601
      o.serviceType = @service_type
      o.packagingType = PackagingType::YOUR_PACKAGING

      o.shipper = Party.new.tap do |o|
        o.address = @from_address
      end

      o.recipient = Party.new.tap do |o|
        o.address = @to_address
      end

      o.shippingChargesPayment = Payment.new.tap do |o|
        o.paymentType = PaymentType::SENDER
        o.payor = Payor.new.tap do |o|
          o.accountNumber = @service.credentials.
        end
      end

      o.rateRequestTypes = [ @rate_request_type ]

      o.packageCount = @requested_package_line_items.size
      o.requestedPackageLineItems = @requested_package_line_items
    end
  end
end

#remote_methodObject



22
23
24
# File 'lib/fedex/web_services/request/get_rates.rb', line 22

def remote_method
  :getRates
end