Class: StarkBank::DictKey
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::DictKey
- Defined in:
- lib/dict_key/dict_key.rb
Overview
# DictKey object
DictKey represents a Pix key registered in Bacen’s DICT system.
## Parameters (optional):
-
id [string]: DictKey object unique id and Pix key itself. ex: ‘[email protected]’, ‘722.461.430-04’, ‘20.018.183/0001-80’, ‘+5511988887777’, ‘b6295ee1-f054-47d1-9e90-ee57b74f60d9’
## Attributes (return-only):
-
type [string]: DICT key type. ex: ‘email’, ‘cpf’, ‘cnpj’, ‘phone’ or ‘evp’
-
name [string]: account owner full name. ex: ‘Tony Stark’
-
tax_id [string]: key owner tax ID (CNPJ or masked CPF). ex: ‘*.345.678-’ or ‘20.018.183/0001-80’
-
owner_type [string]: DICT key owner type. ex ‘naturalPerson’ or ‘legalPerson’
-
bank_name [string]: bank name associated with the DICT key. ex: ‘Stark Bank’
-
ispb [string]: bank ISPB associated with the DICT key. ex: ‘20018183’
-
branch_code [string]: encrypted bank account branch code associated with the DICT key. ex: ‘ZW5jcnlwdGVkLWJyYW5jaC1jb2Rl’
-
account_number [string]: encrypted bank account number associated with the DICT key. ex: ‘ZW5jcnlwdGVkLWFjY291bnQtbnVtYmVy’
-
account_type [string]: bank account type associated with the DICT key. ex: ‘checking’, ‘savings’, ‘salary’ or ‘payment’
-
status [string]: current DICT key status. ex: ‘created’, ‘registered’, ‘canceled’ or ‘failed’
Instance Attribute Summary collapse
-
#account_created ⇒ Object
readonly
Returns the value of attribute account_created.
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#account_type ⇒ Object
readonly
Returns the value of attribute account_type.
-
#bank_name ⇒ Object
readonly
Returns the value of attribute bank_name.
-
#branch_code ⇒ Object
readonly
Returns the value of attribute branch_code.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ispb ⇒ Object
readonly
Returns the value of attribute ispb.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owned ⇒ Object
readonly
Returns the value of attribute owned.
-
#owner_type ⇒ Object
readonly
Returns the value of attribute owner_type.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific DictKey.
-
.page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) ⇒ Object
# Retrieve paged DictKeys.
-
.query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) ⇒ Object
# Retrieve DitcKeys.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:) ⇒ DictKey
constructor
A new instance of DictKey.
Constructor Details
#initialize(id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:) ⇒ DictKey
Returns a new instance of DictKey.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dict_key/dict_key.rb', line 27 def initialize(id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:) 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 end |
Instance Attribute Details
#account_created ⇒ Object (readonly)
Returns the value of attribute account_created.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def account_created @account_created end |
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def account_number @account_number end |
#account_type ⇒ Object (readonly)
Returns the value of attribute account_type.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def account_type @account_type end |
#bank_name ⇒ Object (readonly)
Returns the value of attribute bank_name.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def bank_name @bank_name end |
#branch_code ⇒ Object (readonly)
Returns the value of attribute branch_code.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def branch_code @branch_code end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def id @id end |
#ispb ⇒ Object (readonly)
Returns the value of attribute ispb.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def ispb @ispb end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def name @name end |
#owned ⇒ Object (readonly)
Returns the value of attribute owned.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def owned @owned end |
#owner_type ⇒ Object (readonly)
Returns the value of attribute owner_type.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def owner_type @owner_type end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def status @status end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def tax_id @tax_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
26 27 28 |
# File 'lib/dict_key/dict_key.rb', line 26 def type @type end |
Class Method Details
.get(id, user: nil) ⇒ Object
# 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: ‘[email protected]’, ‘722.461.430-04’, ‘20.018.183/0001-80’, ‘+5511988887777’, ‘b6295ee1-f054-47d1-9e90-ee57b74f60d9’
## Parameters (optional):
-
user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
DictKey object with updated attributes
53 54 55 |
# File 'lib/dict_key/dict_key.rb', line 53 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) ⇒ Object
# 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
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/dict_key/dict_key.rb', line 104 def self.page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::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) ⇒ Object
# 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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/dict_key/dict_key.rb', line 72 def self.query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::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 ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/dict_key/dict_key.rb', line 120 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'] ) } } end |