badbill 0.0.1 → 0.1.0

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.
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,131 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://rediger.billomat.net/api/invoices/352709
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Billomatapikey:
11
+ - e1923a9ab25fc955be3321725be882bd
12
+ Accept:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: !binary |-
22
+ T0s=
23
+ headers:
24
+ !binary "RGF0ZQ==":
25
+ - !binary |-
26
+ TW9uLCAwNSBOb3YgMjAxMiAxNjowMjoyOCBHTVQ=
27
+ !binary "U2VydmVy":
28
+ - !binary |-
29
+ QXBhY2hl
30
+ !binary "WC1Qb3dlcmVkLUJ5":
31
+ - !binary |-
32
+ UEhQLzUuMy4zLTcrc3F1ZWV6ZTE0
33
+ !binary "RXhwaXJlcw==":
34
+ - !binary |-
35
+ VGh1LCAxOSBOb3YgMTk4MSAwODo1MjowMCBHTVQ=
36
+ !binary "Q2FjaGUtQ29udHJvbA==":
37
+ - !binary |-
38
+ bm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hl
39
+ Y2s9MCwgcHJlLWNoZWNrPTA=
40
+ !binary "UHJhZ21h":
41
+ - !binary |-
42
+ bm8tY2FjaGU=
43
+ !binary "U2V0LUNvb2tpZQ==":
44
+ - !binary |-
45
+ bGFuZ3VhZ2U9ZGVfREU7IGV4cGlyZXM9VHVlLCAwNS1Ob3YtMjAxMyAxNjow
46
+ MjoyOCBHTVQ7IHBhdGg9Lw==
47
+ !binary "Q29udGVudC1FbmNvZGluZw==":
48
+ - !binary |-
49
+ Z3ppcA==
50
+ !binary "Q29udGVudC1MZW5ndGg=":
51
+ - !binary |-
52
+ NDI5
53
+ !binary "Q29udGVudC1UeXBl":
54
+ - !binary |-
55
+ YXBwbGljYXRpb24vanNvbg==
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: !binary |-
59
+ H4sIAAAAAAAAA21STW/bMAz9K4GuawLJsdMktwLNpfsK+nEYEEBQZcYRZlOe
60
+ LG0zgv73iXJmxFsvFvlo8vGRPDODP63RwLZnZkq2Zcsiu+UbdsO0A+WBoIyL
61
+ bC7EnOfPYrMtxJZnH3j8cvqrNoBeplSx2uQbSr3UlBiaV3AUieA7jmxdJGbR
62
+ LyPVhCliXWjbupeX0BSQvm8JfXrZ7z99k/d3zzuqEkBOKmVzXox435E8Yldl
63
+ 6aAj90HhfOfM99kjlKYCd8D/kY+HwPlxhabqTsnUFdSzbHnAIuO3+exO6RPg
64
+ Ae8h+E6faoUlNeuVD0Txdb/7Qj2YTtsQR+VGPSP0j3qxngZT4yK/BlVDT4Rp
65
+ B7V6hXooadA7O5ho//J461UtK2eTZMEXaXMDikBV1os8LTM4B6h7qW1JubuX
66
+ x4j+CEMlEfNSpoMyaG8sXviv6suAKZruJjFNuSZxYk3hVvUNXREttbv0rH6T
67
+ eSaDHlQN9fD515OnDoaBCTq2cRRisRrdK13LnL293TB7PMaDS3dKSi0ejWsU
68
+ qRhBBzQAg9WAZGK9LmLuH5ONeg0kAwAA
69
+ http_version:
70
+ recorded_at: Mon, 05 Nov 2012 16:02:28 GMT
71
+ - request:
72
+ method: get
73
+ uri: http://rediger.billomat.net/api/invoices/352320
74
+ body:
75
+ encoding: US-ASCII
76
+ string: ''
77
+ headers:
78
+ X-Billomatapikey:
79
+ - e1923a9ab25fc955be3321725be882bd
80
+ Accept:
81
+ - application/json
82
+ Accept-Encoding:
83
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
84
+ User-Agent:
85
+ - Ruby
86
+ response:
87
+ status:
88
+ code: 404
89
+ message: !binary |-
90
+ Tm90IEZvdW5k
91
+ headers:
92
+ !binary "RGF0ZQ==":
93
+ - !binary |-
94
+ V2VkLCAxNCBOb3YgMjAxMiAxOToyMTowNiBHTVQ=
95
+ !binary "U2VydmVy":
96
+ - !binary |-
97
+ QXBhY2hl
98
+ !binary "WC1Qb3dlcmVkLUJ5":
99
+ - !binary |-
100
+ UEhQLzUuMy4zLTcrc3F1ZWV6ZTE0
101
+ !binary "RXhwaXJlcw==":
102
+ - !binary |-
103
+ VGh1LCAxOSBOb3YgMTk4MSAwODo1MjowMCBHTVQ=
104
+ !binary "Q2FjaGUtQ29udHJvbA==":
105
+ - !binary |-
106
+ bm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hl
107
+ Y2s9MCwgcHJlLWNoZWNrPTA=
108
+ !binary "UHJhZ21h":
109
+ - !binary |-
110
+ bm8tY2FjaGU=
111
+ !binary "U2V0LUNvb2tpZQ==":
112
+ - !binary |-
113
+ bGFuZ3VhZ2U9ZGVfREU7IGV4cGlyZXM9VGh1LCAxNC1Ob3YtMjAxMyAxOToy
114
+ MTowNiBHTVQ7IHBhdGg9Lw==
115
+ !binary "Q29udGVudC1FbmNvZGluZw==":
116
+ - !binary |-
117
+ Z3ppcA==
118
+ !binary "Q29udGVudC1MZW5ndGg=":
119
+ - !binary |-
120
+ NTE=
121
+ !binary "Q29udGVudC1UeXBl":
122
+ - !binary |-
123
+ YXBwbGljYXRpb24vanNvbg==
124
+ body:
125
+ encoding: ASCII-8BIT
126
+ string: !binary |-
127
+ H4sIAAAAAAAAA6tWSi0qyi8qVrKqhrCUrJSC8ssV8vJLFNLyS/NSlGprAel/
128
+ syMkAAAA
129
+ http_version:
130
+ recorded_at: Wed, 14 Nov 2012 19:21:06 GMT
131
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,95 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://rediger.billomat.net/api/invoices/352709/complete
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"complete":{}}'
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
+ - Wed, 14 Nov 2012 19:15:01 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=Thu, 14-Nov-2013 19:15:01 GMT; path=/
37
+ Vary:
38
+ - Accept-Encoding
39
+ Content-Length:
40
+ - '57'
41
+ Connection:
42
+ - close
43
+ Content-Type:
44
+ - application/json
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ! '{"errors":{"error":"Only status DRAFT can be completed"}}'
48
+ http_version:
49
+ recorded_at: Wed, 14 Nov 2012 19:15:01 GMT
50
+ - request:
51
+ method: put
52
+ uri: http://rediger.billomat.net/api/invoices/352320/complete
53
+ body:
54
+ encoding: UTF-8
55
+ string: ! '{"complete":{}}'
56
+ headers:
57
+ X-Billomatapikey:
58
+ - e1923a9ab25fc955be3321725be882bd
59
+ Accept:
60
+ - application/json
61
+ Content-Type:
62
+ - application/json
63
+ User-Agent:
64
+ - Ruby
65
+ response:
66
+ status:
67
+ code: 200
68
+ message: OK
69
+ headers:
70
+ Date:
71
+ - Wed, 14 Nov 2012 19:16:38 GMT
72
+ Server:
73
+ - Apache
74
+ X-Powered-By:
75
+ - PHP/5.3.3-7+squeeze14
76
+ Expires:
77
+ - Thu, 19 Nov 1981 08:52:00 GMT
78
+ Cache-Control:
79
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
80
+ Pragma:
81
+ - no-cache
82
+ Set-Cookie:
83
+ - language=de_DE; expires=Thu, 14-Nov-2013 19:16:38 GMT; path=/
84
+ Vary:
85
+ - Accept-Encoding
86
+ Content-Length:
87
+ - '0'
88
+ Content-Type:
89
+ - application/json
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ http_version:
94
+ recorded_at: Wed, 14 Nov 2012 19:16:39 GMT
95
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,123 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://ruby.billomat.net/api/invoice-payments/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Billomatapikey:
11
+ - '12345'
12
+ Accept:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: !binary |-
22
+ Tm90IEZvdW5k
23
+ headers:
24
+ !binary "RGF0ZQ==":
25
+ - !binary |-
26
+ TW9uLCAwNSBOb3YgMjAxMiAxNTo1OTo0OCBHTVQ=
27
+ !binary "U2VydmVy":
28
+ - !binary |-
29
+ QXBhY2hl
30
+ !binary "WC1Qb3dlcmVkLUJ5":
31
+ - !binary |-
32
+ UEhQLzUuMy4zLTcrc3F1ZWV6ZTE0
33
+ !binary "RXhwaXJlcw==":
34
+ - !binary |-
35
+ VGh1LCAxOSBOb3YgMTk4MSAwODo1MjowMCBHTVQ=
36
+ !binary "Q2FjaGUtQ29udHJvbA==":
37
+ - !binary |-
38
+ bm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hl
39
+ Y2s9MCwgcHJlLWNoZWNrPTA=
40
+ !binary "UHJhZ21h":
41
+ - !binary |-
42
+ bm8tY2FjaGU=
43
+ !binary "U2V0LUNvb2tpZQ==":
44
+ - !binary |-
45
+ bGFuZ3VhZ2U9ZGVfREU7IGV4cGlyZXM9VHVlLCAwNS1Ob3YtMjAxMyAxNTo1
46
+ OTo0OCBHTVQ7IHBhdGg9Lw==
47
+ !binary "Q29udGVudC1FbmNvZGluZw==":
48
+ - !binary |-
49
+ Z3ppcA==
50
+ !binary "Q29udGVudC1MZW5ndGg=":
51
+ - !binary |-
52
+ NTQ=
53
+ !binary "Q29udGVudC1UeXBl":
54
+ - !binary |-
55
+ YXBwbGljYXRpb24vanNvbg==
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: !binary |-
59
+ H4sIAAAAAAAAA6tWSi0qyi8qVrKqhrCUrJQck5PzS/NKFPLySxTcgKwUpdpa
60
+ AK601T0oAAAA
61
+ http_version:
62
+ recorded_at: Mon, 05 Nov 2012 15:59:48 GMT
63
+ - request:
64
+ method: get
65
+ uri: http://rediger.billomat.net/api/invoice-payments/
66
+ body:
67
+ encoding: US-ASCII
68
+ string: ''
69
+ headers:
70
+ X-Billomatapikey:
71
+ - e1923a9ab25fc955be3321725be882bd
72
+ Accept:
73
+ - application/json
74
+ Accept-Encoding:
75
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
76
+ User-Agent:
77
+ - Ruby
78
+ response:
79
+ status:
80
+ code: 200
81
+ message: !binary |-
82
+ T0s=
83
+ headers:
84
+ !binary "RGF0ZQ==":
85
+ - !binary |-
86
+ TW9uLCAwNSBOb3YgMjAxMiAxNjowMDowNSBHTVQ=
87
+ !binary "U2VydmVy":
88
+ - !binary |-
89
+ QXBhY2hl
90
+ !binary "WC1Qb3dlcmVkLUJ5":
91
+ - !binary |-
92
+ UEhQLzUuMy4zLTcrc3F1ZWV6ZTE0
93
+ !binary "RXhwaXJlcw==":
94
+ - !binary |-
95
+ VGh1LCAxOSBOb3YgMTk4MSAwODo1MjowMCBHTVQ=
96
+ !binary "Q2FjaGUtQ29udHJvbA==":
97
+ - !binary |-
98
+ bm8tc3RvcmUsIG5vLWNhY2hlLCBtdXN0LXJldmFsaWRhdGUsIHBvc3QtY2hl
99
+ Y2s9MCwgcHJlLWNoZWNrPTA=
100
+ !binary "UHJhZ21h":
101
+ - !binary |-
102
+ bm8tY2FjaGU=
103
+ !binary "U2V0LUNvb2tpZQ==":
104
+ - !binary |-
105
+ bGFuZ3VhZ2U9ZGVfREU7IGV4cGlyZXM9VHVlLCAwNS1Ob3YtMjAxMyAxNjow
106
+ MDowNSBHTVQ7IHBhdGg9Lw==
107
+ !binary "Q29udGVudC1FbmNvZGluZw==":
108
+ - !binary |-
109
+ Z3ppcA==
110
+ !binary "Q29udGVudC1MZW5ndGg=":
111
+ - !binary |-
112
+ NzQ=
113
+ !binary "Q29udGVudC1UeXBl":
114
+ - !binary |-
115
+ YXBwbGljYXRpb24vanNvbg==
116
+ body:
117
+ encoding: ASCII-8BIT
118
+ string: !binary |-
119
+ H4sIAAAAAAAAA6tWyswry89MTtUtSKzMTc0rKVayqlZyKEhMT1WyUjJU0gGy
120
+ U4viYXwDA5BISX5JYg6Qa6BUWwsAtPgwzUEAAAA=
121
+ http_version:
122
+ recorded_at: Mon, 05 Nov 2012 16:00:05 GMT
123
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://rediger.billomat.net/api/invoices/352709/email
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"email":{"recipients":{"cc":"mail@test.example","to":"M8R-10apg01@mailinator.com"}}}'
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: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Wed, 14 Nov 2012 19:57:14 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=Thu, 14-Nov-2013 19:57:14 GMT; path=/
37
+ Vary:
38
+ - Accept-Encoding
39
+ Content-Length:
40
+ - '0'
41
+ Content-Type:
42
+ - application/json
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ http_version:
47
+ recorded_at: Wed, 14 Nov 2012 19:57:15 GMT
48
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://rediger.billomat.net/api/invoices/352709/email
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"email":{"recipients":{"cc":"mail@test.example","to":"M8R-10apg01@mailinator.com"},"from":"sender@test.example"}}'
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: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Wed, 14 Nov 2012 19:57:15 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=Thu, 14-Nov-2013 19:57:15 GMT; path=/
37
+ Vary:
38
+ - Accept-Encoding
39
+ Content-Length:
40
+ - '0'
41
+ Content-Type:
42
+ - application/json
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ http_version:
47
+ recorded_at: Wed, 14 Nov 2012 19:57:16 GMT
48
+ recorded_with: VCR 2.2.5