Class: Agendrix::Nethris::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/agendrix/nethris/client.rb

Defined Under Namespace

Modules: Vendor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vendor:, session_id: nil, user_code: nil, password: nil, business_code: nil) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/agendrix/nethris/client.rb', line 14

def initialize(vendor:, session_id: nil, user_code: nil, password: nil, business_code: nil)
  unless vendor.in?([Vendor::NETHRIS, Vendor::EMPLOYER_D])
    raise TypeError, "Vendor must be one of :#{Vendor::NETHRIS} or :#{Vendor::EMPLOYER_D}"
  end

  @vendor = vendor
  @session = Services::SessionService.new(
    vendor: @vendor,
    id: session_id,
    business_code: business_code,
    user_code: user_code,
    password: password
  )
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



9
10
11
# File 'lib/agendrix/nethris/client.rb', line 9

def session
  @session
end

#vendorObject (readonly)

Returns the value of attribute vendor.



9
10
11
# File 'lib/agendrix/nethris/client.rb', line 9

def vendor
  @vendor
end

Instance Method Details

#employeesObject



29
30
31
# File 'lib/agendrix/nethris/client.rb', line 29

def employees
  @employees ||= Services::EmployeeService.new(self)
end

#send_request(**args) ⇒ Object



33
34
35
# File 'lib/agendrix/nethris/client.rb', line 33

def send_request(**args)
  Request.new(@vendor, @session.id).execute(**args)
end