Class: ProcessOut::Payout
- Inherits:
-
Object
- Object
- ProcessOut::Payout
- Defined in:
- lib/processout/payout.rb
Instance Attribute Summary collapse
-
#adjustments ⇒ Object
Returns the value of attribute adjustments.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#bank_name ⇒ Object
Returns the value of attribute bank_name.
-
#bank_summary ⇒ Object
Returns the value of attribute bank_summary.
-
#chargebacks_transactions ⇒ Object
Returns the value of attribute chargebacks_transactions.
-
#chargebacks_volume ⇒ Object
Returns the value of attribute chargebacks_volume.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#fees ⇒ Object
Returns the value of attribute fees.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#refunds_transactions ⇒ Object
Returns the value of attribute refunds_transactions.
-
#refunds_volume ⇒ Object
Returns the value of attribute refunds_volume.
-
#reserve ⇒ Object
Returns the value of attribute reserve.
-
#sales_transactions ⇒ Object
Returns the value of attribute sales_transactions.
-
#sales_volume ⇒ Object
Returns the value of attribute sales_volume.
-
#settled_at ⇒ Object
Returns the value of attribute settled_at.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the payouts.
-
#delete(payout_id, options = {}) ⇒ Object
- Delete the payout along with its payout items Params:
payout_id
- ID of the payout
options
-
Hash
of options.
- ID of the payout
- Delete the payout along with its payout items Params:
-
#fetch_items(options = {}) ⇒ Object
Get all the items linked to the payout.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#find(payout_id, options = {}) ⇒ Object
Find a payout by its ID.
-
#initialize(client, data = {}) ⇒ Payout
constructor
- Initializes the Payout object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Payout object Params:
-
#new(data = {}) ⇒ Object
Create a new Payout using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
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
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 |
# File 'lib/processout/payout.rb', line 130 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.settled_at = data.fetch(:settled_at, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#adjustments ⇒ Object
Returns the value of attribute adjustments.
27 28 29 |
# File 'lib/processout/payout.rb', line 27 def adjustments @adjustments end |
#amount ⇒ Object
Returns the value of attribute amount.
15 16 17 |
# File 'lib/processout/payout.rb', line 15 def amount @amount end |
#bank_name ⇒ Object
Returns the value of attribute bank_name.
18 19 20 |
# File 'lib/processout/payout.rb', line 18 def bank_name @bank_name end |
#bank_summary ⇒ Object
Returns the value of attribute bank_summary.
19 20 21 |
# File 'lib/processout/payout.rb', line 19 def bank_summary @bank_summary end |
#chargebacks_transactions ⇒ Object
Returns the value of attribute chargebacks_transactions.
24 25 26 |
# File 'lib/processout/payout.rb', line 24 def chargebacks_transactions @chargebacks_transactions end |
#chargebacks_volume ⇒ Object
Returns the value of attribute chargebacks_volume.
25 26 27 |
# File 'lib/processout/payout.rb', line 25 def chargebacks_volume @chargebacks_volume end |
#created_at ⇒ Object
Returns the value of attribute created_at.
30 31 32 |
# File 'lib/processout/payout.rb', line 30 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
16 17 18 |
# File 'lib/processout/payout.rb', line 16 def currency @currency end |
#fees ⇒ Object
Returns the value of attribute fees.
26 27 28 |
# File 'lib/processout/payout.rb', line 26 def fees @fees end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/processout/payout.rb', line 11 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
17 18 19 |
# File 'lib/processout/payout.rb', line 17 def @metadata end |
#project ⇒ Object
Returns the value of attribute project.
12 13 14 |
# File 'lib/processout/payout.rb', line 12 def project @project end |
#project_id ⇒ Object
Returns the value of attribute project_id.
13 14 15 |
# File 'lib/processout/payout.rb', line 13 def project_id @project_id end |
#refunds_transactions ⇒ Object
Returns the value of attribute refunds_transactions.
22 23 24 |
# File 'lib/processout/payout.rb', line 22 def refunds_transactions @refunds_transactions end |
#refunds_volume ⇒ Object
Returns the value of attribute refunds_volume.
23 24 25 |
# File 'lib/processout/payout.rb', line 23 def refunds_volume @refunds_volume end |
#reserve ⇒ Object
Returns the value of attribute reserve.
28 29 30 |
# File 'lib/processout/payout.rb', line 28 def reserve @reserve end |
#sales_transactions ⇒ Object
Returns the value of attribute sales_transactions.
20 21 22 |
# File 'lib/processout/payout.rb', line 20 def sales_transactions @sales_transactions end |
#sales_volume ⇒ Object
Returns the value of attribute sales_volume.
21 22 23 |
# File 'lib/processout/payout.rb', line 21 def sales_volume @sales_volume end |
#settled_at ⇒ Object
Returns the value of attribute settled_at.
29 30 31 |
# File 'lib/processout/payout.rb', line 29 def settled_at @settled_at end |
#status ⇒ Object
Returns the value of attribute status.
14 15 16 |
# File 'lib/processout/payout.rb', line 14 def status @status end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the payouts. Params:
options
-
Hash
of options
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/processout/payout.rb', line 322 def all( = {}) self.prefill() request = Request.new(@client) path = "/payouts" data = { } response = Response.new(request.get(path, data, )) 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 |
#delete(payout_id, options = {}) ⇒ Object
Delete the payout along with its payout items Params:
payout_id
-
ID of the payout
options
-
Hash
of options
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/processout/payout.rb', line 381 def delete(payout_id, = {}) self.prefill() request = Request.new(@client) path = "/payouts/" + CGI.escape(payout_id) + "" data = { } response = Response.new(request.delete(path, data, )) return_values = Array.new return_values.push(response.success) return_values[0] end |
#fetch_items(options = {}) ⇒ Object
Get all the items linked to the payout. Params:
options
-
Hash
of options
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/processout/payout.rb', line 292 def fetch_items( = {}) self.prefill() request = Request.new(@client) path = "/payouts/" + CGI.escape(@id) + "/items" data = { } response = Response.new(request.get(path, data, )) 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
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/processout/payout.rb', line 190 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? "settled_at" self.settled_at = data["settled_at"] 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
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/processout/payout.rb', line 353 def find(payout_id, = {}) self.prefill() request = Request.new(@client) path = "/payouts/" + CGI.escape(payout_id) + "" data = { } response = Response.new(request.get(path, data, )) 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
157 158 159 |
# File 'lib/processout/payout.rb', line 157 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
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/processout/payout.rb', line 261 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.settled_at = data.fetch(:settled_at, self.settled_at) self.created_at = data.fetch(:created_at, self.created_at) 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 180 181 182 183 184 185 |
# File 'lib/processout/payout.rb', line 162 def to_json() { "id": self.id, "project": self.project, "project_id": self.project_id, "status": self.status, "amount": self.amount, "currency": self.currency, "metadata": self., "bank_name": self.bank_name, "bank_summary": self.bank_summary, "sales_transactions": self.sales_transactions, "sales_volume": self.sales_volume, "refunds_transactions": self.refunds_transactions, "refunds_volume": self.refunds_volume, "chargebacks_transactions": self.chargebacks_transactions, "chargebacks_volume": self.chargebacks_volume, "fees": self.fees, "adjustments": self.adjustments, "reserve": self.reserve, "settled_at": self.settled_at, "created_at": self.created_at, }.to_json end |