Class: StarkBank::Deposit

Inherits:
Utils::Resource show all
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’

  • account_type [string]: payer bank account type. ex: ‘checking’

  • 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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(id:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, amount:, type:, status:, tags:, fee:, transaction_ids:, created:, updated:) ⇒ Deposit

Returns a new instance of Deposit.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/deposit/deposit.rb', line 30

def initialize(
  id:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, 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_type = 
  @amount = amount
  @type = type
  @status = status
  @tags = tags
  @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_numberObject (readonly)

Returns the value of attribute account_number.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def 
  @account_number
end

#account_typeObject (readonly)

Returns the value of attribute account_type.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def 
  @account_type
end

#amountObject (readonly)

Returns the value of attribute amount.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def amount
  @amount
end

#bank_codeObject (readonly)

Returns the value of attribute bank_code.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def bank_code
  @bank_code
end

#branch_codeObject (readonly)

Returns the value of attribute branch_code.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def branch_code
  @branch_code
end

#createdObject (readonly)

Returns the value of attribute created.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def created
  @created
end

#feeObject (readonly)

Returns the value of attribute fee.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def fee
  @fee
end

#idObject (readonly)

Returns the value of attribute id.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def tags
  @tags
end

#tax_idObject (readonly)

Returns the value of attribute tax_id.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def tax_id
  @tax_id
end

#transaction_idsObject (readonly)

Returns the value of attribute transaction_ids.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def transaction_ids
  @transaction_ids
end

#typeObject (readonly)

Returns the value of attribute type.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

def type
  @type
end

#updatedObject (readonly)

Returns the value of attribute updated.



29
30
31
# File 'lib/deposit/deposit.rb', line 29

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



63
64
65
# File 'lib/deposit/deposit.rb', line 63

def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end

.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil) ⇒ Object

# Retrieve paged Deposits

Receive a list of up to 100 Deposit 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 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:

  • list of Deposit objects with updated attributes and cursor to retrieve the next page of Deposit objects



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/deposit/deposit.rb', line 117

def self.page(cursor: nil, 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)
  return StarkBank::Utils::Rest.get_page(
    cursor: cursor,
    limit: limit,
    after: after,
    before: before,
    status: status,
    sort: sort,
    tags: tags,
    ids: ids,
    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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/deposit/deposit.rb', line 83

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_stream(
    limit: limit,
    after: after,
    before: before,
    status: status,
    sort: sort,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end

.resourceObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/deposit/deposit.rb', line 134

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'],
        account_type: json['account_type'],
        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