papierkram_api_client 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +3 -3
- data/README.md +155 -57
- data/lib/papierkram_api/client.rb +91 -0
- data/lib/papierkram_api/v1/business_intelligence/base.rb +23 -0
- data/lib/papierkram_api/v1/business_intelligence/expenses_by_category.rb +98 -0
- data/lib/papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year.rb +58 -0
- data/lib/papierkram_api/v1/endpoints/banking/bank_connections.rb +30 -0
- data/lib/papierkram_api/v1/endpoints/banking/transactions.rb +32 -0
- data/lib/papierkram_api/v1/endpoints/base.rb +77 -0
- data/lib/papierkram_api/v1/endpoints/contact/companies.rb +30 -0
- data/lib/papierkram_api/v1/endpoints/contact/companies_persons.rb +28 -0
- data/lib/papierkram_api/v1/endpoints/expense/vouchers.rb +45 -0
- data/lib/papierkram_api/v1/endpoints/income/estimates.rb +46 -0
- data/lib/papierkram_api/v1/endpoints/income/invoices.rb +46 -0
- data/lib/papierkram_api/v1/endpoints/income/propositions.rb +20 -0
- data/lib/papierkram_api/v1/endpoints/info.rb +14 -0
- data/lib/papierkram_api/v1/endpoints/projects.rb +26 -0
- data/lib/papierkram_api/v1/endpoints/tracker/tasks.rb +33 -0
- data/lib/papierkram_api/v1/endpoints/tracker/time_entries.rb +62 -0
- data/lib/papierkram_api/v1/helper/date_helper.rb +14 -0
- data/lib/{api → papierkram_api}/v1/helper/pdf_from_response.rb +1 -1
- data/lib/papierkram_api/v1/validators/expense_voucher.rb +105 -0
- data/lib/papierkram_api_client/version.rb +1 -1
- data/lib/papierkram_api_client.rb +21 -102
- metadata +22 -16
- data/lib/api/v1/banking/bank_connections.rb +0 -28
- data/lib/api/v1/banking/transactions.rb +0 -18
- data/lib/api/v1/base.rb +0 -75
- data/lib/api/v1/contact/companies.rb +0 -28
- data/lib/api/v1/contact/companies_persons.rb +0 -26
- data/lib/api/v1/expense/vouchers.rb +0 -43
- data/lib/api/v1/income/estimates.rb +0 -44
- data/lib/api/v1/income/invoices.rb +0 -44
- data/lib/api/v1/income/propositions.rb +0 -18
- data/lib/api/v1/info.rb +0 -12
- data/lib/api/v1/projects.rb +0 -24
- data/lib/api/v1/tracker/tasks.rb +0 -31
- data/lib/api/v1/tracker/time_entries.rb +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7efda340be625d91834f22276f4e95767a7d06621bb7d4e8ab6cbb7a503c40f0
|
|
4
|
+
data.tar.gz: dad2650ea0bf6cc8339988ff4e5ab4265e26bad4c203398166d14296db415cdd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '039f293aa1bcf2da3ba920cae9d63ff014a674764f76302f5f318cc89763df94518d69ddc61a105fcd0b13bff487e1a8196ead1a6e32f8e405f26cfb2a54096f'
|
|
7
|
+
data.tar.gz: 41344eba19e9d4d76fca686ec05f8f0724fb38caeb0b08397e54ac2a0464fda1a58d3d7e7118a92c5d5eef7b4f5cf3d9dfd52fd7bbeaf0641f4844b983748eb4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.1] - 2023-04-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [#20](https://github.com/simonneutert/papierkram_api_client/pull/20) Adds Banking::Transactions as endpoint with tests. [@simonneutert](https://github.com/simonneutert)
|
|
8
|
+
|
|
9
|
+
## [0.2.0] - 2023-04-18
|
|
10
|
+
|
|
11
|
+
Das Namespacing hat sich geändert. Die Klasse `PapierkramApiClient` ist jetzt `PapierkramApi::Client`.
|
|
12
|
+
|
|
13
|
+
Bitte schaue für Details in die upgedatete Dokumentation in [README.md](README.md) und passe gegebenenfalls deinen Code an.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- [#19](https://github.com/simonneutert/papierkram_api_client/pull/19) Bump rubocop from 1.50.1 to 1.50.2. [@simonneutert](https://github.com/simonneutert)
|
|
18
|
+
- [#18](https://github.com/simonneutert/papierkram_api_client/pull/18) Stub basic business intelligence module. [@simonneutert](https://github.com/simonneutert)
|
|
19
|
+
|
|
1
20
|
## [0.1.3] - 2023-04-15
|
|
2
21
|
|
|
3
22
|
Solltest du diesen Client mithilfe von Umgebungsvariablen einrichten, musst du deinen Code aktualisieren, um die neuen Variablen zu verwenden. Siehe `.env.sample` für die aktualisierten Variablen.
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
papierkram_api_client (0.1
|
|
4
|
+
papierkram_api_client (0.2.1)
|
|
5
5
|
faraday (~> 2.7)
|
|
6
6
|
httpx (~> 0.22.5)
|
|
7
7
|
|
|
@@ -34,9 +34,9 @@ GEM
|
|
|
34
34
|
method_source (~> 1.0)
|
|
35
35
|
rainbow (3.1.1)
|
|
36
36
|
rake (13.0.6)
|
|
37
|
-
regexp_parser (2.
|
|
37
|
+
regexp_parser (2.8.0)
|
|
38
38
|
rexml (3.2.5)
|
|
39
|
-
rubocop (1.50.
|
|
39
|
+
rubocop (1.50.2)
|
|
40
40
|
json (~> 2.3)
|
|
41
41
|
parallel (~> 1.10)
|
|
42
42
|
parser (>= 3.2.0.0)
|
data/README.md
CHANGED
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
Der erste ~~illegale~~ inoffizielle API Client in [Ruby](https://www.ruby-lang.org/de/) für [Papierkram.de](https://www.papierkram.de)!
|
|
6
6
|
|
|
7
|
+
### Hol mehr aus deinen Daten raus! Dieser Client bietet dir bald einige Features im Bereich [Business Intelligence](#business-intelligence)!<!-- omit in toc -->
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
7
11
|
<img src="pac.svg" alt="PAC Logo, Zunge leckt an Karl Klammer und zieht Daten aus dem Papierkram-Account wie Frosch die Fliege vom Teich" width="300">
|
|
8
12
|
|
|
13
|
+
Hol dir den [Papierkram API Client](https://rubygems.org/gems/papierkram_api_client) als [Ruby Gem](https://rubygems.org/gems/papierkram_api_client)!
|
|
14
|
+
|
|
9
15
|
---
|
|
10
16
|
|
|
11
17
|
**WERBUNG** (es ist ein Aufruf zur Mitarbeit 🫠)
|
|
@@ -20,9 +26,7 @@ Das Gleiche, nur in grün, also für [NodeJS](https://github.com/simonneutert/pa
|
|
|
20
26
|
|
|
21
27
|
Check das [CHANGELOG.md](CHANGELOG.md), Baby!
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
https://DEINE-SUBDOMAIN.papierkram.de/api/v1/api-docs/index.html
|
|
25
|
-
(wenn du bereits ein Papierkram-Konto hast).
|
|
29
|
+
Hier geht es zu den [offiziellen API Docs](https://demo.papierkram.de/api/v1/api-docs/index.html).
|
|
26
30
|
Schau bitte dort um alle Rückgabefelder/-werte zu checken, bis ich die Dokumentation hier komplett habe.
|
|
27
31
|
|
|
28
32
|
---
|
|
@@ -32,7 +36,7 @@ Ruby client für die Papierkram API (V1).
|
|
|
32
36
|
Aktuell unterstützte Endpunkte / Objekte:
|
|
33
37
|
|
|
34
38
|
- [x] Banking::BankConnection
|
|
35
|
-
- [
|
|
39
|
+
- [x] Banking::BankTransaction
|
|
36
40
|
- [x] Contact::Company (Unternehmen)
|
|
37
41
|
- [x] Contact::Company (Kontaktpersonen)
|
|
38
42
|
- [x] Expense::Voucher (Ausgabe Belege)
|
|
@@ -46,7 +50,7 @@ Aktuell unterstützte Endpunkte / Objekte:
|
|
|
46
50
|
|
|
47
51
|
## Was, wie, warum?<!-- omit in toc -->
|
|
48
52
|
|
|
49
|
-
Papierkram.de hat nun endlich eine API Schnittstelle für die Programmierung von eigenen Anwendungen. Die Dokumentation findest du hier: [https://DEINE-SUBDOMAIN.papierkram.de/
|
|
53
|
+
Papierkram.de hat nun endlich eine API Schnittstelle für die Programmierung von eigenen Anwendungen. Die Dokumentation findest du hier: [https://DEINE-SUBDOMAIN.papierkram.de/papierkram_api/v1/api-docs/index.html](https://DEINE-SUBDOMAIN.papierkram.de/papierkram_api/v1/api-docs/index.html). Dieses Projekt soll eine einfache Schnittstelle für die Papierkram API bereitstellen.
|
|
50
54
|
|
|
51
55
|
Ziele:
|
|
52
56
|
|
|
@@ -96,6 +100,10 @@ Ziele:
|
|
|
96
100
|
- [alle Zeiteinträge](#alle-zeiteinträge)
|
|
97
101
|
- [einen Zeiteintrag](#einen-zeiteintrag)
|
|
98
102
|
- [Verbleibendes Quota](#verbleibendes-quota)
|
|
103
|
+
- [Business Intelligence](#business-intelligence)
|
|
104
|
+
- [Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)](#businessintelligence-bi-expensebycategory-ausgaben-nach-kategorie)
|
|
105
|
+
- [alle Ausgaben eines Monats nach Kategorie](#alle-ausgaben-eines-monats-nach-kategorie)
|
|
106
|
+
- [alle Ausgaben eines Monats nach Kategorie gefiltert nach Steuersatz](#alle-ausgaben-eines-monats-nach-kategorie-gefiltert-nach-steuersatz)
|
|
99
107
|
- [Helpers](#helpers)
|
|
100
108
|
- [Generiere ein PDF aus Response](#generiere-ein-pdf-aus-response)
|
|
101
109
|
- [Development](#development)
|
|
@@ -122,10 +130,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
|
122
130
|
# client instanziieren
|
|
123
131
|
|
|
124
132
|
# wenn ENV gesetzt sind (siehe Readme)
|
|
125
|
-
client =
|
|
133
|
+
client = PapierkramApi::Client.new
|
|
126
134
|
|
|
127
135
|
# ODER per Variablen
|
|
128
|
-
client =
|
|
136
|
+
client = PapierkramApi::Client.new('subdomain', "YOUR-API-KEY");
|
|
129
137
|
|
|
130
138
|
# info Endpunkt abfragen
|
|
131
139
|
info_details = client.info.details
|
|
@@ -142,41 +150,44 @@ puts invoices.body
|
|
|
142
150
|
|
|
143
151
|
Der API Client ist die Hauptklasse für die Kommunikation mit der Papierkram API. Er wird mit den Zugangsdaten initialisiert.
|
|
144
152
|
|
|
145
|
-
[Client](
|
|
153
|
+
[Client](lib/papierkram_api/client.rb)
|
|
146
154
|
|
|
147
155
|
Wenn du etwas hinter die Kulissen sehen willst, schau dir diese [Faraday](https://github.com/lostisland/faraday) Klasse an [Faraday::Response](https://github.com/lostisland/faraday/blob/main/lib/faraday/response.rb).
|
|
148
156
|
|
|
149
|
-
|
|
150
157
|
### Initialisierung
|
|
151
158
|
|
|
152
159
|
Entweder werden die Zugangsdaten als Argumente übergeben:
|
|
153
160
|
|
|
154
161
|
```ruby
|
|
155
162
|
# usage with subdomain and api key
|
|
156
|
-
client =
|
|
163
|
+
client = PapierkramApi::Client.new('subdomain', "SUPER-LONG-API-KEY")
|
|
157
164
|
```
|
|
158
165
|
|
|
159
166
|
Oder es werden die Umgebungsvariablen `PAPIERKRAM_API_SUBDOMAIN` und `PAPIERKRAM_API_KEY` gesetzt und der Client ohne Argumente initialisiert.
|
|
160
167
|
|
|
161
168
|
```ruby
|
|
162
169
|
# usage with environment variables
|
|
163
|
-
client =
|
|
170
|
+
client = PapierkramApi::Client.new
|
|
164
171
|
```
|
|
165
172
|
|
|
166
173
|
### Banking::BankConnection (Bankverbindung)
|
|
167
174
|
|
|
168
|
-
Der Endpunkt `/
|
|
175
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/banking/bank_connections` liefert Informationen über die Bankverbindungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
169
176
|
|
|
170
|
-
Siehe [BankConnections](
|
|
177
|
+
Siehe [BankConnections](lib/papierkram_api/v1/endpoints/banking/bank_connections.rb) für mögliche Parameter.
|
|
171
178
|
|
|
172
179
|
#### alle Bankverbindungen
|
|
173
180
|
|
|
174
181
|
```ruby
|
|
175
|
-
bank_connections = client.
|
|
182
|
+
bank_connections = client.banking_bank_connections.all
|
|
176
183
|
puts bank_connections.headers
|
|
177
184
|
puts bank_connections.body
|
|
178
185
|
```
|
|
179
186
|
|
|
187
|
+
<details>
|
|
188
|
+
|
|
189
|
+
<summary>Response</summary>
|
|
190
|
+
|
|
180
191
|
```ruby
|
|
181
192
|
# body
|
|
182
193
|
{
|
|
@@ -194,14 +205,20 @@ puts bank_connections.body
|
|
|
194
205
|
}
|
|
195
206
|
```
|
|
196
207
|
|
|
208
|
+
</details>
|
|
209
|
+
|
|
197
210
|
#### eine Bankverbindung
|
|
198
211
|
|
|
199
212
|
```ruby
|
|
200
|
-
bank_connection = client.
|
|
213
|
+
bank_connection = client.banking_bank_connections.by(id: 1)
|
|
201
214
|
puts bank_connection.headers
|
|
202
215
|
puts bank_connection.body
|
|
203
216
|
```
|
|
204
217
|
|
|
218
|
+
<details>
|
|
219
|
+
|
|
220
|
+
<summary>Response</summary>
|
|
221
|
+
|
|
205
222
|
```ruby
|
|
206
223
|
# body
|
|
207
224
|
{
|
|
@@ -226,17 +243,19 @@ puts bank_connection.body
|
|
|
226
243
|
}
|
|
227
244
|
```
|
|
228
245
|
|
|
246
|
+
</details>
|
|
247
|
+
|
|
229
248
|
### Banking::Transaction (Kontoumsatz)
|
|
230
249
|
|
|
231
250
|
WORK IN PROGRESS
|
|
232
251
|
|
|
233
|
-
[Transactions](
|
|
252
|
+
[Transactions](lib/papierkram_api/v1/endpoints/banking/transactions.rb)
|
|
234
253
|
|
|
235
254
|
### Contact::Company (Unternehmen)
|
|
236
255
|
|
|
237
|
-
Der Endpunkt `/
|
|
256
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/contact/companies` liefert Informationen über die Unternehmen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
238
257
|
|
|
239
|
-
Siehe [Companies](
|
|
258
|
+
Siehe [Companies](lib/papierkram_api/v1/endpoints/contact/companies.rb) für mögliche Parameter.
|
|
240
259
|
|
|
241
260
|
#### alle Unternehmen
|
|
242
261
|
|
|
@@ -256,14 +275,14 @@ puts company.body
|
|
|
256
275
|
|
|
257
276
|
### Contact::Company (Kontaktperson eines Unternehmens)
|
|
258
277
|
|
|
259
|
-
Der Endpunkt `/
|
|
278
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/contact/companies/{company_id}` liefert Informationen über die Kontaktpersonen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
260
279
|
|
|
261
|
-
Siehe [CompaniesPersons](
|
|
280
|
+
Siehe [CompaniesPersons](lib/papierkram_api/v1/endpoints/contact/companies_persons.rb) für mögliche Parameter.
|
|
262
281
|
|
|
263
282
|
#### alle Kontaktpersonen (eines Unternehmens)
|
|
264
283
|
|
|
265
284
|
```ruby
|
|
266
|
-
companies = client.
|
|
285
|
+
companies = client.contact_companies_persons.all(company_id: 1)
|
|
267
286
|
puts companies.headers
|
|
268
287
|
puts companies.body
|
|
269
288
|
```
|
|
@@ -271,21 +290,21 @@ puts companies.body
|
|
|
271
290
|
#### eine Kontaktperson (eines Unternehmens)
|
|
272
291
|
|
|
273
292
|
```ruby
|
|
274
|
-
company = client.
|
|
293
|
+
company = client.contact_companies_persons.by(company_id: 1, id: 1)
|
|
275
294
|
puts company.headers
|
|
276
295
|
puts company.body
|
|
277
296
|
```
|
|
278
297
|
|
|
279
298
|
### Expense::Voucher (Ausgabe Beleg)
|
|
280
299
|
|
|
281
|
-
Der Endpunkt `/
|
|
300
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/expense/vouchers` liefert Informationen über die Ausgabe Belege. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
282
301
|
|
|
283
|
-
Siehe [Vouchers](
|
|
302
|
+
Siehe [Vouchers](lib/papierkram_api/v1/endpoints/expense/vouchers.rb) für mögliche Parameter.
|
|
284
303
|
|
|
285
304
|
#### alle Ausgabe Belege
|
|
286
305
|
|
|
287
306
|
```ruby
|
|
288
|
-
vouchers = client.
|
|
307
|
+
vouchers = client.expense_vouchers.all
|
|
289
308
|
puts vouchers.headers
|
|
290
309
|
puts vouchers.body
|
|
291
310
|
```
|
|
@@ -293,7 +312,7 @@ puts vouchers.body
|
|
|
293
312
|
#### einen Ausgabe Beleg
|
|
294
313
|
|
|
295
314
|
```ruby
|
|
296
|
-
voucher = client.
|
|
315
|
+
voucher = client.expense_vouchers.by(id: 1)
|
|
297
316
|
puts voucher.headers
|
|
298
317
|
puts voucher.body
|
|
299
318
|
```
|
|
@@ -301,21 +320,21 @@ puts voucher.body
|
|
|
301
320
|
#### einen Ausgabe Beleg als PDF
|
|
302
321
|
|
|
303
322
|
```ruby
|
|
304
|
-
voucher = client.
|
|
305
|
-
puts
|
|
323
|
+
voucher = client.expense_vouchers.by(id: 1, pdf: true)
|
|
324
|
+
puts PapierkramApi::V1::Helpers::PdfFromResponse.new(voucher).to_pdf
|
|
306
325
|
# => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
|
|
307
326
|
```
|
|
308
327
|
|
|
309
328
|
### Income::Estimate (Angebot)
|
|
310
329
|
|
|
311
|
-
Der Endpunkt `/
|
|
330
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/income/estimates` liefert Informationen über die Angebote. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
312
331
|
|
|
313
|
-
Siehe [Estimates](
|
|
332
|
+
Siehe [Estimates](lib/papierkram_api/v1/endpoints/income/estimates.rb) für mögliche Parameter.
|
|
314
333
|
|
|
315
334
|
#### alle Angebote
|
|
316
335
|
|
|
317
336
|
```ruby
|
|
318
|
-
estimates = client.
|
|
337
|
+
estimates = client.income_estimates.all
|
|
319
338
|
puts estimates.headers
|
|
320
339
|
puts estimates.body
|
|
321
340
|
```
|
|
@@ -323,7 +342,7 @@ puts estimates.body
|
|
|
323
342
|
#### ein Angebot
|
|
324
343
|
|
|
325
344
|
```ruby
|
|
326
|
-
estimate = client.
|
|
345
|
+
estimate = client.income_estimates.by(id: 1)
|
|
327
346
|
puts estimate.headers
|
|
328
347
|
puts estimate.body
|
|
329
348
|
```
|
|
@@ -331,21 +350,21 @@ puts estimate.body
|
|
|
331
350
|
#### ein Angebot als PDF
|
|
332
351
|
|
|
333
352
|
```ruby
|
|
334
|
-
estimate = client.
|
|
335
|
-
puts
|
|
353
|
+
estimate = client.income_estimates.by(id: 1, pdf: true)
|
|
354
|
+
puts PapierkramApi::V1::Helpers::PdfFromResponse.new(estimate).to_pdf
|
|
336
355
|
# => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
|
|
337
356
|
```
|
|
338
357
|
|
|
339
358
|
### Income::Invoice (Rechnung)
|
|
340
359
|
|
|
341
|
-
Der Endpunkt `/
|
|
360
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/income/invoices` liefert Informationen über die Rechnungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
342
361
|
|
|
343
|
-
Siehe [Invoices](
|
|
362
|
+
Siehe [Invoices](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
|
344
363
|
|
|
345
364
|
#### alle Rechnungen
|
|
346
365
|
|
|
347
366
|
```ruby
|
|
348
|
-
invoices = client.
|
|
367
|
+
invoices = client.income_invoices.all
|
|
349
368
|
puts invoices.headers
|
|
350
369
|
puts invoices.body
|
|
351
370
|
```
|
|
@@ -353,7 +372,7 @@ puts invoices.body
|
|
|
353
372
|
#### eine Rechnung
|
|
354
373
|
|
|
355
374
|
```ruby
|
|
356
|
-
invoice = client.
|
|
375
|
+
invoice = client.income_invoices.by(id: 1)
|
|
357
376
|
puts invoice.headers
|
|
358
377
|
puts invoice.body
|
|
359
378
|
```
|
|
@@ -361,21 +380,21 @@ puts invoice.body
|
|
|
361
380
|
#### eine Rechnung als PDF
|
|
362
381
|
|
|
363
382
|
```ruby
|
|
364
|
-
invoice = client.
|
|
365
|
-
puts
|
|
383
|
+
invoice = client.income_invoices.by(id: 1, pdf: true)
|
|
384
|
+
puts PapierkramApi::V1::Helpers::PdfFromResponse.new(invoice).to_pdf
|
|
366
385
|
# => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
|
|
367
386
|
```
|
|
368
387
|
|
|
369
388
|
### Income::Proposition (Waren / Dienstleistungen)
|
|
370
389
|
|
|
371
|
-
Der Endpunkt `/
|
|
390
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/income/propositions` liefert Informationen über die Waren / Dienstleistungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
372
391
|
|
|
373
|
-
Siehe [Propositions](
|
|
392
|
+
Siehe [Propositions](lib/papierkram_api/v1/endpoints/income/propositions.rb) für mögliche Parameter.
|
|
374
393
|
|
|
375
394
|
#### alle Waren / Dienstleistungen
|
|
376
395
|
|
|
377
396
|
```ruby
|
|
378
|
-
propositions = client.
|
|
397
|
+
propositions = client.income_propositions.all
|
|
379
398
|
puts propositions.headers
|
|
380
399
|
puts propositions.body
|
|
381
400
|
```
|
|
@@ -383,16 +402,16 @@ puts propositions.body
|
|
|
383
402
|
#### eine Ware / Dienstleistung
|
|
384
403
|
|
|
385
404
|
```ruby
|
|
386
|
-
proposition = client.
|
|
405
|
+
proposition = client.income_propositions.by(id: 1)
|
|
387
406
|
puts proposition.headers
|
|
388
407
|
puts proposition.body
|
|
389
408
|
```
|
|
390
409
|
|
|
391
410
|
### Info
|
|
392
411
|
|
|
393
|
-
Der Endpunkt
|
|
412
|
+
Der Endpunkt `lib/papierkram_api/v1/endpoints/info.rb` liefert Informationen über die API. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
394
413
|
|
|
395
|
-
Siehe [Info](
|
|
414
|
+
Siehe [Info](lib/papierkram_api/v1/endpoints/info.rb).
|
|
396
415
|
|
|
397
416
|
```ruby
|
|
398
417
|
info = client.info.details
|
|
@@ -402,9 +421,9 @@ puts info.body
|
|
|
402
421
|
|
|
403
422
|
### Project::Project (Projekt)
|
|
404
423
|
|
|
405
|
-
Der Endpunkt `/
|
|
424
|
+
Der Endpunkt `/papierkram_api/v1/endpoints/projects` liefert Informationen über die Projekte. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
406
425
|
|
|
407
|
-
Siehe [Projects](
|
|
426
|
+
Siehe [Projects](lib/papierkram_api/v1/endpoints/projects.rb) für mögliche Parameter.
|
|
408
427
|
|
|
409
428
|
#### alle Projekte
|
|
410
429
|
|
|
@@ -424,9 +443,9 @@ puts project.body
|
|
|
424
443
|
|
|
425
444
|
### Tracker::Task (Aufgabe)
|
|
426
445
|
|
|
427
|
-
Der Endpunkt `/
|
|
446
|
+
Der Endpunkt `/papierkram_api/v1/tracker/tasks` liefert Informationen über die Aufgaben. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
428
447
|
|
|
429
|
-
Siehe [Tasks](
|
|
448
|
+
Siehe [Tasks](lib/papierkram_api/v1/endpoints/tracker/tasks.rb) für mögliche Parameter.
|
|
430
449
|
|
|
431
450
|
#### alle Aufgaben
|
|
432
451
|
|
|
@@ -446,9 +465,9 @@ puts task.body
|
|
|
446
465
|
|
|
447
466
|
### Tracker::TimeEntry (Zeiteintrag)
|
|
448
467
|
|
|
449
|
-
Der Endpunkt `/
|
|
468
|
+
Der Endpunkt `/papierkram_api/v1/tracker/time_entries` liefert Informationen über die Zeiteinträge. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
|
450
469
|
|
|
451
|
-
[TimeEntries](
|
|
470
|
+
[TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb)
|
|
452
471
|
|
|
453
472
|
#### alle Zeiteinträge
|
|
454
473
|
|
|
@@ -470,7 +489,7 @@ puts time_entry.body
|
|
|
470
489
|
|
|
471
490
|
Jede API Anfrage "kostet" 1 Quota. Das Quota wird bei jedem Request aktualisiert. Um das verbleibende Quota zu erhalten, kann die Methode `remaining_quota` aufgerufen werden.
|
|
472
491
|
|
|
473
|
-
[Base](
|
|
492
|
+
[Base](lib/papierkram_api/v1/endpoints/base.rb)
|
|
474
493
|
|
|
475
494
|
Du kannst dein Quota über die Papierkram Webseite einsehen. Die Anzahl der verbleibenden Anfragen wird dir dort angezeigt.
|
|
476
495
|
|
|
@@ -482,21 +501,100 @@ response = client.info.details
|
|
|
482
501
|
quota = client.info.remaining_quota(response)
|
|
483
502
|
```
|
|
484
503
|
|
|
504
|
+
## Business Intelligence
|
|
505
|
+
|
|
506
|
+
TODO ergänzen wie man `SmartQueries` erstellt und verwendet.
|
|
507
|
+
TODO ergänzen wie man `SmartQueries` funktioneren.
|
|
508
|
+
TODO ergänzen wie die Rückgabewerte von `SmartQueries` gestaltet werden sollten.
|
|
509
|
+
|
|
510
|
+
### Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)
|
|
511
|
+
|
|
512
|
+
Der Endpunkt `/papierkram_api/v1/business_intelligence/expense_by_categories` liefert Informationen über die Ausgaben nach Kategorie. Die Informationen werden als `Hash` zurückgegeben.
|
|
513
|
+
|
|
514
|
+
#### alle Ausgaben eines Monats nach Kategorie
|
|
515
|
+
|
|
516
|
+
```ruby
|
|
517
|
+
client = PapierkramApi::Client.new
|
|
518
|
+
expense_voucher_data_service = client.expense_vouchers.data_service(:for_month_in_year_service)
|
|
519
|
+
expense_vouchers_in_date_range = expense_voucher_data_service.for_month_in_year(year: 2020, month: 8)
|
|
520
|
+
|
|
521
|
+
service = client.business_intelligence.expenses_by_category
|
|
522
|
+
result = service.call(expense_vouchers: expense_vouchers_in_date_range)
|
|
523
|
+
puts result
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
```ruby
|
|
527
|
+
{"Betriebsbedarf"=>
|
|
528
|
+
{"amount"=>476.0,
|
|
529
|
+
"amount_by_creditor"=>{nil=>476.0},
|
|
530
|
+
"line_items"=>
|
|
531
|
+
[{"name"=>"2020-01-03",
|
|
532
|
+
"amount"=>119.0,
|
|
533
|
+
"category"=>"Betriebsbedarf",
|
|
534
|
+
"vat_rate"=>"19%",
|
|
535
|
+
"billing"=>nil,
|
|
536
|
+
"depreciation"=>nil,
|
|
537
|
+
"voucher_name"=>"B-00214 - 2020-08-01",
|
|
538
|
+
"voucher_id"=>641,
|
|
539
|
+
"creditor"=>nil},
|
|
540
|
+
{"name"=>"2020-01-03",
|
|
541
|
+
"amount"=>119.0,
|
|
542
|
+
"category"=>"Betriebsbedarf",
|
|
543
|
+
"vat_rate"=>"19%",
|
|
544
|
+
"billing"=>nil,
|
|
545
|
+
"depreciation"=>nil,
|
|
546
|
+
"voucher_name"=>"B-00215 - 2020-08-02",
|
|
547
|
+
"voucher_id"=>644,
|
|
548
|
+
"creditor"=>nil},
|
|
549
|
+
{"name"=>"2020-01-03",
|
|
550
|
+
"amount"=>119.0,
|
|
551
|
+
"category"=>"Betriebsbedarf",
|
|
552
|
+
"vat_rate"=>"19%",
|
|
553
|
+
"billing"=>nil,
|
|
554
|
+
"depreciation"=>nil,
|
|
555
|
+
"voucher_name"=>"B-00216 - 2020-08-03",
|
|
556
|
+
"voucher_id"=>647,
|
|
557
|
+
"creditor"=>nil},
|
|
558
|
+
{"name"=>"2020-01-03",
|
|
559
|
+
"amount"=>119.0,
|
|
560
|
+
"category"=>"Betriebsbedarf",
|
|
561
|
+
"vat_rate"=>"19%",
|
|
562
|
+
"billing"=>nil,
|
|
563
|
+
"depreciation"=>nil,
|
|
564
|
+
"voucher_name"=>"B-00217 - 2020-08-04",
|
|
565
|
+
"voucher_id"=>650,
|
|
566
|
+
"creditor"=>nil}]}}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
#### alle Ausgaben eines Monats nach Kategorie gefiltert nach Steuersatz
|
|
570
|
+
|
|
571
|
+
```ruby
|
|
572
|
+
client = PapierkramApi::Client.new
|
|
573
|
+
expense_voucher_data_service = client.expense_vouchers.data_service(:for_month_in_year_service)
|
|
574
|
+
expense_vouchers_in_date_range = expense_voucher_data_service.for_month_in_year(year: 2020, month: 8)
|
|
575
|
+
|
|
576
|
+
service = client.business_intelligence.expenses_by_category
|
|
577
|
+
result = service.call(expense_vouchers: expense_vouchers_in_date_range) do |line_items|
|
|
578
|
+
line_items.select { |v| v['vat_rate'] == '19%' }
|
|
579
|
+
end
|
|
580
|
+
puts result
|
|
581
|
+
```
|
|
582
|
+
|
|
485
583
|
## Helpers
|
|
486
584
|
|
|
487
585
|
Es gibt einige Helper, die dir das Leben leichter machen.
|
|
488
586
|
|
|
489
587
|
### Generiere ein PDF aus Response
|
|
490
588
|
|
|
491
|
-
Mit dem Helper `
|
|
589
|
+
Mit dem Helper `PapierkramApi::V1::Helpers::PdfFromResponse` kannst du für unterstützte Endpunkte aus einer `Faraday::Response` ein PDF schreiben.
|
|
492
590
|
|
|
493
591
|
Unterstützte Endpunkte sind beispielsweise: `Income::Estimate`, `Income::Invoice`, `Expense::Voucher`.
|
|
494
592
|
|
|
495
|
-
[Api::V1::Helpers::PdfFromResponse](
|
|
593
|
+
[Api::V1::Helpers::PdfFromResponse](lib/papierkram_api/v1/helper/pdf_from_response.rb)
|
|
496
594
|
|
|
497
595
|
```ruby
|
|
498
596
|
response = client.income_invoices.by(id: 1, pdf: true)
|
|
499
|
-
pdf =
|
|
597
|
+
pdf = PapierkramApi::V1::Helpers::PdfFromResponse.new(response).to_pdf("Rechnung Nummer XXX")
|
|
500
598
|
puts pdf
|
|
501
599
|
```
|
|
502
600
|
|
|
@@ -522,7 +620,7 @@ Bitte achte darauf, dass du die Tests ausführst und die Tests dann auch grün s
|
|
|
522
620
|
|
|
523
621
|
🚨 **SEHR WICHTIG!** Dein API Key wird in den Tests verwendet werden. **Bitte achte darauf**, dass du den API Key nicht in deinen Commits hast! Wenn du per Environment Variable arbeitest, dann wird dein API Key **nicht von VCR aufgezeichnet**. Das bedeutet, dass du deine Tests nicht mit deinem API Key ausführen solltest. ⚠️
|
|
524
622
|
|
|
525
|
-
🚨 **NOCH WICHTIGER!** deine Kundendaten, also Klarnamen, E-Mails und Telefonnummern haben hier nichts verloren! Bitte sorge dafür, dass du deine Tests mit einem Testaccount ausführst. 🙏 ODER editiere deine Kundendaten in den
|
|
623
|
+
🚨 **NOCH WICHTIGER!** deine Kundendaten, also Klarnamen, E-Mails und Telefonnummern haben hier nichts verloren! Bitte sorge dafür, dass du deine Tests mit einem Testaccount ausführst. 🙏 ODER editiere deine Kundendaten in den _VCR Cassettes_ nach dem Test. 🙏
|
|
526
624
|
|
|
527
625
|
Wenn du unsicher bist, sprich mich an oder erstelle ein Issue. Ich helfe dir gerne weiter. 🤗
|
|
528
626
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PapierkramApi
|
|
4
|
+
# The Client class is the main entry point for the Papierkram API Client.
|
|
5
|
+
class Client
|
|
6
|
+
attr_accessor :client,
|
|
7
|
+
:subdomain,
|
|
8
|
+
:api_key,
|
|
9
|
+
:base_url,
|
|
10
|
+
:remaining_quota
|
|
11
|
+
|
|
12
|
+
extend Forwardable
|
|
13
|
+
def_delegators :@client, :get, :post, :put, :patch, :delete
|
|
14
|
+
|
|
15
|
+
def initialize(subdomain = nil, api_key = nil)
|
|
16
|
+
@subdomain = subdomain || ENV.fetch('PAPIERKRAM_API_SUBDOMAIN', nil)
|
|
17
|
+
@api_key = api_key || ENV.fetch('PAPIERKRAM_API_KEY', nil)
|
|
18
|
+
@base_url = base_url_env
|
|
19
|
+
@remaining_quota = nil
|
|
20
|
+
build_client!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def build_client!
|
|
24
|
+
@client = Faraday.new(url: @base_url) do |config|
|
|
25
|
+
config.request :authorization, 'Bearer', @api_key
|
|
26
|
+
config.request :json
|
|
27
|
+
config.response :json
|
|
28
|
+
config.adapter :httpx
|
|
29
|
+
yield(config) if block_given?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def business_intelligence
|
|
34
|
+
@business_intelligence ||= PapierkramApi::V1::BusinessIntelligence::Base.new
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def banking_bank_connections
|
|
38
|
+
@banking_bank_connections ||= PapierkramApi::V1::Endpoints::Banking::BankConnections.new(@client)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def banking_transactions
|
|
42
|
+
@banking_transactions ||= PapierkramApi::V1::Endpoints::Banking::Transactions.new(@client)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def contact_companies
|
|
46
|
+
@contact_companies ||= PapierkramApi::V1::Endpoints::Contact::Companies.new(@client)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def contact_companies_persons
|
|
50
|
+
@contact_companies_persons ||= PapierkramApi::V1::Endpoints::Contact::CompaniesPersons.new(@client)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def expense_vouchers
|
|
54
|
+
@expense_vouchers ||= PapierkramApi::V1::Endpoints::Expense::Vouchers.new(@client)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def income_estimates
|
|
58
|
+
@income_estimates ||= PapierkramApi::V1::Endpoints::Income::Estimates.new(@client)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def income_invoices
|
|
62
|
+
@income_invoices ||= PapierkramApi::V1::Endpoints::Income::Invoices.new(@client)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def income_propositions
|
|
66
|
+
@income_propositions ||= PapierkramApi::V1::Endpoints::Income::Propositions.new(@client)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def info
|
|
70
|
+
@info ||= PapierkramApi::V1::Endpoints::Info.new(@client)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def projects
|
|
74
|
+
@projects ||= PapierkramApi::V1::Endpoints::Projects.new(@client)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def tracker_tasks
|
|
78
|
+
@tracker_tasks ||= PapierkramApi::V1::Endpoints::Tracker::Tasks.new(@client)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def tracker_time_entries
|
|
82
|
+
@tracker_time_entries ||= PapierkramApi::V1::Endpoints::Tracker::TimeEntries.new(@client)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
def base_url_env
|
|
88
|
+
"https://#{@subdomain}.papierkram.de"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PapierkramApi
|
|
4
|
+
module V1
|
|
5
|
+
module BusinessIntelligence
|
|
6
|
+
# Business Intelligence Base Class
|
|
7
|
+
#
|
|
8
|
+
# Business Intelligence is a set of services that can be used to gain
|
|
9
|
+
# insights into the data stored in the system.
|
|
10
|
+
#
|
|
11
|
+
# Therefor you should pass data to the service and get back a result.
|
|
12
|
+
#
|
|
13
|
+
# IMPORTANT no calls to the API should be made in this class.
|
|
14
|
+
# This is an intentional design decision! To seperate logic from the data source.
|
|
15
|
+
#
|
|
16
|
+
class Base
|
|
17
|
+
def expenses_by_category
|
|
18
|
+
@expenses_by_category ||= PapierkramApi::V1::BusinessIntelligence::ExpensesByCategory.new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|