easybill-rest-client 2.0.2

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 (87) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +6 -0
  3. data/Gemfile.lock +152 -0
  4. data/README.md +8 -0
  5. data/Rakefile +4 -0
  6. data/config.json +5 -0
  7. data/easybill-rest-client.gemspec +29 -0
  8. data/lib/easybill-rest-client.rb +15 -0
  9. data/lib/easybill_rest_client/.document_address.rb.swp +0 -0
  10. data/lib/easybill_rest_client/.document_item.rb.swp +0 -0
  11. data/lib/easybill_rest_client/.document_payment.rb.swp +0 -0
  12. data/lib/easybill_rest_client/.document_recurring_options.rb.swp +0 -0
  13. data/lib/easybill_rest_client/.easybill_error.rb.swp +0 -0
  14. data/lib/easybill_rest_client/.log_formatter.rb.swp +0 -0
  15. data/lib/easybill_rest_client/.request_builder.rb.swp +0 -0
  16. data/lib/easybill_rest_client/.too_many_requests_error.rb.swp +0 -0
  17. data/lib/easybill_rest_client/api_client.rb +61 -0
  18. data/lib/easybill_rest_client/client.rb +39 -0
  19. data/lib/easybill_rest_client/customer.rb +70 -0
  20. data/lib/easybill_rest_client/customer_api.rb +15 -0
  21. data/lib/easybill_rest_client/document.rb +53 -0
  22. data/lib/easybill_rest_client/document_address.rb +19 -0
  23. data/lib/easybill_rest_client/document_api.rb +31 -0
  24. data/lib/easybill_rest_client/document_item.rb +34 -0
  25. data/lib/easybill_rest_client/document_payment.rb +15 -0
  26. data/lib/easybill_rest_client/document_payment_api.rb +15 -0
  27. data/lib/easybill_rest_client/document_recurring_options.rb +23 -0
  28. data/lib/easybill_rest_client/document_service_date.rb +12 -0
  29. data/lib/easybill_rest_client/generic_api.rb +39 -0
  30. data/lib/easybill_rest_client/pdf.rb +21 -0
  31. data/lib/easybill_rest_client/post_box.rb +24 -0
  32. data/lib/easybill_rest_client/post_box_api.rb +15 -0
  33. data/lib/easybill_rest_client/request.rb +107 -0
  34. data/lib/easybill_rest_client/request_logger.rb +24 -0
  35. data/lib/easybill_rest_client/response.rb +36 -0
  36. data/lib/easybill_rest_client/retry_on.rb +46 -0
  37. data/lib/easybill_rest_client/version.rb +5 -0
  38. data/log/.gitkeep +0 -0
  39. data/log/test.log +5723 -0
  40. data/script/.generate.swo +0 -0
  41. data/spec/.spec_helper.rb.swp +0 -0
  42. data/spec/fixtures/vcr/EasybillRestClient_CustomerApi/_customers_get/.returns_customers.yml.swo +0 -0
  43. data/spec/fixtures/vcr/EasybillRestClient_CustomerApi/_customers_get/.returns_customers.yml.swp +0 -0
  44. data/spec/fixtures/vcr/EasybillRestClient_CustomerApi/a_list_of_customers/gets_all_customers.yml +84 -0
  45. data/spec/fixtures/vcr/EasybillRestClient_CustomerApi/a_list_of_customers/gets_customers_matching_a_filter.yml +72 -0
  46. data/spec/fixtures/vcr/EasybillRestClient_CustomerApi/creates_updates_and_deletes_customer.yml +377 -0
  47. data/spec/fixtures/vcr/EasybillRestClient_Document/_all/returns_documents.yml +44 -0
  48. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_cancel/cancels_a_document.yml +212 -0
  49. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_create/creates_a_document.yml +53 -0
  50. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_delete/deletes_a_document.yml +174 -0
  51. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_find/returns_a_document.yml +57 -0
  52. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_find_all/paid_and_unpaid_documents_exist/returns_only_unpaid_documents.yml +795 -0
  53. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_find_all/returns_documents.yml +58 -0
  54. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_find_all/returns_documents_by_number.yml +58 -0
  55. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_finish/marks_a_drafted_document_as_finished.yml +212 -0
  56. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_get_pdf/returns_a_PDF.yml +3889 -0
  57. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_send_email/passes_on_additional_params.yml +63 -0
  58. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_send_email/sends_an_email.yml +63 -0
  59. data/spec/fixtures/vcr/EasybillRestClient_DocumentApi/_update/updates_a_document.yml +107 -0
  60. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_create/creates_a_document_payment.yml +195 -0
  61. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_delete/deletes_a_document_payment.yml +168 -0
  62. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_document_payments_get/returns_a_document_s_payments.yml +460 -0
  63. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_document_payments_post/creates_a_document_payment.yml +47 -0
  64. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_find/returns_a_document_payment.yml +66 -0
  65. data/spec/fixtures/vcr/EasybillRestClient_DocumentPaymentApi/_find_all/returns_document_payments.yml +66 -0
  66. data/spec/fixtures/vcr/EasybillRestClient_PostBoxApi/_delete/deletes_a_post_box.yml +174 -0
  67. data/spec/fixtures/vcr/EasybillRestClient_PostBoxApi/_find/returns_a_post_box.yml +72 -0
  68. data/spec/fixtures/vcr/EasybillRestClient_PostBoxApi/_find_all/returns_post_boxes.yml +73 -0
  69. data/spec/fixtures/vcr/EasybillRestClient_PostBoxApi/_post_boxes_get/returns_post_boxes.yml +52 -0
  70. data/spec/integration/.customer_api_spec.rb.swn +0 -0
  71. data/spec/integration/.customer_api_spec.rb.swo +0 -0
  72. data/spec/integration/customer_api_spec.rb +47 -0
  73. data/spec/integration/easybill_rest_client/document_api_spec.rb +129 -0
  74. data/spec/integration/easybill_rest_client/document_payment_api_spec.rb +55 -0
  75. data/spec/integration/easybill_rest_client/post_box_api_spec.rb +31 -0
  76. data/spec/lib/easybill_rest_client/.api_client_spec.rb.swp +0 -0
  77. data/spec/lib/easybill_rest_client/easybill_rest_api/.generic_api_spec.rb.swp +0 -0
  78. data/spec/lib/easybill_rest_client/generic_api_spec.rb +55 -0
  79. data/spec/lib/easybill_rest_client/pdf_spec.rb +29 -0
  80. data/spec/lib/easybill_rest_client/request_logger_spec.rb +14 -0
  81. data/spec/lib/easybill_rest_client/request_spec.rb +32 -0
  82. data/spec/lib/easybill_rest_client/retry_on_spec.rb +37 -0
  83. data/spec/spec_helper.rb +33 -0
  84. data/spec/support/.setup_api_client.rb.swo +0 -0
  85. data/spec/support/setup_client.rb +12 -0
  86. data/swagger.json +3964 -0
  87. metadata +257 -0
@@ -0,0 +1,174 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.easybill.de/rest/v1/post-boxes/58942178
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Authorization:
13
+ - Basic easybill-basic-auth-key
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 10 Jun 2016 09:57:13 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Vary:
34
+ - Accept-Encoding
35
+ - Accept-Encoding
36
+ Cache-Control:
37
+ - private, must-revalidate
38
+ Pragma:
39
+ - no-cache
40
+ Expires:
41
+ - "-1"
42
+ Strict-Transport-Security:
43
+ - max-age=31536000
44
+ X-Frame-Options:
45
+ - SAMEORIGIN
46
+ X-Content-Type-Options:
47
+ - nosniff
48
+ X-Xss-Protection:
49
+ - 1; mode=block
50
+ Content-Security-Policy:
51
+ - 'default-src ''self''; connect-src ''self'' *.easybill.de *.paymill.de *.paymill.com;
52
+ script-src ''self'' ''unsafe-inline'' ''unsafe-eval'' *.paymill.de *.paymill.com
53
+ *.google-analytics.com *.googleadservices.com d2wy8f7a9ursnm.cloudfront.net;
54
+ img-src ''self'' data: *.doubleclick.net notify.bugsnag.com *.paypalobjects.com
55
+ online.swagger.io *.google-analytics.com *.google.com *.google.de *.google.at
56
+ *.google.ch; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com; font-src
57
+ ''self'' themes.googleusercontent.com fonts.gstatic.com; frame-src ''self''
58
+ *.googleadservices.com ssl.kaptcha.com *.paymill.de *.paymill.com *.mediafinanz.de
59
+ *.google.de *.google.com *.google.at *.google.ch *.doubleclick.net player.vimeo.com
60
+ *.facebook.com; object-src ''self'''
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"cc":null,"create_at":"2016-06-10 11:29:11","date":"2016-06-10","document_id":84730384,"from":"billing@ad2games.com","id":58942178,"message":"%Kunde.Anrede%,\n\nanbei
64
+ erhalten Sie Ihre Rechnung Nr. %dokument.nummer% vom %dokument.datum% im pdf-Format.\n\nZum
65
+ \u00d6ffnen dieser Datei ben\u00f6tigen Sie den Adobe Acrobat Reader, welchen
66
+ Sie auf nachfolgender Internetadresse kostenlos herunterladen k\u00f6nnen:\nhttp:\/\/www.adobe.com\/de\/products\/acrobat\/readstep2.html\n\nMit
67
+ freundlichen Gr\u00fc\u00dfen","processed_at":null,"send_by_self":false,"send_with_attachment":true,"status":"ERROR","status_msg":"Smtp
68
+ Fehler. Bitte \u00fcberpr\u00fcfen Sie Ihre \u0022Eigener Mail-Server\u0022
69
+ Einstellungen. (SMTP Error: Could not authenticate.)","subject":"Rechnung-%DOKUMENT.NUMMER%","to":"ns@ad2games.com","type":"EMAIL"}'
70
+ http_version:
71
+ recorded_at: Fri, 10 Jun 2016 09:57:13 GMT
72
+ - request:
73
+ method: delete
74
+ uri: https://api.easybill.de/rest/v1/post-boxes/58942178
75
+ body:
76
+ encoding: US-ASCII
77
+ string: ''
78
+ headers:
79
+ User-Agent:
80
+ - Faraday v0.9.2
81
+ Authorization:
82
+ - Basic easybill-basic-auth-key
83
+ Accept-Encoding:
84
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
85
+ Accept:
86
+ - "*/*"
87
+ response:
88
+ status:
89
+ code: 204
90
+ message: No Content
91
+ headers:
92
+ Server:
93
+ - nginx
94
+ Date:
95
+ - Fri, 10 Jun 2016 09:57:13 GMT
96
+ Content-Type:
97
+ - text/html; charset=UTF-8
98
+ Connection:
99
+ - keep-alive
100
+ Cache-Control:
101
+ - private, must-revalidate
102
+ Pragma:
103
+ - no-cache
104
+ Expires:
105
+ - "-1"
106
+ Strict-Transport-Security:
107
+ - max-age=31536000
108
+ X-Frame-Options:
109
+ - SAMEORIGIN
110
+ X-Content-Type-Options:
111
+ - nosniff
112
+ X-Xss-Protection:
113
+ - 1; mode=block
114
+ Content-Security-Policy:
115
+ - 'default-src ''self''; connect-src ''self'' *.easybill.de *.paymill.de *.paymill.com;
116
+ script-src ''self'' ''unsafe-inline'' ''unsafe-eval'' *.paymill.de *.paymill.com
117
+ *.google-analytics.com *.googleadservices.com d2wy8f7a9ursnm.cloudfront.net;
118
+ img-src ''self'' data: *.doubleclick.net notify.bugsnag.com *.paypalobjects.com
119
+ online.swagger.io *.google-analytics.com *.google.com *.google.de *.google.at
120
+ *.google.ch; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com; font-src
121
+ ''self'' themes.googleusercontent.com fonts.gstatic.com; frame-src ''self''
122
+ *.googleadservices.com ssl.kaptcha.com *.paymill.de *.paymill.com *.mediafinanz.de
123
+ *.google.de *.google.com *.google.at *.google.ch *.doubleclick.net player.vimeo.com
124
+ *.facebook.com; object-src ''self'''
125
+ body:
126
+ encoding: UTF-8
127
+ string: ''
128
+ http_version:
129
+ recorded_at: Fri, 10 Jun 2016 09:57:13 GMT
130
+ - request:
131
+ method: get
132
+ uri: https://api.easybill.de/rest/v1/post-boxes/58942178
133
+ body:
134
+ encoding: US-ASCII
135
+ string: ''
136
+ headers:
137
+ User-Agent:
138
+ - Faraday v0.9.2
139
+ Authorization:
140
+ - Basic easybill-basic-auth-key
141
+ Accept-Encoding:
142
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
143
+ Accept:
144
+ - "*/*"
145
+ response:
146
+ status:
147
+ code: 404
148
+ message: Not Found
149
+ headers:
150
+ Server:
151
+ - nginx
152
+ Date:
153
+ - Fri, 10 Jun 2016 09:57:13 GMT
154
+ Content-Type:
155
+ - application/json
156
+ Transfer-Encoding:
157
+ - chunked
158
+ Connection:
159
+ - keep-alive
160
+ Vary:
161
+ - Accept-Encoding
162
+ - Accept-Encoding
163
+ Cache-Control:
164
+ - private, must-revalidate
165
+ Pragma:
166
+ - no-cache
167
+ Expires:
168
+ - "-1"
169
+ body:
170
+ encoding: ASCII-8BIT
171
+ string: '{"code":404,"message":"PostBox#58942178 not found."}'
172
+ http_version:
173
+ recorded_at: Fri, 10 Jun 2016 09:57:13 GMT
174
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.easybill.de/rest/v1/post-boxes/58942178
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Authorization:
13
+ - Basic easybill-basic-auth-key
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 10 Jun 2016 09:52:11 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Vary:
34
+ - Accept-Encoding
35
+ - Accept-Encoding
36
+ Cache-Control:
37
+ - private, must-revalidate
38
+ Pragma:
39
+ - no-cache
40
+ Expires:
41
+ - "-1"
42
+ Strict-Transport-Security:
43
+ - max-age=31536000
44
+ X-Frame-Options:
45
+ - SAMEORIGIN
46
+ X-Content-Type-Options:
47
+ - nosniff
48
+ X-Xss-Protection:
49
+ - 1; mode=block
50
+ Content-Security-Policy:
51
+ - 'default-src ''self''; connect-src ''self'' *.easybill.de *.paymill.de *.paymill.com;
52
+ script-src ''self'' ''unsafe-inline'' ''unsafe-eval'' *.paymill.de *.paymill.com
53
+ *.google-analytics.com *.googleadservices.com d2wy8f7a9ursnm.cloudfront.net;
54
+ img-src ''self'' data: *.doubleclick.net notify.bugsnag.com *.paypalobjects.com
55
+ online.swagger.io *.google-analytics.com *.google.com *.google.de *.google.at
56
+ *.google.ch; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com; font-src
57
+ ''self'' themes.googleusercontent.com fonts.gstatic.com; frame-src ''self''
58
+ *.googleadservices.com ssl.kaptcha.com *.paymill.de *.paymill.com *.mediafinanz.de
59
+ *.google.de *.google.com *.google.at *.google.ch *.doubleclick.net player.vimeo.com
60
+ *.facebook.com; object-src ''self'''
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"cc":null,"create_at":"2016-06-10 11:29:11","date":"2016-06-10","document_id":84730384,"from":"billing@ad2games.com","id":58942178,"message":"%Kunde.Anrede%,\n\nanbei
64
+ erhalten Sie Ihre Rechnung Nr. %dokument.nummer% vom %dokument.datum% im pdf-Format.\n\nZum
65
+ \u00d6ffnen dieser Datei ben\u00f6tigen Sie den Adobe Acrobat Reader, welchen
66
+ Sie auf nachfolgender Internetadresse kostenlos herunterladen k\u00f6nnen:\nhttp:\/\/www.adobe.com\/de\/products\/acrobat\/readstep2.html\n\nMit
67
+ freundlichen Gr\u00fc\u00dfen","processed_at":null,"send_by_self":false,"send_with_attachment":true,"status":"ERROR","status_msg":"Smtp
68
+ Fehler. Bitte \u00fcberpr\u00fcfen Sie Ihre \u0022Eigener Mail-Server\u0022
69
+ Einstellungen. (SMTP Error: Could not authenticate.)","subject":"Rechnung-%DOKUMENT.NUMMER%","to":"ns@ad2games.com","type":"EMAIL"}'
70
+ http_version:
71
+ recorded_at: Fri, 10 Jun 2016 09:52:11 GMT
72
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,73 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.easybill.de/rest/v1/post-boxes?limit=1000&page=1&type=EMAIL
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Authorization:
13
+ - Basic easybill-basic-auth-key
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 10 Jun 2016 09:29:44 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Vary:
34
+ - Accept-Encoding
35
+ - Accept-Encoding
36
+ Cache-Control:
37
+ - private, must-revalidate
38
+ Pragma:
39
+ - no-cache
40
+ Expires:
41
+ - "-1"
42
+ Strict-Transport-Security:
43
+ - max-age=31536000
44
+ X-Frame-Options:
45
+ - SAMEORIGIN
46
+ X-Content-Type-Options:
47
+ - nosniff
48
+ X-Xss-Protection:
49
+ - 1; mode=block
50
+ Content-Security-Policy:
51
+ - 'default-src ''self''; connect-src ''self'' *.easybill.de *.paymill.de *.paymill.com;
52
+ script-src ''self'' ''unsafe-inline'' ''unsafe-eval'' *.paymill.de *.paymill.com
53
+ *.google-analytics.com *.googleadservices.com d2wy8f7a9ursnm.cloudfront.net;
54
+ img-src ''self'' data: *.doubleclick.net notify.bugsnag.com *.paypalobjects.com
55
+ online.swagger.io *.google-analytics.com *.google.com *.google.de *.google.at
56
+ *.google.ch; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com; font-src
57
+ ''self'' themes.googleusercontent.com fonts.gstatic.com; frame-src ''self''
58
+ *.googleadservices.com ssl.kaptcha.com *.paymill.de *.paymill.com *.mediafinanz.de
59
+ *.google.de *.google.com *.google.at *.google.ch *.doubleclick.net player.vimeo.com
60
+ *.facebook.com; object-src ''self'''
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"page":1,"pages":1,"limit":100,"total":1,"items":[{"cc":null,"create_at":"2016-06-10
64
+ 11:29:11","date":"2016-06-10","document_id":84730384,"from":"billing@ad2games.com","id":58942178,"message":"%Kunde.Anrede%,\n\nanbei
65
+ erhalten Sie Ihre Rechnung Nr. %dokument.nummer% vom %dokument.datum% im pdf-Format.\n\nZum
66
+ \u00d6ffnen dieser Datei ben\u00f6tigen Sie den Adobe Acrobat Reader, welchen
67
+ Sie auf nachfolgender Internetadresse kostenlos herunterladen k\u00f6nnen:\nhttp:\/\/www.adobe.com\/de\/products\/acrobat\/readstep2.html\n\nMit
68
+ freundlichen Gr\u00fc\u00dfen","processed_at":null,"send_by_self":false,"send_with_attachment":true,"status":"ERROR","status_msg":"Smtp
69
+ Fehler. Bitte \u00fcberpr\u00fcfen Sie Ihre \u0022Eigener Mail-Server\u0022
70
+ Einstellungen. (SMTP Error: Could not authenticate.)","subject":"Rechnung-%DOKUMENT.NUMMER%","to":"ns@ad2games.com","type":"EMAIL"}]}'
71
+ http_version:
72
+ recorded_at: Fri, 10 Jun 2016 09:29:44 GMT
73
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.easybill.de/rest/v1/post-boxes?type=EMAIL
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - ruby-swagger-0.0.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ Authorization:
17
+ - Basic easybill-basic-auth-key
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.8.0
25
+ Date:
26
+ - Thu, 21 Jan 2016 12:38:41 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Vary:
34
+ - Accept-Encoding
35
+ - Accept-Encoding
36
+ Cache-Control:
37
+ - private, must-revalidate
38
+ Pragma:
39
+ - no-cache
40
+ Expires:
41
+ - "-1"
42
+ Strict-Transport-Security:
43
+ - max-age=31536000
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"page":1,"pages":1,"limit":100,"total":1,"items":[{"cc":null,"create_at":"2016-01-20
47
+ 15:14:16","date":"2016-01-20","document_id":63199965,"from":null,"id":44291862,"message":null,"processed_at":null,"send_by_self":false,"send_with_attachment":true,"status":"ERROR","status_msg":"Smtp
48
+ Fehler. Bitte \u00fcberpr\u00fcfen Sie Ihre \u0022Eigener Mail-Server\u0022
49
+ Einstellungen. (SMTP Error: Could not authenticate.)","subject":null,"to":null,"type":"EMAIL"}]}'
50
+ http_version:
51
+ recorded_at: Thu, 21 Jan 2016 12:38:41 GMT
52
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EasybillRestClient
4
+ RSpec.describe CustomerApi, :vcr do
5
+ subject(:api) { client.customers }
6
+
7
+ describe 'a list of customers' do
8
+ it 'gets all customers' do
9
+ customers = api.find_all.to_a
10
+ expect(customers).not_to be_empty
11
+ expect(customers).to all(be_a(Customer))
12
+ end
13
+
14
+ it 'gets customers matching a filter' do
15
+ expect(api.find_all(number: '15408').to_a).to match_array [
16
+ an_object_having_attributes(number: '15408')
17
+ ]
18
+ end
19
+ end
20
+
21
+ it 'creates, updates and deletes customer' do
22
+ existing_customer = api.find_all(number: 'TEST').first
23
+ if existing_customer
24
+ api.delete(existing_customer.id)
25
+ expect(api.find_all(number: 'TEST').to_a).to be_empty
26
+ end
27
+
28
+ customer = api.create(
29
+ api.build(
30
+ number: 'TEST',
31
+ company_name: 'Fake',
32
+ first_name: 'John',
33
+ last_name: 'Doe'
34
+ )
35
+ )
36
+
37
+ customer.first_name = 'Bob'
38
+ api.update(customer)
39
+
40
+ customer = api.find(customer.id)
41
+ expect(customer.first_name).to eq('Bob')
42
+
43
+ api.delete(customer.id)
44
+ expect(api.find_all(number: 'TEST').to_a).to be_empty
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe EasybillRestClient::DocumentApi, :vcr do
4
+ subject(:api) { client.documents }
5
+
6
+ describe '#find' do
7
+ it 'returns a document' do
8
+ document = api.find(79121874)
9
+ expect(document).to be_a(EasybillRestClient::Document)
10
+ expect(document.number).to eq('XYZ-123')
11
+ expect(document.address).to be_a(EasybillRestClient::DocumentAddress)
12
+ expect(document.label_address).to be_a(EasybillRestClient::DocumentAddress)
13
+ expect(document.items).to be_a(Array)
14
+ expect(document.items.first).to be_a(EasybillRestClient::DocumentItem)
15
+ end
16
+ end
17
+
18
+ describe '#find_all' do
19
+ it 'returns documents' do
20
+ documents = api.find_all.to_a
21
+ expect(documents.count).to eq(1)
22
+ expect(documents.first.number).to eq('XYZ-123')
23
+ end
24
+
25
+ it 'returns documents by number' do
26
+ documents = api.find_all(number: 'XYZ-123').to_a
27
+ expect(documents.count).to eq(1)
28
+ expect(documents.first.number).to eq('XYZ-123')
29
+ end
30
+
31
+ context 'paid and unpaid documents exist' do
32
+ let(:customer) do
33
+ client.customers.create(
34
+ EasybillRestClient::Customer.new(last_name: 'Mustermann',
35
+ company_name: 'ACME Corp.')
36
+ )
37
+ end
38
+
39
+ let(:unpaid_document) do
40
+ d = api.create(EasybillRestClient::Document.new(customer_id: customer.id))
41
+ api.finish(d.id)
42
+ end
43
+
44
+ let(:paid_document) do
45
+ d = api.create(EasybillRestClient::Document.new(customer_id: customer.id))
46
+ api.finish(d.id)
47
+ client.document_payments.create(
48
+ EasybillRestClient::DocumentPayment.new(document_id: d.id,
49
+ paid: true,
50
+ amount: 0)
51
+ )
52
+ d
53
+ end
54
+
55
+ after do
56
+ api.delete(paid_document.id)
57
+ api.delete(unpaid_document.id)
58
+ client.customers.delete(customer.id)
59
+ end
60
+
61
+ it 'returns only unpaid documents' do
62
+ documents = api.find_all(paid_at: nil,
63
+ number: [paid_document.number, unpaid_document.number])
64
+ expect(documents.count).to eq(1)
65
+ expect(documents.first.paid_at).to be_nil
66
+ expect(documents.first.id).to eq(unpaid_document.id)
67
+ end
68
+ end
69
+ end
70
+
71
+ describe '#create' do
72
+ it 'creates a document' do
73
+ document = api.create(api.build(number: 'Y'))
74
+ expect(document.id).to eq(79126074)
75
+ expect(document.number).to eq('Y')
76
+ end
77
+ end
78
+
79
+ describe '#update' do
80
+ it 'updates a document' do
81
+ api.update(api.build(id: 79125727, number: 'Z'))
82
+ expect(api.find(79125727).number).to eq('Z')
83
+ end
84
+ end
85
+
86
+ describe '#get_pdf' do
87
+ it 'returns a PDF' do
88
+ document = api.get_pdf(84718807)
89
+ expect(document).to be_a(EasybillRestClient::Pdf)
90
+ expect(document.filename).to eq('Rechnung-C1606-16178-154086.pdf')
91
+ expect(document.content).to start_with('%PDF-1.4')
92
+ end
93
+ end
94
+
95
+ describe '#send_email' do
96
+ it 'sends an email' do
97
+ expect(api.send_email(84718807)).to be_nil
98
+ end
99
+
100
+ it 'passes on additional params' do
101
+ expect(api.send_email(257330466, to: 'developers@ad2games.com')).to be_nil
102
+ end
103
+ end
104
+
105
+ describe '#finish' do
106
+ it 'marks a drafted document as finished' do
107
+ expect(api.find(84725627).number).to be_nil
108
+ expect(api.finish(84725627)).to be_a(EasybillRestClient::Document)
109
+ expect(api.find(84725627).number).to be_a(String)
110
+ end
111
+ end
112
+
113
+ describe '#delete' do
114
+ it 'deletes a document' do
115
+ expect(api.find(84718807)).not_to be_nil
116
+ expect(api.delete(84718807)).to be_nil
117
+ expect { api.find(84718807) }
118
+ .to raise_error(EasybillRestClient::ApiError, /Document#84718807 not found./)
119
+ end
120
+ end
121
+
122
+ describe '#cancel' do
123
+ it 'cancels a document' do
124
+ expect(api.find(84727902).cancel_id).to be_nil
125
+ expect(api.cancel(84727902)).to be_a(EasybillRestClient::Document)
126
+ expect(api.find(84727902).cancel_id).to be_a(Integer)
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe EasybillRestClient::DocumentPaymentApi, :vcr do
4
+ subject(:api) { client.document_payments }
5
+
6
+ describe '#find_all' do
7
+ it 'returns document payments' do
8
+ payments = api.find_all.to_a
9
+ expect(payments.last.id).to be_a(Integer)
10
+ end
11
+ end
12
+
13
+ describe '#find' do
14
+ it 'returns a document payment' do
15
+ payment = api.find(74692458)
16
+ expect(payment.id).to eq(74692458)
17
+ expect(payment.amount).to eq(3367)
18
+ expect(payment.document_id).to eq(84730384)
19
+ expect(payment.notice).to eq('Blah!')
20
+ expect(payment.payment_at).to eq(Date.new(2016, 6, 10))
21
+ expect(payment.type).to eq('Überweisung')
22
+ end
23
+ end
24
+
25
+ describe '#delete' do
26
+ it 'deletes a document payment' do
27
+ expect(api.find(74692458)).to be_a(EasybillRestClient::DocumentPayment)
28
+ expect(api.delete(74692458)).to be_nil
29
+ expect { api.find(74692458) }
30
+ .to raise_error(EasybillRestClient::ApiError, /DocumentPayment#74692458 not found./)
31
+ end
32
+ end
33
+
34
+ describe '#create' do
35
+ let(:document_payment) do
36
+ api.build(document_id: 84730384,
37
+ amount: 3367,
38
+ notice: 'Unicorns and rainbows!',
39
+ type: 'Überweisung')
40
+ end
41
+
42
+ it 'creates a document payment' do
43
+ payment = nil
44
+ expect do
45
+ payment = api.create(document_payment)
46
+ end.to change { api.find_all(document_id: 84730384).count }.by(1)
47
+ expect(payment).to have_attributes(
48
+ document_id: 84730384,
49
+ amount: 3367,
50
+ notice: 'Unicorns and rainbows!',
51
+ type: 'Überweisung'
52
+ )
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe EasybillRestClient::PostBoxApi, :vcr do
4
+ subject(:api) { client.post_boxes }
5
+
6
+ describe '#find_all' do
7
+ it 'returns post boxes' do
8
+ post_boxes = api.find_all(type: 'EMAIL').to_a
9
+ expect(post_boxes.count).to eq(1)
10
+ expect(post_boxes.first).to be_a(EasybillRestClient::PostBox)
11
+ expect(post_boxes.first.id).to be_a(Integer)
12
+ end
13
+ end
14
+
15
+ describe '#find' do
16
+ it 'returns a post box' do
17
+ post_box = api.find(58942178)
18
+ expect(post_box).to be_a(EasybillRestClient::PostBox)
19
+ expect(post_box.id).to be_a(Integer)
20
+ end
21
+ end
22
+
23
+ describe '#delete' do
24
+ it 'deletes a post box' do
25
+ api.find(58942178)
26
+ api.delete(58942178)
27
+ expect { api.find(58942178) }
28
+ .to raise_error(EasybillRestClient::ApiError, /PostBox#58942178 not found./)
29
+ end
30
+ end
31
+ end