Appboy

A wrapper for the Appboy REST API.

Installation

Add this line to your application's Gemfile:

gem 'appboy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install appboy

Examples

Initializing API

api = Appboy::API.new('<app-group-id>')

Track User Attributes

See: User Attributes Object Specification

api.track_users(attributes: [{
  external_id: 123,
  first_name: 'John',
  last_name: 'Smith',
  gender: 'male',
  email: '[email protected]'
}])
Track Attributes for Single User
api.track_attribute(external_id: 123, first_name: 'John', ...)

Track Event

See: Event Object Specification

api.track_users(events: [{
  external_id: 123,
  name: 'add-to-cart',
  time: Time.now
}]
Track Events for Single User
api.track_event(external_id: 123, name: 'Event', ...)

Track Purchase

See: Purchase Object Specfication

api.track_users(purchases: [{
  external_id: 123,
  product_id: 456,
  currency: 'CAD',
  price: 1.99,
  time: Time.now
}]
Track Purchases for Single User
api.track_purchase(external_id: 123, product_id: 456, ...)

Track Everything for Everyone All at Once

api.track_users(purchases: purchases, events: events, attributes: attributes)

Send Message

See: Platform Push Object Specifications

Messages Payload
messages = {
  android_push: { alert: 'Hello Android' },
  apple_push:   { alert: "Hello iOS" }
}
Option A, Using External User IDs
api.send_messages(messages: messages, external_user_ids: [123, 456])
Option B, Using Segment ID
api.send_messages(messages: messages, segment_id: '<segment-id>')

Schedule Message

See: Platform Push Object Specifications

api.schedule_messages(send_at: 1.hour.since, messages: messages, segment_id: '<segment-id>')

Changing Email Subscription

See: Changing Email Subscription Status

api.email_status(email: '[email protected]', status: :opted_in)

List Segments

See: Segment Export

api.list_segments

Export Users

See: User Export

By IDs

api.export_users(external_ids: [1])

By Segment

api.export_users(segment_id: segment_id, callback_endpoint: 'https://example.com')

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request