Git Product home page Git Product logo

appboy's Introduction

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>')

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"

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>')

Triggered Delivery Messages

See: Sending Messages via API Triggered Delivery

Option A, Using Campaign ID
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)
)
Option B, Using Canvas ID
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)
)

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

List Canvas

See: Segment Export

api.list_canvas(
  sort_direction: (optional, string, default: 'desc',
  include_archived: (optional, boolean, default: false)
)

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')

Debugging

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

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

appboy's People

Contributors

adayag avatar hugobast avatar joshnuss avatar wenga86 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appboy's Issues

Opportunity to consolidate?

Hey there, my employer Artsy is a new Braze customer and I need a gem to work with their API. I have some bandwidth during work hours to help improve things about the gem I use so I'm trying to figure out where to put that effort.

After some research, I see 4 different Braze client gems:

https://rubygems.org/gems/appboy => https://github.com/DynamoMTL/appboy
https://rubygems.org/gems/braze_ruby => https://github.com/justinboltz/braze_ruby
https://rubygems.org/gems/braze => https://gitlab.com/mtchavez/braze
https://rubygems.org/gems/braze_api => https://github.com/appearhere/braze_api

I was confused about how all these projects related to each other but I think there might be an opportunity to consolidate at least DynamoMTL/appboy and justinboltz/braze_ruby since the latter is a fork of the former. What do people think of this? What would it take to consolidate our efforts?

The other two seem unrelated but I'd certainly invite those peeps to participate in a single effort!

Going to ping a few contributors on both projects that might have strong feelings (feel free to add others I miss):

@FGoessler
@adayag ๐Ÿ‘‹ โค๏ธ
@hugobast
@joshnuss
@justinboltz
@morgoth
@tborlee
@wenga86

`list_canvas()` currently does not support pagination

Hey, I have been using this gem and with their docs and I need to be able to get canvas that are n pages deep. I see currently the gem does not support pagination and proposed this code change on https://github.com/jonallured/appboy/blob/master/lib/appboy/rest/list_canvas.rb

module Appboy
  module REST
    class ListCanvas < Base
      attr_reader :app_group_id, :sort_direction, :include_archived, :page

      def initialize(app_group_id, options = {})
        @app_group_id = app_group_id
        @sort_direction = options[:sort_direction]
        @include_archived = options[:include_archived]
        @page = options[:page]
      end

      def perform
        http.get '/canvas/list', {
          app_group_id: app_group_id,
          sort_direction: sort_direction,
          include_archived: include_archived,
          page: page
        }.compact
      end
    end
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.