Class: Unleashed::CompanyResource

Inherits:
BaseResource show all
Defined in:
lib/unleashed/resources/company_resource.rb

Overview

The Companies resource allows Companies to be listed. An individual Company details can be viewed by appending its identifier (a GUID formatted as XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to the URI. Here are some example URIs: /Companies - returns a list of Company related information.

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from Unleashed::BaseResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Unleashed::BaseResource

Instance Method Details

#allArray<Unleashed::Company>

Lists all information for your company /Companies - returns a list of Company related information.

Returns:



17
18
19
20
21
22
# File 'lib/unleashed/resources/company_resource.rb', line 17

def all
  endpoint = 'Companies'
  response = JSON.parse(@client.get(endpoint).body)
  companies = response.key?('Items') ? response['Items'] : []
  companies.map { |attributes| Unleashed::Company.new(@client, attributes) }
end

#firstUnleashed::Company

Get a first company in all

Returns:



27
28
29
# File 'lib/unleashed/resources/company_resource.rb', line 27

def first
  all.first
end

#lastUnleashed::Company

Get a last company in all

Returns:



34
35
36
# File 'lib/unleashed/resources/company_resource.rb', line 34

def last
  all.last
end

#modelObject



9
10
11
# File 'lib/unleashed/resources/company_resource.rb', line 9

def model
  Unleashed::Company
end