Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby wrapper for the Fogbugz API

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 ruby-fogbugz.gemspec
README.md

ruby-fogbugz

A very simple wrapper for the Fogbugz API. It won't give you fancy classes for everything, it'll simply aid you in sending the API requests, parsing the returned XML finally retuning you a Hash.

Installation

gem install ruby-fogbugz
["mri-1.9,2", "mri-1.8.7", "rbx-1.2.4", "rbx-2.0.0", "jruby-1.6.2"].all? { |implementation| implementation.works? }
# => true

Usage

The Fogbugz API works by sending HTTP GET parameters to the API where the GET parameter cmd invokes a Fogbugz method, e.g. cmd=listProjects to get a list of all projects, cmds then accept further arguments, such as listing all cases assigned to a specific person:

cmd=search&ixAssignedTo=2&cols=sTitle,sStatus # list all cases associated to the user with ID of 2 in Fogbugz

In ruby-fogbugz that request would be:

fogbugz.command(:search, :ixAssignedTo => 2, :cols => "sTitle,sStatus")

Returns your parsed XML:

{
  "description"=>"All open cases assigned to Simon Eskildsen",
  "cases" => {
    "case"=> [
      {"ixBug"=>"143", "sTitle"=>"Write ruby-fogbugz documentation", 
      "sStatus"=>"active", "operations"=>"edit,assign,resolve,email,remind"},
      {"ixBug"=>"146", "sTitle"=>"Tame a unicorn", "sStatus"=>"active", 
      "operations"=>"edit,assign,resolve,email,remind"},
      {"ixBug"=>"152", "sTitle"=>"Hug a walrus", "sStatus"=>"active", 
      "operations"=>"edit,assign,resolve,email,remind"},
    ], "count"=>"3"
  }
}

As you see, ruby-fogbugz is without magic and leaves most to the user.

cmd is the first argument to Fogbugz#command, the second argument being a Hash of additional GET arguments to specify the request further. You can see available cmd's and arguments at the Fogbugz API documentation.

All Fogbugz API requests require a token. Thus #authenticate must be called on the ruby-fogbugz instance before #command's are sent:

require 'fogbugz'

fogbugz = Fogbugz::Interface.new(:email => 'my@email.com', :password => 'seekrit', :uri => 'https://company.fogbugz.com') # remember to use https!
fogbugz.authenticate # token is now automatically attached to every future requests
p fogbugz.command(:listPeople)

#authenticate fetches a new token every time. To avoid the extra request, obtain a token:

require 'fogbugz'

fogbugz = Fogbugz::Interface.new(:email => 'my@email.com', :password => 'seekrit', :uri => 'https://company.fogbugz.com') # remember to use https!
fogbugz.authenticate # token is now automatically attached to every future requests

puts "Token: #{fogbugz.token}"

Run the script, and initialize with the returned token:

fogbugz = Fogbugz::Interface.new(:token => "some token to use from now on", :uri => 'https://company.fogbugz.com') # remember to use https!

License

ruby-fogbugz is released under the MIT license.

Something went wrong with that request. Please try again.