README.md in intercom-4.0.1 vs README.md in intercom-4.1.0

- old
+ new

@@ -34,11 +34,11 @@ 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. 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. @@ -59,10 +59,13 @@ 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 @@ -521,9 +524,106 @@ subscription = intercom.subscriptions.find(id: "nsub_123456789") intercom.subscriptions.delete(subscription) # 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 +article = intercom.articles.create(title: "New Article", + author_id: "123456", + translated_content: {fr: {title: "Nouvel Article"}, es: {title: "Nuevo artículo"}}) + +# 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.es = {title: "Artículo en español"} +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: "Nueva 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.es = {name: "Colección en español", description: "Descripción en español"} +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: "Nueva 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.es = {name: "Sección en español"} +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.