Class: PaypalServerSdk::ItemDetails

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

Overview

The item details.

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(item_code: SKIP, item_name: SKIP, item_description: SKIP, item_options: SKIP, item_quantity: SKIP, item_unit_price: SKIP, item_amount: SKIP, discount_amount: SKIP, adjustment_amount: SKIP, gift_wrap_amount: SKIP, tax_percentage: SKIP, tax_amounts: SKIP, basic_shipping_amount: SKIP, extra_shipping_amount: SKIP, handling_amount: SKIP, insurance_amount: SKIP, total_item_amount: SKIP, invoice_number: SKIP, checkout_options: SKIP) ⇒ ItemDetails

Returns a new instance of ItemDetails.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/paypal_server_sdk/models/item_details.rb', line 157

def initialize(item_code: SKIP, item_name: SKIP, item_description: SKIP,
               item_options: SKIP, item_quantity: SKIP,
               item_unit_price: SKIP, item_amount: SKIP,
               discount_amount: SKIP, adjustment_amount: SKIP,
               gift_wrap_amount: SKIP, tax_percentage: SKIP,
               tax_amounts: SKIP, basic_shipping_amount: SKIP,
               extra_shipping_amount: SKIP, handling_amount: SKIP,
               insurance_amount: SKIP, total_item_amount: SKIP,
               invoice_number: SKIP, checkout_options: SKIP)
  @item_code = item_code unless item_code == SKIP
  @item_name = item_name unless item_name == SKIP
  @item_description = item_description unless item_description == SKIP
  @item_options = item_options unless item_options == SKIP
  @item_quantity = item_quantity unless item_quantity == SKIP
  @item_unit_price = item_unit_price unless item_unit_price == SKIP
  @item_amount = item_amount unless item_amount == SKIP
  @discount_amount = discount_amount unless discount_amount == SKIP
  @adjustment_amount = adjustment_amount unless adjustment_amount == SKIP
  @gift_wrap_amount = gift_wrap_amount unless gift_wrap_amount == SKIP
  @tax_percentage = tax_percentage unless tax_percentage == SKIP
  @tax_amounts = tax_amounts unless tax_amounts == SKIP
  @basic_shipping_amount = basic_shipping_amount unless basic_shipping_amount == SKIP
  @extra_shipping_amount = extra_shipping_amount unless extra_shipping_amount == SKIP
  @handling_amount = handling_amount unless handling_amount == SKIP
  @insurance_amount = insurance_amount unless insurance_amount == SKIP
  @total_item_amount = total_item_amount unless total_item_amount == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @checkout_options = checkout_options unless checkout_options == SKIP
end

Instance Attribute Details

#adjustment_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



51
52
53
# File 'lib/paypal_server_sdk/models/item_details.rb', line 51

def adjustment_amount
  @adjustment_amount
end

#basic_shipping_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



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

def basic_shipping_amount
  @basic_shipping_amount
end

#checkout_optionsArray[CheckoutOption]

An array of checkout options. Each option has a name and value.

Returns:



100
101
102
# File 'lib/paypal_server_sdk/models/item_details.rb', line 100

def checkout_options
  @checkout_options
end

#discount_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



46
47
48
# File 'lib/paypal_server_sdk/models/item_details.rb', line 46

def discount_amount
  @discount_amount
end

#extra_shipping_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



76
77
78
# File 'lib/paypal_server_sdk/models/item_details.rb', line 76

def extra_shipping_amount
  @extra_shipping_amount
end

#gift_wrap_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



56
57
58
# File 'lib/paypal_server_sdk/models/item_details.rb', line 56

def gift_wrap_amount
  @gift_wrap_amount
end

#handling_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



81
82
83
# File 'lib/paypal_server_sdk/models/item_details.rb', line 81

def handling_amount
  @handling_amount
end

#insurance_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



86
87
88
# File 'lib/paypal_server_sdk/models/item_details.rb', line 86

def insurance_amount
  @insurance_amount
end

#invoice_numberString

The invoice number. An alphanumeric string that identifies a billing for a merchant.

Returns:

  • (String)


96
97
98
# File 'lib/paypal_server_sdk/models/item_details.rb', line 96

def invoice_number
  @invoice_number
end

#item_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



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

def item_amount
  @item_amount
end

#item_codeString

An item code that identifies a merchant’s goods or service.

Returns:

  • (String)


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

def item_code
  @item_code
end

#item_descriptionString

The item description.

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/models/item_details.rb', line 22

def item_description
  @item_description
end

#item_nameString

The item name.

Returns:

  • (String)


18
19
20
# File 'lib/paypal_server_sdk/models/item_details.rb', line 18

def item_name
  @item_name
end

#item_optionsString

The item options. Describes option choices on the purchase of the item in some detail.

Returns:

  • (String)


27
28
29
# File 'lib/paypal_server_sdk/models/item_details.rb', line 27

def item_options
  @item_options
end

#item_quantityString

The number of purchased units of goods or a service.

Returns:

  • (String)


31
32
33
# File 'lib/paypal_server_sdk/models/item_details.rb', line 31

def item_quantity
  @item_quantity
end

#item_unit_priceMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



36
37
38
# File 'lib/paypal_server_sdk/models/item_details.rb', line 36

def item_unit_price
  @item_unit_price
end

#tax_amountsArray[TaxAmount]

An array of tax amounts levied by a government on the purchase of goods or services.

Returns:



66
67
68
# File 'lib/paypal_server_sdk/models/item_details.rb', line 66

def tax_amounts
  @tax_amounts
end

#tax_percentageString

The percentage, as a fixed-point, signed decimal number. For example, define a 19.99% interest rate as ‘19.99`.

Returns:

  • (String)


61
62
63
# File 'lib/paypal_server_sdk/models/item_details.rb', line 61

def tax_percentage
  @tax_percentage
end

#total_item_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



91
92
93
# File 'lib/paypal_server_sdk/models/item_details.rb', line 91

def total_item_amount
  @total_item_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/paypal_server_sdk/models/item_details.rb', line 188

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  item_code = hash.key?('item_code') ? hash['item_code'] : SKIP
  item_name = hash.key?('item_name') ? hash['item_name'] : SKIP
  item_description =
    hash.key?('item_description') ? hash['item_description'] : SKIP
  item_options = hash.key?('item_options') ? hash['item_options'] : SKIP
  item_quantity = hash.key?('item_quantity') ? hash['item_quantity'] : SKIP
  item_unit_price = Money.from_hash(hash['item_unit_price']) if hash['item_unit_price']
  item_amount = Money.from_hash(hash['item_amount']) if hash['item_amount']
  discount_amount = Money.from_hash(hash['discount_amount']) if hash['discount_amount']
  adjustment_amount = Money.from_hash(hash['adjustment_amount']) if hash['adjustment_amount']
  gift_wrap_amount = Money.from_hash(hash['gift_wrap_amount']) if hash['gift_wrap_amount']
  tax_percentage =
    hash.key?('tax_percentage') ? hash['tax_percentage'] : SKIP
  # Parameter is an array, so we need to iterate through it

  tax_amounts = nil
  unless hash['tax_amounts'].nil?
    tax_amounts = []
    hash['tax_amounts'].each do |structure|
      tax_amounts << (TaxAmount.from_hash(structure) if structure)
    end
  end

  tax_amounts = SKIP unless hash.key?('tax_amounts')
  basic_shipping_amount = Money.from_hash(hash['basic_shipping_amount']) if
    hash['basic_shipping_amount']
  extra_shipping_amount = Money.from_hash(hash['extra_shipping_amount']) if
    hash['extra_shipping_amount']
  handling_amount = Money.from_hash(hash['handling_amount']) if hash['handling_amount']
  insurance_amount = Money.from_hash(hash['insurance_amount']) if hash['insurance_amount']
  total_item_amount = Money.from_hash(hash['total_item_amount']) if hash['total_item_amount']
  invoice_number =
    hash.key?('invoice_number') ? hash['invoice_number'] : SKIP
  # Parameter is an array, so we need to iterate through it

  checkout_options = nil
  unless hash['checkout_options'].nil?
    checkout_options = []
    hash['checkout_options'].each do |structure|
      checkout_options << (CheckoutOption.from_hash(structure) if structure)
    end
  end

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

  # Create object from extracted values.

  ItemDetails.new(item_code: item_code,
                  item_name: item_name,
                  item_description: item_description,
                  item_options: item_options,
                  item_quantity: item_quantity,
                  item_unit_price: item_unit_price,
                  item_amount: item_amount,
                  discount_amount: discount_amount,
                  adjustment_amount: adjustment_amount,
                  gift_wrap_amount: gift_wrap_amount,
                  tax_percentage: tax_percentage,
                  tax_amounts: tax_amounts,
                  basic_shipping_amount: basic_shipping_amount,
                  extra_shipping_amount: extra_shipping_amount,
                  handling_amount: handling_amount,
                  insurance_amount: insurance_amount,
                  total_item_amount: total_item_amount,
                  invoice_number: invoice_number,
                  checkout_options: checkout_options)
end

.namesObject

A mapping from model property names to API property names.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/paypal_server_sdk/models/item_details.rb', line 103

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_code'] = 'item_code'
  @_hash['item_name'] = 'item_name'
  @_hash['item_description'] = 'item_description'
  @_hash['item_options'] = 'item_options'
  @_hash['item_quantity'] = 'item_quantity'
  @_hash['item_unit_price'] = 'item_unit_price'
  @_hash['item_amount'] = 'item_amount'
  @_hash['discount_amount'] = 'discount_amount'
  @_hash['adjustment_amount'] = 'adjustment_amount'
  @_hash['gift_wrap_amount'] = 'gift_wrap_amount'
  @_hash['tax_percentage'] = 'tax_percentage'
  @_hash['tax_amounts'] = 'tax_amounts'
  @_hash['basic_shipping_amount'] = 'basic_shipping_amount'
  @_hash['extra_shipping_amount'] = 'extra_shipping_amount'
  @_hash['handling_amount'] = 'handling_amount'
  @_hash['insurance_amount'] = 'insurance_amount'
  @_hash['total_item_amount'] = 'total_item_amount'
  @_hash['invoice_number'] = 'invoice_number'
  @_hash['checkout_options'] = 'checkout_options'
  @_hash
end

.nullablesObject

An array for nullable fields



153
154
155
# File 'lib/paypal_server_sdk/models/item_details.rb', line 153

def self.nullables
  []
end

.optionalsObject

An array for optional fields



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/paypal_server_sdk/models/item_details.rb', line 128

def self.optionals
  %w[
    item_code
    item_name
    item_description
    item_options
    item_quantity
    item_unit_price
    item_amount
    discount_amount
    adjustment_amount
    gift_wrap_amount
    tax_percentage
    tax_amounts
    basic_shipping_amount
    extra_shipping_amount
    handling_amount
    insurance_amount
    total_item_amount
    invoice_number
    checkout_options
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/paypal_server_sdk/models/item_details.rb', line 272

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_code: #{@item_code.inspect}, item_name: #{@item_name.inspect},"\
  " item_description: #{@item_description.inspect}, item_options: #{@item_options.inspect},"\
  " item_quantity: #{@item_quantity.inspect}, item_unit_price: #{@item_unit_price.inspect},"\
  " item_amount: #{@item_amount.inspect}, discount_amount: #{@discount_amount.inspect},"\
  " adjustment_amount: #{@adjustment_amount.inspect}, gift_wrap_amount:"\
  " #{@gift_wrap_amount.inspect}, tax_percentage: #{@tax_percentage.inspect}, tax_amounts:"\
  " #{@tax_amounts.inspect}, basic_shipping_amount: #{@basic_shipping_amount.inspect},"\
  " extra_shipping_amount: #{@extra_shipping_amount.inspect}, handling_amount:"\
  " #{@handling_amount.inspect}, insurance_amount: #{@insurance_amount.inspect},"\
  " total_item_amount: #{@total_item_amount.inspect}, invoice_number:"\
  " #{@invoice_number.inspect}, checkout_options: #{@checkout_options.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/paypal_server_sdk/models/item_details.rb', line 258

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_code: #{@item_code}, item_name: #{@item_name}, item_description:"\
  " #{@item_description}, item_options: #{@item_options}, item_quantity: #{@item_quantity},"\
  " item_unit_price: #{@item_unit_price}, item_amount: #{@item_amount}, discount_amount:"\
  " #{@discount_amount}, adjustment_amount: #{@adjustment_amount}, gift_wrap_amount:"\
  " #{@gift_wrap_amount}, tax_percentage: #{@tax_percentage}, tax_amounts: #{@tax_amounts},"\
  " basic_shipping_amount: #{@basic_shipping_amount}, extra_shipping_amount:"\
  " #{@extra_shipping_amount}, handling_amount: #{@handling_amount}, insurance_amount:"\
  " #{@insurance_amount}, total_item_amount: #{@total_item_amount}, invoice_number:"\
  " #{@invoice_number}, checkout_options: #{@checkout_options}>"
end