Class: PaypalServerSdk::Item
- Defined in:
- lib/paypal_server_sdk/models/item.rb
Overview
The details for the items to be purchased.
Instance Attribute Summary collapse
-
#category ⇒ ItemCategory
The item category type.
-
#description ⇒ String
The detailed item description.
-
#image_url ⇒ String
The URL of the item’s image.
-
#name ⇒ String
The item name or title.
-
#quantity ⇒ String
The item quantity.
-
#sku ⇒ String
The stock keeping unit (SKU) for the item.
-
#tax ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
-
#unit_amount ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
-
#upc ⇒ UniversalProductCode
The Universal Product Code of the item.
-
#url ⇒ String
The URL to the item being purchased.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(name:, unit_amount:, quantity:, tax: SKIP, description: SKIP, sku: SKIP, url: SKIP, category: SKIP, image_url: SKIP, upc: SKIP) ⇒ Item
constructor
A new instance of Item.
Methods inherited from BaseModel
Constructor Details
#initialize(name:, unit_amount:, quantity:, tax: SKIP, description: SKIP, sku: SKIP, url: SKIP, category: SKIP, image_url: SKIP, upc: SKIP) ⇒ Item
Returns a new instance of Item.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/paypal_server_sdk/models/item.rb', line 90 def initialize(name:, unit_amount:, quantity:, tax: SKIP, description: SKIP, sku: SKIP, url: SKIP, category: SKIP, image_url: SKIP, upc: SKIP) @name = name @unit_amount = unit_amount @tax = tax unless tax == SKIP @quantity = quantity @description = description unless description == SKIP @sku = sku unless sku == SKIP @url = url unless url == SKIP @category = category unless category == SKIP @image_url = image_url unless image_url == SKIP @upc = upc unless upc == SKIP end |
Instance Attribute Details
#category ⇒ ItemCategory
The item category type.
45 46 47 |
# File 'lib/paypal_server_sdk/models/item.rb', line 45 def category @category end |
#description ⇒ String
The detailed item description.
32 33 34 |
# File 'lib/paypal_server_sdk/models/item.rb', line 32 def description @description end |
#image_url ⇒ String
The URL of the item’s image. File type and size restrictions apply. An image that violates these restrictions will not be honored.
50 51 52 |
# File 'lib/paypal_server_sdk/models/item.rb', line 50 def image_url @image_url end |
#name ⇒ String
The item name or title.
14 15 16 |
# File 'lib/paypal_server_sdk/models/item.rb', line 14 def name @name end |
#quantity ⇒ String
The item quantity. Must be a whole number.
28 29 30 |
# File 'lib/paypal_server_sdk/models/item.rb', line 28 def quantity @quantity end |
#sku ⇒ String
The stock keeping unit (SKU) for the item.
36 37 38 |
# File 'lib/paypal_server_sdk/models/item.rb', line 36 def sku @sku end |
#tax ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
24 25 26 |
# File 'lib/paypal_server_sdk/models/item.rb', line 24 def tax @tax end |
#unit_amount ⇒ Money
The currency and amount for a financial transaction, such as a balance or payment due.
19 20 21 |
# File 'lib/paypal_server_sdk/models/item.rb', line 19 def unit_amount @unit_amount end |
#upc ⇒ UniversalProductCode
The Universal Product Code of the item.
54 55 56 |
# File 'lib/paypal_server_sdk/models/item.rb', line 54 def upc @upc end |
#url ⇒ String
The URL to the item being purchased. Visible to buyer and used in buyer experiences.
41 42 43 |
# File 'lib/paypal_server_sdk/models/item.rb', line 41 def url @url end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/paypal_server_sdk/models/item.rb', line 106 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil unit_amount = Money.from_hash(hash['unit_amount']) if hash['unit_amount'] quantity = hash.key?('quantity') ? hash['quantity'] : nil tax = Money.from_hash(hash['tax']) if hash['tax'] description = hash.key?('description') ? hash['description'] : SKIP sku = hash.key?('sku') ? hash['sku'] : SKIP url = hash.key?('url') ? hash['url'] : SKIP category = hash.key?('category') ? hash['category'] : SKIP image_url = hash.key?('image_url') ? hash['image_url'] : SKIP upc = UniversalProductCode.from_hash(hash['upc']) if hash['upc'] # Create object from extracted values. Item.new(name: name, unit_amount: unit_amount, quantity: quantity, tax: tax, description: description, sku: sku, url: url, category: category, image_url: image_url, upc: upc) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/paypal_server_sdk/models/item.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['unit_amount'] = 'unit_amount' @_hash['tax'] = 'tax' @_hash['quantity'] = 'quantity' @_hash['description'] = 'description' @_hash['sku'] = 'sku' @_hash['url'] = 'url' @_hash['category'] = 'category' @_hash['image_url'] = 'image_url' @_hash['upc'] = 'upc' @_hash end |
.nullables ⇒ Object
An array for nullable fields
86 87 88 |
# File 'lib/paypal_server_sdk/models/item.rb', line 86 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/paypal_server_sdk/models/item.rb', line 73 def self.optionals %w[ tax description sku url category image_url upc ] end |