bcurren / freshbooks.rb Goto Github PK
View Code? Open in Web Editor NEWFreshBooks API wrapper
Home Page: http://freshbooks.rubyforge.org
License: Other
FreshBooks API wrapper
Home Page: http://freshbooks.rubyforge.org
License: Other
[edit] Sorry Ben, I'd installed the original freshbooks.rb, not yours. No issue.
I needed to add tasks to projects using your code, but found that the FreshBooks API rejects any tasks within project XML that include anything other than 'rate' and 'task_id'. My quick-and-dirty solution was to override Task's to_xml to only include those attributes:
class Task < FreshBooks::Task
def to_xml(elem_name = nil)
# The root element is the class name underscored
elem_name ||= self.class.to_s.split('::').last.underscore
root = REXML::Element.new(elem_name)
# only add rate and id to root elem
element = FreshBooks::XmlSerializer.to_node('rate', self.rate, 'fixnum')
root.add_element(element) if element != nil
# add id
element = FreshBooks::XmlSerializer.to_node('task_id', self.task_id, 'fixnum')
root.add_element(element) if element != nil
root.to_s
end
end
I imagine this needs more thought to solve as the above is a pretty messy solution. Perhaps another attribute when defining the attribute schema that defines whether or not each attribute should be included in upload XML. I noticed readonly
attributes are excluded, but these aren't readonly.
If I get a client via client = FreshBooks::Client.get(SOME_ID) & then call client.invoices, it returns all invoices, not just those belonging to the client. The options.merge("client_id" => self.client_id) should be the bang method to change the options variable.... ie options.merge!('client_id' => self.client_id)
Any attempt to update recurring objects seems to fail for me. Is this a known issue and are there any workarounds?
Thanks,
-=Josh
This might be ignorance on my part but when a call fails it seems all that's returned is true or false. I don't see a way to retrieve the error that was returned from FreshBooks.
This wiki says to see bentlegen's wiki which no longer exists.
I was attempting to programatically update a TimeEntry field and received this error:
Failed to update time_entry. Field cannot be changed: 'billed'.
It looks like the line https://github.com/bcurren/freshbooks.rb/blob/master/lib/freshbooks/time_entry.rb#L8 should be changed to
s.boolean :billed, :read_only => true
I did this locally and my update worked.
The documentation for time_entry.create shows that the 'billed' field is not used.
I can't figure out how to page through lists (like Client.list). Seems that any thing i try ends up grabbing the entire list instead of just pages. Any suggestions what I might be doing wrong?
account url permanently moved, what do?
This may be obvious to some, but it took me a while to figure out how to pull in the latest updates from github. It looks like 3.0.18 is the current version over on rubygems.org, so simply adding this to my Gemfile did not work:
gem 'freshbooks.rb', '~> 3.0.23'
Instead I had to do it like this:
gem 'bcurren-freshbooks.rb', :require => 'freshbooks', :git => 'git://github.com/bcurren/freshbooks.rb'
Mostly FYI. Hope that helps someone. Might be worth adding to the readme.
Nice job keeping this going, btw. It's a very critical part of our system! Thx.
I installled the Gem, added this to my environment.rb file:
config.gem 'bcurren-freshbooks.rb', :lib => 'freshbooks', :version => '3.0.23'
And added an initializer (freshbooks_startup.rb):
FreshBooks::Base.establish_connection('mysite.freshbooks.com', 'myapikey')
And I receive this error:
undefined method `api_list_action'
Note that I am using this on a BrowserCMS platform, an open source Rails CMS project. It only happens on one CMS admin page. Here is the full dump, any help is appreciated.
Message
undefined method `api_list_action' for #Class:0x2374a90
Stacktrace
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1994:in method_missing' /opt/local/lib/ruby/gems/1.8/gems/bcurren-freshbooks.rb-3.0.23/lib/freshbooks/base.rb:105:in
list'
/opt/local/lib/ruby/gems/1.8/gems/browsercms-3.1.2/app/controllers/cms/content_block_controller.rb:130:in load_blocks' /opt/local/lib/ruby/gems/1.8/gems/browsercms-3.1.2/app/controllers/cms/content_block_controller.rb:14:in
index'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in send' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in
perform_action_without_filters'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in call_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:610:in
perform_action_without_benchmark'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in
ms'
/opt/local/lib/ruby/1.8/benchmark.rb:308:in realtime' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in
ms'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:160:in
perform_action_without_flash'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in perform_action' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in
send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in process_without_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in
process'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:391:in process' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in
call'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:438:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:87:in
dispatch'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:121:in _call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:130:in
build_middleware_stack'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/string_coercion.rb:25:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/string_coercion.rb:25:in
call'
/Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in call' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in
call'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/session/abstract_store.rb:128:in
call'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in call' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
cache'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:9:in cache' /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:28:in
call'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in
call'
/Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in call' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in
synchronize'
/Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:114:in
call'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/reloader.rb:34:in run' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:108:in
call'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in call' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in
call'
/Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in each' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in
call'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/log_tailer.rb:17:in call' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in
call'
/Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48:in service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in
service'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /opt/local/lib/ruby/1.8/webrick/server.rb:173:in
start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:162:in
start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:92:in
each'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:23:in
start'
/opt/local/lib/ruby/1.8/webrick/server.rb:82:in start' /Users/crh/.gem/ruby/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb:14:in
run'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:111
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
require'
script/server:3
Trying to use freshbooks.rb in a Rails 3 project running on Ruby 1.9.2 and ran into a problem. I got the error below. The error is thrown as soon as I try to run
FreshBooks::Client.list
or
FreshBooks::Client.get(id)
in the rails console. If I run the same code under Ruby 1.8.7 I don't get the error.
FreshBooks::ParseError: Original Error: can't modify frozen string
XML:
<client_id>26</client_id>
danielgaiottino14
<first_name>Daniel</first_name>
<last_name>Gaiottino</last_name>
Burt
[email protected]
<work_phone/>
<home_phone/>
<vat_name/>
<vat_number/>
<p_street1/>
<p_street2/>
<p_city/>
<p_state/>
<p_country/>
<p_code/>
<s_street1/>
<s_street2/>
<s_city/>
<s_state/>
<s_country/>
<s_code/>
en
<currency_code/>
0
0
https://burtcorp.freshbooks.com/view/3LyJG2G8EcmiBBKg
<auth_url deprecated='true'>https://burtcorp.freshbooks.com/clients/26</auth_url>
<client_view>https://burtcorp.freshbooks.com/view/3LyJG2G8EcmiBBKg</client_view>
https://burtcorp.freshbooks.com/clients/26
https://burtcorp.freshbooks.com/view/Nnck2iLJKXuUTwe
2010-11-01 17:29:11
active
Message: FreshBooks::ParseError
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:31:in `rescue in new_from_xml'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:18:in `new_from_xml'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:129:in `block (2 levels) in api_list_action'
from /Users/daniel/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/element.rb:906:in `block in each'
from /Users/daniel/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/xpath.rb:64:in `each'
from /Users/daniel/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/xpath.rb:64:in `each'
from /Users/daniel/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/element.rb:906:in `each'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:129:in `map'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:129:in `block in api_list_action'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/list_proxy.rb:35:in `call'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/list_proxy.rb:35:in `move_to_page'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/list_proxy.rb:7:in `initialize'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:136:in `new'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:136:in `api_list_action'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/bcurren-freshbooks.rb-3.0.12/lib/freshbooks/base.rb:98:in `block (2 levels) in actions'
from (irb):1
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in `start'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/railties-3.0.1/lib/rails/commands/console.rb:8:in `start'
from /Users/daniel/.rvm/gems/ruby-1.9.2-p0@ka-ching/gems/railties-3.0.1/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Ruby it on a mogrel server directly is fine.
But when I run it on passenger, it says that it can't find the gem.
Run `rake gems:install` to install the missing gems.
Missing these required gems:
bcurren-freshbooks.rb
You're running:
ruby 1.8.6.287 at /opt/ruby-enterprise-1.8.6-20090421/bin/ruby
In my environment.rb, I have done this:
config.gem "bcurren-freshbooks.rb", :lib => "freshbooks", :source => "http://gems.github.com"
Instead of:
require 'freshbooks'
I've checked that the gem is installed:
[*@*]# gem list bcurren
*** LOCAL GEMS ***
bcurren-freshbooks.rb (3.0.2)
What could be the issue? This is on a production CentOS machine.
Is this project still actively maintained?
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.