Class: StarkInfra::StaticBrcode
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::StaticBrcode
- Defined in:
- lib/static_brcode/static_brcode.rb
Overview
# StaticBrcode object
A StaticBrcode stores account information in the form of a PixKey and can be used to create Pix transactions easily.
When you initialize a StaticBrcode, 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):
-
name [string]: receiver’s name. ex: ‘Tony Stark’
-
key_id [string]: receiver’s Pixkey id. ex: ‘+5541999999999’
-
city [string, default São Paulo]: receiver’s city name. ex: ‘Rio de Janeiro’
## Parameters (optional):
-
amount [integer, default nil]: positive integer that represents the amount in cents of the resulting Pix transaction. If the amount is zero, the sender can choose any amount in the moment of payment. ex: 1234 (= R$ 12.34)
-
cashier_bank_code [string, default None]: Cashier’s bank code. ex: “20018183”.
-
reconciliation_id [string, default nil]: id to be used for conciliation of the resulting Pix transaction. This id must have up to 25 alphanumeric digits ex: ‘ah27s53agj6493hjds6836v49’
-
description [string, default None]: optional description to override default description to be shown in the bank statement. ex: “Payment for service #1234”
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
## Attributes (return-only):
-
id [string]: id returned on creation, this is the BR Code. ex: ‘00020126360014br.gov.bcb.pix0114+552840092118152040000530398654040.095802BR5915Jamie Lannister6009Sao Paulo620705038566304FC6C’
-
uuid [string]: unique uuid returned when a StaticBrcode is created. ex: ‘97756273400d42ce9086404fe10ea0d6’
-
url [string]: url link to the BR Code image. ex: ‘
’ -
created [DateTime]: creation datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
updated [DateTime]: latest update datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#cashier_bank_code ⇒ Object
readonly
Returns the value of attribute cashier_bank_code.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reconciliation_id ⇒ Object
readonly
Returns the value of attribute reconciliation_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
-
.create(brcodes, user: nil) ⇒ Object
# Create StaticBrcodes.
-
.get(uuid, user: nil) ⇒ Object
# Retrieve a specific StaticBrcode.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: nil, user: nil) ⇒ Object
# Retrieve StaticBrcodes.
-
.query(limit: nil, after: nil, before: nil, uuids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve StaticBrcodes.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags: nil, uuid: nil, url: nil, created: nil, updated: nil) ⇒ StaticBrcode
constructor
A new instance of StaticBrcode.
Constructor Details
#initialize(name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags: nil, uuid: nil, url: nil, created: nil, updated: nil) ⇒ StaticBrcode
Returns a new instance of StaticBrcode.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/static_brcode/static_brcode.rb', line 37 def initialize( name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags:nil, uuid: nil, url: nil, created: nil, updated: nil ) super(id) @name = name @key_id = key_id @city = city @amount = amount @reconciliation_id = reconciliation_id @cashier_bank_code = cashier_bank_code @description = description @tags = @uuid = uuid @url = url @created = StarkCore::Utils::Checks.check_datetime(created) @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def amount @amount end |
#cashier_bank_code ⇒ Object (readonly)
Returns the value of attribute cashier_bank_code.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def cashier_bank_code @cashier_bank_code end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def city @city end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def created @created end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def id @id end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def key_id @key_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def name @name end |
#reconciliation_id ⇒ Object (readonly)
Returns the value of attribute reconciliation_id.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def reconciliation_id @reconciliation_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def @tags end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def updated @updated end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def url @url end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
36 37 38 |
# File 'lib/static_brcode/static_brcode.rb', line 36 def uuid @uuid end |
Class Method Details
.create(brcodes, user: nil) ⇒ Object
# Create StaticBrcodes
Send a list of StaticBrcode objects for creation at the Stark Infra API
## Parameters (required):
-
brcodes [list of StaticBrcode objects]: list of StaticBrcode objects 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:
-
list of StaticBrcode objects with updated attributes
67 68 69 |
# File 'lib/static_brcode/static_brcode.rb', line 67 def self.create(brcodes, user: nil) StarkInfra::Utils::Rest.post(entities: brcodes, user: user, **resource) end |
.get(uuid, user: nil) ⇒ Object
# Retrieve a specific StaticBrcode
Receive a single StaticBrcode object previously created in the Stark Infra API by its uuid
## Parameters (required):
-
uuid [string]: object’s unique uuid. ex: ‘97756273400d42ce9086404fe10ea0d6’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
StaticBrcode object with updated attributes
83 84 85 |
# File 'lib/static_brcode/static_brcode.rb', line 83 def self.get(uuid, user: nil) StarkInfra::Utils::Rest.get_id(id: uuid, user: user, **resource) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: nil, user: nil) ⇒ Object
# Retrieve StaticBrcodes
Receive a list of StaticBrcode objects previously created in the Stark Infra API and the cursor to the next page.
## 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 only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
uuids [list of strings, default nil]: list of uuids to filter retrieved objects. ex: [‘901e71f2447c43c886f58366a5432c4b’, ‘4e2eab725ddd495f9c98ffd97440702d’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of StaticBrcode objects with updated attributes
-
cursor to retrieve the next page of StaticBrcode objects
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/static_brcode/static_brcode.rb', line 131 def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: 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, uuids: uuids, tags: , user: user, **resource ) end |
.query(limit: nil, after: nil, before: nil, uuids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve StaticBrcodes
Receive a generator of StaticBrcode 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 only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
uuids [list of strings, default nil]: list of uuids to filter retrieved objects. ex: [‘901e71f2447c43c886f58366a5432c4b’, ‘4e2eab725ddd495f9c98ffd97440702d’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
generator of StaticBrcode objects with updated attributes
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/static_brcode/static_brcode.rb', line 101 def self.query(limit: nil, after: nil, before: nil, uuids: nil, tags: 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, uuids: uuids, tags: , user: user, **resource ) end |
.resource ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/static_brcode/static_brcode.rb', line 146 def self.resource { resource_name: 'StaticBrcode', resource_maker: proc { |json| StaticBrcode.new( id: json['id'], name: json['name'], key_id: json['key_id'], city: json['city'], amount: json['amount'], reconciliation_id: json['reconciliation_id'], cashier_bank_code: json['cashier_bank_code'], description: json['description'], tags: json['tags'], uuid: json['uuid'], url: json['url'], created: json['created'], updated: json['updated'] ) } } end |