Class: PaypalServerSdk::OrderTrackerRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/order_tracker_request.rb

Overview

The tracking details of an order.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(capture_id:, tracking_number: SKIP, carrier: SKIP, carrier_name_other: SKIP, notify_payer: false, items: SKIP) ⇒ OrderTrackerRequest

Returns a new instance of OrderTrackerRequest.



74
75
76
77
78
79
80
81
82
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 74

def initialize(capture_id:, tracking_number: SKIP, carrier: SKIP,
               carrier_name_other: SKIP, notify_payer: false, items: SKIP)
  @tracking_number = tracking_number unless tracking_number == SKIP
  @carrier = carrier unless carrier == SKIP
  @carrier_name_other = carrier_name_other unless carrier_name_other == SKIP
  @capture_id = capture_id
  @notify_payer = notify_payer unless notify_payer == SKIP
  @items = items unless items == SKIP
end

Instance Attribute Details

#capture_idString

The PayPal capture ID.

Returns:

  • (String)


34
35
36
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 34

def capture_id
  @capture_id
end

#carrierShipmentCarrier

The carrier for the shipment. Some carriers have a global version as well as local subsidiaries. The subsidiaries are repeated over many countries and might also have an entry in the global list. Choose the carrier for your country. If the carrier is not available for your country, choose the global version of the carrier. If your carrier name is not in the list, set ‘carrier` to `OTHER` and set carrier name in `carrier_name_other`. For allowed values, see <a href=“/docs/tracking/reference/carriers/”>Carriers</a>.

Returns:



25
26
27
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 25

def carrier
  @carrier
end

#carrier_name_otherString

The name of the carrier for the shipment. Provide this value only if the carrier parameter is OTHER. This property supports Unicode.

Returns:

  • (String)


30
31
32
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 30

def carrier_name_other
  @carrier_name_other
end

#itemsArray[OrderTrackerItem]

An array of details of items in the shipment.

Returns:



44
45
46
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 44

def items
  @items
end

#notify_payerTrueClass | FalseClass

If true, sends an email notification to the payer of the PayPal transaction. The email contains the tracking information that was uploaded through the API.

Returns:

  • (TrueClass | FalseClass)


40
41
42
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 40

def notify_payer
  @notify_payer
end

#tracking_numberString

The tracking number for the shipment. This property supports Unicode.

Returns:

  • (String)


14
15
16
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 14

def tracking_number
  @tracking_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  capture_id = hash.key?('capture_id') ? hash['capture_id'] : nil
  tracking_number =
    hash.key?('tracking_number') ? hash['tracking_number'] : SKIP
  carrier = hash.key?('carrier') ? hash['carrier'] : SKIP
  carrier_name_other =
    hash.key?('carrier_name_other') ? hash['carrier_name_other'] : SKIP
  notify_payer = hash['notify_payer'] ||= false
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (OrderTrackerItem.from_hash(structure) if structure)
    end
  end

  items = SKIP unless hash.key?('items')

  # Create object from extracted values.
  OrderTrackerRequest.new(capture_id: capture_id,
                          tracking_number: tracking_number,
                          carrier: carrier,
                          carrier_name_other: carrier_name_other,
                          notify_payer: notify_payer,
                          items: items)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tracking_number'] = 'tracking_number'
  @_hash['carrier'] = 'carrier'
  @_hash['carrier_name_other'] = 'carrier_name_other'
  @_hash['capture_id'] = 'capture_id'
  @_hash['notify_payer'] = 'notify_payer'
  @_hash['items'] = 'items'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 59

def self.optionals
  %w[
    tracking_number
    carrier
    carrier_name_other
    notify_payer
    items
  ]
end