Class: Economic::Orders::Repo

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

Direct Known Subclasses

ArchivedRepo, DraftsRepo, SentRepo

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/orders/repo.rb', line 5

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

.filter(filter_text) ⇒ Object



22
23
24
# File 'lib/economic/orders/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/orders/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