Git Product home page Git Product logo

intercom-ruby's Introduction

intercom-ruby

Ruby bindings for the Intercom API (https://api.intercom.io).

API Documentation

Gem Documentation

For generating Intercom javascript script tags for Rails, please see https://github.com/intercom/intercom-rails

Installation

gem install intercom

Using bundler:

gem 'intercom'

Basic Usage

Configure your access credentials

Intercom.app_id = "my_app_iddd"
Intercom.api_key = "my-super-crazy-api-key"

Resources

The API supports:

POST,PUT,GET https://api.intercom.io/v1/users
POST,PUT,GET https://api.intercom.io/v1/users/messages
POST https://api.intercom.io/v1/users/impressions
POST https://api.intercom.io/v1/users/notes

Examples

Users

user = Intercom::User.find_by_email("[email protected]")
user.custom_data["average_monthly_spend"] = 1234.56
user.save
user = Intercom::User.find_by_user_id("[email protected]")
user = Intercom::User.create(:email => "[email protected]", :name => "Bob Smith")
user = Intercom::User.new(params)
user.save
Intercom::User.all.count
Intercom::User.all.each {|user| puts %Q(#{user.email} - #{user.custom_data["average_monthly_spend"]}) }
Intercom::User.all.map {|user| user.email }

Companies

user = Intercom::User.find_by_email("[email protected]")
user.company = {:id => 6, :name => "Intercom"}
user.companies = [{:id => 6, :name => "Intercom"}, {:id => 9, :name => "Test Company"}]

You can also pass custom data within a company:

user.company = {:id => 6, :name => "Intercom", :referral_source => "Google"}

Messages

Intercom::Message.create(:email => "[email protected]", :body => "Example message from [email protected] to your application on Intercom.")
Intercom::Message.find(:email => "[email protected]", :thread_id => 123)
Intercom::Message.find_all(:email => "[email protected]")
Intercom::Message.mark_as_read(:email => "[email protected]", :thread_id => 123)

Impressions

Intercom::Impression.create(:email => "[email protected]", :location => "/path/in/my/app", :user_ip => "1.2.3.4", :user_agent => "my-savage-iphone-app-0.1"

Notes

Intercom::Note.create(:email => "[email protected]", :body => "This is the text of the note")

Errors

Intercom::AuthenticationError
Intercom::ServerError
Intercom::ResourceNotFound

intercom-ruby's People

Contributors

darragh avatar erskingardner avatar kdaigle avatar timcraft avatar benmcredmond avatar ciaranlee avatar jgwhite avatar

Watchers

Graham Ashton avatar James Cloos avatar  avatar

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.