File tree Expand file tree Collapse file tree 7 files changed +89
-0
lines changed
Expand file tree Collapse file tree 7 files changed +89
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ You can also use the [omniauth-intercom lib](https://github.com/intercom/omniaut
4949Resources this API supports:
5050
5151 https://api.intercom.io/users
52+ https://api.intercom.io/teams
5253 https://api.intercom.io/contacts
5354 https://api.intercom.io/companies
5455 https://api.intercom.io/counts
@@ -129,6 +130,14 @@ intercom.admins.find(id: admin_id)
129130intercom.admins.all.each {|admin | puts admin.email }
130131```
131132
133+ #### Teams
134+ ``` ruby
135+ # Find a team by id
136+ intercom.teams.find(id: team_id)
137+ # Iterate over all teams
138+ intercom.teams.all.each {|team | puts team.name }
139+ ```
140+
132141#### Companies
133142``` ruby
134143# Add a user to one or more companies
Original file line number Diff line number Diff line change 1212require 'intercom/service/subscription'
1313require 'intercom/service/segment'
1414require 'intercom/service/tag'
15+ require 'intercom/service/team'
1516require 'intercom/service/user'
1617require 'intercom/service/visitor'
1718require 'intercom/options'
3132require "intercom/admin"
3233require "intercom/request"
3334require "intercom/subscription"
35+ require "intercom/team"
3436require "intercom/errors"
3537require "intercom/visitor"
3638require "json"
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ def tags
9595 Intercom ::Service ::Tag . new ( self )
9696 end
9797
98+ def teams
99+ Intercom ::Service ::Team . new ( self )
100+ end
101+
98102 def users
99103 Intercom ::Service ::User . new ( self )
100104 end
Original file line number Diff line number Diff line change 1+ require 'intercom/service/base_service'
2+ require 'intercom/api_operations/list'
3+ require 'intercom/api_operations/find'
4+
5+ module Intercom
6+ module Service
7+ class Team < BaseService
8+ include ApiOperations ::List
9+ include ApiOperations ::Find
10+
11+ def collection_class
12+ Intercom ::Team
13+ end
14+
15+ end
16+ end
17+ end
Original file line number Diff line number Diff line change 1+ require 'intercom/traits/api_resource'
2+
3+ module Intercom
4+ class Team
5+ include Traits ::ApiResource
6+ end
7+ end
Original file line number Diff line number Diff line change @@ -145,6 +145,35 @@ def test_admin
145145 }
146146end
147147
148+ def test_team_list
149+ {
150+ "type" => "team.list" ,
151+ "teams" => [
152+ {
153+ "type" => "team" ,
154+ "id" => "2744328" ,
155+ "name" => "the_a_team" ,
156+ "admin_ids" => [ 646303 , 814860 ] ,
157+ } ,
158+ {
159+ "type" => "team" ,
160+ "id" => "814865" ,
161+ "name" => "BA_App" ,
162+ "admin_ids" => [ 492881 , 1195856 ]
163+ } ,
164+ ]
165+ }
166+ end
167+
168+ def test_team
169+ {
170+ "type" => "team" ,
171+ "id" => "2744328" ,
172+ "name" => "the_a_team" ,
173+ "admin_ids" => [ 646303 , 814860 ]
174+ }
175+ end
176+
148177def test_company
149178 {
150179 "type" => "company" ,
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe "Intercom::Team" do
4+ let ( :client ) { Intercom ::Client . new ( token : 'token' ) }
5+
6+ it "returns a CollectionProxy for all without making any requests" do
7+ client . expects ( :execute_request ) . never
8+ all = client . teams . all
9+ all . must_be_instance_of ( Intercom ::ClientCollectionProxy )
10+ end
11+
12+ it 'gets an team list' do
13+ client . expects ( :get ) . with ( "/teams" , { } ) . returns ( test_team_list )
14+ client . teams . all . each { |t | }
15+ end
16+
17+ it "gets an team" do
18+ client . expects ( :get ) . with ( "/teams/1234" , { } ) . returns ( test_team )
19+ client . teams . find ( :id => "1234" )
20+ end
21+ end
You can’t perform that action at this time.
0 commit comments