Class: StarkInfra::PixKey
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::PixKey
- Defined in:
- lib/pix_key/pix_key.rb,
lib/pix_key/log.rb
Overview
# PixKey object
PixKeys link bank account information to key ids. Key ids are a convenient way to search and pass bank account information.
When you initialize a Pix Key, the entity will not be automatically created in the Stark Infra API. The ‘create’ function sends the objects to the Stark Infra API and returns the created object.
## Parameters (required):
-
account_created [DateTime or string]: opening Date or DateTime for the linked account. ex: ‘2020-03-10T10:30:00.000000+00:00’ or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
-
account_number [string]: number of the linked account. ex: ‘76543’.
-
account_type [string]: type of the linked account. Options: ‘checking’, ‘savings’, ‘salary’ or ‘payment’.
-
branch_code [string]: branch code of the linked account. ex: ‘1234’.
-
name [string]: holder’s name of the linked account. ex: ‘Jamie Lannister’.
-
tax_id [string]: holder’s taxId (CPF/CNPJ) of the linked account. ex: ‘012.345.678-90’.
## Parameters (optional):
-
id [string, default nil]: id of the registered PixKey. Allowed types are: CPF, CNPJ, phone number or email. If this parameter is not passed, an EVP will be created. ex: ‘+5511989898989’
-
tags [list of strings, default nil]: list of strings for reference when searching for PixKeys. ex: [‘employees’, ‘monthly’]
## Attributes (return-only):
-
owned [DateTime]: datetime when the key was owned by the holder. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
owner_type [string]: type of the owner of the PixKey. Options: ‘business’ or ‘individual’.
-
status [string]: current PixKey status. Options: ‘created’, ‘registered’, ‘canceled’, ‘failed’
-
bank_code [string]: bank_code of the account linked to the Pix Key. ex: ‘20018183’.
-
bank_name [string]: name of the bank that holds the account linked to the PixKey. ex: ‘StarkBank’
-
type [string]: type of the PixKey. Options: ‘cpf’, ‘cnpj’, ‘phone’, ‘email’ and ‘evp’,
-
created [DateTime]: creation datetime for the PixKey. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
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_code ⇒ Object
readonly
Returns the value of attribute bank_code.
-
#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.
-
#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.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.cancel(id, user: nil) ⇒ Object
# Cancel a PixKey entity.
-
.create(key, user: nil) ⇒ Object
# Create a PixKey.
-
.get(id, payer_id:, end_to_end_id: nil, user: nil) ⇒ Object
# Retrieve a specific PixKey.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) ⇒ Object
# Retrieve paged PixKeys.
-
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) ⇒ Object
# Retrieve PixKeys.
- .resource ⇒ Object
-
.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil) ⇒ Object
# Update a PixKey entity.
Instance Method Summary collapse
-
#initialize(account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil, owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil) ⇒ PixKey
constructor
A new instance of PixKey.
Constructor Details
#initialize(account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil, owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil) ⇒ PixKey
Returns a new instance of PixKey.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pix_key/pix_key.rb', line 39 def initialize( account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil, owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil ) super(id) @account_created = account_created @account_number = account_number @account_type = account_type @branch_code = branch_code @name = name @tax_id = tax_id @tags = @owned = StarkCore::Utils::Checks.check_datetime(owned) @owner_type = owner_type @status = status @bank_code = bank_code @bank_name = bank_name @type = type @created = StarkCore::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#account_created ⇒ Object (readonly)
Returns the value of attribute account_created.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def account_created @account_created end |
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def account_number @account_number end |
#account_type ⇒ Object (readonly)
Returns the value of attribute account_type.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def account_type @account_type end |
#bank_code ⇒ Object (readonly)
Returns the value of attribute bank_code.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def bank_code @bank_code end |
#bank_name ⇒ Object (readonly)
Returns the value of attribute bank_name.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def bank_name @bank_name end |
#branch_code ⇒ Object (readonly)
Returns the value of attribute branch_code.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def branch_code @branch_code end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def name @name end |
#owned ⇒ Object (readonly)
Returns the value of attribute owned.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def owned @owned end |
#owner_type ⇒ Object (readonly)
Returns the value of attribute owner_type.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def owner_type @owner_type end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def @tags end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def tax_id @tax_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
37 38 39 |
# File 'lib/pix_key/pix_key.rb', line 37 def type @type end |
Class Method Details
.cancel(id, user: nil) ⇒ Object
# Cancel a PixKey entity
Cancel a PixKey entity previously created in the Stark Infra API
## Parameters (required):
-
id [string]: PixKey unique id. ex: ‘+5511989898989’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
canceled PixKey object
212 213 214 |
# File 'lib/pix_key/pix_key.rb', line 212 def self.cancel(id, user: nil) StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource) end |
.create(key, user: nil) ⇒ Object
# Create a PixKey
Create a PixKey linked to a specific account in the Stark Infra API
## Parameters (required):
-
key [PixKey object]: PixKey object to be created in the API
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
PixKey object with updated attributes
72 73 74 |
# File 'lib/pix_key/pix_key.rb', line 72 def self.create(key, user: nil) StarkInfra::Utils::Rest.post_single(entity: key, user: user, **resource) end |
.get(id, payer_id:, end_to_end_id: nil, user: nil) ⇒ Object
# Retrieve a specific PixKey
Receive a single PixKey object previously created in the Stark Infra API by passing its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘+5511989898989’
-
payer_id [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: ‘20.018.183/0001-80’.
## Parameters (optional):
-
end_to_end_id [string, default nil]: central bank’s unique transaction id. If the request results in the creation of a PixRequest, the same end_to_end_id should be used. If this parameter is not passed, one end_to_end_id will be automatically created. Example: ‘E00002649202201172211u34srod19le’
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
PixKey object with updated attributes
90 91 92 93 94 95 96 97 98 |
# File 'lib/pix_key/pix_key.rb', line 90 def self.get(id, payer_id:, end_to_end_id: nil, user: nil) StarkInfra::Utils::Rest.get_id( id: id, payer_id: payer_id, end_to_end_id: end_to_end_id, user: user, **resource ) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) ⇒ Object
# Retrieve paged PixKeys
Receive a list of up to 100 PixKey objects previously created in the Stark infra API and the cursor to the next page. Use this function instead of query if you want to manually page your keys.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call
-
limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘success’ or ‘failed’
-
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: [‘+5511989898989’, ‘+5511967676767’]
-
type [string, default nil]: filter for the type of retrieved PixKeys. Options: ‘cpf’, ‘cnpj’, ‘phone’, ‘email’ and ‘evp’
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of PixKey objects with updated attributes
-
cursor to retrieve the next page of PixKey objects
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/pix_key/pix_key.rb', line 151 def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, limit: limit, after: after, before: before, status: status, tags: , ids: ids, type: type, user: user, **resource ) end |
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) ⇒ Object
# Retrieve PixKeys
Receive a generator of PixKey objects previously created in the Stark Infra API
## Parameters (optional):
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘success’ or ‘failed’
-
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: [‘+5511989898989’, ‘+5511967676767’]
-
type [string, default nil]: filter for the type of retrieved PixKeys. Options: ‘cpf’, ‘cnpj’, ‘phone’, ‘email’ and ‘evp’
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
generator of PixKey objects with updated attributes
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/pix_key/pix_key.rb', line 116 def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( limit: limit, after: after, before: before, status: status, tags: , ids: ids, type: type, user: user, **resource ) end |
.resource ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/pix_key/pix_key.rb', line 216 def self.resource { resource_name: 'PixKey', resource_maker: proc { |json| PixKey.new( id: json['id'], account_created: json['account_created'], account_number: json['account_number'], account_type: json['account_type'], branch_code: json['branch_code'], name: json['name'], tax_id: json['tax_id'], tags: json['tags'], owned: json['owned'], owner_type: json['owner_type'], status: json['status'], bank_code: json['bank_code'], bank_name: json['bank_name'], type: json['type'], created: json['created'] ) } } end |
.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil) ⇒ Object
# Update a PixKey entity
Update a PixKey parameters by passing id.
## Parameters (required):
-
id [string]: PixKey unique id. ex: ‘+5511989898989’
-
reason [string]: reason why the PixKey is being patched. Options: ‘branchTransfer’, ‘reconciliation’ or ‘userRequested’.
## Parameters (optional):
-
account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: ‘2022-01-01’, Date.new(2020, 3, 10) or DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
account_number [string, default nil]: number of the account to be linked. ex: ‘76543’.
-
account_type [string, default nil]: type of the account to be linked. Options: ‘checking’, ‘savings’, ‘salary’ or ‘payment’.
-
branch_code [string, default nil]: branch code of the account to be linked. ex: 1234’.
-
name [string, default nil]: holder’s name of the account to be linked. ex: ‘Jamie Lannister’.
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
PixKey object with updated attributes
186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/pix_key/pix_key.rb', line 186 def self.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil) StarkInfra::Utils::Rest.patch_id( id: id, reason: reason, account_created: account_created, account_number: account_number, account_type: account_type, branch_code: branch_code, name: name, user: user, **resource ) end |