Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added view function mailboxes, which maps to API viewMailboxes. Also …
…added ability to add new Areas (area function), new Person (person function), and new FixFox's (new_fix_for function)
  • Loading branch information
austinmoody committed Jul 9, 2008
1 parent 11a6e53 commit b37d7ed
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
11 changes: 0 additions & 11 deletions TODO
Expand Up @@ -4,17 +4,6 @@
* Case manipulation
* edit, assign, reactivate, reopen, resolve, close, email, reply, forward
* file uploads
* new area
* new person
* new fix for
* view project
* view area
* view person
* view fix for
* view category
* view priority
* view status
* view mailbox
* working schedule
* time tracking
* source control
Expand Down
4 changes: 2 additions & 2 deletions fogbugz-api.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "fogbugz-api"
s.version = "0.0.3"
s.date = "2008-07-03"
s.version = "0.0.4"
s.date = "2008-07-09"

s.summary = "Ruby wrapper for FogBugz API"

Expand Down
50 changes: 50 additions & 0 deletions lib/fogbugz-api.rb
Expand Up @@ -2,6 +2,7 @@
require 'hpricot'
require 'net/https'
require 'cgi'
require 'date'

class FogBugzError < StandardError; end

Expand Down Expand Up @@ -166,6 +167,17 @@ def areas(fWrite=false, ixProject=nil, ixArea=nil)
result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)
return list_process(result,"area","sArea")
end

# Creates a new area within a specific project
#
# * ixProject: ID of the project to contain the new area.
# * sArea: Title of the new area.
# * ixPersonPrimaryContact: ID of the person who will be the primary contact for this area. -1 will set to the Project's primary contact, which is the default if not specified.
def new_area(ixProject,sArea,ixPersonPrimaryContact=-1)
cmd = {"cmd" => "newArea", "token" => @token, "ixProject" => ixProject.to_s, "sArea" => sArea.to_s, "ixPersonPrimaryContact" => ixPersonPrimaryContact.to_s}
result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)
return (result/"ixArea").inner_html.to_i
end

# Returns details about a specific area
#
Expand Down Expand Up @@ -209,6 +221,20 @@ def fix_for(fix_for,ixProject=nil)
return_value = list_process(result,"fixfor","sFixFor")
return_value[return_value.keys[0]]
end

# Creates a new FixFor within FogBugz.
#
# * sFixFor: Title for the new FixFor
# * fAssignable: Can cases be assigned to this FixFor? true/false Default is true.
# * ixProject: ID of the project this FixFor belongs to. If -1 (which is default when not specified) this will be a global FixFor.
# * dtRelease: Release date for the new FixFor. If not passed, no release date will be set. Expecting DateTime class if value is passed.
def new_fix_for(sFixFor,fAssignable=true,ixProject=-1,dtRelease=nil)
return nil if dtRelease and dtRelease.class != DateTime
cmd = {"cmd" => "newFixFor","token"=>@token,"sFixFor"=>sFixFor,"fAssignable"=>(fAssignable) ? "1" : "0","ixProject"=>ixProject.to_s}
cmd = {"dtRelease"=>dtRelease}.merge(cmd) if dtRelease
result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)
return (result/"ixFixFor").inner_html.to_i
end

def categories
cmd = {"cmd" => "listCategories", "token" => @token}
Expand Down Expand Up @@ -281,6 +307,18 @@ def person(ixPerson=nil,sEmail=nil)
return_value = list_process(result,"person","sFullName")
return_value[return_value.keys[0]]
end

# Creates a new Person within FogBugz.
#
# * sEmail: Email address of the new Person.
# * sFullname: Fullname of the new Person.
# * nType: Type for the new user. 0 = Normal User, 1 = Administrator, 2 = Community User, 3 = Virtual User
# * fActive: Is the new Person active? true/false
def new_person(sEmail,sFullname,nType,fActive=true)
cmd = {"cmd" => "newPerson", "token" => @token, "sEmail" => sEmail.to_s, "sFullname" => sFullname.to_s, "nType" => nType.to_s, "fActive" => (fActive) ? "1" : "0"}
result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)
return (result/"ixPerson").inner_html.to_i
end

# Returns a list of statuses for a particular category.
#
Expand Down Expand Up @@ -321,6 +359,18 @@ def mailboxes
return list_process(result,"mailbox","ixMailbox")
end

# Returns details about a specific mailbox
#
# * ixMailbox: The id of the Mailbox to view
#
# Value returned is a Hash containing all properties of the located Mailbox. nil is returned for unsuccessful search.
def mailbox(ixMailbox)
cmd = {"cmd" => "viewMailbox", "token" => @token, "ixMailbox" => ixMailbox.to_s}
result = Hpricot.XML(@connection.post(@api_url,to_params(cmd)).body)
return_value = list_process(result,"mailbox","ixMailbox")
return_value[return_value.keys[0]]
end

# Searches for FogBugz cases
#
# * q: Query for searching. Should hopefully work just like the Search box
Expand Down

0 comments on commit b37d7ed

Please sign in to comment.