Class: Myfinance::Resources::Category
- Defined in:
- lib/myfinance/resources/category.rb
Overview
A wrapper to Myfinance categories API
[API] Documentation: https://sandbox.myfinance.com.br/docs/api/categories
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(params) ⇒ Object
Creates a category.
-
#destroy(id) ⇒ Object
Destroy a category.
-
#find(id) ⇒ Object
Find a category.
-
#find_all(params = {}) ⇒ Object
List all categories.
-
#update(id, params = {}) ⇒ Object
Updates a category.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Myfinance::Resources::Base
Instance Method Details
#create(params) ⇒ Object
Creates a category
[API] Method: POST /categories
Documentation: https://sandbox.myfinance.com.br/docs/api/categories#post_create
48 49 50 51 52 |
# File 'lib/myfinance/resources/category.rb', line 48 def create(params) http.post("/categories", body: { category: params }) do |response| respond_with_object response, "category" end end |
#destroy(id) ⇒ Object
Destroy a category
[API] Method: DELETE /categories/:id
Documentation: https://sandbox.myfinance.com.br/docs/api/categories#delete_destroy
76 77 78 79 80 |
# File 'lib/myfinance/resources/category.rb', line 76 def destroy(id) http.delete("/categories/#{id}", body: {}) do |response| respond_with_object response, "category" end end |
#find(id) ⇒ Object
Find a category
[API] Method: GET /categories/:id
Documentation: https://sandbox.myfinance.com.br/docs/api/categories#get_show
34 35 36 37 38 |
# File 'lib/myfinance/resources/category.rb', line 34 def find(id) http.get("/categories/#{id}", body: {}) do |response| respond_with_object response, "category" end end |
#find_all(params = {}) ⇒ Object
List all categories
[API] Method: GET /categories
Documentation: https://sandbox.myfinance.com.br/docs/api/categories#get_index
18 19 20 21 22 23 24 |
# File 'lib/myfinance/resources/category.rb', line 18 def find_all(params = {}) search_endpoint = build_search_endpoint(params) http.get(search_endpoint) do |response| respond_with_collection(response) end end |
#update(id, params = {}) ⇒ Object
Updates a category
[API] Method: PUT /categories/:id
Documentation: https://sandbox.myfinance.com.br/docs/api/categories#put_update
62 63 64 65 66 |
# File 'lib/myfinance/resources/category.rb', line 62 def update(id, params = {}) http.put("/categories/#{id}", body: { category: params }) do |response| respond_with_object response, "category" end end |