Module: SmartHR::Client::DepartmentMethods

Included in:
SmartHR::Client
Defined in:
lib/smarthr/client/department_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_department(body:) {|response_body, response_header| ... } ⇒ Hashie::Mash

Create a new department

Parameters:

  • body (Hash)

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-Rate-Limit-Limit, X-Rate-Limit-Reset, X-Rate-Limit-Remaining)

Returns:

  • (Hashie::Mash)

See Also:



81
82
83
# File 'lib/smarthr/client/department_methods.rb', line 81

def create_department(body:, &block)
  post("/departments", body, &block)
end

#destroy_department(id:) {|response_body, response_header| ... } ⇒ Object

Delete the department

Parameters:

  • id (String)

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-Rate-Limit-Limit, X-Rate-Limit-Reset, X-Rate-Limit-Remaining)

See Also:



11
12
13
# File 'lib/smarthr/client/department_methods.rb', line 11

def destroy_department(id:, &block)
  delete("/departments/#{id}", &block)
end

#find_department(id:) {|response_body, response_header| ... } ⇒ Hashie::Mash

Get the department

Parameters:

  • id (String)

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-Rate-Limit-Limit, X-Rate-Limit-Reset, X-Rate-Limit-Remaining)

Returns:

  • (Hashie::Mash)

See Also:



26
27
28
# File 'lib/smarthr/client/department_methods.rb', line 26

def find_department(id:, &block)
  get("/departments/#{id}", &block)
end

#get_departments(page: 1, per_page: 10, code: nil, sort: nil) {|response_body, response_header| ... } ⇒ Array<Hashie::Mash>

Get the list of departments

Parameters:

  • page (Integer) (defaults to: 1)
  • per_page (Integer) (defaults to: 10)
  • code (String) (defaults to: nil)
  • sort (String) (defaults to: nil)

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Array<Hashie::Mash>)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-Rate-Limit-Limit, X-Rate-Limit-Reset, X-Rate-Limit-Remaining)

Returns:

  • (Array<Hashie::Mash>)

See Also:



60
61
62
63
64
65
66
67
68
# File 'lib/smarthr/client/department_methods.rb', line 60

def get_departments(page: 1, per_page: 10, code: nil, sort: nil, &block)
  get("/departments",
    page: page,
    per_page: per_page,
    code: code,
    sort: sort,
    &block
  )
end

#update_department(id:, body:) {|response_body, response_header| ... } ⇒ Hashie::Mash

Change the data of the specified department

Parameters:

  • id (String)
  • body (Hash)

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-Rate-Limit-Limit, X-Rate-Limit-Reset, X-Rate-Limit-Remaining)

Returns:

  • (Hashie::Mash)

See Also:



42
43
44
# File 'lib/smarthr/client/department_methods.rb', line 42

def update_department(id:, body:, &block)
  patch("/departments/#{id}", body, &block)
end