ruby-freshbooks 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.3.1
2
+ * *actually* add LoggingClient example
3
+
1
4
  == 0.3.0
2
5
  * added LoggingClient example, pretty printing for generated xml, terrible hack to cover weird response FreshBooks' API gives instead of 404s
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'ruby-freshbooks'
3
+ require 'logger'
4
+
5
+ module FreshBooks
6
+ class LoggingClient < TokenClient
7
+ def initialize(domain, api_token, logger)
8
+ @logger = logger
9
+ super domain, api_token
10
+ end
11
+
12
+ def post(method, params={})
13
+ body = Client.xml_body(method, params)
14
+ @logger.info "\n== Request ==\n#{body}"
15
+ data = Client.post(api_url,
16
+ :headers => auth,
17
+ :body => body)
18
+ @logger.info "\n== Response ==\n#{data.body}\n"
19
+ Response.new data
20
+ end
21
+ end
22
+ end
23
+
24
+ logger = Logger.new(STDOUT)
25
+
26
+ lc = FreshBooks::LoggingClient.new('youraccount.freshbooks.com',
27
+ 'yourfreshbooksapitoken',
28
+ logger)
29
+
30
+ lc.client.get :client_id => 2
31
+ # prints the following to standard out:
32
+ #
33
+ # I, [2010-05-15T22:42:23.496144 #91945] INFO -- :
34
+ # == Request ==
35
+ # <?xml version="1.0" encoding="utf-8"?>
36
+ # <request method="client.get">
37
+ # <client_id>2</client_id>
38
+ # </request>
39
+ #
40
+ #
41
+ # I, [2010-05-15T22:42:24.061579 #91945] INFO -- :
42
+ # == Response ==
43
+ # <?xml version="1.0" encoding="utf-8"?>
44
+ # <response xmlns="http://www.freshbooks.com/api/" status="ok">
45
+ # <client>
46
+ # <client_id>2</client_id>
47
+ # <username>foolhardy</username>
48
+ # ...
49
+ # </client>
50
+ # </repsonse>
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.date = Date.today.to_s
8
8
  s.description = %q{simple FreshBooks API wrapper. supports both OAuth and API token authentication}
9
9
  s.email = %q{elucid@gmail.com}
10
- s.files = ["README.md", "LICENSE", "VERSION", "CHANGELOG", "ruby-freshbooks.gemspec", "lib/freshbooks.rb", "lib/ruby-freshbooks.rb", "spec/freshbooks_spec.rb"]
10
+ s.files = ["README.md", "LICENSE", "VERSION", "CHANGELOG", "ruby-freshbooks.gemspec", "lib/freshbooks.rb", "lib/ruby-freshbooks.rb", "spec/freshbooks_spec.rb", "examples/logging_client.rb"]
11
11
  s.has_rdoc = false
12
12
  s.homepage = %q{http://github.com/elucid/ruby-freshbooks}
13
13
  s.require_paths = ["lib"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Justin Giancola
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-26 00:00:00 -04:00
17
+ date: 2010-05-27 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -76,6 +76,7 @@ files:
76
76
  - lib/freshbooks.rb
77
77
  - lib/ruby-freshbooks.rb
78
78
  - spec/freshbooks_spec.rb
79
+ - examples/logging_client.rb
79
80
  has_rdoc: true
80
81
  homepage: http://github.com/elucid/ruby-freshbooks
81
82
  licenses: []