Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from tstachl/clean
Add groups and max requests limit.
- Loading branch information
Showing
11 changed files
with
265 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Desk | ||
class Client | ||
# Defines methods related to groups | ||
module Group | ||
# Returns extended information of groups | ||
# | ||
# @option options [Boolean, String, Integer] | ||
# @example Return extended information for 12345 | ||
# Desk.groups | ||
# Desk.groups(:count => 5) | ||
# Desk.groups(:count => 5, :page => 3) | ||
# @format :json | ||
# @authenticated true | ||
# @see http://dev.desk.com/docs/api/groups | ||
def groups(*args) | ||
options = args.last.is_a?(Hash) ? args.pop : {} | ||
response = get("groups",options) | ||
response | ||
end | ||
|
||
# Returns extended information on a single group | ||
# | ||
# @param id [Integer] a group ID | ||
# @option options [Hash] | ||
# @example Return extended information for 12345 | ||
# Desk.group(12345) | ||
# @format :json | ||
# @authenticated true | ||
# @see http://dev.desk.com/docs/api/groups/show | ||
def group(id) | ||
response = get("groups/#{id}") | ||
response.group | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'helper' | ||
|
||
describe Desk::Client do | ||
Desk::Configuration::VALID_FORMATS.each do |format| | ||
context ".new(:format => '#{format}')" do | ||
before do | ||
@client = Desk::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS') | ||
end | ||
|
||
describe ".groups" do | ||
context "lookup" do | ||
before do | ||
stub_get("groups.#{format}"). | ||
to_return(:body => fixture("groups.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) | ||
end | ||
|
||
it "should get the correct resource" do | ||
@client.groups | ||
a_get("groups.#{format}"). | ||
should have_been_made | ||
end | ||
|
||
it "should return up to 100 groups worth of extended information" do | ||
groups = @client.groups | ||
groups.results.should be_a Array | ||
groups.results.last.group.id.should == 2 | ||
groups.results.last.group.name.should == "Administrators" | ||
end | ||
end | ||
end | ||
|
||
describe ".group" do | ||
context "lookup" do | ||
before do | ||
stub_get("groups/1.#{format}"). | ||
to_return(:body => fixture("group.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) | ||
end | ||
|
||
it "should get the correct resource" do | ||
@client.group(1) | ||
a_get("groups/1.#{format}"). | ||
should have_been_made | ||
end | ||
|
||
it "should return up to 100 cases worth of extended information" do | ||
group = @client.group(1) | ||
group.id.should == 1 | ||
group.name.should == "Sales" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"group": { | ||
"id": 1, | ||
"name": "Sales", | ||
"created_at": "2013-01-21T09:47:23Z", | ||
"updated_at": "2013-01-21T09:47:23Z" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"results": [ | ||
{ | ||
"group": { | ||
"id": 1, | ||
"name": "Sales", | ||
"created_at": "2013-01-21T09:47:23Z", | ||
"updated_at": "2013-01-21T09:47:23Z" | ||
} | ||
}, | ||
{ | ||
"group": { | ||
"id": 2, | ||
"name": "Administrators", | ||
"created_at": "2013-01-21T09:47:23Z", | ||
"updated_at": "2013-01-21T09:47:23Z" | ||
} | ||
} | ||
], | ||
"page": 1, | ||
"count": 20, | ||
"total": 2 | ||
} |