Git Product home page Git Product logo

freshbooks.rb's People

Contributors

ahoward avatar anlek avatar bcurren avatar calebhaye avatar fuzzygroup avatar gregg avatar lawrencepit avatar lukeledet avatar mattc58 avatar meceo avatar mrw avatar trabianmatt avatar tylerrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

freshbooks.rb's Issues

Adding tasks to projects

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.

client.invoices returns wrong info

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)

Unable to see errors

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.

Problems paging lists

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?

Trouble installing most recent updates via Bundler

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.

undefined method `api_list_action' v 3.0.23 with BrowserCMS

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:inlist'
/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:inindex'
/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:inperform_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:inperform_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:inms'
/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:inms'
/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:inperform_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:insend'
/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:inprocess'
/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:incall'
/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:indispatch'
/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:inbuild_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:incall'
/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:incall'
/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:incall'
/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:incache'
/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:incall'
/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:incall'
/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:insynchronize'
/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:incall'
/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:incall'
/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:incall'
/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:incall'
/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:incall'
/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:inservice'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /opt/local/lib/ruby/1.8/webrick/server.rb:173:instart_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:162:instart_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:92:ineach'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:23:instart'
/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:inrun'
/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:inrequire'
script/server:3

can't modify frozen string

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>'

Problem running on Passenger

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.

Active?

Is this project still actively maintained?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.