class StarkBank::TaxPayment

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

## Parameters (required):

## Parameters (optional):

## Attributes (return-only):

Attributes

amount[R]
bar_code[R]
created[R]
description[R]
fee[R]
id[R]
line[R]
scheduled[R]
status[R]
tags[R]
type[R]
updated[R]

Public Class Methods

create(payments, user: nil) click to toggle source

# Create TaxPayments

Send a list of TaxPayment objects for creation in the Stark Bank API

## Parameters (required):

## Parameters (optional):

## Return:

  • list of TaxPayment objects with updated attributes

# File lib/tax_payment/tax_payment.rb, line 65
def self.create(payments, user: nil)
  StarkBank::Utils::Rest.post(entities: payments, user: user, **resource)
end
delete(id, user: nil) click to toggle source

# Delete a TaxPayment entity

Delete a TaxPayment entity previously created in the Stark Bank API

## Parameters (required):

## Parameters (optional):

## Return:

# File lib/tax_payment/tax_payment.rb, line 177
def self.delete(id, user: nil)
  StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
end
get(id, user: nil) click to toggle source

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

## Return:

# File lib/tax_payment/tax_payment.rb, line 81
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new( id: nil, line: nil, bar_code: nil, description:, tags: nil, scheduled: nil, status: nil, amount: nil, fee: nil, type: nil, updated: nil, created: nil ) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/tax_payment/tax_payment.rb, line 35
def initialize(
  id: nil, line: nil, bar_code: nil, description:, tags: nil, scheduled: nil, 
  status: nil, amount: nil, fee: nil, type: nil, updated: nil, created: nil
)
  super(id)
  @line = line
  @bar_code = bar_code
  @description = description
  @tags = tags
  @scheduled = StarkBank::Utils::Checks.check_date(scheduled)
  @status = status
  @amount = amount
  @fee = fee
  @type = type
  @updated = StarkBank::Utils::Checks.check_datetime(updated)
  @created = StarkBank::Utils::Checks.check_datetime(created)
end
page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) click to toggle source

# 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

# File lib/tax_payment/tax_payment.rb, line 149
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, 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,
    tags: tags,
    ids: ids,
    status: status,
    user: user,
    **resource
  )
end
pdf(id, user: nil) click to toggle source

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

## Return:

# File lib/tax_payment/tax_payment.rb, line 98
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) click to toggle source

# 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

# File lib/tax_payment/tax_payment.rb, line 117
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, 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,
    tags: tags,
    ids: ids,
    status: status,
    user: user,
    **resource
  )
end
resource() click to toggle source
# File lib/tax_payment/tax_payment.rb, line 181
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'],
        updated: json['updated'],
        created: json['created']
      )
    }
  }
end