Module: Intercom::ApiOperations::Load

Included in:
Service::Company, Service::Contact, Service::Conversation, Service::Job, Service::Note, Service::User, Service::Visitor
Defined in:
lib/intercom/api_operations/load.rb

Instance Method Summary collapse

Instance Method Details

#load(object) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/intercom/api_operations/load.rb', line 6

def load(object)
  collection_name = Utils.resource_class_to_collection_name(collection_class)
  if object.id
    response = @client.get("/#{collection_name}/#{object.id}", {})
  else
    raise "Cannot load #{collection_class} as it does not have a valid id."
  end
  raise Intercom::HttpError.new('Http Error - No response entity returned') unless response
  object.from_response(response)
end