Class: Urbanairship::CustomEvents::CustomEvent
- Inherits:
-
Object
- Object
- Urbanairship::CustomEvents::CustomEvent
- Includes:
- Urbanairship::Common, Loggable
- Defined in:
- lib/urbanairship/custom_events/custom_event.rb
Constant Summary
Constants included from Urbanairship::Common
Urbanairship::Common::CONTENT_TYPE
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(client: required('client')) ⇒ CustomEvent
constructor
A new instance of CustomEvent.
Methods included from Loggable
create_logger, logger, #logger
Methods included from Urbanairship::Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(client: required('client')) ⇒ CustomEvent
Returns a new instance of CustomEvent.
14 15 16 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 14 def initialize(client: required('client')) @client = client end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
12 13 14 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 12 def events @events end |
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 18 def create fail ArgumentError, 'events must be an array of custom events' unless events.is_a?(Array) response = @client.send_request( auth_type: :bearer, body: JSON.dump(events), content_type: 'application/json', method: 'POST', path: custom_events_path ) cer = CustomEventResponse.new(body: response['body'], code: response['code']) logger.info { cer.format } cer end |