Class: StarkInfra::IssuingInvoice
- Inherits:
-
Utils::Resource
- Object
- Utils::SubResource
- Utils::Resource
- StarkInfra::IssuingInvoice
- Defined in:
- lib/issuinginvoice/issuinginvoice.rb,
lib/issuinginvoice/log.rb
Overview
# IssuingInvoice object
The IssuingInvoice objects created in your Workspace load your Issuing balance when paid.
## Parameters (required):
-
amount [integer]: IssuingInvoice value in cents. ex: 1234 (= R$ 12.34)
## Parameters (optional):
-
tax_id [string, default sub-issuer tax ID]: payer tax ID (CPF or CNPJ) with or without formatting. ex: ‘01234567890’ or ‘20.018.183/0001-80’
-
name [string, default sub-issuer name]: payer name. ex: ‘Iron Bank S.A.’
-
tags [list of strings, default []]: list of strings for tagging. ex: [‘travel’, ‘food’]
## Attributes (return-only):
-
id [string]: unique id returned when IssuingInvoice is created. ex: ‘5656565656565656’
-
status [string]: current IssuingInvoice status. ex: ‘created’, ‘expired’, ‘overdue’, ‘paid’
-
issuing_transaction_id [string]: ledger transaction ids linked to this IssuingInvoice. ex: ‘issuing-invoice/5656565656565656’
-
updated [DateTime]: latest update datetime for the IssuingInvoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
created [DateTime]: creation datetime for the IssuingInvoice. 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.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#issuing_transaction_id ⇒ Object
readonly
Returns the value of attribute issuing_transaction_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#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.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.create(invoice, user: nil) ⇒ Object
# Create an IssuingInvoice.
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingInvoice.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged IssuingInvoices.
-
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) ⇒ Object
# Retrieve IssuingInvoices.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(amount:, id: nil, name: nil, tax_id: nil, status: nil, issuing_transaction_id: nil, tags: nil, updated: nil, created: nil) ⇒ IssuingInvoice
constructor
A new instance of IssuingInvoice.
Methods inherited from Utils::SubResource
Constructor Details
#initialize(amount:, id: nil, name: nil, tax_id: nil, status: nil, issuing_transaction_id: nil, tags: nil, updated: nil, created: nil) ⇒ IssuingInvoice
Returns a new instance of IssuingInvoice.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 28 def initialize( amount:, id: nil, name: nil, tax_id: nil, status: nil, issuing_transaction_id: nil, tags: nil, updated: nil, created: nil ) super(id) @amount = amount @name = name @tax_id = tax_id @status = status @issuing_transaction_id = issuing_transaction_id @tags = @created = StarkInfra::Utils::Checks.check_datetime(created) @updated = StarkInfra::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def amount @amount end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def id @id end |
#issuing_transaction_id ⇒ Object (readonly)
Returns the value of attribute issuing_transaction_id.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def issuing_transaction_id @issuing_transaction_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def @tags end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def tax_id @tax_id end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
27 28 29 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 27 def updated @updated end |
Class Method Details
.create(invoice, user: nil) ⇒ Object
# Create an IssuingInvoice
Send a single IssuingInvoice object for creation in the Stark Infra API
## Parameters (required):
-
invoice [IssuingInvoice object]: IssuingInvoice 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:
-
IssuingInvoice object with updated attributes
54 55 56 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 54 def self.create(invoice, user: nil) StarkInfra::Utils::Rest.post_single(entity: invoice, user: user, **resource) end |
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingInvoice
Receive a single IssuingInvoice object previously created in the Stark Infra API by 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 StarkInfra.user was set before function call
## Return:
-
IssuingInvoice object with updated attributes
70 71 72 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 70 def self.get(id, user: nil) StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged IssuingInvoices
Receive a list of IssuingInvoices 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)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [‘created’, ‘expired’, ‘overdue’, ‘paid’]
-
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 IssuingInvoice objects with updated attributes
-
cursor to retrieve the next page of IssuingInvoice objects
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 118 def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, limit: limit, after: after, before: before, status: status, tags: , user: user, **resource ) end |
.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) ⇒ Object
# Retrieve IssuingInvoices
Receive a generator of IssuingInvoices 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)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [‘created’, ‘expired’, ‘overdue’, ‘paid’]
-
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 IssuingInvoices objects with updated attributes
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 88 def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( limit: limit, after: after, before: before, status: status, tags: , user: user, **resource ) end |
.resource ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/issuinginvoice/issuinginvoice.rb', line 133 def self.resource { resource_name: 'IssuingInvoice', resource_maker: proc { |json| IssuingInvoice.new( id: json['id'], amount: json['amount'], name: json['name'], tax_id: json['tax_id'], status: json['status'], issuing_transaction_id: json['issuing_transaction_id'], tags: json['tags'], updated: json['updated'], created: json['created'] ) } } end |