class Urbanairship::CustomEvents::CustomEvent

Attributes

events[RW]

Public Class Methods

new(client: required('client')) click to toggle source
# File lib/urbanairship/custom_events/custom_event.rb, line 14
def initialize(client: required('client'))
  @client = client
end

Public Instance Methods

create() click to toggle source
# 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