class StarkBank::DarfPayment::Log

# DarfPayment::Log object

Every time a DarfPayment entity is updated, a corresponding DarfPayment::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 DarfPayment.

## Attributes:

Attributes

created[R]
errors[R]
id[R]
payment[R]
type[R]

Public Class Methods

get(id, user: nil) click to toggle source

# 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):

## Return:

  • Log object with updated attributes

# File lib/darf_payment/log.rb, line 45
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new(id:, created:, type:, errors:, payment:) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/darf_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
page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil) click to toggle source

# 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 or Project object. Not necessary if Starkbank.user was set before function call

## Return:

  • list of Log objects with updated attributes and cursor to retrieve the next page of Log objects

# File lib/darf_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
query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil) click to toggle source

# 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 or Project object. Not necessary if Starkbank.user was set before function call

## Return:

  • list of Log objects with updated attributes

# File lib/darf_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
resource() click to toggle source
# File lib/darf_payment/log.rb, line 108
def self.resource
  darf_payment_maker = StarkBank::DarfPayment.resource[:resource_maker]
  {
    resource_name: 'DarfPaymentLog',
    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(darf_payment_maker, json['payment'])
      )
    }
  }
end