Class: ProcessOut::PayoutItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the PayoutItem object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/processout/payout_item.rb', line 136

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.payout = data.fetch(:payout, nil)
  self.payout_id = data.fetch(:payout_id, nil)
  self.transaction = data.fetch(:transaction, nil)
  self.transaction_id = data.fetch(:transaction_id, nil)
  self.type = data.fetch(:type, nil)
  self.gateway_resource_id = data.fetch(:gateway_resource_id, nil)
  self.amount = data.fetch(:amount, nil)
  self.fees = data.fetch(:fees, nil)
  self. = data.fetch(:metadata, nil)
  self.created_at = data.fetch(:created_at, nil)
  self.breakdown = data.fetch(:breakdown, nil)
  
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#breakdownObject

Returns the value of attribute breakdown.



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

def breakdown
  @breakdown
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#feesObject

Returns the value of attribute fees.



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

def fees
  @fees
end

#gateway_resource_idObject

Returns the value of attribute gateway_resource_id.



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

def gateway_resource_id
  @gateway_resource_id
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#payoutObject

Returns the value of attribute payout.



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

def payout
  @payout
end

#payout_idObject

Returns the value of attribute payout_id.



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

def payout_id
  @payout_id
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#project_idObject

Returns the value of attribute project_id.



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

def project_id
  @project_id
end

#transactionObject

Returns the value of attribute transaction.



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

def transaction
  @transaction
end

#transaction_idObject

Returns the value of attribute transaction_id.



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

def transaction_id
  @transaction_id
end

#typeObject

Returns the value of attribute type.



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

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



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
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/processout/payout_item.rb', line 184

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? "payout"
    self.payout = data["payout"]
  end
  if data.include? "payout_id"
    self.payout_id = data["payout_id"]
  end
  if data.include? "transaction"
    self.transaction = data["transaction"]
  end
  if data.include? "transaction_id"
    self.transaction_id = data["transaction_id"]
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "gateway_resource_id"
    self.gateway_resource_id = data["gateway_resource_id"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "fees"
    self.fees = data["fees"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  if data.include? "breakdown"
    self.breakdown = data["breakdown"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new PayoutItem using the current client



157
158
159
# File 'lib/processout/payout_item.rb', line 157

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/processout/payout_item.rb', line 237

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.payout = data.fetch(:payout, self.payout)
  self.payout_id = data.fetch(:payout_id, self.payout_id)
  self.transaction = data.fetch(:transaction, self.transaction)
  self.transaction_id = data.fetch(:transaction_id, self.transaction_id)
  self.type = data.fetch(:type, self.type)
  self.gateway_resource_id = data.fetch(:gateway_resource_id, self.gateway_resource_id)
  self.amount = data.fetch(:amount, self.amount)
  self.fees = data.fetch(:fees, self.fees)
  self. = data.fetch(:metadata, self.)
  self.created_at = data.fetch(:created_at, self.created_at)
  self.breakdown = data.fetch(:breakdown, self.breakdown)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/processout/payout_item.rb', line 162

def to_json(options)
  {
      "id": self.id,
      "project": self.project,
      "project_id": self.project_id,
      "payout": self.payout,
      "payout_id": self.payout_id,
      "transaction": self.transaction,
      "transaction_id": self.transaction_id,
      "type": self.type,
      "gateway_resource_id": self.gateway_resource_id,
      "amount": self.amount,
      "fees": self.fees,
      "metadata": self.,
      "created_at": self.created_at,
      "breakdown": self.breakdown,
  }.to_json
end