README.md in intercom-4.1.2 vs README.md in intercom-4.1.3
- old
+ new
@@ -1,29 +1,46 @@
# intercom-ruby
-Ruby bindings for the Intercom API (https://developers.intercom.io/reference).
+[![Circle CI](https://circleci.com/gh/intercom/intercom-ruby.png?style=shield)](https://circleci.com/gh/intercom/intercom-ruby)
+[![gem](https://img.shields.io/gem/v/intercom)](https://rubygems.org/gems/intercom)
+![Intercom API Version](https://img.shields.io/badge/Intercom%20API%20Version-2.2-blue)
+> Ruby bindings for the [Intercom API](https://developers.intercom.io/reference).
+
+## Project Updates
+
+### Maintenance
+
+We're currently building a new team to provide in-depth and dedicated SDK support.
+
+In the meantime, we'll be operating on limited capacity, meaning all pull requests will be evaluated on a best effort basis and will be limited to critical issues.
+
+We'll communicate all relevant updates as we build this new team and support strategy in the coming months.
+
[API Documentation](https://developers.intercom.io/docs)
[Gem Documentation](http://rubydoc.info/github/intercom/intercom-ruby/master/frames)
-For generating Intercom JavaScript script tags for Rails, please see https://github.com/intercom/intercom-rails.
+For generating Intercom JavaScript script tags for Rails, please see [intercom/intercom-rails](https://github.com/intercom/intercom-rails)
## Upgrading information
Version 4 of intercom-ruby is not backwards compatible with previous versions. Please see our [migration guide](https://github.com/intercom/intercom-ruby/wiki/Migration-guide-for-v4) for full details of breaking changes.
This version of the gem is compatible with `Ruby 2.1` and above.
## Installation
+```bash
+gem install intercom
+```
- gem install intercom
-
Using bundler:
- gem 'intercom', '~> 4.1'
+```bundler
+gem 'intercom', '~> 4.1'
+```
## Basic Usage
### Configure your client
@@ -34,43 +51,45 @@
intercom = Intercom::Client.new(token: 'my_token')
```
```ruby
# With a versioned app:
-intercom = Intercom::Client.new(token: 'my_token', api_version: '2.1')
+intercom = Intercom::Client.new(token: 'my_token', api_version: '2.2')
```
If you are building a third party application you can get your access_tokens by [setting-up-oauth](https://developers.intercom.io/page/setting-up-oauth) for Intercom.
You can also use the [omniauth-intercom lib](https://github.com/intercom/omniauth-intercom) which is a middleware helping you to handle the authentication process with Intercom.
### Resources
Resources this API supports:
- https://api.intercom.io/contacts
- https://api.intercom.io/visitors
- https://api.intercom.io/companies
- https://api.intercom.io/data_attributes
- https://api.intercom.io/events
- https://api.intercom.io/tags
- https://api.intercom.io/notes
- https://api.intercom.io/segments
- https://api.intercom.io/conversations
- https://api.intercom.io/messages
- https://api.intercom.io/admins
- https://api.intercom.io/teams
- https://api.intercom.io/counts
- https://api.intercom.io/subscriptions
- https://api.intercom.io/jobs
- https://api.intercom.io/articles
- https://api.intercom.io/help_center/collections
- https://api.intercom.io/help_center/sections
+```text
+https://api.intercom.io/contacts
+https://api.intercom.io/visitors
+https://api.intercom.io/companies
+https://api.intercom.io/data_attributes
+https://api.intercom.io/events
+https://api.intercom.io/tags
+https://api.intercom.io/notes
+https://api.intercom.io/segments
+https://api.intercom.io/conversations
+https://api.intercom.io/messages
+https://api.intercom.io/admins
+https://api.intercom.io/teams
+https://api.intercom.io/counts
+https://api.intercom.io/subscriptions
+https://api.intercom.io/jobs
+https://api.intercom.io/articles
+https://api.intercom.io/help_center/collections
+https://api.intercom.io/help_center/sections
+```
-
### Examples
#### Contacts
+
Note that this is a new resource compatible only with the new [Contacts API](https://developers.intercom.com/intercom-api-reference/reference#contacts-model) released in API v2.0.
```ruby
# Create a contact with "lead" role
contact = intercom.contacts.create(email: "some_contact2@example.com", role: "lead")
@@ -144,10 +163,11 @@
# List companies for a contact
contact.companies.each {|c| p c.name}
```
#### Visitors
+
```ruby
# Get and update a visitor
visitor = intercom.visitors.find(id: "5dd570e7b1b922452676af23")
visitor.name = "New name"
intercom.visitors.save(visitor)
@@ -159,10 +179,11 @@
user = intercom.contacts.find(id: "5db2e7f5b1b92243d2188cb3")
intercom.visitors.convert(visitor, user)
```
#### Companies
+
```ruby
# Find a company by company_id
company = intercom.companies.find(company_id: "44")
# Find a company by name
@@ -186,11 +207,13 @@
intercom.companies.scroll.each { |comp| puts comp.name}
# Please see users scroll for more details of how to use scroll
```
#### Data Attributes
+
Data Attributes are a type of metadata used to describe your customer and company models. These include standard and custom attributes.
+
```ruby
# Create a new custom data attribute
intercom.data_attributes.create({ name: "test_attribute", model: "contact", data_type: "string" })
# List all data attributes
@@ -206,14 +229,15 @@
attribute.archived = true
intercom.data_attributes.save(attribute)
# Find all customer attributes including archived
customer_attributes_incl_archived = intercom.data_attributes.find_all({"model": "contact", "include_archived": true})
-customer_attributes_incl_archived.each { |attr| p attribute.name }
+customer_attributes_incl_archived.each { |attr| p attr.name }
```
#### Events
+
```ruby
intercom.events.create(
event_name: "invited-friend",
created_at: Time.now.to_i,
email: user.email,
@@ -255,19 +279,21 @@
}
}
)
```
-The metadata key values in the example are treated as follows-
+The metadata key values in the example are treated as follows:
+
- order_date: a Date (key ends with '_date')
- stripe_invoice: The identifier of the Stripe invoice (has a 'stripe_invoice' key)
- order_number: a Rich Link (value contains 'url' and 'value' keys)
- price: An Amount in US Dollars (value contains 'amount' and 'currency' keys)
*NB:* This version of the gem reserves the field name `type` in Event data.
#### Tags
+
```ruby
# Iterate over all tags
intercom.tags.all.each {|tag| "#{tag.id} - #{tag.name}" }
intercom.tags.all.map {|tag| tag.name }
@@ -277,25 +303,28 @@
# Untag Companies
tag = intercom.tags.untag(name: 'blue', companies: [{ company_id: "42ea2f1b93891f6a99000427" }])
```
#### Notes
+
```ruby
# Find a note by id
note = intercom.notes.find(id: "123")
```
#### Segments
+
```ruby
# Find a segment
segment = intercom.segments.find(id: segment_id)
# Iterate over all segments
intercom.segments.all.each {|segment| puts "id: #{segment.id} name: #{segment.name}"}
```
#### Conversations
+
```ruby
# Iterate over all conversations for your app
intercom.conversations.all.each { |convo| ... }
# FINDING CONVERSATIONS FOR AN ADMIN
@@ -422,17 +451,19 @@
# Remove a contact from a conversation
conversation.remove_contact(id: contact.id, admin_id: admin.id)
```
#### Full loading of an embedded entity
+
```ruby
# Given a conversation with a partial contact, load the full contact. This can be
# done for any entity
intercom.contacts.load(conversation.contacts.first)
```
#### Sending messages
+
```ruby
# InApp message from admin to user
intercom.messages.create({
message_type: 'inapp',
@@ -495,20 +526,22 @@
body: "halp"
})
```
#### Admins
+
```ruby
# Find access token owner (only with Personal Access Token and OAuth)
intercom.admins.me
# Find an admin by id
intercom.admins.find(id: admin_id)
# Iterate over all admins
intercom.admins.all.each {|admin| puts admin.email }
```
#### Teams
+
```ruby
# Find a team by id
intercom.teams.find(id: team_id)
# Iterate over all teams
intercom.teams.all.each {|team| puts team.name }
@@ -542,10 +575,11 @@
# list subscriptions
intercom.subscriptions.all
```
#### Articles
+
```ruby
# Create an article
article = intercom.articles.create(title: "New Article", author_id: "123456")
# Create an article with translations
@@ -575,10 +609,11 @@
# Delete an article
intercom.articles.delete(article)
```
#### Collections
+
```ruby
# Create a collection
collection = intercom.collections.create(name: "New Collection")
# Create a collection with translations
@@ -607,10 +642,11 @@
# Delete an collection
intercom.collections.delete(collection)
```
#### Sections
+
```ruby
# Create a section
section = intercom.sections.create(name: "New Section", parent_id: "123456")
# Create a section with translations
@@ -658,10 +694,11 @@
Intercom::BadRequestError
Intercom::RateLimitExceeded
Intercom::AttributeNotSetError # Raised when you try to call a getter that does not exist on an object
Intercom::MultipleMatchingUsersError
Intercom::HttpError # Raised when response object is unexpectedly nil
+Intercom::GatewayTimeoutError
```
### Rate Limiting
Calling your client's `rate_limit_details` returns a Hash that contains details about your app's current rate limit.
@@ -672,11 +709,11 @@
```
You can handle the rate limits yourself but a simple option is to use the handle_rate_limit flag.
This will automatically catch the 429 rate limit exceeded error and wait until the reset time to retry. After three retries a rate limit exception will be raised. Encountering this error frequently may require a revisiting of your usage of the API.
-```
+```ruby
intercom = Intercom::Client.new(token: ENV['AT'], handle_rate_limit: true)
```
### Pull Requests
@@ -698,16 +735,16 @@
#### Running tests
```bash
# all tests
-bundle exec spec
+bundle exec rake spec
# unit tests
-bundle exec spec:unit
+bundle exec rake spec:unit
# integration tests
-bundle exec spec:integration
+bundle exec rake spec:integration
# single test file
bundle exec m spec/unit/intercom/job_spec.rb
# single test