class StarkBank::Boleto

# Boleto object

When you initialize a Boleto, the entity will not be automatically sent to the Stark Bank API. The 'create' function sends the objects to the Stark Bank API and returns the list of created objects.

## Parameters (required):

## Parameters (optional):

## Attributes (return-only):

Attributes

amount[R]
bar_code[R]
city[R]
created[R]
descriptions[R]
discounts[R]
district[R]
due[R]
fee[R]
fine[R]
id[R]
interest[R]
line[R]
name[R]
our_number[R]
overdue_limit[R]
receiver_name[R]
receiver_tax_id[R]
state_code[R]
status[R]
street_line_1[R]
street_line_2[R]
tags[R]
tax_id[R]
transaction_ids[R]
zip_code[R]

Public Class Methods

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

# Create Boletos

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

## Parameters (required):

  • boletos [list of Boleto objects]: list of Boleto objects to be created in the API

## Parameters (optional):

## Return:

  • list of Boleto objects with updated attributes

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

# Delete a Boleto entity

Delete a Boleto entity previously created in the Stark Bank API

## Parameters (required):

  • id [string]: Boleto unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

# File lib/boleto/boleto.rb, line 206
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 Boleto

Receive a single Boleto object previously created in the Stark Bank API by passing its id

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

  • Boleto object with updated attributes

# File lib/boleto/boleto.rb, line 109
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new( amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:, due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil, tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil, status: nil, transaction_ids: nil, created: nil, our_number: nil ) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/boleto/boleto.rb, line 47
def initialize(
  amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
  due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil,
  tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil,
  status: nil, transaction_ids: nil, created: nil, our_number: nil
)
  super(id)
  @amount = amount
  @name = name
  @tax_id = tax_id
  @street_line_1 = street_line_1
  @street_line_2 = street_line_2
  @district = district
  @city = city
  @state_code = state_code
  @zip_code = zip_code
  @due = StarkBank::Utils::Checks.check_date(due)
  @fine = fine
  @interest = interest
  @overdue_limit = overdue_limit
  @receiver_name = receiver_name
  @receiver_tax_id = receiver_tax_id
  @tags = tags
  @descriptions = descriptions
  @discounts = discounts
  @fee = fee
  @line = line
  @bar_code = bar_code
  @status = status
  @transaction_ids = transaction_ids
  @created = StarkBank::Utils::Checks.check_datetime(created)
  @our_number = our_number
end
page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) click to toggle source

# Retrieve paged Boletos

Receive a list of up to 100 Boleto 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)

  • status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'

  • 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']

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

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

# File lib/boleto/boleto.rb, line 178
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,
    status: status,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end
pdf(id, layout: nil, hidden_fields: nil, user: nil) click to toggle source

# Retrieve a specific Boleto pdf file

Receive a single Boleto pdf file generated in the Stark Bank API by passing its id.

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

  • layout [string]: Layout specification. Available options are 'default' and 'booklet'

  • hidden_fields [list of strings, default nil]: List of string fields to be hidden in Boleto pdf. ex: ['customerAddress']

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

# File lib/boleto/boleto.rb, line 127
def self.pdf(id, layout: nil, hidden_fields: nil, user: nil)
  StarkBank::Utils::Rest.get_content(id: id, layout: layout, hidden_fields: hidden_fields, sub_resource_name: 'pdf', user: user, **resource)
end
query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) click to toggle source

# Retrieve Boletos

Receive a generator of Boleto 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)

  • status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'

  • 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']

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

  • generator of Boleto objects with updated attributes

# File lib/boleto/boleto.rb, line 146
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,
    status: status,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end
resource() click to toggle source
# File lib/boleto/boleto.rb, line 210
def self.resource
  {
    resource_name: 'Boleto',
    resource_maker: proc { |json|
      Boleto.new(
        amount: json['amount'],
        name: json['name'],
        tax_id: json['tax_id'],
        street_line_1: json['street_line_1'],
        street_line_2: json['street_line_2'],
        district: json['district'],
        city: json['city'],
        state_code: json['state_code'],
        zip_code: json['zip_code'],
        due: json['due'],
        fine: json['fine'],
        interest: json['interest'],
        overdue_limit: json['overdue_limit'],
        receiver_name: json['receiver_name'],
        receiver_tax_id: json['receiver_tax_id'],
        tags: json['tags'],
        descriptions: json['descriptions'],
        discounts: json['discounts'],
        id: json['id'],
        fee: json['fee'],
        line: json['line'],
        bar_code: json['bar_code'],
        status: json['status'],
        transaction_ids: json['transaction_ids'],
        created: json['created'],
        our_number: json['our_number']
      )
    }
  }
end