Class: StarkBank::TaxPayment
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkBank::TaxPayment
- Defined in:
- lib/tax_payment/tax_payment.rb,
lib/tax_payment/log.rb
Overview
# TaxPayment object
When you initialize a TaxPayment, the entity will not be automatically created in the Stark Bank API. The ‘create’ function sends the objects to the Stark Bank API and returns the list of created objects.
## Parameters (conditionally required):
-
line [string, default nil]: Number sequence that describes the payment. Either ‘line’ or ‘bar_code’ parameters are required. If both are sent, they must match. ex: ‘85800000003 0 28960328203 1 56072020190 5 22109674804 0’
-
bar_code [string, default nil]: Bar code number that describes the payment. Either ‘line’ or ‘barCode’ parameters are required. If both are sent, they must match. ex: ‘83660000001084301380074119002551100010601813’
## Parameters (required):
-
description [string]: Text to be displayed in your statement (min. 10 characters). ex: ‘payment ABC’
## Parameters (optional):
-
scheduled [Date, DateTime, Time or string, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
-
tags [list of strings, default nil]: list of strings for tagging
## Attributes (return-only):
-
id [string]: unique id returned when payment is created. ex: ‘5656565656565656’
-
type [string]: tax type. ex: ‘das’
-
status [string]: current payment status. ex: ‘success’ or ‘failed’
-
amount [int]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
-
fee [integer]: fee charged when tax payment is created. ex: 200 (= R$ 2.00)
-
transaction_ids [list of strings]: ledger transaction ids linked to this TaxPayment. ex: [“19827356981273”]
-
created [DateTime]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
updated [DateTime]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#bar_code ⇒ Object
readonly
Returns the value of attribute bar_code.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#fee ⇒ Object
readonly
Returns the value of attribute fee.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#scheduled ⇒ Object
readonly
Returns the value of attribute scheduled.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#transaction_ids ⇒ Object
readonly
Returns the value of attribute transaction_ids.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.create(payments, user: nil) ⇒ Object
# Create TaxPayments.
-
.delete(id, user: nil) ⇒ Object
# Delete a TaxPayment entity.
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific TaxPayment.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve paged Tax Payments.
-
.pdf(id, user: nil) ⇒ Object
# Retrieve a specific TaxPayment pdf file.
-
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve TaxPayments.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id: nil, line: nil, bar_code: nil, description:, tags: nil, scheduled: nil, status: nil, amount: nil, fee: nil, transaction_ids: nil, type: nil, updated: nil, created: nil) ⇒ TaxPayment
constructor
A new instance of TaxPayment.
Constructor Details
#initialize(id: nil, line: nil, bar_code: nil, description:, tags: nil, scheduled: nil, status: nil, amount: nil, fee: nil, transaction_ids: nil, type: nil, updated: nil, created: nil) ⇒ TaxPayment
Returns a new instance of TaxPayment.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tax_payment/tax_payment.rb', line 36 def initialize( id: nil, line: nil, bar_code: nil, description:, tags: nil, scheduled: nil, status: nil, amount: nil, fee: nil, transaction_ids: nil, type: nil, updated: nil, created: nil ) super(id) @line = line @bar_code = @description = description @tags = @scheduled = StarkCore::Utils::Checks.check_date(scheduled) @status = status @amount = amount @fee = fee @type = type @transaction_ids = transaction_ids @updated = StarkCore::Utils::Checks.check_datetime(updated) @created = StarkCore::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def amount @amount end |
#bar_code ⇒ Object (readonly)
Returns the value of attribute bar_code.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def @bar_code end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def created @created end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def description @description end |
#fee ⇒ Object (readonly)
Returns the value of attribute fee.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def fee @fee end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def id @id end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def line @line end |
#scheduled ⇒ Object (readonly)
Returns the value of attribute scheduled.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def scheduled @scheduled end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def @tags end |
#transaction_ids ⇒ Object (readonly)
Returns the value of attribute transaction_ids.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def transaction_ids @transaction_ids end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def type @type end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
35 36 37 |
# File 'lib/tax_payment/tax_payment.rb', line 35 def updated @updated end |
Class Method Details
.create(payments, user: nil) ⇒ Object
# Create TaxPayments
Send a list of TaxPayment objects for creation in the Stark Bank API
## Parameters (required):
-
payments [list of TaxPayment objects]: list of TaxPayment objects to be created in the API
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
list of TaxPayment objects with updated attributes
67 68 69 |
# File 'lib/tax_payment/tax_payment.rb', line 67 def self.create(payments, user: nil) StarkBank::Utils::Rest.post(entities: payments, user: user, **resource) end |
.delete(id, user: nil) ⇒ Object
# Delete a TaxPayment entity
Delete a TaxPayment entity previously created in the Stark Bank API
## Parameters (required):
-
id [string]: UtilityPayment unique id. ex:‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
deleted TaxPayment object
179 180 181 |
# File 'lib/tax_payment/tax_payment.rb', line 179 def self.delete(id, user: nil) StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource) end |
.get(id, user: nil) ⇒ Object
# Retrieve a specific TaxPayment
Receive a single TaxPayment object previously created by the Stark Bank API by passing its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
TaxPayment object with updated attributes
83 84 85 |
# File 'lib/tax_payment/tax_payment.rb', line 83 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve paged Tax Payments
Receive a list of up to 100 Tax Payment 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
-
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)
-
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: [‘5656565656565656’, ‘4545454545454545’]
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘paid’ or ‘registered’
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
list of Tax Payment objects with updated attributes and cursor to retrieve the next page of Tax Payment objects
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/tax_payment/tax_payment.rb', line 151 def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: 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, after: after, before: before, tags: , ids: ids, status: status, user: user, **resource ) end |
.pdf(id, user: nil) ⇒ Object
# Retrieve a specific TaxPayment pdf file
Receive a single TaxPayment pdf file generated in the Stark Bank API by passing its id. Only valid for tax payments with ‘success’ status.
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
TaxPayment pdf file
100 101 102 |
# File 'lib/tax_payment/tax_payment.rb', line 100 def self.pdf(id, user: nil) StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource) end |
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object
# Retrieve TaxPayments
Receive a generator of TaxPayment 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
-
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)
-
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: [‘5656565656565656’, ‘4545454545454545’]
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘paid’ or ‘registered’
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
generator of TaxPayment objects with updated attributes
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/tax_payment/tax_payment.rb', line 119 def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_stream( limit: limit, after: after, before: before, tags: , ids: ids, status: status, user: user, **resource ) end |
.resource ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/tax_payment/tax_payment.rb', line 183 def self.resource { resource_name: 'TaxPayment', resource_maker: proc { |json| TaxPayment.new( id: json['id'], line: json['line'], bar_code: json['bar_code'], description: json['description'], tags: json['tags'], scheduled: json['scheduled'], status: json['status'], amount: json['amount'], fee: json['fee'], type: json['type'], transaction_ids: json['transaction_ids'], updated: json['updated'], created: json['created'] ) } } end |