A wrapper for the Appboy REST API.
Add this line to your application's Gemfile:
gem 'appboy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install appboy
api = Appboy::API.new('<app-group-id>')
By default Appboy will be using 'https://api.appboy.com' as the default REST API base url, but you can override this base url by setting the env variable APPBOY_REST_BASE_URL
. E.G.
APPBOY_REST_BASE_URL="https://rest.iad-01.braze.com"
See: User Attributes Object Specification
api.track_users(attributes: [{
external_id: 123,
first_name: 'John',
last_name: 'Smith',
gender: 'male',
email: '[email protected]'
}])
api.track_attribute(external_id: 123, first_name: 'John', ...)
See: Event Object Specification
api.track_users(events: [{
external_id: 123,
name: 'add-to-cart',
time: Time.now
}])
api.track_event(external_id: 123, name: 'Event', ...)
See: Purchase Object Specfication
api.track_users(purchases: [{
external_id: 123,
product_id: 456,
currency: 'CAD',
price: 1.99,
time: Time.now
}])
api.track_purchase(external_id: 123, product_id: 456, ...)
api.track_users(purchases: purchases, events: events, attributes: attributes)
See: Platform Push Object Specifications
messages = {
android_push: { alert: 'Hello Android' },
apple_push: { alert: "Hello iOS" }
}
api.send_messages(messages: messages, external_user_ids: [123, 456])
api.send_messages(messages: messages, segment_id: '<segment-id>')
See: Sending Messages via API Triggered Delivery
api.trigger_campaign(
api_key: (required, string),
campaign_id: (required, string),
send_id: (optional, string),
audience: (optional, string),
trigger_properties: (optional, object),
broadcast: (optional, boolean, default, false),
recipients: (optional, array of recipient objects)
)
api.trigger_canvas(
api_key: (required, string),
campaign_id: (required, string),
audience: (optional, string),
canvas_entry_properties: (optional, object),
broadcast: (optional, boolean, default, false),
recipients: (optional, array of recipient objects)
)
See: Platform Push Object Specifications
api.schedule_messages(send_at: 1.hour.since, messages: messages, segment_id: '<segment-id>')
See: Changing Email Subscription Status
api.email_status(email: '[email protected]', status: :opted_in)
See: Segment Export
api.list_segments
See: User Export
api.export_users(external_ids: [1])
api.export_users(segment_id: segment_id, callback_endpoint: 'https://example.com')
The APPBOY_DEBUG environment variable will trigger full printouts of the Faraday gem's HTTP requests and responses.
cd /my/app
export APPBOY_DEBUG=true
bundle exec rails whatever
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request