Skip to content

version 3 - client based intercom ruby#159

Merged
josler merged 1 commit intomasterfrom
jo/client-based-intercom-ruby
Jun 4, 2015
Merged

version 3 - client based intercom ruby#159
josler merged 1 commit intomasterfrom
jo/client-based-intercom-ruby

Conversation

@josler
Copy link
Copy Markdown
Contributor

@josler josler commented May 28, 2015

client = Intercom::Client.new(app_id: 'app_id', api_key: 'api_key')

# find user by email
user = client.users.find(email: 'test1@example.com')
puts user.email

# loop over all users
client.users.all.each do |user|
  puts user.email
end

# save existing
user.user_id = "77bnh4"
client.users.save(user)

# create new, then delete (2 requests)
u = client.users.create( user_id: 'doodoo' )
client.users.delete(u)

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

contacts:

contact = client.contacts.find(id: "63g78ac87ec4")
new_user = client.contacts.convert(contact, user)

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

puts client.rate_limit_details
# {:limit=>500, :remaining=>500, :reset_at=>2015-05-28 16:00:00 +0100}

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

admins:

admin = client.admins.all.each { |a| puts a.name }

companies:

client.companies.find(id: "abc6123def87")

#users in company
client.companies.users("abc6123def87").each do { |u| puts u.id }

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

subscriptions:

client.subscriptions.create(:url => "http://example.com", :topics => ["user.created"])
subscription = client.subscriptions.find(:id => "nsub_123456789")

events:

client.events.create(:event_name => "item_sold", :email => 'joe@example.com')

@josler josler force-pushed the jo/client-based-intercom-ruby branch from f86ba3d to 6667374 Compare May 28, 2015 17:00
@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

messages:

client.messages.create(:from => { :type => "user", :email => "jim@example.com" }, :body => "halp")

notes:

client.notes.create("body" => "Note to leave on user")
client.notes.find(id: '123')

@josler josler force-pushed the jo/client-based-intercom-ruby branch from 233e3e0 to 7d5e17e Compare May 28, 2015 17:34
@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

tags:

client.tags.tag(:name => "Test Tag", :user_ids => ["abc123", "def456"])
client.tags.untag(:name => "Test Tag", :user_ids => ["abc123", "def456"])

users by tag:

client.users.by_tag(124).each { |u| puts u.email  }

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

segments:

client.segments.all.to_a

users by segment:

client.users.by_segment('55490e308a6818289f000007').each { |u| puts u.email }

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

conversations:

client.conversations.mark_read('157')
client.conversations.reply(id: '157', type: 'user', body: 'Thanks again', message_type: 'comment', intercom_id: '55390fd78a6818acb1000099')

@josler josler changed the title WIP client based intercom ruby version 3 - client based intercom ruby May 28, 2015
@brandonweiss
Copy link
Copy Markdown

Nice! If 1.9.3 support is being dropped perhaps some named parameters would be nice? E.g.

Intercom::Client.new(app_id: 'my_app_id', api_key: 'my_api_key')

@josler
Copy link
Copy Markdown
Contributor Author

josler commented May 28, 2015

👍 done

@josler josler force-pushed the jo/client-based-intercom-ruby branch 3 times, most recently from bfb67ba to 86af5dc Compare June 4, 2015 09:26
josler added a commit that referenced this pull request Jun 4, 2015
@josler josler merged commit 7cd38b3 into master Jun 4, 2015
@gaffneyc
Copy link
Copy Markdown

gaffneyc commented Jun 9, 2015

This is all really interesting but I am having trouble understanding what necessitated this change or what the benefits are. Is there a rationale somewhere or list of issues we may run into if we stay on version 2?

@josler
Copy link
Copy Markdown
Contributor Author

josler commented Jun 9, 2015

@gaffneyc - this change lets you use Intercom in a multi-app environment. For example, if you're providing an integration with Intercom to your own customers, creating client objects to interact with Intercom's API with different permission sets is much better that swizzling global settings under Intercom::.

New functionality as it arrives will be going into v3 though we're committed to not making breaking changes to our API that would affect v2 (or any client) going forward.

@gaffneyc
Copy link
Copy Markdown

gaffneyc commented Jun 9, 2015

@josler thanks for the response. That makes sense, though it's not a use case we're likely to run into only managing a single application.

@cormac cormac deleted the jo/client-based-intercom-ruby branch June 9, 2015 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants