class Myfinance::Resources::DepositAccount

A wrapper to Myfinance deposit accounts API

API

Documentation: app.myfinance.com.br/docs/api/deposit_accounts

Public Instance Methods

create(entity_id, params = {}) click to toggle source

Creates a deposit account of entity

API

Method: POST /entities/:entity_id/deposit_accounts

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

# File lib/myfinance/resources/deposit_account.rb, line 48
def create(entity_id, params = {})
  http.post("/entities/#{entity_id}/deposit_accounts", body: { deposit_account: params }) do |response|
    respond_with_object(response, "deposit_account")
  end
end
destroy(entity_id, id) click to toggle source

Destroy a deposit account of entity

API

Method: DELETE /entities/:entity_id/deposit_accounts/:id

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

# File lib/myfinance/resources/deposit_account.rb, line 76
def destroy(entity_id, id)
  http.delete("/entities/#{entity_id}/deposit_accounts/#{id}", body: {}) do |response|
    respond_with_object(response, "deposit_account")
  end
end
find(entity_id, id) click to toggle source

List a deposit account of entity

API

Method: GET /entities/:entity_id/deposit_accounts/:id

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

# File lib/myfinance/resources/deposit_account.rb, line 34
def find(entity_id, id)
  http.get("/entities/#{entity_id}/deposit_accounts/#{id}", body: {}) do |response|
    respond_with_object(response, "deposit_account")
  end
end
find_all(entity_id, params = {}) click to toggle source

List all deposit accounts of entity with optional filters for refinement

API

Method: GET /entities/:entity_id/deposit_accounts

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

# File lib/myfinance/resources/deposit_account.rb, line 18
def find_all(entity_id, params = {})
  search_endpoint = build_search_endpoint(entity_id, params)

  http.get(search_endpoint) do |response|
    respond_with_collection(response)
  end
end
update(entity_id, id, params = {}) click to toggle source

Updates a deposit account of entity

API

Method: PUT /entities/:entity_id/deposit_accounts/:id

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

# File lib/myfinance/resources/deposit_account.rb, line 62
def update(entity_id, id, params = {})
  http.put("/entities/#{entity_id}/deposit_accounts/#{id}", body: { deposit_account: params }) do |response|
    respond_with_object(response, "deposit_account")
  end
end

Private Instance Methods

build_search_endpoint(entity_id, params) click to toggle source
# File lib/myfinance/resources/deposit_account.rb, line 84
def build_search_endpoint(entity_id, params)
  query_string = query(params).join("&")
  deposit_endpoint = endpoint(entity_id)

  URI.encode("#{deposit_endpoint}?#{query_string}")
end
endpoint(entity_id) click to toggle source
# File lib/myfinance/resources/deposit_account.rb, line 91
def endpoint(entity_id)
  "/entities/#{entity_id}/deposit_accounts"
end