Sha256: 96c7d66d16c1cc0fc9eda977ce19d2bc33c128bc12fd69c196d964b38a41bed5

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

module Billogram
  class Invoice < Resource
    endpoint 'billogram'

    attr_accessor :id, :invoice_no, :ocr_number, :invoice_date, :due_date, :due_days, 
                  :invoice_fee, :invoice_fee_vat, :reminder_fee, :interest_rate,
                  :interest_fee, :currency, :delivery_method, :state, :url, :flags,
                  :remaining_sum, :total_sum, :rounding_value, :automatic_reminders,
                  :reminder_count, :created_at, :attested_at, :updated_at, :detailed_sums,
                  :attachment

    relation :info, :one
    relation :customer, :one
    relation :regional_sweden, :one
    relation :callbacks, :one
    relation :detailed_sums, :one

    relation :items, :many
    relation :events, :many

    def sell
      perform_request(command_path(:sell), :post)
    end

    def collect
      perform_request(command_path(:collect), :post)
    end

    def writeoff
      perform_request(command_path(:writeoff), :post)
    end

    def send!(method: )
      perform_request(command_path(:send), :post, {method: method})
    end

    def resend(method: )
      perform_request(command_path(:resend), :post, {method: method})
    end

    def remind(method: )
      perform_request(command_path(:remind), :post, {method: method})
    end

    def payment(amount: )
      perform_request(command_path(:payment), :post, {amount: amount})
    end

    def credit(options = {})
      perform_request(command_path(:credit), :post, options)
    end

    def message(message: )
      perform_request(command_path(:message), :post, {message: message})
    end

    def attach(options = {})
      perform_request(command_path(:attach), :post, options)
    end

    private

    def command_path(command)
      "#{endpoint}/#{id}/command/#{command}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
billogram-0.3.6 lib/billogram/resources/invoice.rb
billogram-0.3.5 lib/billogram/resources/invoice.rb