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
-
#billing_plan ⇒ OrderBillingPlan
Metadata for merchant-managed recurring billing plans.
-
#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, billing_plan: SKIP) ⇒ Item
constructor
A new instance of Item.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name:, unit_amount:, quantity:, tax: SKIP, description: SKIP, sku: SKIP, url: SKIP, category: SKIP, image_url: SKIP, upc: SKIP, billing_plan: SKIP) ⇒ Item
Returns a new instance of Item.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/paypal_server_sdk/models/item.rb', line 97 def initialize(name:, unit_amount:, quantity:, tax: SKIP, description: SKIP, sku: SKIP, url: SKIP, category: SKIP, image_url: SKIP, upc: SKIP, billing_plan: 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 @billing_plan = billing_plan unless billing_plan == SKIP end |
Instance Attribute Details
#billing_plan ⇒ OrderBillingPlan
Metadata for merchant-managed recurring billing plans. Valid only during the saved payment method token or billing agreement creation.
59 60 61 |
# File 'lib/paypal_server_sdk/models/item.rb', line 59 def billing_plan @billing_plan end |
#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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/paypal_server_sdk/models/item.rb', line 114 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'] billing_plan = OrderBillingPlan.from_hash(hash['billing_plan']) if hash['billing_plan'] # 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, billing_plan: billing_plan) end |
.names ⇒ Object
A mapping from model property names to API property names.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/paypal_server_sdk/models/item.rb', line 62 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['billing_plan'] = 'billing_plan' @_hash end |
.nullables ⇒ Object
An array for nullable fields
93 94 95 |
# File 'lib/paypal_server_sdk/models/item.rb', line 93 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/paypal_server_sdk/models/item.rb', line 79 def self.optionals %w[ tax description sku url category image_url upc billing_plan ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
153 154 155 156 157 158 159 |
# File 'lib/paypal_server_sdk/models/item.rb', line 153 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, unit_amount: #{@unit_amount.inspect}, tax:"\ " #{@tax.inspect}, quantity: #{@quantity.inspect}, description: #{@description.inspect},"\ " sku: #{@sku.inspect}, url: #{@url.inspect}, category: #{@category.inspect}, image_url:"\ " #{@image_url.inspect}, upc: #{@upc.inspect}, billing_plan: #{@billing_plan.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
145 146 147 148 149 150 |
# File 'lib/paypal_server_sdk/models/item.rb', line 145 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, unit_amount: #{@unit_amount}, tax: #{@tax}, quantity:"\ " #{@quantity}, description: #{@description}, sku: #{@sku}, url: #{@url}, category:"\ " #{@category}, image_url: #{@image_url}, upc: #{@upc}, billing_plan: #{@billing_plan}>" end |