Class: GustoApi::Company

Inherits:
Object
  • Object
show all
Defined in:
lib/gusto_api/company.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, access_token) ⇒ Company

Returns a new instance of Company.



13
14
15
16
# File 'lib/gusto_api/company.rb', line 13

def initialize(id, access_token)
  self.id = id
  self.access_token = access_token
end

Class Method Details

.create(user:, company:) ⇒ Object

Raises:



3
4
5
6
7
8
9
10
11
# File 'lib/gusto_api/company.rb', line 3

def self.create(user:, company:)
  raise Error.new("Missing a required attribute") unless user[:first_name] && user[:last_name] && user[:email] && company[:name]

  TokenRequest.new(
    endpoint: 'v1/provision',
    method: :post,
    params: { user: user, company: company }
  ).submit
end

Instance Method Details

#employees(include_terminated: false) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/gusto_api/company.rb', line 18

def employees(include_terminated: false)
  params = include_terminated ? {} : { terminated: false }
  BearerRequest.new(
    endpoint: "v1/companies/#{id}/employees",
    method: :get,
    params: params,
    auth_token: access_token
  ).submit
end