papierkram_api_client 0.3.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3ca301db014f077381022d10aa1a30faa6e192e9cfe77e933e6aa8b0cd2f0a2
4
- data.tar.gz: 57c63278246aae9764e6ee60d9f8aaa3ed50d076ebee4a43da7f130bf35243cc
3
+ metadata.gz: e1b8b7a1214d098bc7b757e9e7025b4f7c59a3711031eeb1b25304498bf14c7d
4
+ data.tar.gz: c9eb2be1ecd5d58614348b53f8ba4b80f93f90ce6a4d981baf7bbe0f1aecd45d
5
5
  SHA512:
6
- metadata.gz: 3ba2d768a34ddf446dcf1ded72ec06e91db2391a4ce344e80d49876846acd6d4fbe951513879b11cbafffd805727f77d29785257d7ab077dedc1cceb52c7e5bd
7
- data.tar.gz: 2050971c4a484acd2b01e5d75bd4c38a35c85811ee9c1b4f7175392f4dc584d80ed2a5b5c245d608eb4e610142b7662ac408df5272049f0a8ca73ec1249b2b6c
6
+ metadata.gz: 970159a1f873b3115c19ff378e42aef86ae3d7488c17d7d53372c795378aa0100d7a0c13315c7a85ac4e91005c4a22bb66ce29e2302bc4b14942a9135fe0c70b
7
+ data.tar.gz: 0d62509c7594db275108218d4d777c5a509348a5c4d06d1002dd99755ad237ef6a9f233c038fb3e038d86f1ef18f2a278751120897973a46fe3608211afe2981
data/.rubocop.yml CHANGED
@@ -33,7 +33,7 @@ Metrics/ParameterLists:
33
33
  - "lib/api/v1/**/*"
34
34
 
35
35
  Metrics/ClassLength:
36
- Max: 150
36
+ Max: 250
37
37
  CountAsOne:
38
38
  - "array"
39
39
  - "hash"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0] - 2023-12-02
4
+
5
+ ### Changes (BREAKING! ⚠️)
6
+
7
+ - [#92](https://github.com/simonneutert/papierkram_api_client/pull/92) changes how updating a company person works. [@simonneutert](https://github.com/simonneutert)
8
+
9
+ ### Added
10
+
11
+ - [#90](https://github.com/simonneutert/papierkram_api_client/pull/90) crud ops for time_entries. [@simonneutert](https://github.com/simonneutert)
12
+ - [#89](https://github.com/simonneutert/papierkram_api_client/pull/89) CRUD for tracker tasks. [@simonneutert](https://github.com/simonneutert)
13
+ - [#88](https://github.com/simonneutert/papierkram_api_client/pull/88) Adds Income::PaymentTerm endpoints. [@simonneutert](https://github.com/simonneutert)
14
+
3
15
  ## [0.3.1] - 2023-10-05
4
16
 
5
17
  ### Updated
data/Gemfile CHANGED
@@ -8,9 +8,9 @@ gemspec
8
8
  gem 'minitest', '~> 5.17'
9
9
  gem 'minitest-vcr', '~> 1.4'
10
10
  gem 'pry', '~> 0.14.2'
11
- gem 'rake', '~> 13.0'
12
- gem 'rubocop', '~> 1.56', require: false
13
- gem 'rubocop-minitest', '~> 0.32.2', require: false
11
+ gem 'rake', '~> 13.1'
12
+ gem 'rubocop', '~> 1.58', require: false
13
+ gem 'rubocop-minitest', '~> 0.33.0', require: false
14
14
  gem 'rubocop-performance', '~> 1.19', require: false
15
15
  gem 'rubocop-rake', '~> 0.6.0', require: false
16
16
  gem 'vcr', '~> 6.2'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- papierkram_api_client (0.3.1)
4
+ papierkram_api_client (0.4.0)
5
5
  faraday (~> 2.7)
6
- httpx (>= 0.22.5, < 0.25.0)
6
+ httpx (>= 0.22.5, < 1.2.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -11,20 +11,20 @@ GEM
11
11
  addressable (2.8.5)
12
12
  public_suffix (>= 2.0.2, < 6.0)
13
13
  ast (2.4.2)
14
- base64 (0.1.1)
14
+ base64 (0.2.0)
15
15
  coderay (1.1.3)
16
16
  crack (0.4.5)
17
17
  rexml
18
- faraday (2.7.11)
18
+ faraday (2.7.12)
19
19
  base64
20
20
  faraday-net_http (>= 2.0, < 3.1)
21
21
  ruby2_keywords (>= 0.0.4)
22
22
  faraday-net_http (3.0.2)
23
23
  hashdiff (1.0.1)
24
- http-2-next (0.5.1)
25
- httpx (0.24.6)
26
- http-2-next (>= 0.4.1)
27
- json (2.6.3)
24
+ http-2-next (1.0.1)
25
+ httpx (1.1.5)
26
+ http-2-next (>= 1.0.1)
27
+ json (2.7.0)
28
28
  language_server-protocol (3.17.0.3)
29
29
  method_source (1.0.0)
30
30
  minispec-metadata (2.0.0)
@@ -35,33 +35,32 @@ GEM
35
35
  minitest (>= 4.7.5)
36
36
  vcr (>= 2.9)
37
37
  parallel (1.23.0)
38
- parser (3.2.2.3)
38
+ parser (3.2.2.4)
39
39
  ast (~> 2.4.1)
40
40
  racc
41
41
  pry (0.14.2)
42
42
  coderay (~> 1.1)
43
43
  method_source (~> 1.0)
44
44
  public_suffix (5.0.3)
45
- racc (1.7.1)
45
+ racc (1.7.3)
46
46
  rainbow (3.1.1)
47
- rake (13.0.6)
48
- regexp_parser (2.8.1)
47
+ rake (13.1.0)
48
+ regexp_parser (2.8.2)
49
49
  rexml (3.2.6)
50
- rubocop (1.56.4)
51
- base64 (~> 0.1.1)
50
+ rubocop (1.58.0)
52
51
  json (~> 2.3)
53
52
  language_server-protocol (>= 3.17.0)
54
53
  parallel (~> 1.10)
55
- parser (>= 3.2.2.3)
54
+ parser (>= 3.2.2.4)
56
55
  rainbow (>= 2.2.2, < 4.0)
57
56
  regexp_parser (>= 1.8, < 3.0)
58
57
  rexml (>= 3.2.5, < 4.0)
59
- rubocop-ast (>= 1.28.1, < 2.0)
58
+ rubocop-ast (>= 1.30.0, < 2.0)
60
59
  ruby-progressbar (~> 1.7)
61
60
  unicode-display_width (>= 2.4.0, < 3.0)
62
- rubocop-ast (1.29.0)
61
+ rubocop-ast (1.30.0)
63
62
  parser (>= 3.2.1.0)
64
- rubocop-minitest (0.32.2)
63
+ rubocop-minitest (0.33.0)
65
64
  rubocop (>= 1.39, < 2.0)
66
65
  rubocop-performance (1.19.1)
67
66
  rubocop (>= 1.7.0, < 2.0)
@@ -87,13 +86,13 @@ DEPENDENCIES
87
86
  minitest-vcr (~> 1.4)
88
87
  papierkram_api_client!
89
88
  pry (~> 0.14.2)
90
- rake (~> 13.0)
91
- rubocop (~> 1.56)
92
- rubocop-minitest (~> 0.32.2)
89
+ rake (~> 13.1)
90
+ rubocop (~> 1.58)
91
+ rubocop-minitest (~> 0.33.0)
93
92
  rubocop-performance (~> 1.19)
94
93
  rubocop-rake (~> 0.6.0)
95
94
  vcr (~> 6.2)
96
95
  webmock (~> 3.19)
97
96
 
98
97
  BUNDLED WITH
99
- 2.4.19
98
+ 2.4.20
data/README.md CHANGED
@@ -37,6 +37,7 @@ Schau bitte dort um alle Rückgabefelder/-werte zu checken, bis ich (oder du mit
37
37
  - [x] Expense::Voucher (Ausgabe Belege)
38
38
  - [x] Income::Estimate (Angebote)
39
39
  - [x] Income::Invoice (Rechnungen)
40
+ - [x] Income::PaymentTerms (Zahlungsbedingungen)
40
41
  - [x] Income::Proposition (Waren / Dienstleistungen)
41
42
  - [x] Info
42
43
  - [x] Project (Projekte)
@@ -90,6 +91,9 @@ Ziele:
90
91
  - [alle Rechnungen](#alle-rechnungen)
91
92
  - [eine Rechnung](#eine-rechnung)
92
93
  - [eine Rechnung als PDF](#eine-rechnung-als-pdf)
94
+ - [Income::PaymentTerms (Zahlungsbedingungen)](#incomepaymentterms-zahlungsbedingungen)
95
+ - [eine Zahlungsbedingung](#eine-zahlungsbedingung)
96
+ - [alle Zahlungsbedingungen](#alle-zahlungsbedingungen)
93
97
  - [Income::Proposition (Waren / Dienstleistungen)](#incomeproposition-waren--dienstleistungen)
94
98
  - [alle Waren / Dienstleistungen](#alle-waren--dienstleistungen)
95
99
  - [eine Ware / Dienstleistung](#eine-ware--dienstleistung)
@@ -110,9 +114,19 @@ Ziele:
110
114
  - [Tracker::Task (Aufgabe)](#trackertask-aufgabe)
111
115
  - [alle Aufgaben](#alle-aufgaben)
112
116
  - [eine Aufgabe](#eine-aufgabe)
117
+ - [erstelle eine Aufgabe](#erstelle-eine-aufgabe)
118
+ - [aktualisiere eine Aufgabe](#aktualisiere-eine-aufgabe)
119
+ - [lösche eine Aufgabe](#lösche-eine-aufgabe)
120
+ - [archiviere eine Aufgabe](#archiviere-eine-aufgabe)
121
+ - [unarchiviere eine Aufgabe](#unarchiviere-eine-aufgabe)
113
122
  - [Tracker::TimeEntry (Zeiteintrag)](#trackertimeentry-zeiteintrag)
114
123
  - [alle Zeiteinträge](#alle-zeiteinträge)
115
124
  - [einen Zeiteintrag](#einen-zeiteintrag)
125
+ - [erstelle einen Zeiteintrag](#erstelle-einen-zeiteintrag)
126
+ - [aktualisiere einen Zeiteintrag](#aktualisiere-einen-zeiteintrag)
127
+ - [lösche einen Zeiteintrag](#lösche-einen-zeiteintrag)
128
+ - [archiviere einen Zeiteintrag](#archiviere-einen-zeiteintrag)
129
+ - [unarchiviere einen Zeiteintrag](#unarchiviere-einen-zeiteintrag)
116
130
  - [Verbleibendes Quota](#verbleibendes-quota)
117
131
  - [Business Intelligence](#business-intelligence)
118
132
  - [Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)](#businessintelligence-bi-expensebycategory-ausgaben-nach-kategorie)
@@ -325,8 +339,10 @@ Siehe [Companies#create_customer](lib/papierkram_api/v1/endpoints/contact/compan
325
339
  #### aktualisiere ein Unternehmen
326
340
 
327
341
  ```ruby
328
- company = client.contact_companies
329
- .update_by(id: 1, attributes: { name: 'Test GmbH' })
342
+ company = client.contact_companies.update_by(
343
+ id: 1,
344
+ name: 'Test GmbH'
345
+ )
330
346
  puts company.headers
331
347
  puts company.body
332
348
  ```
@@ -381,11 +397,9 @@ puts company.body
381
397
 
382
398
  ```ruby
383
399
  company = client.contact_companies_persons.create(
384
- company_id: 1,
385
- attributes: {
386
- first_name: 'Max',
387
- last_name: 'Mustermann'
388
- }
400
+ company_id: 1,
401
+ first_name: 'Max',
402
+ last_name: 'Mustermann'
389
403
  )
390
404
  puts company.headers
391
405
  puts company.body
@@ -396,8 +410,11 @@ Siehe [CompaniesPersons#create](lib/papierkram_api/v1/endpoints/contact/companie
396
410
  #### aktualisiere eine Kontaktperson (eines Unternehmens)
397
411
 
398
412
  ```ruby
399
- company = client.contact_companies_persons
400
- .update_by(company_id: 1, id: 1, attributes: { first_name: 'Moritz' })
413
+ company = client.contact_companies_persons.update_by(
414
+ id: 1,
415
+ company_id: 1,
416
+ first_name: 'Moritz'
417
+ )
401
418
  puts company.headers
402
419
  puts company.body
403
420
  ```
@@ -502,6 +519,28 @@ puts PapierkramApi::V1::Helpers::PdfFromResponse.new(invoice).to_pdf
502
519
  # => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
503
520
  ```
504
521
 
522
+ ### Income::PaymentTerms (Zahlungsbedingungen)
523
+
524
+ Der Endpunkt `/papierkram_api/v1/endpoints/income/payment_terms` liefert Informationen über die Zahlungsbedingungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
525
+
526
+ #### eine Zahlungsbedingung
527
+
528
+ ```ruby
529
+ payment_term = client.income_payment_terms.find_by(id: 1)
530
+ puts payment_term.headers
531
+ puts payment_term.body
532
+ ```
533
+
534
+ #### alle Zahlungsbedingungen
535
+
536
+ Siehe [PaymentTerms](lib/papierkram_api/v1/endpoints/income/payment_terms.rb) für mögliche Parameter.
537
+
538
+ ```ruby
539
+ payment_terms = client.income_payment_terms.all
540
+ puts payment_terms.headers
541
+ puts payment_terms.body
542
+ ```
543
+
505
544
  ### Income::Proposition (Waren / Dienstleistungen)
506
545
 
507
546
  Der Endpunkt `/papierkram_api/v1/endpoints/income/propositions` liefert Informationen über die Waren / Dienstleistungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
@@ -547,10 +586,8 @@ Siehe [Propositions#create](lib/papierkram_api/v1/endpoints/income/propositions.
547
586
  ```ruby
548
587
  client.income_propositions.update_by(
549
588
  id: 1,
550
- attributes: {
551
- name: 'Software design',
552
- vat_rate: '19%' # verpflichtend bei Änderung
553
- }
589
+ name: 'Software design',
590
+ vat_rate: '19%' # verpflichtend bei Änderung
554
591
  )
555
592
  ```
556
593
 
@@ -621,7 +658,10 @@ Siehe [Projects](lib/papierkram_api/v1/endpoints/projects.rb) für mögliche Par
621
658
  #### aktualisiere ein Projekt
622
659
 
623
660
  ```ruby
624
- project = client.projects.update_by(id: 1, attributes: { name: 'Projekt 2' })
661
+ project = client.projects.update_by(
662
+ id: 1,
663
+ name: 'Projekt 2'
664
+ )
625
665
  puts project.headers
626
666
  puts project.body
627
667
  ```
@@ -674,6 +714,50 @@ puts task.headers
674
714
  puts task.body
675
715
  ```
676
716
 
717
+ #### erstelle eine Aufgabe
718
+
719
+ siehe [Tasks#create](lib/papierkram_api/v1/endpoints/tracker/tasks.rb) für mögliche Parameter.
720
+
721
+ ```ruby
722
+ task = client.tracker_tasks.create(name: 'Aufgabe 1')
723
+ puts task.headers
724
+ puts task.body
725
+ ```
726
+
727
+ #### aktualisiere eine Aufgabe
728
+
729
+ siehe [Tasks#update_by](lib/papierkram_api/v1/endpoints/tracker/tasks.rb) für mögliche Parameter.
730
+
731
+ ```ruby
732
+ task = client.tracker_tasks.update_by(id: 1, name: 'Aufgabe 2' )
733
+ puts task.headers
734
+ puts task.body
735
+ ```
736
+
737
+ #### lösche eine Aufgabe
738
+
739
+ ```ruby
740
+ task = client.tracker_tasks.delete_by(id: 1)
741
+ puts task.headers
742
+ puts task.body
743
+ ```
744
+
745
+ #### archiviere eine Aufgabe
746
+
747
+ ```ruby
748
+ task = client.tracker_tasks.archive_by(id: 1)
749
+ puts task.headers
750
+ puts task.body
751
+ ```
752
+
753
+ #### unarchiviere eine Aufgabe
754
+
755
+ ```ruby
756
+ task = client.tracker_tasks.unarchive_by(id: 1)
757
+ puts task.headers
758
+ puts task.body
759
+ ```
760
+
677
761
  ### Tracker::TimeEntry (Zeiteintrag)
678
762
 
679
763
  Der Endpunkt `/papierkram_api/v1/tracker/time_entries` liefert Informationen über die Zeiteinträge. Die Informationen werden als `Faraday::Response` zurückgegeben.
@@ -682,6 +766,8 @@ Der Endpunkt `/papierkram_api/v1/tracker/time_entries` liefert Informationen üb
682
766
 
683
767
  #### alle Zeiteinträge
684
768
 
769
+ siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
770
+
685
771
  ```ruby
686
772
  time_entries = client.tracker_time_entries.all
687
773
  puts time_entries.headers
@@ -696,6 +782,58 @@ puts time_entry.headers
696
782
  puts time_entry.body
697
783
  ```
698
784
 
785
+ #### erstelle einen Zeiteintrag
786
+
787
+ siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
788
+
789
+ ```ruby
790
+ time_entry = client.tracker_time_entries.create(
791
+ task_id: 1,
792
+ date: '2020-01-01',
793
+ duration: 60,
794
+ description: 'Test'
795
+ )
796
+ puts time_entry.headers
797
+ puts time_entry.body
798
+ ```
799
+
800
+ #### aktualisiere einen Zeiteintrag
801
+
802
+ siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
803
+
804
+ ```ruby
805
+ time_entry = client.tracker_time_entries.update_by(
806
+ id: 1,
807
+ comments: 'Test'
808
+ )
809
+ puts time_entry.headers
810
+ puts time_entry.body
811
+ ```
812
+
813
+ #### lösche einen Zeiteintrag
814
+
815
+ ```ruby
816
+ time_entry = client.tracker_time_entries.delete_by(id: 1)
817
+ puts time_entry.headers
818
+ puts time_entry.body
819
+ ```
820
+
821
+ #### archiviere einen Zeiteintrag
822
+
823
+ ```ruby
824
+ time_entry = client.tracker_time_entries.archive_by(id: 1)
825
+ puts time_entry.headers
826
+ puts time_entry.body
827
+ ```
828
+
829
+ #### unarchiviere einen Zeiteintrag
830
+
831
+ ```ruby
832
+ time_entry = client.tracker_time_entries.unarchive_by(id: 1)
833
+ puts time_entry.headers
834
+ puts time_entry.body
835
+ ```
836
+
699
837
  ### Verbleibendes Quota
700
838
 
701
839
  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.
data/UPGRADING.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## From 0.3 to 0.4
2
+
3
+ Some endpoints are calling `update` have changed. Instead of `update_by(id: 123, attributes: { ... })` you now use keywords e.g. `update_by(id: 123, name: 'New name')`.
4
+
5
+ Please check the [CHANGELOG](CHANGELOG.md) for more details.
6
+
7
+ - Income::Propositions
8
+ - Projects
9
+ - Contact::Companies
10
+
1
11
  ## From 0.2 to 0.3
2
12
 
3
13
  Finding specific records has changed. Instead of `by(id: 123)` you now use `find_by(id: 123)`.
@@ -70,6 +70,11 @@ module PapierkramApi
70
70
  PapierkramApi::V1::Endpoints::Income::Invoices.new(@client)
71
71
  end
72
72
 
73
+ def income_payment_terms
74
+ @income_payment_terms ||=
75
+ PapierkramApi::V1::Endpoints::Income::PaymentTerms.new(@client)
76
+ end
77
+
73
78
  def income_propositions
74
79
  @income_propositions ||=
75
80
  PapierkramApi::V1::Endpoints::Income::Propositions.new(@client)
@@ -134,11 +134,62 @@ module PapierkramApi
134
134
  http_post("#{@url_api_path}/contact/companies", body)
135
135
  end
136
136
 
137
- def update_by(id:, attributes: {})
137
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/ParameterLists
138
+ id:,
139
+ name: nil,
140
+ contact_type: nil,
141
+ phone: nil,
142
+ fax: nil,
143
+ email: nil,
144
+ website: nil,
145
+ twitter: nil,
146
+ ust_idnr: nil,
147
+ delivery_method: nil,
148
+ postal_street: nil,
149
+ postal_zip: nil,
150
+ postal_city: nil,
151
+ postal_country: nil,
152
+ physical_street: nil,
153
+ physical_zip: nil,
154
+ physical_city: nil,
155
+ physical_country: nil,
156
+ bank_account_no: nil,
157
+ bank_blz: nil,
158
+ bank_institute: nil,
159
+ bank_bic: nil,
160
+ bank_iban: nil,
161
+ notes: nil,
162
+ color: nil
163
+ )
138
164
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
139
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
140
165
 
141
- http_put("#{@url_api_path}/contact/companies/#{id}", attributes)
166
+ body = {}
167
+ body[:name] = name if name
168
+ body[:contact_type] = contact_type if contact_type
169
+ body[:phone] = phone if phone
170
+ body[:fax] = fax if fax
171
+ body[:email] = email if email
172
+ body[:website] = website if website
173
+ body[:twitter] = twitter if twitter
174
+ body[:ust_idnr] = ust_idnr if ust_idnr
175
+ body[:delivery_method] = delivery_method if delivery_method
176
+ body[:postal_street] = postal_street if postal_street
177
+ body[:postal_zip] = postal_zip if postal_zip
178
+ body[:postal_city] = postal_city if postal_city
179
+ body[:postal_country] = postal_country if postal_country
180
+ body[:physical_street] = physical_street if physical_street
181
+ body[:physical_zip] = physical_zip if physical_zip
182
+ body[:physical_city] = physical_city if physical_city
183
+ body[:physical_country] = physical_country if physical_country
184
+ body[:bank_account_no] = bank_account_no if bank_account_no
185
+ body[:bank_blz] = bank_blz if bank_blz
186
+ body[:bank_institute] = bank_institute if bank_institute
187
+ body[:bank_bic] = bank_bic if bank_bic
188
+ body[:bank_iban] = bank_iban if bank_iban
189
+ body[:notes] = notes if notes
190
+ body[:color] = color if color
191
+
192
+ http_put("#{@url_api_path}/contact/companies/#{id}", body)
142
193
  end
143
194
 
144
195
  def delete_by(id:)
@@ -54,12 +54,44 @@ module PapierkramApi
54
54
  http_post("#{@url_api_path}/contact/companies/#{company_id}/persons", body)
55
55
  end
56
56
 
57
- def update_by(company_id:, id:, attributes: {})
58
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
57
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength
58
+ id:,
59
+ company_id:,
60
+ title: nil,
61
+ salutation: nil,
62
+ first_name: nil,
63
+ last_name: nil,
64
+ position: nil,
65
+ department: nil,
66
+ phone: nil,
67
+ skype: nil,
68
+ fax: nil,
69
+ email: nil,
70
+ flagged: nil,
71
+ mobile: nil,
72
+ comment: nil,
73
+ default: nil
74
+ )
59
75
  raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer)
60
76
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
61
77
 
62
- http_put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", attributes)
78
+ body = {}
79
+ body[:title] = title if title
80
+ body[:salutation] = salutation if salutation
81
+ body[:first_name] = first_name if first_name
82
+ body[:last_name] = last_name if last_name
83
+ body[:position] = position if position
84
+ body[:department] = department if department
85
+ body[:phone] = phone if phone
86
+ body[:skype] = skype if skype
87
+ body[:fax] = fax if fax
88
+ body[:email] = email if email
89
+ body[:flagged] = flagged if flagged
90
+ body[:mobile] = mobile if mobile
91
+ body[:comment] = comment if comment
92
+ body[:default] = default if default
93
+
94
+ http_put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", body)
63
95
  end
64
96
 
65
97
  def delete_by(company_id:, id:)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PapierkramApi
4
+ module V1
5
+ module Endpoints
6
+ module Income
7
+ # This class is responsible for all the API calls related to income propositions.
8
+ class PaymentTerms < PapierkramApi::V1::Endpoints::Base
9
+ def find_by(id:)
10
+ http_get("#{@url_api_path}/income/payment_terms/#{id}")
11
+ end
12
+
13
+ def all(page: 1,
14
+ page_size: 100,
15
+ order_by: nil,
16
+ order_direction: nil)
17
+ query = {
18
+ page: page,
19
+ page_size: page_size
20
+ }
21
+ query[:order_by] = order_by if order_by
22
+ query[:order_direction] = order_direction if order_direction
23
+
24
+ http_get("#{@url_api_path}/income/payment_terms", query)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -36,12 +36,27 @@ module PapierkramApi
36
36
  http_post("#{@url_api_path}/income/propositions", body)
37
37
  end
38
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
39
+ def update_by( # rubocop:disable Metrics/CyclomaticComplexity
40
+ id:,
41
+ name: nil,
42
+ description: nil,
43
+ article_no: nil,
44
+ price: nil,
45
+ proposition_type: nil,
46
+ time_unit: nil,
47
+ vat_rate: nil
48
+ )
49
+
50
+ body = {}
51
+ body[:name] = name if name
52
+ body[:description] = description if description
53
+ body[:article_no] = article_no if article_no
54
+ body[:price] = price if price
55
+ body[:proposition_type] = proposition_type if proposition_type
56
+ body[:time_unit] = time_unit if time_unit
57
+ body[:vat_rate] = vat_rate if vat_rate
43
58
 
44
- http_put("#{@url_api_path}/income/propositions/#{id}", attributes)
59
+ http_put("#{@url_api_path}/income/propositions/#{id}", body)
45
60
  end
46
61
 
47
62
  def delete_by(id:)
@@ -55,10 +55,39 @@ module PapierkramApi
55
55
  http_post("#{@url_api_path}/projects", body)
56
56
  end
57
57
 
58
- def update_by(id:, attributes: {})
59
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
58
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists
59
+ id:,
60
+ name: nil,
61
+ customer_id: nil,
62
+ description: nil,
63
+ start_date: nil,
64
+ end_date: nil,
65
+ flagged: nil,
66
+ budget_type: nil,
67
+ budget_money: nil,
68
+ budget_time: nil,
69
+ budget_time_unit: nil,
70
+ color: nil,
71
+ default_proposition: nil,
72
+ team_members: nil
73
+ )
74
+
75
+ body = {}
76
+ body[:name] = name if name
77
+ body[:customer] = { id: customer_id } if customer_id
78
+ body[:description] = description if description
79
+ body[:start_date] = start_date if start_date
80
+ body[:end_date] = end_date if end_date
81
+ body[:flagged] = flagged if flagged
82
+ body[:budget_type] = budget_type if budget_type
83
+ body[:budget_money] = budget_money if budget_money
84
+ body[:budget_time] = budget_time if budget_time
85
+ body[:budget_time_unit] = budget_time_unit if budget_time_unit
86
+ body[:color] = color if color
87
+ body[:default_proposition] = default_proposition if default_proposition
88
+ body[:team_members] = team_members if team_members
60
89
 
61
- http_put("#{@url_api_path}/projects/#{id}", attributes)
90
+ http_put("#{@url_api_path}/projects/#{id}", body)
62
91
  end
63
92
 
64
93
  def delete_by(id:)
@@ -26,6 +26,69 @@ module PapierkramApi
26
26
  query[:proposition_id] = proposition_id if proposition_id
27
27
  http_get("#{@url_api_path}/tracker/tasks", query)
28
28
  end
29
+
30
+ def create(
31
+ name:,
32
+ project_id:,
33
+ proposition_id: nil,
34
+ deadline: nil,
35
+ relative_costs: nil,
36
+ complete: nil,
37
+ flagged: nil,
38
+ user_id: nil
39
+ )
40
+ body = {}
41
+ body[:name] = name
42
+ body[:project] = { id: project_id }
43
+ body[:proposition] = { id: proposition_id } if proposition_id
44
+ body[:deadline] = deadline if deadline
45
+ body[:relative_costs] = relative_costs if relative_costs
46
+ body[:complete] = complete if complete
47
+ body[:flagged] = flagged if flagged
48
+ body[:user] = { id: user_id } if user_id
49
+
50
+ http_post("#{@url_api_path}/tracker/tasks", body)
51
+ end
52
+
53
+ def update_by( # rubocop:disable Metrics/ParameterLists
54
+ id:,
55
+ name:,
56
+ project_id:,
57
+ proposition_id: nil,
58
+ deadline: nil,
59
+ relative_costs: nil,
60
+ complete: nil,
61
+ flagged: nil,
62
+ user_id: nil
63
+ )
64
+ body = {}
65
+ body[:name] = name
66
+ body[:project] = { id: project_id }
67
+ body[:proposition] = { id: proposition_id } if proposition_id
68
+ body[:deadline] = deadline if deadline
69
+ body[:relative_costs] = relative_costs if relative_costs
70
+ body[:complete] = complete if complete
71
+ body[:flagged] = flagged if flagged
72
+ body[:user] = { id: user_id } if user_id
73
+
74
+ http_put("#{@url_api_path}/tracker/tasks/#{id}", body)
75
+ end
76
+
77
+ def delete_by(id:)
78
+ http_delete("#{@url_api_path}/tracker/tasks/#{id}")
79
+ end
80
+
81
+ def archive_by(id:)
82
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
83
+
84
+ http_post("#{@url_api_path}/tracker/tasks/#{id}/archive")
85
+ end
86
+
87
+ def unarchive_by(id:)
88
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
89
+
90
+ http_post("#{@url_api_path}/tracker/tasks/#{id}/unarchive")
91
+ end
29
92
  end
30
93
  end
31
94
  end
@@ -42,6 +42,65 @@ module PapierkramApi
42
42
  http_get("#{@url_api_path}/tracker/time_entries", query)
43
43
  end
44
44
 
45
+ def create(
46
+ entry_date:,
47
+ started_at_time:,
48
+ ended_at_time:,
49
+ task_id:,
50
+ user_id:,
51
+ comments: nil,
52
+ billable_duration: nil,
53
+ unbillable: nil
54
+ )
55
+ body = {}
56
+ body[:entry_date] = entry_date
57
+ body[:started_at_time] = started_at_time
58
+ body[:ended_at_time] = ended_at_time
59
+ body[:task] = { id: task_id }
60
+ body[:user] = { id: user_id }
61
+ body[:comments] = comments if comments
62
+ body[:billable_duration] = billable_duration if billable_duration
63
+ body[:unbillable] = unbillable if unbillable
64
+
65
+ http_post("#{@url_api_path}/tracker/time_entries", body)
66
+ end
67
+
68
+ def update_by( # rubocop:disable Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
69
+ id:,
70
+ entry_date: nil,
71
+ started_at_time: nil,
72
+ ended_at_time: nil,
73
+ task_id: nil,
74
+ user_id: nil,
75
+ comments: nil,
76
+ billable_duration: nil,
77
+ unbillable: nil
78
+ )
79
+ body = {}
80
+ body[:entry_date] = entry_date if entry_date
81
+ body[:started_at_time] = started_at_time if started_at_time
82
+ body[:ended_at_time] = ended_at_time if ended_at_time
83
+ body[:task] = { id: task_id } if task_id
84
+ body[:user] = { id: user_id } if user_id
85
+ body[:comments] = comments if comments
86
+ body[:billable_duration] = billable_duration if billable_duration
87
+ body[:unbillable] = unbillable if unbillable
88
+
89
+ http_put("#{@url_api_path}/tracker/time_entries/#{id}", body)
90
+ end
91
+
92
+ def delete_by(id:)
93
+ http_delete("#{@url_api_path}/tracker/time_entries/#{id}")
94
+ end
95
+
96
+ def archive_by(id:)
97
+ http_post("#{@url_api_path}/tracker/time_entries/#{id}/archive")
98
+ end
99
+
100
+ def unarchive_by(id:)
101
+ http_post("#{@url_api_path}/tracker/time_entries/#{id}/unarchive")
102
+ end
103
+
45
104
  private
46
105
 
47
106
  def validate!(billing_state:, start_time_range_start:, start_time_range_end:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PapierkramApiClient
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -17,6 +17,7 @@ require_relative 'papierkram_api/v1/endpoints/contact/companies_persons'
17
17
  require_relative 'papierkram_api/v1/endpoints/expense/vouchers'
18
18
  require_relative 'papierkram_api/v1/endpoints/income/estimates'
19
19
  require_relative 'papierkram_api/v1/endpoints/income/invoices'
20
+ require_relative 'papierkram_api/v1/endpoints/income/payment_terms'
20
21
  require_relative 'papierkram_api/v1/endpoints/income/propositions'
21
22
  require_relative 'papierkram_api/v1/endpoints/info'
22
23
  require_relative 'papierkram_api/v1/endpoints/projects'
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.3.1
4
+ version: 0.4.0
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-10-05 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.22.5
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 0.25.0
36
+ version: 1.2.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.22.5
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.25.0
46
+ version: 1.2.0
47
47
  description: Papierkram API Client, um deine Buchhaltung auf das nächste Level zu
48
48
  bringen.
49
49
  email:
@@ -76,6 +76,7 @@ files:
76
76
  - lib/papierkram_api/v1/endpoints/expense/vouchers.rb
77
77
  - lib/papierkram_api/v1/endpoints/income/estimates.rb
78
78
  - lib/papierkram_api/v1/endpoints/income/invoices.rb
79
+ - lib/papierkram_api/v1/endpoints/income/payment_terms.rb
79
80
  - lib/papierkram_api/v1/endpoints/income/propositions.rb
80
81
  - lib/papierkram_api/v1/endpoints/info.rb
81
82
  - lib/papierkram_api/v1/endpoints/projects.rb