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



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

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.



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

def amount
  @amount
end

#brandObject

Returns the value of attribute brand.



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

def brand
  @brand
end

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#conditionObject

Returns the value of attribute condition.



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

def condition
  @condition
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#discount_amountObject

Returns the value of attribute discount_amount.



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

def discount_amount
  @discount_amount
end

#marketplace_merchantObject

Returns the value of attribute marketplace_merchant.



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

def marketplace_merchant
  @marketplace_merchant
end

#marketplace_merchant_created_atObject

Returns the value of attribute marketplace_merchant_created_at.



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

def marketplace_merchant_created_at
  @marketplace_merchant_created_at
end

#marketplace_merchant_is_businessObject

Returns the value of attribute marketplace_merchant_is_business.



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

def marketplace_merchant_is_business
  @marketplace_merchant_is_business
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#modelObject

Returns the value of attribute model.



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

def model
  @model
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#quantityObject

Returns the value of attribute quantity.



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

def quantity
  @quantity
end

#referenceObject

Returns the value of attribute reference.



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

def reference
  @reference
end

#typeObject

Returns the value of attribute type.



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

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



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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/processout/invoice_detail.rb', line 143

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



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

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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/processout/invoice_detail.rb', line 199

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

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/processout/invoice_detail.rb', line 120

def to_json(options)
  {
      "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