class StarkBank::TaxPayment::Log
# TaxPayment::Log
object
Every time a TaxPayment
entity is updated, a corresponding TaxPayment::Log
is generated for the entity. This log is never generated by the user, but it can be retrieved to check additional information on the TaxPayment
.
## Attributes:
-
id [string]: unique id returned when the log is created. ex: '5656565656565656'
-
payment [TaxPayment]:
TaxPayment
entity to which the log refers to. -
errors [list of strings]: list of errors linked to this
TaxPayment
event -
type [string]: type of the
TaxPayment
event which triggered the log creation. ex: 'canceled' or 'paid' -
created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Attributes
Public Class Methods
# Retrieve a specific Log
Receive a single Log
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
orProject
object. Not necessary ifStarkBank.user
was set before function call
## Return:
-
Log
object with updated attributes
# File lib/tax_payment/log.rb, line 45 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end
StarkBank::Utils::Resource::new
# File lib/tax_payment/log.rb, line 25 def initialize(id:, created:, type:, errors:, payment:) super(id) @type = type @errors = errors @payment = payment @created = StarkBank::Utils::Checks.check_datetime(created) end
# Retrieve paged Logs
Receive a list of up to 100 Log
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)
-
types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
-
payment_ids [list of strings, default nil]: list of
TaxPayment
ids to filter logs. ex: ['5656565656565656', '4545454545454545'] -
user [Organization/Project object, default nil]:
Organization
orProject
object. Not necessary if Starkbank.user was set before function call
## Return:
# File lib/tax_payment/log.rb, line 93 def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil) after = StarkBank::Utils::Checks.check_date(after) before = StarkBank::Utils::Checks.check_date(before) return StarkBank::Utils::Rest.get_page( cursor: cursor, limit: limit, after: after, before: before, types: types, payment_ids: payment_ids, user: user, **resource ) end
# Retrieve Logs
Receive a generator of Log
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)
-
types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
-
payment_ids [list of strings, default nil]: list of
TaxPayment
ids to filter logs. ex: ['5656565656565656', '4545454545454545'] -
user [Organization/Project object, default nil]:
Organization
orProject
object. Not necessary if Starkbank.user was set before function call
## Return:
-
list of
Log
objects with updated attributes
# File lib/tax_payment/log.rb, line 63 def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil) after = StarkBank::Utils::Checks.check_date(after) before = StarkBank::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_stream( limit: limit, after: after, before: before, types: types, payment_ids: payment_ids, user: user, **resource ) end
# File lib/tax_payment/log.rb, line 108 def self.resource tax_payment_maker = StarkBank::TaxPayment.resource[:resource_maker] { resource_name: 'TaxPaymentLog', resource_maker: proc { |json| Log.new( id: json['id'], created: json['created'], type: json['type'], errors: json['errors'], payment: StarkBank::Utils::API.from_api_json(tax_payment_maker, json['payment']) ) } } end