class Myfinance::Resources::ClassificationCenter
A wrapper to Myfinance
classification center API
- API
-
Documentation: app.myfinance.com.br/docs/api/classification_centers
Public Instance Methods
Creates a classification center
- API
-
Method:
POST /classification_centers
Documentation: app.myfinance.com.br/docs/api/classification_centers#post_create
# 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 a classification center
- API
-
Method:
DELETE /classification_centers/:id
Documentation: app.myfinance.com.br/docs/api/classification_centers#delete_destroy
# 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
Show a classification center
- API
-
Method:
GET /classification_centers/:id
Documentation: app.myfinance.com.br/docs/api/classification_centers#get_show
# 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
List all classification centers, supplying optional params for refinement
- API
-
Method:
GET /classification_centers
Documentation: app.myfinance.com.br/docs/api/classification_centers#get_index
# 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
Updates a classification center
- API
-
Method:
PUT /classification_centers/:id
Documentation: app.myfinance.com.br/docs/api/classification_centers#put_update
# 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
Private Instance Methods
# File lib/myfinance/resources/classification_center.rb, line 92 def build_search_endpoint(params) query_string = query(params).join("&") URI.encode("#{endpoint}?#{query_string}") end
# File lib/myfinance/resources/classification_center.rb, line 88 def endpoint "/classification_centers" end
# File lib/myfinance/resources/classification_center.rb, line 97 def query(params) page = params.delete(:page) per_page = params.delete(:per_page) query = params.map { |key, value| "search[#{key}]=#{value}" } query << "page=#{page}" if page query << "per_page=#{per_page}" if per_page query end