Class: StarkInfra::IssuingTransaction
- Inherits:
-
Utils::Resource
- Object
- Utils::SubResource
- Utils::Resource
- StarkInfra::IssuingTransaction
- Defined in:
- lib/issuingtransaction/issuingtransaction.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.
Methods inherited from Utils::SubResource
Constructor Details
#initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil) ⇒ IssuingTransaction
Returns a new instance of IssuingTransaction.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 23 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 @tags = @created = StarkInfra::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def amount @amount end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def balance @balance end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def created @created end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def id @id end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def source @source end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
21 22 23 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 21 def @tags 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
47 48 49 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 47 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 IssuingTransaction objects previously created in the Stark Infra API and the cursor to the next page.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call.
-
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 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 101 def self.page(cursor: nil, tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::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 []]: 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 [], 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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 67 def self.query(tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::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
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/issuingtransaction/issuingtransaction.rb', line 119 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 |