Class: PapierkramApi::V1::Endpoints::Contact::CompaniesPersons
- Defined in:
- lib/papierkram_api/v1/endpoints/contact/companies_persons.rb
Overview
This class is responsible for all the API calls related to companies’ persons connections.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #all(company_id:, page: 1, page_size: 100, order_by: nil, order_direction: nil) ⇒ Object
-
#create(company_id:, first_name:, last_name:, title: nil, salutation: nil, position: nil, department: nil, email: nil, phone: nil, mobile: nil, fax: nil, skype: nil, comment: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #delete_by(company_id:, id:) ⇒ Object
- #find_by(company_id:, id:) ⇒ Object
-
#update_by(id:, company_id:, title: nil, salutation: nil, first_name: nil, last_name: nil, position: nil, department: nil, phone: nil, skype: nil, fax: nil, email: nil, flagged: nil, mobile: nil, comment: nil, default: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength.
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(company_id:, page: 1, page_size: 100, order_by: nil, order_direction: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/papierkram_api/v1/endpoints/contact/companies_persons.rb', line 13 def all(company_id:, page: 1, page_size: 100, order_by: nil, order_direction: nil) query = { company_id: company_id, 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/#{company_id}/persons", query) end |
#create(company_id:, first_name:, last_name:, title: nil, salutation: nil, position: nil, department: nil, email: nil, phone: nil, mobile: nil, fax: nil, skype: nil, comment: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25 26 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 |
# File 'lib/papierkram_api/v1/endpoints/contact/companies_persons.rb', line 25 def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity company_id:, first_name:, last_name:, title: nil, salutation: nil, position: nil, department: nil, email: nil, phone: nil, mobile: nil, fax: nil, skype: nil, comment: nil ) body = {} body[:first_name] = first_name body[:last_name] = last_name body[:title] = title if title body[:salutation] = salutation if salutation body[:position] = position if position body[:department] = department if department body[:email] = email if email body[:phone] = phone if phone body[:mobile] = mobile if mobile body[:fax] = fax if fax body[:skype] = skype if skype body[:comment] = comment if comment http_post("#{@url_api_path}/contact/companies/#{company_id}/persons", body) end |
#delete_by(company_id:, id:) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/papierkram_api/v1/endpoints/contact/companies_persons.rb', line 97 def delete_by(company_id:, id:) raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer) raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer) http_delete("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}") end |
#find_by(company_id:, id:) ⇒ Object
9 10 11 |
# File 'lib/papierkram_api/v1/endpoints/contact/companies_persons.rb', line 9 def find_by(company_id:, id:) http_get("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}") end |
#update_by(id:, company_id:, title: nil, salutation: nil, first_name: nil, last_name: nil, position: nil, department: nil, phone: nil, skype: nil, fax: nil, email: nil, flagged: nil, mobile: nil, comment: nil, default: nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/papierkram_api/v1/endpoints/contact/companies_persons.rb', line 57 def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength id:, company_id:, title: nil, salutation: nil, first_name: nil, last_name: nil, position: nil, department: nil, phone: nil, skype: nil, fax: nil, email: nil, flagged: nil, mobile: nil, comment: nil, default: nil ) raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer) raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer) body = {} body[:title] = title if title body[:salutation] = salutation if salutation body[:first_name] = first_name if first_name body[:last_name] = last_name if last_name body[:position] = position if position body[:department] = department if department body[:phone] = phone if phone body[:skype] = skype if skype body[:fax] = fax if fax body[:email] = email if email body[:flagged] = flagged if flagged body[:mobile] = mobile if mobile body[:comment] = comment if comment body[:default] = default if default http_put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", body) end |