Class: PaypalServerSdk::ItemRequest
- Defined in:
- lib/paypal_server_sdk/models/item_request.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
This field supports up to 4000 characters, but any content beyond 2048 characters (including spaces) will be truncated.
-
#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) ⇒ ItemRequest
constructor
A new instance of ItemRequest.
-
#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) ⇒ ItemRequest
Returns a new instance of ItemRequest.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 99 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.
61 62 63 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 61 def billing_plan @billing_plan end |
#category ⇒ ItemCategory
The item category type.
47 48 49 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 47 def category @category end |
#description ⇒ String
This field supports up to 4000 characters, but any content beyond 2048 characters (including spaces) will be truncated. The 2048 character limit is reflected in the response representation of this field.
34 35 36 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 34 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.
52 53 54 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 52 def image_url @image_url end |
#name ⇒ String
The item name or title.
14 15 16 |
# File 'lib/paypal_server_sdk/models/item_request.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_request.rb', line 28 def quantity @quantity end |
#sku ⇒ String
The stock keeping unit (SKU) for the item.
38 39 40 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 38 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_request.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_request.rb', line 19 def unit_amount @unit_amount end |
#upc ⇒ UniversalProductCode
The Universal Product Code of the item.
56 57 58 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 56 def upc @upc end |
#url ⇒ String
The URL to the item being purchased. Visible to buyer and used in buyer experiences.
43 44 45 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 43 def url @url end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 143 144 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 116 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. ItemRequest.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.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 64 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
95 96 97 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 95 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 81 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.
155 156 157 158 159 160 161 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 155 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.
147 148 149 150 151 152 |
# File 'lib/paypal_server_sdk/models/item_request.rb', line 147 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 |