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

#get(id, only: nil, except: nil, include: nil) ⇒ 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)


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

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

#list(only: [], except: [], include: [], page: nil, per_page: nil) ⇒ 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
# File 'lib/payroll_hero/api/v4/employees.rb', line 12

def list(only: [], except: [], include: [], page: nil, per_page: nil)
  params = {
    only: Array(only),
    except: Array(except),
    include: Array(include),
    page: page,
    per_page: per_page,
  }

  remove_empty_values_from!(params)
  client.get("/api/v4/employees", params)
end

#subordinates(id, only: [], except: [], include: [], page: nil, per_page: nil) ⇒ 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)


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

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

#superiors(id, only: [], except: [], include: [], page: nil, per_page: nil) ⇒ 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)


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

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