README.md in intercom-4.1.3 vs README.md in intercom-4.2.0
- old
+ new
@@ -1,10 +1,10 @@
# intercom-ruby
[![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)
+![Intercom API Version](https://img.shields.io/badge/Intercom%20API%20Version-2.6-blue)
> Ruby bindings for the [Intercom API](https://developers.intercom.io/reference).
## Project Updates
@@ -80,10 +80,13 @@
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
+https://api.intercom.io/phone_call_redirects
+https://api.intercom.io/subscription_types
+https://api.intercom.io/export/content/data
```
### Examples
#### Contacts
@@ -112,10 +115,13 @@
intercom.contacts.unarchive(contact)
# Delete a contact permanently
intercom.contacts.delete(contact)
+# Deletes an archived contact permanently
+intercom.contacts.delete_archived_contact(contact.id)
+
# List all contacts
contacts = intercom.contacts.all
contacts.each { |contact| p contact.name }
# Search for contacts by email
@@ -160,10 +166,20 @@
# Remove a contact from a company
contact.remove_company(id: company.id)
# List companies for a contact
contact.companies.each {|c| p c.name}
+
+# attach a subscription_types on a contact
+contact.create_subscription_types(id: subscription_type.id)
+
+# List subscription_types for a contact
+contact.subscription_types.each {|n| p n.id}
+
+# Remove subscription_types
+contact.remove_subscription_type({ "id": subscription_type.id })
+
```
#### Visitors
```ruby
@@ -255,10 +271,18 @@
user_id: user.uuid,
)
# Retrieve event list for user with id:'123abc'
intercom.events.find_all("type" => "user", "intercom_user_id" => "123abc")
+
+# Retrieve the event summary for user with id: 'abc' this will return an event object with the following characteristics:
+# name - name of the event
+# first - time when event first occured.
+# last - time when event last occured
+# count - number of times the event occured
+# description - description of the event
+ events = intercom.events.find_all(type: 'user',intercom_user_id: 'abc',summary: true)
```
Metadata Objects support a few simple types that Intercom can present on your behalf
```ruby
@@ -300,10 +324,17 @@
# Tag companies
tag = intercom.tags.tag(name: 'blue', companies: [{company_id: "42ea2f1b93891f6a99000427"}])
# Untag Companies
tag = intercom.tags.untag(name: 'blue', companies: [{ company_id: "42ea2f1b93891f6a99000427" }])
+
+
+# Delete Tags
+
+# Note : If there any depedent objects for the tag we are trying to delete, then an error TagHasDependentObjects will be thrown.
+tag = intercom.tags.find(id:"123")
+intercom.tags.delete(tag)
```
#### Notes
```ruby
@@ -325,10 +356,12 @@
```ruby
# Iterate over all conversations for your app
intercom.conversations.all.each { |convo| ... }
+# The below method of finding conversations by using the find_all method work only for API versions 2.5 and below
+
# FINDING CONVERSATIONS FOR AN ADMIN
# Iterate over all conversations (open and closed) assigned to an admin
intercom.conversations.find_all(type: 'admin', id: '7').each {|convo| ... }
# Iterate over all open conversations assigned to an admin
intercom.conversations.find_all(type: 'admin', id: 7, open: true).each {|convo| ... }
@@ -523,10 +556,20 @@
type: "contact",
id: "536e5643as316c83104c400671"
},
body: "halp"
})
+
+#From version 2.6 the type contact is not supported and you would have to use leads to send messages to a lead.
+
+intercom.messages.create({
+ from: {
+ type: "lead",
+ id: "536e5643as316c83104c400671"
+ },
+ body: "halp"
+})
```
#### Admins
```ruby
@@ -574,10 +617,23 @@
# list subscriptions
intercom.subscriptions.all
```
+
+#### Subscription Types
+
+List all the subscription types that a contact can opt in to
+
+```ruby
+
+# fetch a subscription
+intercom.subscription_types.find(id: "1")
+
+intercom.subscription_types.all
+```
+
#### Articles
```ruby
# Create an article
article = intercom.articles.create(title: "New Article", author_id: "123456")
@@ -672,9 +728,32 @@
section.translated_content.es = {name: "Sección en español"}
intercom.collections.save(section)
# Delete an section
intercom.sections.delete(section)
+```
+
+#### Phone Call Redirect (switch)
+
+```ruby
+# Create a redirect
+redirect = intercom.phone_call_redirect.create(phone_number: "+353871234567")
+
+```
+
+#### Data Content Export
+
+```ruby
+# Create a data export
+export = intercom.export_content.create(created_at_after: 1667566801, created_at_before: 1668085202)
+
+
+#View a data export
+export = intercom.export_content.find(id: 'k0e27ohsyvh8ef3m')
+
+# Cancel a data export
+export = intercom.export_content.cancel('k0e27ohsyvh8ef3m')
+
```
### Errors
There are different styles for error handling - some people prefer exceptions; some prefer nil and check; some prefer error objects/codes. Balancing these preferences alongside our wish to provide an idiomatic gem has brought us to use the current mechanism of throwing specific exceptions. Our approach in the client is to propagate errors and signal our failure loudly so that erroneous data does not get propagated through our customers' systems - in other words, if you see a `Intercom::ServiceUnavailableError` you know where the problem is.