class StarkBank::Institution

# Institution object

This resource is used to get information on the institutions that are recognized by the Brazilian Central Bank. Besides the display name and full name, they also include the STR code (used for TEDs) and the SPI Code (used for Pix) for the institutions. Either of these codes may be empty if the institution is not registered on that Central Bank service.

## Attributes (return-only):

Attributes

display_name[R]
name[R]
spi_code[R]
str_code[R]

Public Class Methods

new(display_name: nil, name: nil, spi_code: nil, str_code: nil) click to toggle source
# File lib/institution/institution.rb, line 22
def initialize(display_name: nil, name: nil, spi_code: nil, str_code: nil)
  @display_name = display_name
  @name = name
  @spi_code = spi_code
  @str_code = str_code
end
query(limit: nil, search: nil, spi_codes: nil, str_codes: nil, user: nil) click to toggle source

# Retrieve Bacen Institutions

Receive a list of Institution objects that are recognized by the Brazilian Central bank for Pix and TED transactions

## Parameters (optional):

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • search [string, default nil]: part of the institution name to be searched. ex: 'stark'

  • spi_codes [list of strings, default nil]: list of SPI (Pix) codes to be searched. ex: ['20018183']

  • str_codes [list of strings, default nil]: list of STR (TED) codes to be searched. ex: ['260']

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

## Return:

# File lib/institution/institution.rb, line 42
def self.query(limit: nil, search: nil, spi_codes: nil, str_codes: nil, user: nil)
  StarkBank::Utils::Rest.get_page(
      limit: limit,
      search: search, 
      spi_codes: spi_codes, 
      str_codes: str_codes,
      user: user,
      **resource
  ).first
end
resource() click to toggle source
# File lib/institution/institution.rb, line 53
def self.resource
  {
    resource_name: 'Institution',
    resource_maker: proc { |json|
      Institution.new(      
        display_name: json['display_name'],
        name: json['name'],
        spi_code: json['spi_code'],
        str_code: json['str_code']
      )
    }
  }
end