Skip to content

Commit 84ce4a9

Browse files
committed
Add support to find admin by id
1 parent 4641787 commit 84ce4a9

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
@@ -92,6 +92,8 @@ intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@exampl
9292

9393
#### Admins
9494
```ruby
95+
# Find an admin by id
96+
intercom.admins.find(:id => admin_id)
9597
# Iterate over all admins
9698
intercom.admins.all.each {|admin| puts admin.email }
9799
```

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
@@ -71,6 +71,15 @@ def test_admin_list
7171
}
7272
end
7373

74+
def test_admin
75+
{
76+
"type" => "admin",
77+
"id" => "1234",
78+
"name" => "Hoban Washburne",
79+
"email" => "[email protected]"
80+
}
81+
end
82+
7483
def test_company
7584
{
7685
"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)