Class: StarkInfra::CreditNote::Transfer

Inherits:
Utils::Resource show all
Defined in:
lib/creditnote/creditnote.rb

Overview

# CreditNote::Transfer object

Transfer sent to the credit receiver after the contract is signed.

## Parameters (required):

  • name [string]: receiver full name. ex: ‘Anthony Edward Stark’

  • tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: ‘01234567890’ or ‘20.018.183/0001-80’

  • bank_code [string]: code of the receiver bank institution in Brazil. ex: ‘20018183’

  • branch_code [string]: receiver bank account branch. Use ‘-’ in case there is a verifier digit. ex: ‘1357-9’

  • account_number [string]: receiver bank account number. Use ‘-’ before the verifier digit. ex: ‘876543-2’

## Parameters (optional):

  • account_type [string, default ‘checking’]: Receiver bank account type. This parameter only has effect on Pix Transfers. ex: ‘checking’, ‘savings’, ‘salary’ or ‘payment’

  • tags [list of strings, default nil]: list of strings for reference when searching for transfers. ex: [‘employees’, ‘monthly’]

## Attributes (return-only):

  • amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34)

  • external_id [string]: url safe string that must be unique among all your transfers. Duplicated external_ids will cause failures. By default, this parameter will block any transfer that repeats amount and receiver information on the same date. ex: ‘my-internal-id-123456’

  • scheduled [DateTime, Date or string]: date or datetime when the transfer will be processed. May be pushed to next business day if necessary. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

  • description [string]: optional description to override default description to be shown in the bank statement. ex: ‘Payment for service #1234’

  • id [string]: unique id returned when the transfer is created. ex: ‘5656565656565656’

  • fee [integer]: fee charged when the Transfer is processed. ex: 200 (= R$ 2.00)

  • status [string]: current transfer status. ex: ‘success’ or ‘failed’

  • transaction_ids [list of strings]: ledger Transaction IDs linked to this Transfer (if there are two, the second is the chargeback). ex: [‘19827356981273’]

  • created [DateTime]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

  • updated [DateTime]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

Instance Attribute Summary collapse

Attributes inherited from Utils::Resource

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Utils::SubResource

#inspect, #to_s

Constructor Details

#initialize(name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil, tags: nil, id: nil, amount: nil, external_id: nil, scheduled: nil, description: nil, fee: nil, status: nil, created: nil, updated: nil, transaction_ids: nil) ⇒ Transfer

Returns a new instance of Transfer.



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/creditnote/creditnote.rb', line 295

def initialize(
  name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil,
  tags: nil, id: nil, amount: nil, external_id: nil, scheduled: nil,
  description: nil, fee: nil, status: nil, created: nil, updated: nil,
  transaction_ids: nil
)
  super(id)
  @name = name
  @tax_id = tax_id
  @bank_code = bank_code
  @branch_code = branch_code
  @account_number = 
  @account_type = 
  @tags = tags
  @amount = amount
  @external_id = external_id
  @scheduled = scheduled
  @description = description
  @fee = fee
  @status = status
  @transaction_ids = transaction_ids
  @created = StarkInfra::Utils::Checks.check_datetime(created)
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def 
  @account_number
end

#account_typeObject (readonly)

Returns the value of attribute account_type.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def 
  @account_type
end

#amountObject (readonly)

Returns the value of attribute amount.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def amount
  @amount
end

#bank_codeObject (readonly)

Returns the value of attribute bank_code.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def bank_code
  @bank_code
end

#branch_codeObject (readonly)

Returns the value of attribute branch_code.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def branch_code
  @branch_code
end

#createdObject (readonly)

Returns the value of attribute created.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def created
  @created
end

#descriptionObject (readonly)

Returns the value of attribute description.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def description
  @description
end

#external_idObject (readonly)

Returns the value of attribute external_id.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def external_id
  @external_id
end

#feeObject (readonly)

Returns the value of attribute fee.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def fee
  @fee
end

#nameObject (readonly)

Returns the value of attribute name.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def name
  @name
end

#scheduledObject (readonly)

Returns the value of attribute scheduled.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def scheduled
  @scheduled
end

#statusObject (readonly)

Returns the value of attribute status.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def tags
  @tags
end

#tax_idObject (readonly)

Returns the value of attribute tax_id.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def tax_id
  @tax_id
end

#transaction_idsObject (readonly)

Returns the value of attribute transaction_ids.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def transaction_ids
  @transaction_ids
end

#updatedObject (readonly)

Returns the value of attribute updated.



294
295
296
# File 'lib/creditnote/creditnote.rb', line 294

def updated
  @updated
end

Class Method Details

.resourceObject



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/creditnote/creditnote.rb', line 320

def self.resource
  {
    resource_name: 'Transfer',
    resource_maker: proc { |json|
      Transfer.new(
        id: json['id'],
        tax_id: json['tax_id'],
        name: json['name'],
        bank_code: json['bank_code'],
        branch_code: json['branch_code'],
        account_number: json['account_number'],
        amount: json['amount'],
        account_type: json['account_type'],
        external_id: json['external_id'],
        scheduled: json['scheduled'],
        description: json['description'],
        tags: json['tags'],
        fee: json['fee'],
        status: json['status'],
        created: json['created'],
        updated: json['updated'],
        transaction_ids: json['transaction_ids']
      )
    }
  }
end