Class: LucidIntercom::SendEvent
- Inherits:
-
Object
- Object
- LucidIntercom::SendEvent
- Defined in:
- lib/lucid_intercom/send_event.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#call(event_name, event_metadata) ⇒ Object
Send event for user identified by attributes.
-
#initialize(shop_attributes, credentials = LucidIntercom.credentials) ⇒ SendEvent
constructor
A new instance of SendEvent.
Constructor Details
#initialize(shop_attributes, credentials = LucidIntercom.credentials) ⇒ SendEvent
Returns a new instance of SendEvent.
16 17 18 19 |
# File 'lib/lucid_intercom/send_event.rb', line 16 def initialize(shop_attributes, credentials = LucidIntercom.credentials) @attributes = Attributes.new(shop_attributes, {}, credentials) @credentials = credentials end |
Instance Attribute Details
#attributes ⇒ LucidIntercom::Attributes (readonly)
22 23 24 |
# File 'lib/lucid_intercom/send_event.rb', line 22 def attributes @attributes end |
#credentials ⇒ LucidIntercom::Credentials (readonly)
24 25 26 |
# File 'lib/lucid_intercom/send_event.rb', line 24 def credentials @credentials end |
Instance Method Details
#call(event_name, event_metadata) ⇒ Object
Send event for user identified by attributes.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lucid_intercom/send_event.rb', line 34 def call(event_name, ) res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req, data(event_name, )) end status = res.code.to_i if status >= 400 # rubocop:disable Style/GuardClause raise LucidIntercom::RequestError.new(status), 'invalid response code %s' % status end end |