Class: ProcessOut::Payout

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ Payout

Initializes the Payout object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/processout/payout.rb', line 124

def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.project = data.fetch(:project, nil)
  self.project_id = data.fetch(:project_id, nil)
  self.status = data.fetch(:status, nil)
  self.amount = data.fetch(:amount, nil)
  self.currency = data.fetch(:currency, nil)
  self. = data.fetch(:metadata, nil)
  self.bank_name = data.fetch(:bank_name, nil)
  self.bank_summary = data.fetch(:bank_summary, nil)
  self.sales_transactions = data.fetch(:sales_transactions, nil)
  self.sales_volume = data.fetch(:sales_volume, nil)
  self.refunds_transactions = data.fetch(:refunds_transactions, nil)
  self.refunds_volume = data.fetch(:refunds_volume, nil)
  self.chargebacks_transactions = data.fetch(:chargebacks_transactions, nil)
  self.chargebacks_volume = data.fetch(:chargebacks_volume, nil)
  self.fees = data.fetch(:fees, nil)
  self.adjustments = data.fetch(:adjustments, nil)
  self.reserve = data.fetch(:reserve, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#adjustmentsObject

Returns the value of attribute adjustments.



26
27
28
# File 'lib/processout/payout.rb', line 26

def adjustments
  @adjustments
end

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#bank_nameObject

Returns the value of attribute bank_name.



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

def bank_name
  @bank_name
end

#bank_summaryObject

Returns the value of attribute bank_summary.



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

def bank_summary
  @bank_summary
end

#chargebacks_transactionsObject

Returns the value of attribute chargebacks_transactions.



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

def chargebacks_transactions
  @chargebacks_transactions
end

#chargebacks_volumeObject

Returns the value of attribute chargebacks_volume.



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

def chargebacks_volume
  @chargebacks_volume
end

#created_atObject

Returns the value of attribute created_at.



28
29
30
# File 'lib/processout/payout.rb', line 28

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



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

def currency
  @currency
end

#feesObject

Returns the value of attribute fees.



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

def fees
  @fees
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#project_idObject

Returns the value of attribute project_id.



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

def project_id
  @project_id
end

#refunds_transactionsObject

Returns the value of attribute refunds_transactions.



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

def refunds_transactions
  @refunds_transactions
end

#refunds_volumeObject

Returns the value of attribute refunds_volume.



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

def refunds_volume
  @refunds_volume
end

#reserveObject

Returns the value of attribute reserve.



27
28
29
# File 'lib/processout/payout.rb', line 27

def reserve
  @reserve
end

#sales_transactionsObject

Returns the value of attribute sales_transactions.



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

def sales_transactions
  @sales_transactions
end

#sales_volumeObject

Returns the value of attribute sales_volume.



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

def sales_volume
  @sales_volume
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#all(options = {}) ⇒ Object

Get all the payouts. Params:

options

Hash of options



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/processout/payout.rb', line 285

def all(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/payouts"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['payouts']
    tmp = Payout.new(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#fetch_items(options = {}) ⇒ Object

Get all the items linked to the payout. Params:

options

Hash of options



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/processout/payout.rb', line 255

def fetch_items(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/payouts/" + CGI.escape(@id) + "/items"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['items']
    tmp = PayoutItem.new(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/processout/payout.rb', line 157

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "project"
    self.project = data["project"]
  end
  if data.include? "project_id"
    self.project_id = data["project_id"]
  end
  if data.include? "status"
    self.status = data["status"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "currency"
    self.currency = data["currency"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  if data.include? "bank_name"
    self.bank_name = data["bank_name"]
  end
  if data.include? "bank_summary"
    self.bank_summary = data["bank_summary"]
  end
  if data.include? "sales_transactions"
    self.sales_transactions = data["sales_transactions"]
  end
  if data.include? "sales_volume"
    self.sales_volume = data["sales_volume"]
  end
  if data.include? "refunds_transactions"
    self.refunds_transactions = data["refunds_transactions"]
  end
  if data.include? "refunds_volume"
    self.refunds_volume = data["refunds_volume"]
  end
  if data.include? "chargebacks_transactions"
    self.chargebacks_transactions = data["chargebacks_transactions"]
  end
  if data.include? "chargebacks_volume"
    self.chargebacks_volume = data["chargebacks_volume"]
  end
  if data.include? "fees"
    self.fees = data["fees"]
  end
  if data.include? "adjustments"
    self.adjustments = data["adjustments"]
  end
  if data.include? "reserve"
    self.reserve = data["reserve"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end

#find(payout_id, options = {}) ⇒ Object

Find a payout by its ID. Params:

payout_id

ID of the payout

options

Hash of options



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/processout/payout.rb', line 316

def find(payout_id, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/payouts/" + CGI.escape(payout_id) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body["payout"]
  
  
  obj = Payout.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end

#new(data = {}) ⇒ Object

Create a new Payout using the current client



150
151
152
# File 'lib/processout/payout.rb', line 150

def new(data = {})
  Payout.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/processout/payout.rb', line 225

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.project = data.fetch(:project, self.project)
  self.project_id = data.fetch(:project_id, self.project_id)
  self.status = data.fetch(:status, self.status)
  self.amount = data.fetch(:amount, self.amount)
  self.currency = data.fetch(:currency, self.currency)
  self. = data.fetch(:metadata, self.)
  self.bank_name = data.fetch(:bank_name, self.bank_name)
  self.bank_summary = data.fetch(:bank_summary, self.bank_summary)
  self.sales_transactions = data.fetch(:sales_transactions, self.sales_transactions)
  self.sales_volume = data.fetch(:sales_volume, self.sales_volume)
  self.refunds_transactions = data.fetch(:refunds_transactions, self.refunds_transactions)
  self.refunds_volume = data.fetch(:refunds_volume, self.refunds_volume)
  self.chargebacks_transactions = data.fetch(:chargebacks_transactions, self.chargebacks_transactions)
  self.chargebacks_volume = data.fetch(:chargebacks_volume, self.chargebacks_volume)
  self.fees = data.fetch(:fees, self.fees)
  self.adjustments = data.fetch(:adjustments, self.adjustments)
  self.reserve = data.fetch(:reserve, self.reserve)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end