Skip to content

Commit f62cf4b

Browse files
authored
Merge pull request #250 from productboard/find-admin
Add support to find admin by id
2 parents 72b77da + 84ce4a9 commit f62cf4b

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@exampl
118118

119119
#### Admins
120120
```ruby
121+
# Find an admin by id
122+
intercom.admins.find(:id => admin_id)
121123
# Iterate over all admins
122124
intercom.admins.all.each {|admin| puts admin.email }
123125
```

lib/intercom/service/admin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
require 'intercom/service/base_service'
22
require 'intercom/api_operations/list'
3+
require 'intercom/api_operations/find'
34

45
module Intercom
56
module Service
67
class Admin < BaseService
78
include ApiOperations::List
9+
include ApiOperations::Find
810

911
def collection_class
1012
Intercom::Admin

spec/spec_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ def test_admin_list
126126
}
127127
end
128128

129+
def test_admin
130+
{
131+
"type" => "admin",
132+
"id" => "1234",
133+
"name" => "Hoban Washburne",
134+
"email" => "[email protected]"
135+
}
136+
end
137+
129138
def test_company
130139
{
131140
"type" => "company",

spec/unit/intercom/admin_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313
client.expects(:get).with("/admins", {}).returns(test_admin_list)
1414
client.admins.all.each { |a| }
1515
end
16+
17+
it "gets an admin" do
18+
client.expects(:get).with("/admins/1234", {}).returns(test_admin)
19+
client.admins.find(:id => "1234")
20+
end
1621
end

0 commit comments

Comments
 (0)