Class: StarkInfra::IssuingTransaction
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::IssuingTransaction
- Defined in:
- lib/issuing_transaction/issuing_transaction.rb
Overview
# IssuingTransaction object
The IssuingTransaction objects created in your Workspace to represent each balance shift.
## Attributes (return-only):
-
id [string]: unique id returned when IssuingTransaction is created. ex: ‘5656565656565656’
-
amount [integer]: IssuingTransaction value in cents. ex: 1234 (= R$ 12.34)
-
balance [integer]: balance amount of the Workspace at the instant of the Transaction in cents. ex: 200 (= R$ 2.00)
-
description [string]: IssuingTransaction description. ex: ‘Buying food’
-
source [string]: source of the transaction. ex: ‘issuing-purchase/5656565656565656’
-
tags [string]: list of strings inherited from the source resource. ex: [‘tony’, ‘stark’]
-
created [DateTime]: creation datetime for the IssuingTransaction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingTransaction.
-
.page(cursor: nil, tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) ⇒ Object
# Retrieve paged IssuingTransactions.
-
.query(tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) ⇒ Object
# Retrieve IssuingTransactions.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil) ⇒ IssuingTransaction
constructor
A new instance of IssuingTransaction.
Constructor Details
#initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil) ⇒ IssuingTransaction
Returns a new instance of IssuingTransaction.
22 23 24 25 26 27 28 29 30 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 22 def initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil) super(id) @amount = amount @balance = balance @description = description @source = source = @created = StarkCore::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def amount @amount end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def balance @balance end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def created @created end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def id @id end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def source @source end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
20 21 22 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 20 def end |
Class Method Details
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingTransaction
Receive a single IssuingTransaction object previously created in the Stark Infra API by its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
IssuingTransaction object with updated attributes
44 45 46 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 44 def self.get(id, user: nil) StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) ⇒ Object
# Retrieve paged IssuingTransactions
Receive a list of up to 100 IssuingTransaction objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call.
-
limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
external_ids [list of strings, default nil]: external IDs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘approved’, ‘canceled’, ‘denied’, ‘confirmed’ or ‘voided’
-
ids [list of strings, default nil]: purchase IDs
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
list of IssuingTransactions objects with updated attributes
-
cursor to retrieve the next page of IssuingTransactions objects
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 99 def self.page(cursor: nil, tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, tags: , external_ids: external_ids, after: after, before: before, status: status, ids: ids, limit: limit, user: user, **resource ) end |
.query(tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) ⇒ Object
# Retrieve IssuingTransactions
Receive a generator of IssuingTransaction objects previously created in the Stark Infra API
## Parameters (optional):
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
external_ids [list of strings, default nil]: external IDs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘approved’, ‘canceled’, ‘denied’, ‘confirmed’ or ‘voided’
-
ids [list of strings, default nil]: purchase IDs
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
generator of IssuingTransaction objects with updated attributes
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 64 def self.query(tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( tags: , external_ids: external_ids, after: after, before: before, status: status, ids: ids, limit: limit, user: user, **resource ) end |
.resource ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/issuing_transaction/issuing_transaction.rb', line 117 def self.resource { resource_name: 'IssuingTransaction', resource_maker: proc { |json| IssuingTransaction.new( id: json['id'], amount: json['amount'], balance: json['balance'], description: json['description'], source: json['source'], tags: json['tags'], created: json['created'] ) } } end |