class StarkBank::DictKey

# DictKey object

DictKey represents a PIX key registered in Bacen's DICT system.

## Parameters (required):

## Attributes (return-only):

Attributes

account_created[R]
account_number[R]
account_type[R]
bank_name[R]
branch_code[R]
created[R]
id[R]
ispb[R]
name[R]
owned[R]
owner_type[R]
status[R]
tax_id[R]
type[R]

Public Class Methods

get(id, user: nil) click to toggle source

# Retrieve a specific DictKey

Receive a single DictKey object by passing its id

## Parameters (required):

  • id [string]: DictKey object unique id and PIX key itself. ex: 'tony@starkbank.com', '722.461.430-04', '20.018.183/0001-80', '+5511988887777', 'b6295ee1-f054-47d1-9e90-ee57b74f60d9'

## Parameters (optional):

## Return:

  • DictKey object with updated attributes

# File lib/dict_key/dict_key.rb, line 63
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new( id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:, account_created:, owned:, created: ) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/dict_key/dict_key.rb, line 31
def initialize(
  id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, 
  account_type:, status:, account_created:, owned:, created:
)
  super(id)
  @type = type
  @name = name
  @tax_id = tax_id
  @owner_type = owner_type
  @bank_name = bank_name
  @ispb = ispb
  @branch_code = branch_code
  @account_number = account_number
  @account_type = account_type
  @status = status
  @account_created = StarkBank::Utils::Checks.check_datetime(account_created)
  @owned = StarkBank::Utils::Checks.check_datetime(owned)
  @created = StarkBank::Utils::Checks.check_datetime(created)
end
page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) click to toggle source

# Retrieve paged DictKeys

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

  • type [string, default nil]: DictKey type. ex: 'cpf', 'cnpj', 'phone', 'email' or 'evp'

  • 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)

  • ids [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: 'canceled', 'registered'

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

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

# File lib/dict_key/dict_key.rb, line 114
def self.page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: 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,
    type: type,
    after: after,
    before: before,
    ids: ids,
    status: status,
    user: user,
    **resource
  )
end
query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) click to toggle source

# Retrieve DitcKeys

Receive a generator of DitcKey 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

  • type [string, default nil]: DictKey type. ex: 'cpf', 'cnpj', 'phone', 'email' or 'evp'

  • 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)

  • ids [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: 'canceled', 'registered'

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

  • generator of DitcKey objects with updated attributes

# File lib/dict_key/dict_key.rb, line 82
def self.query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil)
  after = StarkBank::Utils::Checks.check_date(after)
  before = StarkBank::Utils::Checks.check_date(before)
  StarkBank::Utils::Rest.get_stream(
    limit: limit,
    type: type,
    after: after,
    before: before,
    ids: ids,
    status: status,
    user: user,
    **resource
  )
end
resource() click to toggle source
# File lib/dict_key/dict_key.rb, line 130
def self.resource
  {
    resource_name: 'DictKey',
    resource_maker: proc { |json|
      DictKey.new(
        id: json['id'],
        account_type: json['account_type'],
        name: json['name'],
        tax_id: json['tax_id'],
        owner_type: json['owner_type'],
        bank_name: json['bank_name'],
        ispb: json['ispb'],
        branch_code: json['branch_code'],
        account_number: json['account_number'],
        type: json['type'],
        status: json['status'],
        account_created: json['account_created'],
        owned: json['owned'],
        created: json['created']
      )
    }
  }
end