Class: Economic::Invoices::Repo

Inherits:
BaseRepo
  • Object
show all
Defined in:
lib/economic/invoices/repo.rb

Constant Summary

Constants inherited from BaseRepo

BaseRepo::URL

Class Method Summary collapse

Methods inherited from BaseRepo

destroy, endpoint_url, find, id_to_url_formatted_id, save, send_request, updated_after

Class Method Details

.all(filter_text: "") ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/economic/invoices/repo.rb', line 5

def all(filter_text: "")
  invoices = super(filter_text: filter_text)
  invoices.each do |invoice|
    invoice.remove_instance_variable("@lines")
    class << invoice
      define_method(:lines) { raise NoMethodError }
    end
  end
  invoices
end

.filter(filter_text) ⇒ Object



22
23
24
# File 'lib/economic/invoices/repo.rb', line 22

def filter(filter_text)
  all(filter_text: filter_text)
end

.send(model, url: endpoint_url) ⇒ Object



16
17
18
19
20
# File 'lib/economic/invoices/repo.rb', line 16

def send(model, url: endpoint_url)
  response = send_request(method: :post, url: url, payload: model.to_h.to_json)

  modelize_response(response)
end