Module: Paychex::Client::Workers

Included in:
Paychex::Client
Defined in:
lib/paychex/client/workers.rb

Instance Method Summary collapse

Instance Method Details

#create_worker(company_id, options = {}) ⇒ Object

Create a worker



15
16
17
# File 'lib/paychex/client/workers.rb', line 15

def create_worker(company_id, options = {})
  post("companies/#{company_id}/workers", options)
end

#create_worker_contacts(worker_id, options = {}) ⇒ Object



19
20
21
# File 'lib/paychex/client/workers.rb', line 19

def create_worker_contacts(worker_id, options = {})
  post("workers/#{worker_id}/contacts", options)
end

#remove_worker(worker_id, options = {}) ⇒ Object



23
24
25
# File 'lib/paychex/client/workers.rb', line 23

def remove_worker(worker_id, options = {})
  delete("workers/#{worker_id}", options)
end

#worker(worker_id, options = {}) ⇒ Object

Get a specific worker’s profile



10
11
12
# File 'lib/paychex/client/workers.rb', line 10

def worker(worker_id, options = {})
  get("workers/#{worker_id}", options)
end

#worker_status(company_id, worker_id) ⇒ Object

Get company’s linked status



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/paychex/client/workers.rb', line 28

def worker_status(company_id, worker_id)
  begin
    content = workers(company_id).body.fetch('content')
    return 'valid' if content.one?{ |worker| worker.fetch('workerId') == worker_id }
  rescue Paychex::NoAccess => e
    return 'not-linked'
  rescue Paychex::NotFound => e
    return 'invalid'
  rescue StandardError => e
    p 'Paychex Gem: Handle more errors'
    p e
  end
  'unsupported'
end

#workers(company_id, options = {}) ⇒ Object

Get a list of the workers of the company



5
6
7
# File 'lib/paychex/client/workers.rb', line 5

def workers(company_id, options = {})
  get("companies/#{company_id}/workers", options)
end