Class: Myfinance::Resources::Sale

Inherits:
Base
  • Object
show all
Defined in:
lib/myfinance/resources/sale.rb

Instance Attribute Summary

Attributes inherited from Base

#http

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Myfinance::Resources::Base

Instance Method Details

#create(entity_id, params = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/myfinance/resources/sale.rb', line 17

def create(entity_id, params = {})
  path = "/entities/#{entity_id}/sales/"
  http.post(path, body: { sale: params }) do |response|
    respond_with_object(response, "sale")
  end
end

#destroy(entity_id, sale_id, params = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/myfinance/resources/sale.rb', line 31

def destroy(entity_id, sale_id, params = {})
  path = "/entities/#{entity_id}/sales/#{sale_id}"
  http.delete(path, body: { sale: params }) do |response|
    response
  end
end

#find(entity_id, sale_id) ⇒ Object



10
11
12
13
14
15
# File 'lib/myfinance/resources/sale.rb', line 10

def find(entity_id, sale_id)
  path = "/entities/#{entity_id}/sales/#{sale_id}"
  http.get(path, body: {}) do |response|
    respond_with_object(response, "sale")
  end
end

#find_all(entity_id) ⇒ Object



4
5
6
7
8
# File 'lib/myfinance/resources/sale.rb', line 4

def find_all(entity_id)
  http.get("/entities/#{entity_id}/sales", body: {}) do |response|
    respond_with_collection(response)
  end
end

#update(entity_id, sale_id, params = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/myfinance/resources/sale.rb', line 24

def update(entity_id, sale_id, params = {})
  path = "/entities/#{entity_id}/sales/#{sale_id}"
  http.put(path, body: { sale: params }) do |response|
    respond_with_object(response, "sale")
  end
end