Class: StarkBank::Deposit
- Inherits:
-
Utils::Resource
- Object
- Utils::Resource
- StarkBank::Deposit
- Defined in:
- lib/deposit/deposit.rb,
lib/deposit/log.rb
Overview
# Deposit object
Deposits represent passive cash-in received by your account from external transfers
Attributes (return-only):
-
id [string]: unique id associated with a Deposit when it is created. ex: ‘5656565656565656’
-
name [string]: payer name. ex: ‘Iron Bank S.A.’
-
tax_id [string]: payer tax ID (CPF or CNPJ). ex: ‘012.345.678-90’ or ‘20.018.183/0001-80’
-
bank_code [string]: payer bank code in Brazil. ex: ‘20018183’ or ‘341’
-
branch_code [string]: payer bank account branch. ex: ‘1357-9’s
-
account_number [string]: payer bank account number. ex: ‘876543-2’
-
amount [integer]: Deposit value in cents. ex: 1234 (= R$ 12.34)
-
type [string]: Type of settlement that originated the deposit. ex: ‘pix’ or ‘ted’
-
status [string]: current Deposit status. ex: ‘created’
-
tags [list of strings]: list of strings that are tagging the deposit. ex: [‘reconciliationId’, ‘txId’]
-
fee [integer]: fee charged by this deposit. ex: 50 (= R$ 0.50)
-
transaction_ids [list of strings]: ledger transaction ids linked to this Deposit (if there are more than one, all but first are reversals). ex: [‘19827356981273’]
-
created [datetime.datetime]: creation datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
-
updated [datetime.datetime]: latest update datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#bank_code ⇒ Object
readonly
Returns the value of attribute bank_code.
-
#branch_code ⇒ Object
readonly
Returns the value of attribute branch_code.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#fee ⇒ Object
readonly
Returns the value of attribute fee.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#transaction_ids ⇒ Object
readonly
Returns the value of attribute transaction_ids.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific Deposit.
-
.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve Deposits.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id:, name:, tax_id:, bank_code:, branch_code:, account_number:, amount:, type:, status:, tags:, fee:, transaction_ids:, created:, updated:) ⇒ Deposit
constructor
A new instance of Deposit.
Methods inherited from Utils::Resource
Constructor Details
#initialize(id:, name:, tax_id:, bank_code:, branch_code:, account_number:, amount:, type:, status:, tags:, fee:, transaction_ids:, created:, updated:) ⇒ Deposit
Returns a new instance of Deposit.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/deposit/deposit.rb', line 29 def initialize( id:, name:, tax_id:, bank_code:, branch_code:, account_number:, amount:, type:, status:, tags:, fee:, transaction_ids:, created:, updated: ) super(id) @name = name @tax_id = tax_id @bank_code = bank_code @branch_code = branch_code @account_number = account_number @amount = amount @type = type @status = status = @fee = fee @transaction_ids = transaction_ids @created = StarkBank::Utils::Checks.check_datetime(created) @updated = StarkBank::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def account_number @account_number end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def amount @amount end |
#bank_code ⇒ Object (readonly)
Returns the value of attribute bank_code.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def bank_code @bank_code end |
#branch_code ⇒ Object (readonly)
Returns the value of attribute branch_code.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def branch_code @branch_code end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def created @created end |
#fee ⇒ Object (readonly)
Returns the value of attribute fee.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def fee @fee end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def tax_id @tax_id end |
#transaction_ids ⇒ Object (readonly)
Returns the value of attribute transaction_ids.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def transaction_ids @transaction_ids end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def type @type end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
28 29 30 |
# File 'lib/deposit/deposit.rb', line 28 def updated @updated end |
Class Method Details
.get(id, user: nil) ⇒ Object
# Retrieve a specific Deposit
Receive a single Deposit object previously created in the Stark Bank API by passing its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
Deposit object with updated attributes
61 62 63 |
# File 'lib/deposit/deposit.rb', line 61 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end |
.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve Deposits
Receive a generator of Deposit 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 , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date, DateTime, Time 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: ‘paid’ or ‘registered’
-
sort [string, default ‘-created’]: sort order considered in response. Valid options are ‘created’ or ‘-created’.
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
## Return:
-
generator of Deposit objects with updated attributes
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/deposit/deposit.rb', line 81 def self.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil) after = StarkBank::Utils::Checks.check_date(after) before = StarkBank::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_list( limit: limit, after: after, before: before, status: status, sort: sort, tags: , ids: ids, user: user, **resource ) end |
.resource ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/deposit/deposit.rb', line 97 def self.resource { resource_name: 'Deposit', resource_maker: proc { |json| Deposit.new( id: json['id'], name: json['name'], tax_id: json['tax_id'], bank_code: json['bank_code'], branch_code: json['branch_code'], account_number: json['account_number'], amount: json['amount'], type: json['type'], status: json['status'], tags: json['tags'], fee: json['fee'], transaction_ids: json['transaction_ids'], created: json['created'], updated: json['updated'] ) } } end |