Class: Myfinance::Resources::Person

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

Overview

A wrapper to Myfinance people API

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

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 person

[API] Method: POST /people

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


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

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

#destroy(id) ⇒ Object

Destroy a person

[API] Method: DELETE /people/:id

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


77
78
79
80
81
# File 'lib/myfinance/resources/person.rb', line 77

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

#find(id) ⇒ Object

Show a person

[API] Method: GET /people/:id

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


35
36
37
38
39
# File 'lib/myfinance/resources/person.rb', line 35

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

#find_all(params = {}) ⇒ Object

List all people with optional filters for refinement

[API] Method: GET /people

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


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

[API] Method: PUT /people/:id

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


63
64
65
66
67
# File 'lib/myfinance/resources/person.rb', line 63

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