Module: Companies

Included in:
CRM
Defined in:
lib/user/crm/companies.rb

Instance Method Summary collapse

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, options = nil)
  @client.raw('post', '/crm/companies/', options, 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

options = { fields: 'id, title', sort: '-id' }
@data = @cxf_user.get_companies(options)

Third Example

options = { fields: 'id, title', sort: '-id' }
@data = @cxf_user.get_companies(options, false)


35
36
37
# File 'lib/user/crm/companies.rb', line 35

def get_companies(options = nil, use_post = true)
  get_query_results('/crm/companies', options, use_post)
end

#get_companies_support_dataObject

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

options = { fields: 'id, title' }
@data = @cxf_user.get_company(21, options)


52
53
54
# File 'lib/user/crm/companies.rb', line 52

def get_company(id, options = nil)
  @client.raw('get', "/crm/companies/#{id}", options)
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, options = nil)
  @client.raw('put', "/crm/companies/#{id}", options, data_transform(data))
end