class Recras::Invoice

links to 'arrangement_regels' in the API recras.github.io/docs/endpoints/facturen.html

Attributes

customer_id[RW]
id[RW]

@note The is a required parameter.

message[RW]
payment_url[RW]
status[RW]

Public Class Methods

attribute_mapping() click to toggle source

translates the mapping between the Recras API and the terms used in this gem

# File lib/recras/invoice.rb, line 27
def self.attribute_mapping
  [
    ["id", "id"],
    ["status", "status"]
  ]
end
new(args=nil) click to toggle source

Initializer to transform a Hash into an Client object

@param [Hash] args

# File lib/recras/invoice.rb, line 17
def initialize(args=nil)
  required_args = []
  return if args.nil?
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Public Instance Methods

make_payment(status: "concept", comment: "", payment_method_id: nil, amount: 0.0) click to toggle source
# File lib/recras/invoice.rb, line 35
def make_payment(status: "concept", comment: "", payment_method_id: nil, amount: 0.0)
  body_data = {
    factuur_id: id,
    betaalmethode_id: payment_method_id,
    bedrag: amount
  }
  json = client.make_request("facturen/#{id}/betalingen", body: body_data.to_json, http_method: :post)
  if json.is_a?(Hash) && json["error"]
    raise RecrasError.new(self), json["error"]["message"]
  else
    payment = Recras.parse_json(json: json, endpoint: "betalingen")
    return payment
  end

end