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.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#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 -
Hashof 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 ProcessOutclient 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 -
Hashof data.
- Prefills the object with the data passed as parameters Params:
Constructor Details
#initialize(client, data = {}) ⇒ InvoiceDetail
Initializes the InvoiceDetail object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/processout/invoice_detail.rb', line 42 def initialize(client, data = {}) @client = client 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) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
12 13 14 |
# File 'lib/processout/invoice_detail.rb', line 12 def amount @amount end |
#metadata ⇒ Object
Returns the value of attribute metadata.
14 15 16 |
# File 'lib/processout/invoice_detail.rb', line 14 def end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/processout/invoice_detail.rb', line 10 def name @name end |
#quantity ⇒ Object
Returns the value of attribute quantity.
13 14 15 |
# File 'lib/processout/invoice_detail.rb', line 13 def quantity @quantity end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/processout/invoice_detail.rb', line 11 def type @type end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data-
Hashof data coming from the API
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/processout/invoice_detail.rb', line 61 def fill_with_data(data) if data.nil? return self 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 self end |
#new(data = {}) ⇒ Object
Create a new InvoiceDetail using the current client
54 55 56 |
# File 'lib/processout/invoice_detail.rb', line 54 def new(data = {}) InvoiceDetail.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/processout/invoice_detail.rb', line 87 def prefill(data) if data.nil? return self end 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 end |