Skip to content

Readme update for v4.1.0 #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 101 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ intercom = Intercom::Client.new(token: 'my_token')

```ruby
# With a versioned app:
intercom = Intercom::Client.new(token: 'my_token', api_version: '2.0')
intercom = Intercom::Client.new(token: 'my_token', api_version: '2.1')
```

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.
Expand All @@ -61,6 +61,9 @@ Resources this API supports:
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
Expand Down Expand Up @@ -525,6 +528,103 @@ intercom.subscriptions.delete(subscription)
intercom.subscriptions.all
```

#### Articles
```ruby
# Create an article
article = intercom.articles.create(title: "New Article", author_id: "123456")

# Create an article with translations
article = intercom.articles.create(title: "New Article",
author_id: "123456",
translated_content: {fr: {title: "Nouvel Article"}, es: {title: "Articulo nuevo"}})

# Fetch an article
intercom.articles.find(id: "123456")

# List all articles
articles = intercom.articles.all
articles.each { |article| p article.title }

# Update an article
article.title = "Article Updated!"
intercom.articles.save(article)

# Update an article's existing translation
article.translated_content.en.title = "English Updated!"
intercom.articles.save(article)

# Update an article by adding a new translation
article.translated_content.fr = {title: "French Added!"}
intercom.articles.save(article)

# Delete an article
intercom.articles.delete(article)
```

#### Collections
```ruby
# Create a collection
collection = intercom.collections.create(name: "New Collection")

# Create a collection with translations
collection = intercom.collections.create(name: "New Collection",
translated_content: {fr: {name: "Nouvelle collection"}, es: {name: "Nuevo colección"}})

# Fetch a collection
intercom.collections.find(id: "123456")

# List all collections
collections = intercom.collections.all
collections.each { |collection| p collection.name }

# Update a collection
collection.name = "Collection updated!"
intercom.collections.save(collection)

# Update a collection's existing translation
collection.translated_content.en.name = "English Updated!"
intercom.collections.save(collection)

# Update a collection by adding a new translation
collection.translated_content.fr = {name: "French Added", description: "French description"}
intercom.collections.save(collection)

# 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
section = intercom.sections.create(name: "New Section",
translated_content: {fr: {name: "Nouvelle section"}, es: {name: "Nuevo sección"}})

# Fetch a section
intercom.sections.find(id: "123456")

# List all sections
sections = intercom.sections.all
sections.each { |section| p section.name }

# Update a section
section.name = "Section updated!"
intercom.sections.save(section)

# Update a section's existing translation
section.translated_content.en.name = "English Updated!"
intercom.collections.save(section)

# Update a section by adding a new translation
section.translated_content.fr = {name: "French Added"}
intercom.collections.save(section)

# Delete an section
intercom.sections.delete(section)
```

### 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.
Expand Down
7 changes: 7 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
4.1.0
- Added support for new Articles API.
- Added support for new Collections API.
- Added support for new Sections API.
- Added support to equate two resources.
- Fixed issue for dirty tracking nested typed objects.

4.0.1
- Fixed bug with nested resources.
- Support for add/remove contact on conversation object.
Expand Down