Class: PayrollHero::Api::V4::Employees

Inherits:
BaseGroup
  • Object
show all
Defined in:
lib/payroll_hero/api/v4/employees.rb

Overview

Employees Endpoint

Instance Attribute Summary

Attributes inherited from BaseGroup

#client

Instance Method Summary collapse

Methods inherited from BaseGroup

#initialize

Constructor Details

This class inherits a constructor from PayrollHero::Api::BaseGroup

Instance Method Details

#convert_leaves(id, attributes) ⇒ Object

Final Pay Feature: Convert all applicable leaves to work time only,except,include and paging params don’t apply here as it’s a write call expected attributes: { leaves: [ { name: ‘Vacation’, number_of_days: 28.0 },…] }



63
64
65
# File 'lib/payroll_hero/api/v4/employees.rb', line 63

def convert_leaves(id, attributes)
  client.put "/api/v4/employees/#{id}/convert_leaves", attributes
end

#get(id, only: nil, except: nil, include: nil, **params) ⇒ Hashie::Mash

implements the interface to get a single Employee record

Parameters:

  • id (Fixnum|String)
  • only (Array|Symbol) (defaults to: nil)
    • Attribute names to be included on the response

  • except (Array|Symbol) (defaults to: nil)
    • Attribute names to be excluded on the response

  • include (Array|Symbol) (defaults to: nil)
    • Association names to be included in the response

Returns:

  • (Hashie::Mash)


33
34
35
# File 'lib/payroll_hero/api/v4/employees.rb', line 33

def get(id, only: nil, except: nil, include: nil, **params)
  fetch id, only: only, except: except, include: include, **params
end

#list(only: [], except: [], include: [], page: nil, per_page: nil, **params) ⇒ Hashie::Mash

Implements the interface to get a list of accessible employees.

Parameters:

  • only (Array|Symbol) (defaults to: [])
    • Attribute names to be included on the response

  • except (Array|Symbol) (defaults to: [])
    • Attribute names to be excluded on the response

  • include (Array|Symbol) (defaults to: [])
    • Association names to be included in the response

Returns:

  • (Hashie::Mash)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/payroll_hero/api/v4/employees.rb', line 12

def list(only: [], except: [], include: [], page: nil, per_page: nil, **params)
  combined_params = params.merge(
    remove_empty_values_from!(
      only: Array(only),
      except: Array(except),
      include: Array(include),
      page: page,
      per_page: per_page
    )
  )

  client.get "/api/v4/employees", combined_params
end

#subordinates(id, only: [], except: [], include: [], page: nil, per_page: nil, **params) ⇒ Hashie::Mash

Implements the interface to get a list of the API token owner’s subordinates

Parameters:

  • id (Fixnum|String)
  • only (Array|Symbol) (defaults to: [])
    • Attribute names to be included on the response

  • except (Array|Symbol) (defaults to: [])
    • Attribute names to be excluded on the response

  • include (Array|Symbol) (defaults to: [])
    • Association names to be included in the response

Returns:

  • (Hashie::Mash)


44
45
46
# File 'lib/payroll_hero/api/v4/employees.rb', line 44

def subordinates(id, only: [], except: [], include: [], page: nil, per_page: nil, **params)
  fetch "#{id}/subordinates", only: only, except: except, include: include, page: page, per_page: per_page, **params
end

#superiors(id, only: [], except: [], include: [], page: nil, per_page: nil, **params) ⇒ Hashie::Mash

Implements the interface to get a list of the API token owner’s superiors

Parameters:

  • id (Fixnum|String)
  • only (Array|Symbol) (defaults to: [])
    • Attribute names to be included on the response

  • except (Array|Symbol) (defaults to: [])
    • Attribute names to be excluded on the response

  • include (Array|Symbol) (defaults to: [])
    • Association names to be included in the response

Returns:

  • (Hashie::Mash)


55
56
57
# File 'lib/payroll_hero/api/v4/employees.rb', line 55

def superiors(id, only: [], except: [], include: [], page: nil, per_page: nil, **params)
  fetch"#{id}/superiors", only: only, except: except, include: include, page: page, per_page: per_page, **params
end