badbill 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CONTRIBUTING.md +5 -2
  2. data/Gemfile +14 -3
  3. data/Gemfile.lock +51 -15
  4. data/Guardfile +6 -0
  5. data/LICENSE +1 -1
  6. data/README.md +8 -3
  7. data/Rakefile +5 -1
  8. data/badbill.gemspec +86 -0
  9. data/lib/badbill.rb +32 -2
  10. data/lib/badbill/base_resource.rb +51 -9
  11. data/lib/badbill/client.rb +1 -1
  12. data/lib/badbill/faraday_gzip.rb +18 -0
  13. data/lib/badbill/forward_methods.rb +6 -0
  14. data/lib/badbill/invoice.rb +31 -1
  15. data/lib/badbill/invoice_comment.rb +24 -0
  16. data/lib/badbill/invoice_item.rb +17 -0
  17. data/lib/badbill/invoice_payment.rb +28 -0
  18. data/lib/badbill/recurring.rb +11 -0
  19. data/spec/badbill/base_resource_spec.rb +1 -1
  20. data/spec/badbill/client_spec.rb +72 -68
  21. data/spec/badbill/invoice_comment_spec.rb +33 -0
  22. data/spec/badbill/invoice_item_spec.rb +17 -0
  23. data/spec/badbill/invoice_payment_spec.rb +17 -0
  24. data/spec/badbill/invoice_spec.rb +77 -176
  25. data/spec/badbill/recurring_spec.rb +18 -0
  26. data/spec/badbill_spec.rb +19 -17
  27. data/spec/fixtures/vcr_cassettes/aggregated_invoices.yml +64 -0
  28. data/spec/fixtures/vcr_cassettes/all_clients.yml +72 -0
  29. data/spec/fixtures/vcr_cassettes/all_invoices.yml +134 -0
  30. data/spec/fixtures/vcr_cassettes/all_recurring_invoices.yml +131 -0
  31. data/spec/fixtures/vcr_cassettes/client_on_change.yml +54 -0
  32. data/spec/fixtures/vcr_cassettes/draft_item.yml +71 -0
  33. data/spec/fixtures/vcr_cassettes/existent_client.yml +71 -0
  34. data/spec/fixtures/vcr_cassettes/fetched_invoice_pdf.yml +2111 -0
  35. data/spec/fixtures/vcr_cassettes/fetches_invoice-item_by_id.yml +123 -0
  36. data/spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id.yml +68 -0
  37. data/spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id_and_actionkey_PAYMENT.yml +131 -0
  38. data/spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id_and_actionkeys.yml +67 -0
  39. data/spec/fixtures/vcr_cassettes/invoice_canceled.yml +50 -0
  40. data/spec/fixtures/vcr_cassettes/invoice_deleted.yml +46 -0
  41. data/spec/fixtures/vcr_cassettes/invoice_info.yml +131 -0
  42. data/spec/fixtures/vcr_cassettes/invoice_marked_as_complete.yml +95 -0
  43. data/spec/fixtures/vcr_cassettes/invoice_payments.yml +123 -0
  44. data/spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info.yml +48 -0
  45. data/spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info_and_from.yml +48 -0
  46. data/spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info_from_and_subject.yml +48 -0
  47. data/spec/fixtures/vcr_cassettes/invoice_send_mail.yml +48 -0
  48. data/spec/fixtures/vcr_cassettes/invoice_send_mail_invalid_address.yml +48 -0
  49. data/spec/fixtures/vcr_cassettes/invoice_uploaded_signature.yml +48 -0
  50. data/spec/fixtures/vcr_cassettes/myself_client.yml +70 -0
  51. data/spec/fixtures/vcr_cassettes/new_client.yml +50 -0
  52. data/spec/fixtures/vcr_cassettes/non_existent_client.yml +303 -0
  53. data/spec/fixtures/vcr_cassettes/save_for_non-existent_client.yml +48 -0
  54. data/spec/fixtures/vcr_cassettes/wrong_data_for_client.yml +50 -0
  55. data/spec/spec_helper.rb +50 -0
  56. metadata +43 -4
  57. data/spec/helper.rb +0 -24
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://rediger.billomat.net/api/clients/169500
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"client":{"name":"new name","id":169500}}'
9
+ headers:
10
+ X-Billomatapikey:
11
+ - e1923a9ab25fc955be3321725be882bd
12
+ Accept:
13
+ - application/json
14
+ Content-Type:
15
+ - application/json
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Date:
24
+ - Thu, 15 Nov 2012 20:20:04 GMT
25
+ Server:
26
+ - Apache
27
+ X-Powered-By:
28
+ - PHP/5.3.3-7+squeeze14
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Cache-Control:
32
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
33
+ Pragma:
34
+ - no-cache
35
+ Set-Cookie:
36
+ - language=de_DE; expires=Fri, 15-Nov-2013 20:20:04 GMT; path=/
37
+ Vary:
38
+ - Accept-Encoding
39
+ Content-Length:
40
+ - '36'
41
+ Content-Type:
42
+ - application/json
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ! '{"errors":{"error":"Row not found"}}'
46
+ http_version:
47
+ recorded_at: Thu, 15 Nov 2012 20:20:04 GMT
48
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://rediger.billomat.net/api/clients/
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"client":{"email":"this@is.invalid"}}'
9
+ headers:
10
+ X-Billomatapikey:
11
+ - e1923a9ab25fc955be3321725be882bd
12
+ Accept:
13
+ - application/json
14
+ Content-Type:
15
+ - application/json
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 400
21
+ message: Bad Request
22
+ headers:
23
+ Date:
24
+ - Mon, 05 Nov 2012 15:46:42 GMT
25
+ Server:
26
+ - Apache
27
+ X-Powered-By:
28
+ - PHP/5.3.3-7+squeeze14
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Cache-Control:
32
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
33
+ Pragma:
34
+ - no-cache
35
+ Set-Cookie:
36
+ - language=de_DE; expires=Tue, 05-Nov-2013 15:46:42 GMT; path=/
37
+ Vary:
38
+ - Accept-Encoding
39
+ Content-Length:
40
+ - '44'
41
+ Connection:
42
+ - close
43
+ Content-Type:
44
+ - application/json
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ! '{"errors":{"error":"invalid email address"}}'
48
+ http_version:
49
+ recorded_at: Mon, 05 Nov 2012 15:46:42 GMT
50
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ if ENV['COVERAGE']
4
+ require 'simplecov'
5
+
6
+ SimpleCov.formatter = Class.new do
7
+ def format(result)
8
+ SimpleCov::Formatter::HTMLFormatter.new.format(result) unless ENV['CI']
9
+ File.open('coverage/covered_percent', 'w') do |f|
10
+ f.puts result.source_files.covered_percent.to_i
11
+ end
12
+ end
13
+ end
14
+
15
+ SimpleCov.start
16
+ end
17
+
18
+ require 'rspec'
19
+ require 'webmock/rspec'
20
+ require 'vcr'
21
+
22
+ VCR.configure do |c|
23
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
24
+ c.hook_into :webmock
25
+ c.default_cassette_options = { :record => :new_episodes }
26
+ end
27
+
28
+ here = File.expand_path(File.dirname(__FILE__) + '/..')
29
+ $LOAD_PATH.unshift here+'/lib'
30
+
31
+ def new_badbill version
32
+ key = nil
33
+ id = nil
34
+
35
+ # We need a working id/key combination just once,
36
+ # test cases are recorded through VCR for later use.
37
+ #
38
+ # Whenever a new test is added, get a new API key.
39
+ case version
40
+ when 1
41
+ id = 'rediger'
42
+ key = 'e1923a9ab25fc955be3321725be882bd'
43
+ end
44
+ fail('need Billomat ID') unless id
45
+ fail('need Billomat API key') unless key
46
+
47
+ BadBill.new id, key
48
+ end
49
+
50
+ require 'badbill'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badbill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2013-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -119,20 +119,59 @@ files:
119
119
  - ./CONTRIBUTING.md
120
120
  - ./Gemfile
121
121
  - ./Gemfile.lock
122
+ - ./Guardfile
122
123
  - ./LICENSE
123
124
  - ./README.md
124
125
  - ./Rakefile
126
+ - ./badbill.gemspec
125
127
  - ./lib/badbill.rb
126
128
  - ./lib/badbill/base_resource.rb
127
129
  - ./lib/badbill/client.rb
130
+ - ./lib/badbill/faraday_gzip.rb
128
131
  - ./lib/badbill/forward_methods.rb
129
132
  - ./lib/badbill/invoice.rb
133
+ - ./lib/badbill/invoice_comment.rb
134
+ - ./lib/badbill/invoice_item.rb
135
+ - ./lib/badbill/invoice_payment.rb
136
+ - ./lib/badbill/recurring.rb
130
137
  - ./lib/badbill/resource.rb
131
138
  - ./spec/badbill/base_resource_spec.rb
132
139
  - ./spec/badbill/client_spec.rb
140
+ - ./spec/badbill/invoice_comment_spec.rb
141
+ - ./spec/badbill/invoice_item_spec.rb
142
+ - ./spec/badbill/invoice_payment_spec.rb
133
143
  - ./spec/badbill/invoice_spec.rb
144
+ - ./spec/badbill/recurring_spec.rb
134
145
  - ./spec/badbill_spec.rb
135
- - ./spec/helper.rb
146
+ - ./spec/fixtures/vcr_cassettes/aggregated_invoices.yml
147
+ - ./spec/fixtures/vcr_cassettes/all_clients.yml
148
+ - ./spec/fixtures/vcr_cassettes/all_invoices.yml
149
+ - ./spec/fixtures/vcr_cassettes/all_recurring_invoices.yml
150
+ - ./spec/fixtures/vcr_cassettes/client_on_change.yml
151
+ - ./spec/fixtures/vcr_cassettes/draft_item.yml
152
+ - ./spec/fixtures/vcr_cassettes/existent_client.yml
153
+ - ./spec/fixtures/vcr_cassettes/fetched_invoice_pdf.yml
154
+ - ./spec/fixtures/vcr_cassettes/fetches_invoice-item_by_id.yml
155
+ - ./spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id.yml
156
+ - ./spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id_and_actionkey_PAYMENT.yml
157
+ - ./spec/fixtures/vcr_cassettes/invoice-comments_by_invoice_id_and_actionkeys.yml
158
+ - ./spec/fixtures/vcr_cassettes/invoice_canceled.yml
159
+ - ./spec/fixtures/vcr_cassettes/invoice_deleted.yml
160
+ - ./spec/fixtures/vcr_cassettes/invoice_info.yml
161
+ - ./spec/fixtures/vcr_cassettes/invoice_marked_as_complete.yml
162
+ - ./spec/fixtures/vcr_cassettes/invoice_payments.yml
163
+ - ./spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info.yml
164
+ - ./spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info_and_from.yml
165
+ - ./spec/fixtures/vcr_cassettes/invoice_send_email_with_basic_info_from_and_subject.yml
166
+ - ./spec/fixtures/vcr_cassettes/invoice_send_mail.yml
167
+ - ./spec/fixtures/vcr_cassettes/invoice_send_mail_invalid_address.yml
168
+ - ./spec/fixtures/vcr_cassettes/invoice_uploaded_signature.yml
169
+ - ./spec/fixtures/vcr_cassettes/myself_client.yml
170
+ - ./spec/fixtures/vcr_cassettes/new_client.yml
171
+ - ./spec/fixtures/vcr_cassettes/non_existent_client.yml
172
+ - ./spec/fixtures/vcr_cassettes/save_for_non-existent_client.yml
173
+ - ./spec/fixtures/vcr_cassettes/wrong_data_for_client.yml
174
+ - ./spec/spec_helper.rb
136
175
  homepage: https://github.com/badboy/badbill
137
176
  licenses: []
138
177
  post_install_message:
@@ -153,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
192
  version: 1.3.5
154
193
  requirements: []
155
194
  rubyforge_project:
156
- rubygems_version: 1.8.24
195
+ rubygems_version: 1.8.23
157
196
  signing_key:
158
197
  specification_version: 2
159
198
  summary: Simple but working API client for the Billomat API.
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
-
3
- if ENV['COVERAGE']
4
- require 'simplecov'
5
-
6
- SimpleCov.formatter = Class.new do
7
- def format(result)
8
- SimpleCov::Formatter::HTMLFormatter.new.format(result) unless ENV['CI']
9
- File.open('coverage/covered_percent', 'w') do |f|
10
- f.puts result.source_files.covered_percent.to_i
11
- end
12
- end
13
- end
14
-
15
- SimpleCov.start
16
- end
17
-
18
- require 'rspec'
19
- require 'webmock/rspec'
20
-
21
- here = File.expand_path(File.dirname(__FILE__) + '/..')
22
- $LOAD_PATH.unshift here+'/lib'
23
-
24
- require 'badbill'