Module: Companies
- Included in:
- CRM
- Defined in:
- lib/user/crm/companies.rb
Instance Method Summary collapse
-
#create_company(data, options = nil) ⇒ Object
Create company.
-
#delete_companies(data) ⇒ Object
Delete Companies.
-
#get_companies(options = nil, use_post = true) ⇒ Object
Get companies.
-
#get_companies_support_data ⇒ Object
Get companies support data.
-
#get_company(id, options = nil) ⇒ Object
Get company.
-
#update_company(id, data, options = nil) ⇒ Object
Update company.
Instance Method Details
#create_company(data, options = nil) ⇒ Object
Create company.
Create a company with data.
Parameters
- data
-
(Hash) – Data to be submitted.
Example
data = {
title: 'Company Title',
alias: 'Alias',
website: 'www.company.example.com',
street1: 'Company St',
city: 'Company City',
region: 'Company Region',
postal_code: '12345',
country_id: 144,
tax_identifier: nil
}
@data = @cxf_user.create_company(data)
75 76 77 |
# File 'lib/user/crm/companies.rb', line 75 def create_company(data, = nil) @client.raw('post', '/crm/companies/', , data_transform(data)) end |
#delete_companies(data) ⇒ Object
Delete Companies.
Delete a group of companies.
Parameters
- data
-
(Hash) – Data to be submitted.
Example
data = { ids: %w[21 22] }
@data = @cxf_user.delete_companies(data)
108 109 110 |
# File 'lib/user/crm/companies.rb', line 108 def delete_companies(data) @client.raw('delete', '/crm/companies/delete', nil, data_transform(data)) end |
#get_companies(options = nil, use_post = true) ⇒ Object
Get companies.
Get a collection of companies.
Parameters
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
- use_post
-
(Boolean) – Variable to determine if the request is by ‘post’ or ‘get’ functions.
First Example
@data = @cxf_user.get_companies
Second Example
= { fields: 'id, title', sort: '-id' }
@data = @cxf_user.get_companies()
Third Example
= { fields: 'id, title', sort: '-id' }
@data = @cxf_user.get_companies(, false)
35 36 37 |
# File 'lib/user/crm/companies.rb', line 35 def get_companies( = nil, use_post = true) get_query_results('/crm/companies', , use_post) end |
#get_companies_support_data ⇒ Object
Get companies support data.
Get support data of companies.
Example
@data = @cxf_user.get_companies_support_data
14 15 16 |
# File 'lib/user/crm/companies.rb', line 14 def get_companies_support_data @client.raw('get', '/crm/companies/support-data') end |
#get_company(id, options = nil) ⇒ Object
Get company.
Get a company info.
Parameters
- id
-
(Integer) – Company id.
- options
-
(Hash) – List of Resource Collection Options shown above can be used as parameter.
First Example
@data = @cxf_user.get_company(21)
Second Example
= { fields: 'id, title' }
@data = @cxf_user.get_company(21, )
52 53 54 |
# File 'lib/user/crm/companies.rb', line 52 def get_company(id, = nil) @client.raw('get', "/crm/companies/#{id}", ) end |
#update_company(id, data, options = nil) ⇒ Object
Update company.
Update a company info.
Parameters
- id
-
(Integer) – Company id.
- data
-
(Hash) – Data to be submitted.
Example
data = {
title: 'Company Title Modified'
}
@data = @cxf_user.update_company(23, data)
91 92 93 |
# File 'lib/user/crm/companies.rb', line 91 def update_company(id, data, = nil) @client.raw('put', "/crm/companies/#{id}", , data_transform(data)) end |