Module: Creditario::API::Retrieve
- Included in:
- Creditario::Applications, Creditario::Attachments, Contracts, CreditEstimates, Credits, Crowdfunding::Contracts, Crowdfunding::Crowdfunds, Crowdfunding::Funds, Crowdfunding::Investors, Crowdfunding::Movements, Customers, Expenses, Incomes, Investors, Movements, Products, References
- Defined in:
- lib/creditario/api/retrieve.rb
Overview
Creditario::API::Retrieve
Modulo encargado de obtener un solo recurso de la API de creditar.io
Instance Method Summary collapse
-
#retrieve(id, query_params = {}) ⇒ Object
Realiza una llamada GET al path del Repositorio que este haciendo uso de este modulo.
Instance Method Details
#retrieve(id, query_params = {}) ⇒ Object
Realiza una llamada GET al path del Repositorio que este haciendo uso de este modulo.
Si todo sale bien devuelve una instancia del Recurso especĂfico que el Repositorio maneja. De lo contrario, regresa un Hash con los errores arrojados por el servidor de creditar.io
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/creditario/api/retrieve.rb', line 16 def retrieve(id, query_params = {}) parts = [self.resource_path, id] path = parts.compact.join("/") query_params[:cache] = true response = API.request(:get, path, query_params) attributes = response.dig("data").first links = response.dig("links") self.resource_class.new(attributes, links) rescue Creditario::Exceptions::ResourceNotFoundError => exception exception.server_response rescue Creditario::Exceptions::UnprocessableEntityError => exception exception.server_response end |