class StarkBank::Transfer

# Transfer object

When you initialize a Transfer, the entity will not be automatically created in the Stark Bank API. The 'create' function sends the objects to the Stark Bank API and returns the list of created objects.

## Parameters (required):

## Parameters (optional):

## Attributes (return-only):

Attributes

account_number[R]
account_type[R]
amount[R]
bank_code[R]
branch_code[R]
created[R]
description[R]
external_id[R]
fee[R]
id[R]
name[R]
scheduled[R]
status[R]
tags[R]
tax_id[R]
transaction_ids[R]
updated[R]

Public Class Methods

create(transfers, user: nil) click to toggle source

# Create Transfers

Send a list of Transfer objects for creation in the Stark Bank API

## Parameters (required):

  • transfers [list of Transfer objects]: list of Transfer objects to be created in the API

## Parameters (optional):

## Return:

  • list of Transfer objects with updated attributes

# File lib/transfer/transfer.rb, line 70
def self.create(transfers, user: nil)
  StarkBank::Utils::Rest.post(entities: transfers, user: user, **resource)
end
delete(id, user: nil) click to toggle source

# Delete a Transfer entity

Delete a Transfer entity previously created in the Stark Bank API

## Parameters (required):

  • id [string]: Transfer unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

# File lib/transfer/transfer.rb, line 102
def self.delete(id, user: nil)
  StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
end
get(id, user: nil) click to toggle source

# Retrieve a specific Transfer

Receive a single Transfer object previously created in the Stark Bank API by passing its id

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

  • Transfer object with updated attributes

# File lib/transfer/transfer.rb, line 86
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new(amount:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil, external_id: nil, scheduled: nil, description: nil, transaction_ids: nil, fee: nil, tags: nil, status: nil, id: nil, created: nil, updated: nil) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/transfer/transfer.rb, line 38
def initialize(amount:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil, external_id: nil, scheduled: nil, description: nil, transaction_ids: nil, fee: nil, tags: nil, status: nil, id: nil, created: nil, updated: nil)
  super(id)
  @amount = amount
  @name = name
  @tax_id = tax_id
  @bank_code = bank_code
  @branch_code = branch_code
  @account_number = account_number
  @account_type = account_type
  @external_id = external_id
  @scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
  @description = description
  @transaction_ids = transaction_ids
  @fee = fee
  @tags = tags
  @status = status
  @created = StarkBank::Utils::Checks.check_datetime(created)
  @updated = StarkBank::Utils::Checks.check_datetime(updated)
end
page(cursor: nil, limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, ids: nil, user: nil) click to toggle source

# Retrieve paged Transfers

Receive a list of up to 100 Transfer 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'

  • 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 Transfer objects with updated attributes and cursor to retrieve the next page of Transfer objects

# File lib/transfer/transfer.rb, line 175
def self.page(cursor: nil, limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: 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,
    transaction_ids: transaction_ids,
    status: status,
    tax_id: tax_id,
    sort: sort,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end
pdf(id, user: nil) click to toggle source

# Retrieve a specific Transfer pdf file

Receive a single Transfer pdf receipt file generated in the Stark Bank API by passing its id. Only valid for transfers with 'processing' and 'success' status.

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

# File lib/transfer/transfer.rb, line 119
def self.pdf(id, user: nil)
  StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
end
query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, ids: nil, user: nil) click to toggle source

# Retrieve Transfers

Receive a generator of Transfer 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 or updated only after specified date. ex: Date.new(2020, 3, 10)

  • before [Date, DateTime, Time or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)

  • transactionIds [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']

  • status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'

  • tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: '012.345.678-90'

  • 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 Transfer objects with updated attributes

# File lib/transfer/transfer.rb, line 140
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: 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,
    transaction_ids: transaction_ids,
    status: status,
    tax_id: tax_id,
    sort: sort,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end
resource() click to toggle source
# File lib/transfer/transfer.rb, line 194
def self.resource
  {
    resource_name: 'Transfer',
    resource_maker: proc { |json|
      Transfer.new(
        id: json['id'],
        amount: json['amount'],
        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'],
        external_id: json['external_id'],
        scheduled: json['scheduled'],
        description: json['description'],
        transaction_ids: json['transaction_ids'],
        fee: json['fee'],
        tags: json['tags'],
        status: json['status'],
        created: json['created'],
        updated: json['updated']
      )
    }
  }
end