Class: StarkBank::CorporateWithdrawal
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::CorporateWithdrawal
- Defined in:
- lib/corporate_withdrawal/corporatewithdrawal.rb
Overview
# CorporateWithdrawal object
The CorporateWithdrawal objects created in your Workspace return cash from your Corporate balance to your Banking balance.
## Parameters (required):
-
amount [integer]: CorporateWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
-
external_id [string] CorporateWithdrawal external ID. ex: ‘12345’
## Parameters (optional):
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘tony’, ‘stark’]
## Attributes (return-only):
-
id [string]: unique id returned when CorporateWithdrawal is created. ex: ‘5656565656565656’
-
transaction_id [string]: Stark Bank ledger transaction ids linked to this CorporateWithdrawal
-
corporate_transaction_id [string]: corporate ledger transaction ids linked to this CorporateWithdrawal
-
updated [DateTime]: latest update datetime for the CorporateWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
created [DateTime]: creation datetime for the CorporateWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#corporate_transaction_id ⇒ Object
readonly
Returns the value of attribute corporate_transaction_id.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.create(withdrawal, user: nil) ⇒ Object
# Create a CorporateWithdrawal.
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific CorporateWithdrawal.
-
.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged CorporateWithdrawals.
-
.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object
# Retrieve CorporateWithdrawals.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(amount:, external_id:, tags: nil, id: nil, transaction_id: nil, corporate_transaction_id: nil, updated: nil, created: nil) ⇒ CorporateWithdrawal
constructor
A new instance of CorporateWithdrawal.
Constructor Details
#initialize(amount:, external_id:, tags: nil, id: nil, transaction_id: nil, corporate_transaction_id: nil, updated: nil, created: nil) ⇒ CorporateWithdrawal
Returns a new instance of CorporateWithdrawal.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 26 def initialize( amount:, external_id:, tags: nil, id: nil, transaction_id: nil, corporate_transaction_id: nil, updated: nil, created: nil ) super(id) @amount = amount @external_id = external_id @tags = @transaction_id = transaction_id @corporate_transaction_id = corporate_transaction_id @updated = StarkCore::Utils::Checks.check_datetime(updated) @created = StarkCore::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def amount @amount end |
#corporate_transaction_id ⇒ Object (readonly)
Returns the value of attribute corporate_transaction_id.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def corporate_transaction_id @corporate_transaction_id end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def created @created end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def external_id @external_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def id @id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def @tags end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def transaction_id @transaction_id end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
25 26 27 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 25 def updated @updated end |
Class Method Details
.create(withdrawal, user: nil) ⇒ Object
# Create a CorporateWithdrawal
Send a single CorporateWithdrawal object for creation in the Stark Bank API
## Parameters (required):
-
withdrawal [CorporateWithdrawal object]: CorporateWithdrawal object to be created in the API.
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
## Return:
-
CorporateWithdrawal object with updated attributes
52 53 54 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 52 def self.create(withdrawal, user: nil) StarkBank::Utils::Rest.post_single(entity: withdrawal, user: user, **resource) end |
.get(id, user: nil) ⇒ Object
# Retrieve a specific CorporateWithdrawal
Receive a single CorporateWithdrawal object previously created in the Stark Bank 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 starkbank.user was set before function call
## Return:
-
CorporateWithdrawal object with updated attributes
68 69 70 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 68 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged CorporateWithdrawals
Receive a list of up to 100 CorporateWithdrawal objects previously created in the Stark Bank 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’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
## Return:
-
list of CorporateWithdrawal objects with updated attributes
-
cursor to retrieve the next page of CorporateWithdrawal objects
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 117 def self.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_page( cursor: cursor, limit: limit, external_ids: external_ids, after: after, before: before, tags: , user: user, **resource ) end |
.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) ⇒ Object
# Retrieve CorporateWithdrawals
Receive a generator of CorporateWithdrawal objects previously created in the Stark Bank API
## Parameters (optional):
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. 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’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
## Return:
-
generator of CorporateWithdrawal objects with updated attributes
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 86 def self.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_stream( limit: limit, external_ids: external_ids, after: after, before: before, tags: , user: user, **resource ) end |
.resource ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/corporate_withdrawal/corporatewithdrawal.rb', line 132 def self.resource { resource_name: 'CorporateWithdrawal', resource_maker: proc { |json| CorporateWithdrawal.new( id: json['id'], amount: json['amount'], external_id: json['external_id'], tags: json['tags'], transaction_id: json['transaction_id'], corporate_transaction_id: json['corporate_transaction_id'], updated: json['updated'], created: json['created'] ) } } end |