class StarkBank::DarfPayment

# DarfPayment object

When you initialize a DarfPayment, 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 (required):

## Parameters (optional):

## Attributes (return-only):

Attributes

amount[R]
competence[R]
created[R]
description[R]
due[R]
fee[R]
fine_amount[R]
id[R]
interest_amount[R]
nominal_amount[R]
reference_number[R]
revenue_code[R]
scheduled[R]
status[R]
tags[R]
tax_id[R]
updated[R]

Public Class Methods

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

# Create DarfPayments

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

## Parameters (required):

## Parameters (optional):

## Return:

# File lib/darf_payment/darf_payment.rb, line 75
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 DarfPayment entity

Delete a DarfPayment entity previously created in the Stark Bank API

## Parameters (required):

## Parameters (optional):

## Return:

# File lib/darf_payment/darf_payment.rb, line 187
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 DarfPayment

Receive a single DarfPayment 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/darf_payment/darf_payment.rb, line 91
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new( id: nil, revenue_code:, tax_id:, competence:, reference_number:, fine_amount:, interest_amount:, due:, description: nil, tags: nil, scheduled: nil, status: nil, amount: nil, nominal_amount: nil, fee: nil, updated: nil, created: nil ) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/darf_payment/darf_payment.rb, line 40
def initialize(
    id: nil, revenue_code:, tax_id:, competence:, reference_number:, fine_amount:, interest_amount:, due:, description: nil, 
    tags: nil, scheduled: nil, status: nil, amount: nil, nominal_amount: nil, fee: nil, updated: nil, created: nil
)
  super(id)
  @revenue_code = revenue_code
  @tax_id = tax_id
  @competence = StarkBank::Utils::Checks.check_date(competence)
  @reference_number = reference_number
  @fine_amount = fine_amount
  @interest_amount = interest_amount
  @due = StarkBank::Utils::Checks.check_date(due)
  @description = description
  @tags = tags
  @scheduled = StarkBank::Utils::Checks.check_date(scheduled)
  @status = status
  @amount = amount
  @nominal_amount = nominal_amount
  @fee = fee
  @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 Darf Payments

Receive a list of up to 100 Darf 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 Darf Payment objects with updated attributes and cursor to retrieve the next page of Darf Payment objects

# File lib/darf_payment/darf_payment.rb, line 159
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 DarfPayment pdf file

Receive a single DarfPayment pdf file generated in the Stark Bank API by passing its id. Only valid for darf payments with 'success' status.

## Parameters (required):

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

## Parameters (optional):

## Return:

# File lib/darf_payment/darf_payment.rb, line 108
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 DarfPayments

Receive a generator of DarfPayment 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 DarfPayment objects with updated attributes

# File lib/darf_payment/darf_payment.rb, line 127
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/darf_payment/darf_payment.rb, line 191
def self.resource
  {
    resource_name: 'DarfPayment',
    resource_maker: proc { |json|
      DarfPayment.new(
        id: json['id'],
        revenue_code: json['revenue_code'],
        tax_id: json['tax_id'],
        competence: json['competence'],
        reference_number: json['reference_number'],
        fine_amount: json['fine_amount'],
        interest_amount: json['interest_amount'],
        due: json['due'],
        description: json['description'],
        tags: json['tags'],
        scheduled: json['scheduled'],
        status: json['status'],
        amount: json['amount'],
        nominal_amount: json['nominal_amount'],
        fee: json['fee'],
        updated: json['updated'],
        created: json['created'],          
      )
    }
  }
end