papierkram_api_client 0.2.2 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c711543eff8d01b4052e9de92dc9d3a4f436107c71c9944ab63d5943d28d73a9
4
- data.tar.gz: 156999ce0d5031096ee95cf034849bc7f3b7bf29c3321daec47cd75f228391b7
3
+ metadata.gz: 149edeeed9ee09d36a1c017a9a831eb00dcf347c507d89b37c498bef24ff87f6
4
+ data.tar.gz: 48e326b8fc0c92af833e8e928daba56ca0b8f9d28e3d2490af07ffad5cf317de
5
5
  SHA512:
6
- metadata.gz: 0104eda136279d4c82cf0671d1e5c64650f9eeda00a5b26813bd16f85756168747816b68a0a1c576f9a513a10d7e133b99055a9aab75240395ce0cfdc3867f2e
7
- data.tar.gz: 377a731d8eaadc2016d264390963fcb995673815a35053c5ee9ee3c1bb83b783a77fda9568db2b15149df69f8c752636521bde07009ee773c46c301dd1fa6b50
6
+ metadata.gz: fc5b3801503c34095ae1cad9695e78eb749ba8b1c65f2704978bda859640f8e342339aaa1a7b0354a672be2433366bee7436ec6d57b42eaa560216dde9f025e8
7
+ data.tar.gz: 669678b6e1cc39a506c95ad3d05ab705acbc3ee51f0377ef682ad06b7b1b0daacceb58b8c3da7a9e692f7d7960a7faeac51e2af11c9d79be3d735feb26b31304
data/.rubocop.yml CHANGED
@@ -33,6 +33,7 @@ Metrics/ParameterLists:
33
33
  - "lib/api/v1/**/*"
34
34
 
35
35
  Metrics/ClassLength:
36
+ Max: 150
36
37
  CountAsOne:
37
38
  - "array"
38
39
  - "hash"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ [0.2.4] - 2023-06-30
4
+
5
+ #### Fixed
6
+
7
+ - [#48](https://github.com/simonneutert/papierkram_api_client/pull/48) Arguments weren't truly optional when possible. [@simonneutert](https://github.com/simonneutert)
8
+
9
+ [0.2.3] - 2023-06-29
10
+
11
+ ### Added
12
+
13
+ - [#47](https://github.com/simonneutert/papierkram_api_client/pull/47) Adds CRUD endpoint support for income propositions. [@simonneutert](https://github.com/simonneutert)
14
+ - [#46](https://github.com/simonneutert/papierkram_api_client/pull/46) Adds CRUD endpoint support for projects. [@simonneutert](https://github.com/simonneutert)
15
+ - [#45](https://github.com/simonneutert/papierkram_api_client/pull/45) Adds CRUD endpoint support for contact companies persons. [@simonneutert](https://github.com/simonneutert)
16
+
3
17
  ## [0.2.2] - 2023-06-28
4
18
 
5
19
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- papierkram_api_client (0.2.2)
4
+ papierkram_api_client (0.2.4)
5
5
  faraday (~> 2.7)
6
6
  httpx (>= 0.22.5, < 0.25.0)
7
7
 
data/README.md CHANGED
@@ -77,6 +77,9 @@ Ziele:
77
77
  - [Contact::Company (Kontaktperson eines Unternehmens)](#contactcompany-kontaktperson-eines-unternehmens)
78
78
  - [alle Kontaktpersonen (eines Unternehmens)](#alle-kontaktpersonen-eines-unternehmens)
79
79
  - [eine Kontaktperson (eines Unternehmens)](#eine-kontaktperson-eines-unternehmens)
80
+ - [erstelle eine Kontaktperson (eines Unternehmens)](#erstelle-eine-kontaktperson-eines-unternehmens)
81
+ - [aktualisiere eine Kontaktperson (eines Unternehmens)](#aktualisiere-eine-kontaktperson-eines-unternehmens)
82
+ - [lösche eine Kontaktperson (eines Unternehmens)](#lösche-eine-kontaktperson-eines-unternehmens)
80
83
  - [Expense::Voucher (Ausgabe Beleg)](#expensevoucher-ausgabe-beleg)
81
84
  - [alle Ausgabe Belege](#alle-ausgabe-belege)
82
85
  - [einen Ausgabe Beleg](#einen-ausgabe-beleg)
@@ -92,10 +95,20 @@ Ziele:
92
95
  - [Income::Proposition (Waren / Dienstleistungen)](#incomeproposition-waren--dienstleistungen)
93
96
  - [alle Waren / Dienstleistungen](#alle-waren--dienstleistungen)
94
97
  - [eine Ware / Dienstleistung](#eine-ware--dienstleistung)
98
+ - [eine Ware / Dienstleistung erstellen](#eine-ware--dienstleistung-erstellen)
99
+ - [eine Ware / Dienstleistung aktualisieren](#eine-ware--dienstleistung-aktualisieren)
100
+ - [eine Ware / Dienstleistung löschen](#eine-ware--dienstleistung-löschen)
101
+ - [eine Ware / Dienstleistung archivieren](#eine-ware--dienstleistung-archivieren)
102
+ - [eine Ware / Dienstleistung unarchivieren](#eine-ware--dienstleistung-unarchivieren)
95
103
  - [Info](#info)
96
104
  - [Project::Project (Projekt)](#projectproject-projekt)
97
105
  - [alle Projekte](#alle-projekte)
98
106
  - [ein Projekt](#ein-projekt)
107
+ - [erstelle ein Projekt](#erstelle-ein-projekt)
108
+ - [aktualisiere ein Projekt](#aktualisiere-ein-projekt)
109
+ - [lösche ein Projekt](#lösche-ein-projekt)
110
+ - [archiviere ein Projekt](#archiviere-ein-projekt)
111
+ - [unarchiviere ein Projekt](#unarchiviere-ein-projekt)
99
112
  - [Tracker::Task (Aufgabe)](#trackertask-aufgabe)
100
113
  - [alle Aufgaben](#alle-aufgaben)
101
114
  - [eine Aufgabe](#eine-aufgabe)
@@ -347,6 +360,41 @@ puts company.headers
347
360
  puts company.body
348
361
  ```
349
362
 
363
+ #### erstelle eine Kontaktperson (eines Unternehmens)
364
+
365
+ ```ruby
366
+ company = client.contact_companies_persons.create(
367
+ company_id: 1,
368
+ attributes: {
369
+ first_name: 'Max',
370
+ last_name: 'Mustermann'
371
+ }
372
+ )
373
+ puts company.headers
374
+ puts company.body
375
+ ```
376
+
377
+ Siehe [CompaniesPersons#create](lib/papierkram_api/v1/endpoints/contact/companies_persons.rb) für mögliche Parameter.
378
+
379
+ #### aktualisiere eine Kontaktperson (eines Unternehmens)
380
+
381
+ ```ruby
382
+ company = client.contact_companies_persons
383
+ .update_by(company_id: 1, id: 1, attributes: { first_name: 'Moritz' })
384
+ puts company.headers
385
+ puts company.body
386
+ ```
387
+
388
+ Siehe [CompaniesPersons#update_by](lib/papierkram_api/v1/endpoints/contact/companies_persons.rb) für mögliche Parameter.
389
+
390
+ #### lösche eine Kontaktperson (eines Unternehmens)
391
+
392
+ ```ruby
393
+ company = client.contact_companies_persons.delete_by(company_id: 1, id: 1)
394
+ puts company.headers
395
+ puts company.body
396
+ ```
397
+
350
398
  ### Expense::Voucher (Ausgabe Beleg)
351
399
 
352
400
  Der Endpunkt `/papierkram_api/v1/endpoints/expense/vouchers` liefert Informationen über die Ausgabe Belege. Die Informationen werden als `Faraday::Response` zurückgegeben.
@@ -459,6 +507,56 @@ puts proposition.headers
459
507
  puts proposition.body
460
508
  ```
461
509
 
510
+ #### eine Ware / Dienstleistung erstellen
511
+
512
+ ```ruby
513
+ proposition = client.income_propositions.create(
514
+ name: 'Software design',
515
+ article_no: '12345',
516
+ description: 'Here, we can describe what "Software design" actually entails.',
517
+ time_unit: 'hour',
518
+ proposition_type: 'service',
519
+ price: '150.0',
520
+ vat_rate: '19%'
521
+ )
522
+ puts proposition.headers
523
+ puts proposition.body
524
+ ```
525
+
526
+ Siehe [Propositions#create](lib/papierkram_api/v1/endpoints/income/propositions.rb) für mögliche Parameter.
527
+
528
+ #### eine Ware / Dienstleistung aktualisieren
529
+
530
+ ```ruby
531
+ client.income_propositions.update_by(
532
+ id: 1,
533
+ attributes: {
534
+ name: 'Software design',
535
+ vat_rate: '19%' # verpflichtend bei Änderung
536
+ }
537
+ )
538
+ ```
539
+
540
+ Siehe [Propositions#update_by](lib/papierkram_api/v1/endpoints/income/propositions.rb) für mögliche Parameter.
541
+
542
+ #### eine Ware / Dienstleistung löschen
543
+
544
+ ```ruby
545
+ client.income_propositions.delete_by(id: 1)
546
+ ```
547
+
548
+ #### eine Ware / Dienstleistung archivieren
549
+
550
+ ```ruby
551
+ client.income_propositions.archive_by(id: 1)
552
+ ```
553
+
554
+ #### eine Ware / Dienstleistung unarchivieren
555
+
556
+ ```ruby
557
+ client.income_propositions.unarchive_by(id: 1)
558
+ ```
559
+
462
560
  ### Info
463
561
 
464
562
  Der Endpunkt `lib/papierkram_api/v1/endpoints/info.rb` liefert Informationen über die API. Die Informationen werden als `Faraday::Response` zurückgegeben.
@@ -493,6 +591,50 @@ puts project.headers
493
591
  puts project.body
494
592
  ```
495
593
 
594
+ #### erstelle ein Projekt
595
+
596
+ ```ruby
597
+ project = client.projects.create(name: 'Projekt 1')
598
+ puts project.headers
599
+ puts project.body
600
+ ```
601
+
602
+ Siehe [Projects](lib/papierkram_api/v1/endpoints/projects.rb) für mögliche Parameter.
603
+
604
+ #### aktualisiere ein Projekt
605
+
606
+ ```ruby
607
+ project = client.projects.update_by(id: 1, attributes: { name: 'Projekt 2' })
608
+ puts project.headers
609
+ puts project.body
610
+ ```
611
+
612
+ Siehe [Projects](lib/papierkram_api/v1/endpoints/projects.rb) für mögliche Parameter.
613
+
614
+ #### lösche ein Projekt
615
+
616
+ ```ruby
617
+ project = client.projects.delete_by(id: 1)
618
+ puts project.headers
619
+ puts project.body
620
+ ```
621
+
622
+ #### archiviere ein Projekt
623
+
624
+ ```ruby
625
+ project = client.projects.archive_by(id: 1)
626
+ puts project.headers
627
+ puts project.body
628
+ ```
629
+
630
+ #### unarchiviere ein Projekt
631
+
632
+ ```ruby
633
+ project = client.projects.unarchive_by(id: 1)
634
+ puts project.headers
635
+ puts project.body
636
+ ```
637
+
496
638
  ### Tracker::Task (Aufgabe)
497
639
 
498
640
  Der Endpunkt `/papierkram_api/v1/tracker/tasks` liefert Informationen über die Aufgaben. Die Informationen werden als `Faraday::Response` zurückgegeben.
@@ -24,7 +24,7 @@ module PapierkramApi
24
24
  get("#{@url_api_path}/contact/companies", query)
25
25
  end
26
26
 
27
- def create_supplier( # rubocop:disable Metrics/ParameterLists
27
+ def create_supplier( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
28
28
  name:,
29
29
  phone: nil,
30
30
  fax: nil,
@@ -50,37 +50,36 @@ module PapierkramApi
50
50
  color: nil
51
51
  )
52
52
 
53
- body = {
54
- contact_type: :supplier,
55
- name: name,
56
- phone: phone,
57
- fax: fax,
58
- email: email,
59
- delivery_method: delivery_method,
60
- ust_idnr: ust_idnr,
61
- website: website,
62
- twitter: twitter,
63
- postal_street: postal_street,
64
- postal_city: postal_city,
65
- postal_zip: postal_zip,
66
- postal_country: postal_country,
67
- physical_street: physical_street,
68
- physical_city: physical_city,
69
- physical_zip: physical_zip,
70
- physical_country: physical_country,
71
- bank_blz: bank_blz,
72
- bank_institute: bank_institute,
73
- bank_account_no: bank_account_no,
74
- bank_bic: bank_bic,
75
- bank_iban: bank_iban,
76
- notes: notes,
77
- color: color
78
- }
53
+ body = {}
54
+ body[:contact_type] = 'supplier'
55
+ body[:name] = name
56
+ body[:phone] = phone if phone
57
+ body[:fax] = fax if fax
58
+ body[:email] = email if email
59
+ body[:delivery_method] = delivery_method if delivery_method
60
+ body[:ust_idnr] = ust_idnr if ust_idnr
61
+ body[:website] = website if website
62
+ body[:twitter] = twitter if twitter
63
+ body[:postal_street] = postal_street if postal_street
64
+ body[:postal_city] = postal_city if postal_city
65
+ body[:postal_zip] = postal_zip if postal_zip
66
+ body[:postal_country] = postal_country if postal_country
67
+ body[:physical_street] = physical_street if physical_street
68
+ body[:physical_city] = physical_city if physical_city
69
+ body[:physical_zip] = physical_zip if physical_zip
70
+ body[:physical_country] = physical_country if physical_country
71
+ body[:bank_blz] = bank_blz if bank_blz
72
+ body[:bank_institute] = bank_institute if bank_institute
73
+ body[:bank_account_no] = bank_account_no if bank_account_no
74
+ body[:bank_bic] = bank_bic if bank_bic
75
+ body[:bank_iban] = bank_iban if bank_iban
76
+ body[:notes] = notes if notes
77
+ body[:color] = color if color
79
78
 
80
79
  post("#{@url_api_path}/contact/companies", body)
81
80
  end
82
81
 
83
- def create_customer( # rubocop:disable Metrics/ParameterLists
82
+ def create_customer( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
84
83
  name:,
85
84
  phone: nil,
86
85
  fax: nil,
@@ -106,32 +105,31 @@ module PapierkramApi
106
105
  color: nil
107
106
  )
108
107
 
109
- body = {
110
- contact_type: :customer,
111
- name: name,
112
- phone: phone,
113
- fax: fax,
114
- email: email,
115
- delivery_method: delivery_method,
116
- ust_idnr: ust_idnr,
117
- website: website,
118
- twitter: twitter,
119
- postal_street: postal_street,
120
- postal_city: postal_city,
121
- postal_zip: postal_zip,
122
- postal_country: postal_country,
123
- physical_street: physical_street,
124
- physical_city: physical_city,
125
- physical_zip: physical_zip,
126
- physical_country: physical_country,
127
- bank_blz: bank_blz,
128
- bank_institute: bank_institute,
129
- bank_account_no: bank_account_no,
130
- bank_bic: bank_bic,
131
- bank_iban: bank_iban,
132
- notes: notes,
133
- color: color
134
- }
108
+ body = {}
109
+ body[:contact_type] = 'customer'
110
+ body[:name] = name
111
+ body[:phone] = phone if phone
112
+ body[:fax] = fax if fax
113
+ body[:email] = email if email
114
+ body[:delivery_method] = delivery_method if delivery_method
115
+ body[:ust_idnr] = ust_idnr if ust_idnr
116
+ body[:website] = website if website
117
+ body[:twitter] = twitter if twitter
118
+ body[:postal_street] = postal_street if postal_street
119
+ body[:postal_city] = postal_city if postal_city
120
+ body[:postal_zip] = postal_zip if postal_zip
121
+ body[:postal_country] = postal_country if postal_country
122
+ body[:physical_street] = physical_street if physical_street
123
+ body[:physical_city] = physical_city if physical_city
124
+ body[:physical_zip] = physical_zip if physical_zip
125
+ body[:physical_country] = physical_country if physical_country
126
+ body[:bank_blz] = bank_blz if bank_blz
127
+ body[:bank_institute] = bank_institute if bank_institute
128
+ body[:bank_account_no] = bank_account_no if bank_account_no
129
+ body[:bank_bic] = bank_bic if bank_bic
130
+ body[:bank_iban] = bank_iban if bank_iban
131
+ body[:notes] = notes if notes
132
+ body[:color] = color if color
135
133
 
136
134
  post("#{@url_api_path}/contact/companies", body)
137
135
  end
@@ -21,6 +21,53 @@ module PapierkramApi
21
21
 
22
22
  get("#{@url_api_path}/contact/companies/#{company_id}/persons", query)
23
23
  end
24
+
25
+ def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
26
+ company_id:,
27
+ first_name:,
28
+ last_name:,
29
+ title: nil,
30
+ salutation: nil,
31
+ position: nil,
32
+ department: nil,
33
+ email: nil,
34
+ phone: nil,
35
+ mobile: nil,
36
+ fax: nil,
37
+ skype: nil,
38
+ comment: nil
39
+ )
40
+ body = {}
41
+ body[:first_name] = first_name
42
+ body[:last_name] = last_name
43
+ body[:title] = title if title
44
+ body[:salutation] = salutation if salutation
45
+ body[:position] = position if position
46
+ body[:department] = department if department
47
+ body[:email] = email if email
48
+ body[:phone] = phone if phone
49
+ body[:mobile] = mobile if mobile
50
+ body[:fax] = fax if fax
51
+ body[:skype] = skype if skype
52
+ body[:comment] = comment if comment
53
+
54
+ post("#{@url_api_path}/contact/companies/#{company_id}/persons", body)
55
+ end
56
+
57
+ def update_by(company_id:, id:, attributes: {})
58
+ raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
59
+ raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer)
60
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
61
+
62
+ put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", attributes)
63
+ end
64
+
65
+ def delete_by(company_id:, id:)
66
+ raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer)
67
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
68
+
69
+ delete("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}")
70
+ end
24
71
  end
25
72
  end
26
73
  end
@@ -13,6 +13,48 @@ module PapierkramApi
13
13
  def all
14
14
  get("#{@url_api_path}/income/propositions")
15
15
  end
16
+
17
+ def create(
18
+ name:,
19
+ article_no:,
20
+ description: nil,
21
+ time_unit: nil,
22
+ proposition_type: nil,
23
+ price: nil,
24
+ vat_rate: nil
25
+ )
26
+
27
+ body = {}
28
+ body[:name] = name
29
+ body[:article_no] = article_no
30
+ body[:description] = description if description
31
+ body[:time_unit] = time_unit if time_unit
32
+ body[:proposition_type] = proposition_type if proposition_type
33
+ body[:price] = price if price
34
+ body[:vat_rate] = vat_rate if vat_rate
35
+
36
+ post("#{@url_api_path}/income/propositions", body)
37
+ end
38
+
39
+ def update_by(id:, attributes: {})
40
+ if attributes[:vat_rate] && (attributes[:vat_rate].empty? || !attributes[:vat_rate].include?('%'))
41
+ raise ArgumentError, 'vat_rate must be a percentage and include a % sign'
42
+ end
43
+
44
+ put("#{@url_api_path}/income/propositions/#{id}", attributes)
45
+ end
46
+
47
+ def delete_by(id:)
48
+ delete("#{@url_api_path}/income/propositions/#{id}")
49
+ end
50
+
51
+ def archive_by(id:)
52
+ post("#{@url_api_path}/income/propositions/#{id}/archive")
53
+ end
54
+
55
+ def unarchive_by(id:)
56
+ post("#{@url_api_path}/income/propositions/#{id}/unarchive")
57
+ end
16
58
  end
17
59
  end
18
60
  end
@@ -20,6 +20,58 @@ module PapierkramApi
20
20
 
21
21
  get("#{@url_api_path}/projects", query)
22
22
  end
23
+
24
+ def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25
+ name:,
26
+ customer_id:,
27
+ description: nil,
28
+ start_date: nil,
29
+ end_date: nil,
30
+ flagged: nil,
31
+ budget_type: nil,
32
+ budget_money: nil,
33
+ budget_time: nil,
34
+ budget_time_unit: nil,
35
+ color: nil,
36
+ default_proposition: nil,
37
+ team_members: nil
38
+ )
39
+
40
+ body = {}
41
+ body[:name] = name
42
+ body[:customer] = { id: customer_id }
43
+ body[:description] = description if description
44
+ body[:start_date] = start_date if start_date
45
+ body[:end_date] = end_date if end_date
46
+ body[:flagged] = flagged if flagged
47
+ body[:budget_type] = budget_type if budget_type
48
+ body[:budget_money] = budget_money if budget_money
49
+ body[:budget_time] = budget_time if budget_time
50
+ body[:budget_time_unit] = budget_time_unit if budget_time_unit
51
+ body[:color] = color if color
52
+ body[:default_proposition] = default_proposition if default_proposition
53
+ body[:team_members] = team_members if team_members
54
+
55
+ post("#{@url_api_path}/projects", body)
56
+ end
57
+
58
+ def update_by(id:, attributes: {})
59
+ raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
60
+
61
+ put("#{@url_api_path}/projects/#{id}", attributes)
62
+ end
63
+
64
+ def delete_by(id:)
65
+ delete("#{@url_api_path}/projects/#{id}")
66
+ end
67
+
68
+ def archive_by(id:)
69
+ post("#{@url_api_path}/projects/#{id}/archive")
70
+ end
71
+
72
+ def unarchive_by(id:)
73
+ post("#{@url_api_path}/projects/#{id}/unarchive")
74
+ end
23
75
  end
24
76
  end
25
77
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PapierkramApiClient
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papierkram_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Neutert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday