Class: PapierkramApi::V1::Endpoints::Contact::Companies

Inherits:
Base
  • Object
show all
Defined in:
lib/papierkram_api/v1/endpoints/contact/companies.rb

Overview

This class is responsible for all the API calls related to banking bank connections.

Instance Attribute Summary

Attributes inherited from Base

#client, #url_api_path

Instance Method Summary collapse

Methods inherited from Base

#http_delete, #http_get, #http_patch, #http_post, #http_put, #initialize, #remaining_quota

Constructor Details

This class inherits a constructor from PapierkramApi::V1::Endpoints::Base

Instance Method Details

#all(page: 1, page_size: 100, order_by: nil, order_direction: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 13

def all(page: 1,
        page_size: 100,
        order_by: nil,
        order_direction: nil)
  query = {
    page: page,
    page_size: page_size
  }
  query[:order_by] = order_by if order_by
  query[:order_direction] = order_direction if order_direction

  http_get("#{@url_api_path}/contact/companies", query)
end

#archive_by(id:) ⇒ Object

Raises:

  • (ArgumentError)


199
200
201
202
203
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 199

def archive_by(id:)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  http_post("#{@url_api_path}/contact/companies/#{id}/archive")
end

#create_customer(name:, phone: nil, fax: nil, email: nil, delivery_method: nil, ust_idnr: nil, website: nil, twitter: nil, postal_street: nil, postal_city: nil, postal_zip: nil, postal_country: nil, physical_street: nil, physical_city: nil, physical_zip: nil, physical_country: nil, bank_blz: nil, bank_institute: nil, bank_account_no: nil, bank_bic: nil, bank_iban: nil, notes: nil, color: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 81

def create_customer( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  name:,
  phone: nil,
  fax: nil,
  email: nil,
  delivery_method: nil,
  ust_idnr: nil,
  website: nil,
  twitter: nil,
  postal_street: nil,
  postal_city: nil,
  postal_zip: nil,
  postal_country: nil,
  physical_street: nil,
  physical_city: nil,
  physical_zip: nil,
  physical_country: nil,
  bank_blz: nil,
  bank_institute: nil,
  bank_account_no: nil,
  bank_bic: nil,
  bank_iban: nil,
  notes: nil,
  color: nil
)
  body = {}
  body[:contact_type] = 'customer'
  body[:name] = name
  body[:phone] = phone if phone
  body[:fax] = fax if fax
  body[:email] = email if email
  body[:delivery_method] = delivery_method if delivery_method
  body[:ust_idnr] = ust_idnr if ust_idnr
  body[:website] = website if website
  body[:twitter] = twitter if twitter
  body[:postal_street] = postal_street if postal_street
  body[:postal_city] = postal_city if postal_city
  body[:postal_zip] = postal_zip if postal_zip
  body[:postal_country] = postal_country if postal_country
  body[:physical_street] = physical_street if physical_street
  body[:physical_city] = physical_city if physical_city
  body[:physical_zip] = physical_zip if physical_zip
  body[:physical_country] = physical_country if physical_country
  body[:bank_blz] = bank_blz if bank_blz
  body[:bank_institute] = bank_institute if bank_institute
  body[:bank_account_no] =  if 
  body[:bank_bic] = bank_bic if bank_bic
  body[:bank_iban] = bank_iban if bank_iban
  body[:notes] = notes if notes
  body[:color] = color if color

  http_post("#{@url_api_path}/contact/companies", body)
end

#create_supplier(name:, phone: nil, fax: nil, email: nil, delivery_method: nil, ust_idnr: nil, website: nil, twitter: nil, postal_street: nil, postal_city: nil, postal_zip: nil, postal_country: nil, physical_street: nil, physical_city: nil, physical_zip: nil, physical_country: nil, bank_blz: nil, bank_institute: nil, bank_account_no: nil, bank_bic: nil, bank_iban: nil, notes: nil, color: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 27

def create_supplier( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  name:,
  phone: nil,
  fax: nil,
  email: nil,
  delivery_method: nil,
  ust_idnr: nil,
  website: nil,
  twitter: nil,
  postal_street: nil,
  postal_city: nil,
  postal_zip: nil,
  postal_country: nil,
  physical_street: nil,
  physical_city: nil,
  physical_zip: nil,
  physical_country: nil,
  bank_blz: nil,
  bank_institute: nil,
  bank_account_no: nil,
  bank_bic: nil,
  bank_iban: nil,
  notes: nil,
  color: nil
)
  body = {}
  body[:contact_type] = 'supplier'
  body[:name] = name
  body[:phone] = phone if phone
  body[:fax] = fax if fax
  body[:email] = email if email
  body[:delivery_method] = delivery_method if delivery_method
  body[:ust_idnr] = ust_idnr if ust_idnr
  body[:website] = website if website
  body[:twitter] = twitter if twitter
  body[:postal_street] = postal_street if postal_street
  body[:postal_city] = postal_city if postal_city
  body[:postal_zip] = postal_zip if postal_zip
  body[:postal_country] = postal_country if postal_country
  body[:physical_street] = physical_street if physical_street
  body[:physical_city] = physical_city if physical_city
  body[:physical_zip] = physical_zip if physical_zip
  body[:physical_country] = physical_country if physical_country
  body[:bank_blz] = bank_blz if bank_blz
  body[:bank_institute] = bank_institute if bank_institute
  body[:bank_account_no] =  if 
  body[:bank_bic] = bank_bic if bank_bic
  body[:bank_iban] = bank_iban if bank_iban
  body[:notes] = notes if notes
  body[:color] = color if color

  http_post("#{@url_api_path}/contact/companies", body)
end

#delete_by(id:) ⇒ Object

Raises:

  • (ArgumentError)


193
194
195
196
197
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 193

def delete_by(id:)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  http_delete("#{@url_api_path}/contact/companies/#{id}")
end

#find_by(id:) ⇒ Object



9
10
11
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 9

def find_by(id:)
  http_get("#{@url_api_path}/contact/companies/#{id}")
end

#unarchive_by(id:) ⇒ Object

Raises:

  • (ArgumentError)


205
206
207
208
209
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 205

def unarchive_by(id:)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  http_post("#{@url_api_path}/contact/companies/#{id}/unarchive")
end

#update_by(id:, name: nil, contact_type: nil, phone: nil, fax: nil, email: nil, website: nil, twitter: nil, ust_idnr: nil, delivery_method: nil, postal_street: nil, postal_zip: nil, postal_city: nil, postal_country: nil, physical_street: nil, physical_zip: nil, physical_city: nil, physical_country: nil, bank_account_no: nil, bank_blz: nil, bank_institute: nil, bank_bic: nil, bank_iban: nil, notes: nil, color: nil) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/ParameterLists

Raises:

  • (ArgumentError)


135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/papierkram_api/v1/endpoints/contact/companies.rb', line 135

def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/ParameterLists
  id:,
  name: nil,
  contact_type: nil,
  phone: nil,
  fax: nil,
  email: nil,
  website: nil,
  twitter: nil,
  ust_idnr: nil,
  delivery_method: nil,
  postal_street: nil,
  postal_zip: nil,
  postal_city: nil,
  postal_country: nil,
  physical_street: nil,
  physical_zip: nil,
  physical_city: nil,
  physical_country: nil,
  bank_account_no: nil,
  bank_blz: nil,
  bank_institute: nil,
  bank_bic: nil,
  bank_iban: nil,
  notes: nil,
  color: nil
)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  body = {}
  body[:name] = name if name
  body[:contact_type] = contact_type if contact_type
  body[:phone] = phone if phone
  body[:fax] = fax if fax
  body[:email] = email if email
  body[:website] = website if website
  body[:twitter] = twitter if twitter
  body[:ust_idnr] = ust_idnr if ust_idnr
  body[:delivery_method] = delivery_method if delivery_method
  body[:postal_street] = postal_street if postal_street
  body[:postal_zip] = postal_zip if postal_zip
  body[:postal_city] = postal_city if postal_city
  body[:postal_country] = postal_country if postal_country
  body[:physical_street] = physical_street if physical_street
  body[:physical_zip] = physical_zip if physical_zip
  body[:physical_city] = physical_city if physical_city
  body[:physical_country] = physical_country if physical_country
  body[:bank_account_no] =  if 
  body[:bank_blz] = bank_blz if bank_blz
  body[:bank_institute] = bank_institute if bank_institute
  body[:bank_bic] = bank_bic if bank_bic
  body[:bank_iban] = bank_iban if bank_iban
  body[:notes] = notes if notes
  body[:color] = color if color

  http_put("#{@url_api_path}/contact/companies/#{id}", body)
end