urbanairship / ruby-library

A Ruby wrapper for the Urban Airship API.
Other
200 stars 117 forks source link

Custom Event code does not work/undocumented #130

Closed lloydwatkin closed 2 years ago

lloydwatkin commented 2 years ago

All bugs, feature requests, implementation concerns or general queries should be sent to our support team.

You are welcome to submit an issue here for bugs, but please also reach out to our support team as well.

Before completing the form below, please check the following:

Expected Behavior

Custom event should be created on airship

Current Behavior

Does not work.

Firstly it fails on authentication, because the event code forces the uses of 'bearer' auth type. If I remove this code I then receive the following error:

{"ok":false,"operationId":"60645f1b-539a-4f2d-8d34-2b732dbf877e","error":"Malformed or missing header 'X-UA-Appkey: <appkey>'"}

Possible Solution

Firstly remove auth_type: :bearer from https://github.com/urbanairship/ruby-library/blob/main/lib/urbanairship/custom_events/custom_event.rb#L22. Then fix other bugs. Also please document the usage of this endpoint :)

Steps to Reproduce

client = Urbanairship::Client.new(key: ENV.fetch('AIRSHIP_APP_KEY'), secret: ENV.fetch('AIRSHIP_APP_SECRET'))
events = [{
  user: {
    named_user_id: named_user_id,    
  },
  body: {
    name: 'custom-event-send',
  },
}]
event = Urbanairship::CustomEvents::CustomEvent.new(client: AIRSHIP_CLIENT)
event.events = events
err = nil
begin
  event.create
rescue => error
  err = error
end
lloydwatkin commented 2 years ago

Closing, it seems this API requires a bearer style token with full access permissions.

pdxmele commented 2 years ago

Yep, we'll work on getting the example added to the API documentation though. Thanks!

pdxmele commented 2 years ago

This is now documented here when you select "Ruby Library" from the dropdown for the example code format: https://docs.airship.com/api/ua/#operation-api-custom-events-post

Screen Shot 2021-10-05 at 4 07 07 PM

Future docs will also be included within these larger API reference docs instead of within the repo (expect those to be removed eventually)