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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #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.



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

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)


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

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 Carriers.

Returns:



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

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)


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

def carrier_name_other
  @carrier_name_other
end

#itemsArray[OrderTrackerItem]

An array of details of items in the shipment.

Returns:



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

def items
  @items
end

#notify_payerTrueClass | FalseClass

If true, PayPal will send an email notification to the payer of the PayPal transaction. The email contains the tracking details provided through the Orders tracking API request. Independent of any value passed for ‘notify_payer`, the payer may receive tracking notifications within the PayPal app, based on the user’s notification preferences.

Returns:

  • (TrueClass | FalseClass)


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

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.



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
115
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 86

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.



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

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



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 126

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} tracking_number: #{@tracking_number.inspect}, carrier: #{@carrier.inspect},"\
  " carrier_name_other: #{@carrier_name_other.inspect}, capture_id: #{@capture_id.inspect},"\
  " notify_payer: #{@notify_payer.inspect}, items: #{@items.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
# File 'lib/paypal_server_sdk/models/order_tracker_request.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} tracking_number: #{@tracking_number}, carrier: #{@carrier},"\
  " carrier_name_other: #{@carrier_name_other}, capture_id: #{@capture_id}, notify_payer:"\
  " #{@notify_payer}, items: #{@items}>"
end