Class: ProcessOut::InvoiceDetail
- Inherits:
-
Object
- Object
- ProcessOut::InvoiceDetail
- Defined in:
- lib/processout/invoice_detail.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#brand ⇒ Object
Returns the value of attribute brand.
-
#category ⇒ Object
Returns the value of attribute category.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#description ⇒ Object
Returns the value of attribute description.
-
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
-
#id ⇒ Object
Returns the value of attribute id.
-
#marketplace_merchant ⇒ Object
Returns the value of attribute marketplace_merchant.
-
#marketplace_merchant_created_at ⇒ Object
Returns the value of attribute marketplace_merchant_created_at.
-
#marketplace_merchant_is_business ⇒ Object
Returns the value of attribute marketplace_merchant_is_business.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ InvoiceDetail
constructor
- Initializes the InvoiceDetail object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the InvoiceDetail object Params:
-
#new(data = {}) ⇒ Object
Create a new InvoiceDetail using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ InvoiceDetail
Initializes the InvoiceDetail object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/processout/invoice_detail.rb', line 98 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.name = data.fetch(:name, nil) self.type = data.fetch(:type, nil) self.amount = data.fetch(:amount, nil) self.quantity = data.fetch(:quantity, nil) self. = data.fetch(:metadata, nil) self.reference = data.fetch(:reference, nil) self.description = data.fetch(:description, nil) self.brand = data.fetch(:brand, nil) self.model = data.fetch(:model, nil) self.discount_amount = data.fetch(:discount_amount, nil) self.condition = data.fetch(:condition, nil) self.marketplace_merchant = data.fetch(:marketplace_merchant, nil) self.marketplace_merchant_is_business = data.fetch(:marketplace_merchant_is_business, nil) self.marketplace_merchant_created_at = data.fetch(:marketplace_merchant_created_at, nil) self.category = data.fetch(:category, nil) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
14 15 16 |
# File 'lib/processout/invoice_detail.rb', line 14 def amount @amount end |
#brand ⇒ Object
Returns the value of attribute brand.
19 20 21 |
# File 'lib/processout/invoice_detail.rb', line 19 def brand @brand end |
#category ⇒ Object
Returns the value of attribute category.
26 27 28 |
# File 'lib/processout/invoice_detail.rb', line 26 def category @category end |
#condition ⇒ Object
Returns the value of attribute condition.
22 23 24 |
# File 'lib/processout/invoice_detail.rb', line 22 def condition @condition end |
#description ⇒ Object
Returns the value of attribute description.
18 19 20 |
# File 'lib/processout/invoice_detail.rb', line 18 def description @description end |
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
21 22 23 |
# File 'lib/processout/invoice_detail.rb', line 21 def discount_amount @discount_amount end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/processout/invoice_detail.rb', line 11 def id @id end |
#marketplace_merchant ⇒ Object
Returns the value of attribute marketplace_merchant.
23 24 25 |
# File 'lib/processout/invoice_detail.rb', line 23 def marketplace_merchant @marketplace_merchant end |
#marketplace_merchant_created_at ⇒ Object
Returns the value of attribute marketplace_merchant_created_at.
25 26 27 |
# File 'lib/processout/invoice_detail.rb', line 25 def marketplace_merchant_created_at @marketplace_merchant_created_at end |
#marketplace_merchant_is_business ⇒ Object
Returns the value of attribute marketplace_merchant_is_business.
24 25 26 |
# File 'lib/processout/invoice_detail.rb', line 24 def marketplace_merchant_is_business @marketplace_merchant_is_business end |
#metadata ⇒ Object
Returns the value of attribute metadata.
16 17 18 |
# File 'lib/processout/invoice_detail.rb', line 16 def @metadata end |
#model ⇒ Object
Returns the value of attribute model.
20 21 22 |
# File 'lib/processout/invoice_detail.rb', line 20 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/processout/invoice_detail.rb', line 12 def name @name end |
#quantity ⇒ Object
Returns the value of attribute quantity.
15 16 17 |
# File 'lib/processout/invoice_detail.rb', line 15 def quantity @quantity end |
#reference ⇒ Object
Returns the value of attribute reference.
17 18 19 |
# File 'lib/processout/invoice_detail.rb', line 17 def reference @reference end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/processout/invoice_detail.rb', line 13 def type @type end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API
150 151 152 153 154 155 156 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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/processout/invoice_detail.rb', line 150 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "name" self.name = data["name"] end if data.include? "type" self.type = data["type"] end if data.include? "amount" self.amount = data["amount"] end if data.include? "quantity" self.quantity = data["quantity"] end if data.include? "metadata" self. = data["metadata"] end if data.include? "reference" self.reference = data["reference"] end if data.include? "description" self.description = data["description"] end if data.include? "brand" self.brand = data["brand"] end if data.include? "model" self.model = data["model"] end if data.include? "discount_amount" self.discount_amount = data["discount_amount"] end if data.include? "condition" self.condition = data["condition"] end if data.include? "marketplace_merchant" self.marketplace_merchant = data["marketplace_merchant"] end if data.include? "marketplace_merchant_is_business" self.marketplace_merchant_is_business = data["marketplace_merchant_is_business"] end if data.include? "marketplace_merchant_created_at" self.marketplace_merchant_created_at = data["marketplace_merchant_created_at"] end if data.include? "category" self.category = data["category"] end self end |
#new(data = {}) ⇒ Object
Create a new InvoiceDetail using the current client
121 122 123 |
# File 'lib/processout/invoice_detail.rb', line 121 def new(data = {}) InvoiceDetail.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/processout/invoice_detail.rb', line 209 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.name = data.fetch(:name, self.name) self.type = data.fetch(:type, self.type) self.amount = data.fetch(:amount, self.amount) self.quantity = data.fetch(:quantity, self.quantity) self. = data.fetch(:metadata, self.) self.reference = data.fetch(:reference, self.reference) self.description = data.fetch(:description, self.description) self.brand = data.fetch(:brand, self.brand) self.model = data.fetch(:model, self.model) self.discount_amount = data.fetch(:discount_amount, self.discount_amount) self.condition = data.fetch(:condition, self.condition) self.marketplace_merchant = data.fetch(:marketplace_merchant, self.marketplace_merchant) self.marketplace_merchant_is_business = data.fetch(:marketplace_merchant_is_business, self.marketplace_merchant_is_business) self.marketplace_merchant_created_at = data.fetch(:marketplace_merchant_created_at, self.marketplace_merchant_created_at) self.category = data.fetch(:category, self.category) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/processout/invoice_detail.rb', line 126 def to_json() { "id": self.id, "name": self.name, "type": self.type, "amount": self.amount, "quantity": self.quantity, "metadata": self., "reference": self.reference, "description": self.description, "brand": self.brand, "model": self.model, "discount_amount": self.discount_amount, "condition": self.condition, "marketplace_merchant": self.marketplace_merchant, "marketplace_merchant_is_business": self.marketplace_merchant_is_business, "marketplace_merchant_created_at": self.marketplace_merchant_created_at, "category": self.category, }.to_json end |