Class: Intercom::EventWrapper

Inherits:
Event
  • Object
show all
Defined in:
lib/intercom_event_wrapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(params, app_id, app_api_key) ⇒ Object



9
10
11
12
13
# File 'lib/intercom_event_wrapper.rb', line 9

def self.create(params, app_id, app_api_key)
  instance = self.new(params)
  instance.mark_fields_as_changed!(params.keys)
  instance.save(app_id, app_api_key)
end

Instance Method Details

#save(app_id, app_api_key) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/intercom_event_wrapper.rb', line 15

def save(app_id, app_api_key)
  collection_name = Utils.resource_class_to_collection_name(self.class.superclass)
  if id_present? && !posted_updates?
    response = IntercomWrapper.put("/#{collection_name}/#{id}", to_submittable_hash, app_id, app_api_key)
  else
    response = IntercomWrapper.post("/#{collection_name}", to_submittable_hash.merge(identity_hash), app_id, app_api_key)
  end
  from_response(response) if response # may be nil we received back a 202
end