Method: Harvest::Behavior::Crud#find

Defined in:
lib/harvest/behavior/crud.rb

#find(id) ⇒ Harvest::BaseModel #find(id) ⇒ Harvest::BaseModel #find(model) ⇒ Harvest::BaseModel

Retrieves an item by id

Overloads:

  • #find(id) ⇒ Harvest::BaseModel

    Parameters:

    • the (Integer)

      id of the item you want to retreive

  • #find(id) ⇒ Harvest::BaseModel

    Parameters:

    • id (String)

      the String version of the id

  • #find(model) ⇒ Harvest::BaseModel

    Parameters:

    • id (Harvest::BaseModel)

      you can pass a model and it will return a refreshed version

Returns:

  • (Harvest::BaseModel)

    the model depends on where you’re calling it from (e.g. Harvest::Client from Harvest::Base#clients)



37
38
39
40
41
42
# File 'lib/harvest/behavior/crud.rb', line 37

def find(id, query_options = {})
  raise 'ID is required' unless id

  response = request(:get, credentials, "#{api_model.api_path}/#{id}", query: query_options)
  api_model.parse(response.parsed_response).first
end