Class: ProcessOut::InvoiceDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/invoice_detail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/processout/invoice_detail.rb', line 92

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)
  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

#amountObject

Returns the value of attribute amount.



12
13
14
# File 'lib/processout/invoice_detail.rb', line 12

def amount
  @amount
end

#brandObject

Returns the value of attribute brand.



17
18
19
# File 'lib/processout/invoice_detail.rb', line 17

def brand
  @brand
end

#categoryObject

Returns the value of attribute category.



24
25
26
# File 'lib/processout/invoice_detail.rb', line 24

def category
  @category
end

#conditionObject

Returns the value of attribute condition.



20
21
22
# File 'lib/processout/invoice_detail.rb', line 20

def condition
  @condition
end

#descriptionObject

Returns the value of attribute description.



16
17
18
# File 'lib/processout/invoice_detail.rb', line 16

def description
  @description
end

#discount_amountObject

Returns the value of attribute discount_amount.



19
20
21
# File 'lib/processout/invoice_detail.rb', line 19

def discount_amount
  @discount_amount
end

#marketplace_merchantObject

Returns the value of attribute marketplace_merchant.



21
22
23
# File 'lib/processout/invoice_detail.rb', line 21

def marketplace_merchant
  @marketplace_merchant
end

#marketplace_merchant_created_atObject

Returns the value of attribute marketplace_merchant_created_at.



23
24
25
# File 'lib/processout/invoice_detail.rb', line 23

def marketplace_merchant_created_at
  @marketplace_merchant_created_at
end

#marketplace_merchant_is_businessObject

Returns the value of attribute marketplace_merchant_is_business.



22
23
24
# File 'lib/processout/invoice_detail.rb', line 22

def marketplace_merchant_is_business
  @marketplace_merchant_is_business
end

#metadataObject

Returns the value of attribute metadata.



14
15
16
# File 'lib/processout/invoice_detail.rb', line 14

def 
  
end

#modelObject

Returns the value of attribute model.



18
19
20
# File 'lib/processout/invoice_detail.rb', line 18

def model
  @model
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/processout/invoice_detail.rb', line 10

def name
  @name
end

#quantityObject

Returns the value of attribute quantity.



13
14
15
# File 'lib/processout/invoice_detail.rb', line 13

def quantity
  @quantity
end

#referenceObject

Returns the value of attribute reference.



15
16
17
# File 'lib/processout/invoice_detail.rb', line 15

def reference
  @reference
end

#typeObject

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

Hash of data coming from the API



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/processout/invoice_detail.rb', line 121

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
  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



114
115
116
# File 'lib/processout/invoice_detail.rb', line 114

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



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/processout/invoice_detail.rb', line 177

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.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