anibalcucco / basecamp-wrapper Goto Github PK
View Code? Open in Web Editor NEWUsing the Basecamp API with Ruby
License: Apache License 2.0
Using the Basecamp API with Ruby
License: Apache License 2.0
Hi guys,
How can I change the default format from JSON to XML?
Thanks in advance.
Hi,
I'm having trouble updating time_entries, wondered if I am doing something wrong, this is what I'm doing:
time_entry = Basecamp::TimeEntry.find(params[:id])
returns:
<Basecamp::TimeEntry:0x007fd2a5622468 @attributes={"date"=>Fri, 27 Apr 2012, "description"=>"", "hours"=>8.0, "person_id"=>6506151, "person_name"=>"Chris Miller"}, @prefix_options={}, @persisted=true>
I change the hours:
time_entry.hours = 4
then save
time_entry.save
returns
ActiveResource::ResourceNotFound Exception: Failed. Response code = 404. Response message = Not Found.
I tried setting the id for the time_entry
time_entry.id = params[:id]
and then saving, which gives this response:
false
Am I missing something perhaps?
cheers
Chris :)
Storing the connection at the class-level means that all threads try to use the same Net::HTTP instance concurrently. I was able to make the gem thread-safe by changing one line to use a connection pool from the connection_pool gem:
@connection = ConnectionPool::Wrapper.new(:size => 5) { Connection.new(self) }
This creates 5 connections which are shared by all threads.
How can we get the same data that Launchpad displays via this wrapper?
We want a user to be able to access all projects across all BC 'accounts' they are a part of. We are targeting our app at freelancers who have multiple clients on their Launchpad and who we wouldn't want to ask to login on every 'account'.
Kind regards,
Gareth
Hi Guys,
I can't seem to get any further than this:
Loading development environment (Rails 3.1.1)
irb(main):001:0> Basecamp.establish_connection!('xxxxxxxxxxx.basecamphq.com', 'xxxxxxxxxxxxxxxxxxx', 'X', true)
=> #<Basecamp::Connection:0x00000100d7e0c8 @master=Basecamp, @connection=#<Net::HTTP xxxxxxx.basecamphq.com:443 open=false>>
irb(main):002:0> Basecamp::Person.me
=> #<Basecamp::Person:0x00000100bd4bc8 @attributes={"name"=>"Gareth Edwards", "title"=>"Developer", "phoneNumberMobile"=>"xxxxxxx", "recentProjectsCount"=>6, "admin"=>false, "avatarUrl"=>"https://asset0.37img.com/global/missing/avatar.png?r=3", "phoneNumberHome"=>"", "baseType"=>"Person", "firmId"=>xxxxxx, "id"=>xxxxxxx, "emailAddress"=>"[email protected]", "type"=>"FirmEmployee", "phoneNumberOfficeExt"=>"", "clientId"=>0, "phoneNumberOffice"=>""}, @prefix_options={}, @persisted=false>
irb(main):003:0> Basecamp::Project.all
NoMethodError: undefined method collect!' for #<Hash:0x00000100b74c50> from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/activeresource-3.1.1/lib/active_resource/base.rb:922:in
instantiate_collection'
from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/activeresource-3.1.1/lib/active_resource/base.rb:894:in find_every' from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/activeresource-3.1.1/lib/active_resource/base.rb:806:in
find'
from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/activeresource-3.1.1/lib/active_resource/base.rb:832:in all' from (irb):3 from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in
start'
from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in start' from /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:40:in
<top (required)>'
from script/rails:6:in require' from script/rails:6:in
I'm getting 404 errors when trying to create Basecamp messages using the wrapper.
I can create Projects successfully:
p = Basecamp::Project.new()
p.name = 'My Test Project'
p.save
The project shows up in Basecamp on the web without problem.
And I can grab the new project id:
proj_id = p.id
But when I try to create messages on the project...
m = Basecamp::Message.new(:project_id => proj_id)
m.title = 'Message in a bottle'
m.body = 'Another lonely day, with no one here but me'
m.save
It returns a 404 error after the save method:
ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found.
from /Users/benunsworth/.rvm/gems/ruby-1.9.3-p0/gems/activeresource-3.2.0/lib/active_resource/connection.rb:136:in `handle_response' ...
Any idea?
Thanks,
Ben
For some reason I am not getting the todo item id as an attribute for a time entry? I see it in the XML, but not in the object. Any idea what I may be doing wrong?
Comments come back with a "continued-at" attribute that this library doesn't seem to respect. This means that only the most 75 most recent comments will be returned.
Hi,
It seems that the Basecamp.record(s) methods always send a POST request (even with no parameters to post).
So when I try to do Basecamp.records("project", "/projects")
, I get a Unprocessable Entity (422) error message but with Basecamp::Project.all
, everything's working great.
Am I missing something ?
Thanks in advance.
I install the gem and add the config.gem line to my environment.rb โ ./script/server works fine and I can keep developing just fine. Then I try to rake...
rake aborted!
can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.1.0 for ["faraday-0.4.6", "oauth2-0.0.13", "basecamp-0.0.2"]
So I comment out the line "config.gem 'basecamp', :version => '0.0.2'" and rake again. All works fine. This is...kind of annoying but not that bad for development. However when I try to deploy I get the Phusion exception page with the above error.
I know I may be trying to finagle the gem into a version set it's not meant for. But I'm just looking for any help I can get as far as making rack, rails, and this basecamp gem work together.
Hello,
Which version of Rails is needed to run this code? I have been trying for hours to get this to work, but I keep getting this error:
The 'activeresource' library could not be loaded. If you have RubyGems
installed you can install ActiveResource by doing "gem install activeresource".
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0.rc)
actionpack (3.0.0.rc)
activemodel (3.0.0.rc)
activerecord (3.0.0.rc)
activeresource (3.0.0.rc, 2.3.8)
activesupport (3.0.0.rc, 2.3.8)
addressable (2.1.2)
etc...
I'm not sure if this is an ActiveRecord issue or one with the wrapper. If you create a message/post like this:
object = Basecamp::Message.create(:project_id => self.basecamp_id, :title => title, :body => body, :use_textile => true)}
Their is something wrong with the object that is returned:
object.reload
ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found.
object.destroy
ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found.
I am trying to retrieve time entries for a specific todo item but it doesn't seem to be working.
Initially I tried:
Basecamp::TimeEntry.find(:all, :params => { :todo_item_id => 114748954 })
but that resulted in:
ActiveResource::MissingPrefixParam: project_id prefix_option is missing
so I tried:
Basecamp::TimeEntry.find(:all, :params => { :todo_item_id => 114748954, :project_id => 8471706 })
but I keep getting a nil result
I have also tried accessing all time entries for a project like:
Basecamp::TimeEntry.all(8471706, 1)
and I get:
ActiveResource::MissingPrefixParam: todo_item_id prefix_option is missing
is there a way to get the time entries for an individual todo_item? I would even be happy enough to get the time entries by page for a project.
Cheers,
Jon
Hi,
I'm trying to create a project using a project template. http://help.37signals.com/basecamp/questions/126-can-i-create-a-project-template-so-i-don-t-have-to-start-from-scratch-each-time
Because I didn't find any documentation on this, I found this on google: https://groups.google.com/group/37signals-api/tree/browse_frm/thread/57175dfe4ff7fb49/cefcef722bda6378?hide_quotes=no
To add this param, I changed my code to this:
Basecamp::Project.create(:name => self.basecamp_name, :project_template_id => template_project_id)
But unfortunately, this 'project_template_id' param seems to be ignored..
Am I doing something wrong or is this param not implemented?
Thank you for your time!
I haven't found a good way to get a hold of the ActiveResponse response headers. This is kind of crucial for the API as pagination data is passed back in the headers. This snippet gets an empty list of headers:
Basecamp.establish_connection!('domain.basecamphq.com', 'xxxxxxxxxxxx', 'X', true)
entries = Basecamp::TimeEntry.find(:all, :params => { :project_id => xxxxxx, :page => 1 })
puts Basecamp::TimeEntry.headers.inspect
Thanks in advance,
Appears that Basecamp altered the API to support RESTful calendar entries for milestones and events.
I think the same issue we had with messages exists with todo_items. Because the todo_list is the parent the todo_list_id is being consumed and you can't do this:
> todo_items = Basecamp::TodoItem.find(:all, :params => { :todo_list_id => 3422 })
> todo_items.first.todo_list
NameError Exception: undefined local variable or method `todo_list_id' for #<Basecamp::TodoItem:0x007fe52a9b5980>
Unfortunately, this becomes an issue when you access time entries because you only get the todo_item_id along with the entry. That makes it pretty hard to go from the time entry to the todo item and the todo list associated with it.
The new version seems to have broken the project.
This works:
Basecamp.establish_connection!('https://basecamp.com', 'login', 'password')
This does not:
Basecamp::Person.me
or
Basecamp::Person.me.token
My suspicion is that the new version which removed tokens also moved things around.
Ruby 1.9.3 / Rails 3.2.3
I'm trying to request a variety of data using the find method and passing in some params, however I only seem to be able to get back data without any influence from the params. Eg:
Basecamp::Project.find(:all, :params => { :id => @project.id } # returns all projects
Basecamp::Project.find(:first, :params => { :id => @project.id } # returns the first of all projects
Could this be an issue (although surprised nobody has raised it before now if it is), or, more likely, am I perhaps doing something wrong somewhere along the line?
Thanks!
how i can use following lines
Basecamp::TodoList.find(List_Id).project || Basecamp::TodoList.find(List_Id).project_id
the line in Basecamp::TodoList#parent_resource
has magic, which i don't understand.
Pls help me :)
Basecamp.establish_connection!('site', 'username', 'password')
Basecamp::Project.all
Gives:
Failed. Response code = 301. Response message = Moved Permanently. => https://site.basecamphq.com/projects.json
Shouldn't redirects be followed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.