papierkram_api_client 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1a03790a5079d46fc57b6efa84682046fbfd4f4e916e68fd9e4132863dc07c3
4
- data.tar.gz: b6edd7e886bcaf9a9f761fec07494c2f6e292f77b946e0fc2f2ee33b8228d60e
3
+ metadata.gz: 149edeeed9ee09d36a1c017a9a831eb00dcf347c507d89b37c498bef24ff87f6
4
+ data.tar.gz: 48e326b8fc0c92af833e8e928daba56ca0b8f9d28e3d2490af07ffad5cf317de
5
5
  SHA512:
6
- metadata.gz: 299c6bcf0f35da94d1e1e6298f2aee5cc70b4eaddc3abe2e36fd051a3286290f9182f87331debc8c79f4ddca429f4fbb14aa4a95c0276fa857177165ab7ac36f
7
- data.tar.gz: df625c5ce0e31b68b4ebcbd80e681d58674396843c43f5631544891b6e8eeeef1e788d19b38930e3cd4555755444b5e7430ebee7610df2550d22225d136df2b5
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,11 @@
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
+
3
9
  [0.2.3] - 2023-06-29
4
10
 
5
11
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- papierkram_api_client (0.2.3)
4
+ papierkram_api_client (0.2.4)
5
5
  faraday (~> 2.7)
6
6
  httpx (>= 0.22.5, < 0.25.0)
7
7
 
@@ -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
@@ -22,7 +22,7 @@ module PapierkramApi
22
22
  get("#{@url_api_path}/contact/companies/#{company_id}/persons", query)
23
23
  end
24
24
 
25
- def create( # rubocop:disable Metrics/ParameterLists
25
+ def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
26
26
  company_id:,
27
27
  first_name:,
28
28
  last_name:,
@@ -37,20 +37,19 @@ module PapierkramApi
37
37
  skype: nil,
38
38
  comment: nil
39
39
  )
40
- body = {
41
- first_name: first_name,
42
- last_name: last_name,
43
- title: title,
44
- salutation: salutation,
45
- position: position,
46
- department: department,
47
- email: email,
48
- phone: phone,
49
- mobile: mobile,
50
- fax: fax,
51
- skype: skype,
52
- comment: comment
53
- }
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
54
53
 
55
54
  post("#{@url_api_path}/contact/companies/#{company_id}/persons", body)
56
55
  end
@@ -21,24 +21,23 @@ module PapierkramApi
21
21
  time_unit: nil,
22
22
  proposition_type: nil,
23
23
  price: nil,
24
- vat_rate: ''
24
+ vat_rate: nil
25
25
  )
26
- body = {
27
- name: name,
28
- article_no: article_no,
29
- description: description,
30
- time_unit: time_unit,
31
- proposition_type: proposition_type,
32
- price: price,
33
- vat_rate: vat_rate
34
- }
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
+
35
36
  post("#{@url_api_path}/income/propositions", body)
36
37
  end
37
38
 
38
39
  def update_by(id:, attributes: {})
39
- attributes[:vat_rate] ||= attributes['vat_rate']
40
- attributes[:vat_rate] ||= ''
41
- if attributes[:vat_rate].empty? || !attributes[:vat_rate].include?('%')
40
+ if attributes[:vat_rate] && (attributes[:vat_rate].empty? || !attributes[:vat_rate].include?('%'))
42
41
  raise ArgumentError, 'vat_rate must be a percentage and include a % sign'
43
42
  end
44
43
 
@@ -21,7 +21,7 @@ module PapierkramApi
21
21
  get("#{@url_api_path}/projects", query)
22
22
  end
23
23
 
24
- def create( # rubocop:disable Metrics/ParameterLists
24
+ def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25
25
  name:,
26
26
  customer_id:,
27
27
  description: nil,
@@ -33,24 +33,24 @@ module PapierkramApi
33
33
  budget_time: nil,
34
34
  budget_time_unit: nil,
35
35
  color: nil,
36
- default_proposition: {},
37
- team_members: []
36
+ default_proposition: nil,
37
+ team_members: nil
38
38
  )
39
- body = {
40
- name: name,
41
- description: description,
42
- start_date: start_date,
43
- end_date: end_date,
44
- flagged: flagged,
45
- budget_type: budget_type,
46
- budget_money: budget_money,
47
- budget_time: budget_time,
48
- budget_time_unit: budget_time_unit,
49
- color: color,
50
- customer: { id: customer_id },
51
- default_proposition: default_proposition,
52
- team_members: team_members
53
- }
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
54
 
55
55
  post("#{@url_api_path}/projects", body)
56
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PapierkramApiClient
4
- VERSION = '0.2.3'
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.3
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-29 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