Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/freshbooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@ def api_url # :nodoc:
"https://#{@domain}/api/#{API_VERSION}/xml-in"
end

def user_agent
{"User-Agent" => "ruby-freshbooks"}
end

# HTTParty (sort of) assumes global connections to services
# but we can easily avoid that by making an instance method
# that knows account-specific details that calls its
# coresponding class method.
# note: we only need to provide a #post method because the
# FreshBooks API is POST only
def post(method, params={}) # :nodoc:
headers = user_agent.merge(auth)
Response.new Client.post(api_url,
:headers => auth,
:headers => headers,
:body => Client.xml_body(method, params))
end

Expand Down