README.md in intercom-3.5.4 vs README.md in intercom-3.5.5

- old
+ new

@@ -20,11 +20,11 @@ gem install intercom Using bundler: - gem 'intercom', "~> 3.5.3" + gem 'intercom', "~> 3.5.5" ## Basic Usage ### Configure your client @@ -33,11 +33,11 @@ ``` You can get your `app_id` from the URL when you're logged into Intercom (it's the alphanumeric just after `/apps/`) and your API key from the API keys integration settings page (under your app settings - integrations in Intercom). ```ruby -# With an OAuth token: +# With an OAuth or Personal Access token: intercom = Intercom::Client.new(token: 'my_token') ``` 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. @@ -80,25 +80,48 @@ user.custom_attributes["average_monthly_spend"] = 1234.56 intercom.users.save(user) # Perform incrementing user.increment('karma') intercom.users.save(user) +# Perform decrementing +user.decrement('karma', 5) +intercom.users.save(user) # Iterate over all users intercom.users.all.each {|user| puts %Q(#{user.email} - #{user.custom_attributes["average_monthly_spend"]}) } intercom.users.all.map {|user| user.email } +# List your users create in the last two days +intercom.users.find_all(type: 'users', page: 1, per_page: 10, created_since: 2, order: :asc).to_a.each_with_index {|usr, i| puts "#{i+1}: #{usr.name}"}; +# Paginate through your list of users choosing how many to return per page (default and max is 50 per page) +intercom.users.find_all(type: 'users', page: 1, per_page: 10, order: :asc).to_a.each_with_index {|usr, i| puts "#{i+1}: #{usr.name}"} +# If you have over 10,000 users then you will need to use the scroll function to list your users +# otherwise you will encounter a page limit with list all your users +# You can use the scroll method to list all your users +intercom.users.scroll.each { |user| puts user.name} +# Alternatively you can use the scroll.next method to get 100 users with each request +result = intercom.users.scroll.next +# The result object then contains a records attributes that is an array of your user objects and it also contains a scroll_param which +# you can then use to request the next 100 users. Note that the scroll parameter will time out after one minute and you will need to +# make a new request +result.scroll_param +=> "0730e341-63ef-44da-ab9c-9113f886326d" +result = = intercom.users.scroll.next("0730e341-63ef-44da-ab9c-9113f886326d"); #Bulk operations. -# Submit bulk job, to create users, if any of the items in create_items match an existing user that user will be updated +# Submit bulk job to create users. If any of the items in create_items match an existing user that user will be updated intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}]) +# Submit bulk job to create users with companies. Companies must be sent as an array of objects nested within each applicable user object +intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com", companies: [{:company_id => 9, :name => "Test Company"}]}]) # Submit bulk job, to delete users intercom.users.submit_bulk_job(delete_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}]) # Submit bulk job, to add items to existing job intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com"}], delete_items: [{user_id: 25, email: "bob@example.com"}], job_id:'job_abcd1234') ``` #### Admins ```ruby +# Find an admin by id +intercom.admins.find(:id => admin_id) # Iterate over all admins intercom.admins.all.each {|admin| puts admin.email } ``` #### Companies @@ -467,5 +490,22 @@ ```ruby intercom.rate_limit_details #=> {:limit=>180, :remaining=>179, :reset_at=>2014-10-07 14:58:00 +0100} ``` + + +### Pull Requests + +- **Add tests!** Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour**. Make sure the README and any other + relevant documentation are kept up-to-date. + +- **Create topic branches**. Don't ask us to pull from your master branch. + +- **One pull request per feature**. If you want to do more than one thing, send + multiple pull requests. + +- **Send coherent history**. Make sure each individual commit in your pull + request is meaningful. If you had to make multiple intermediate commits while + developing, please squash them before sending them to us.