Class: Myfinance::Resources::ClassificationCenter

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

Overview

A wrapper to Myfinance classification center API

[API] Documentation: https://app.myfinance.com.br/docs/api/classification_centers

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(params) ⇒ Object

Creates a classification center

[API] Method: POST /classification_centers

Documentation: https://app.myfinance.com.br/docs/api/classification_centers#post_create


47
48
49
50
51
52
53
# File 'lib/myfinance/resources/classification_center.rb', line 47

def create(params)
  http.post(
    "/classification_centers", body: { classification_center: params }
  ) do |response|
    respond_with_object response, "classification_center"
  end
end

#destroy(id) ⇒ Object

Destroy a classification center

[API] Method: DELETE /classification_centers/:id

Documentation: https://app.myfinance.com.br/docs/api/classification_centers#delete_destroy


80
81
82
83
84
# File 'lib/myfinance/resources/classification_center.rb', line 80

def destroy(id)
  http.delete("/classification_centers/#{id}", body: {}) do |response|
    respond_with_object response, "classification_center"
  end
end

#find(id) ⇒ Object

Show a classification center

[API] Method: GET /classification_centers/:id

Documentation: https://app.myfinance.com.br/docs/api/classification_centers#get_show


34
35
36
37
38
# File 'lib/myfinance/resources/classification_center.rb', line 34

def find(id)
  http.get("/classification_centers/#{id}", body: {}) do |response|
    respond_with_object response, "classification_center"
  end
end

#find_all(params = {}) ⇒ Object

List all classification centers, supplying optional params for refinement

[API] Method: GET /classification_centers

Documentation: https://app.myfinance.com.br/docs/api/classification_centers#get_index


18
19
20
21
22
23
24
# File 'lib/myfinance/resources/classification_center.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 classification center

[API] Method: PUT /classification_centers/:id

Documentation: https://app.myfinance.com.br/docs/api/classification_centers#put_update


63
64
65
66
67
68
69
70
# File 'lib/myfinance/resources/classification_center.rb', line 63

def update(id, params)
  http.put(
    "/classification_centers/#{id}",
    body: { classification_center: params }
  ) do |response|
    respond_with_object response, "classification_center"
  end
end