Class: Gusto::Employees::AsyncGarnishmentsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/employees/garnishments/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Gusto::Employees::AsyncGarnishmentsClient

Parameters:



289
290
291
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 289

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientGusto::AsyncRequestClient (readonly)



284
285
286
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 284

def request_client
  @request_client
end

Instance Method Details

#create(employee_id:, active: nil, amount:, description: nil, court_ordered:, garnishment_type: nil, times: nil, recurring: nil, annual_maximum: nil, pay_period_maximum: nil, deduct_as_percentage: nil, total_amount: nil, child_support: nil, request_options: nil) ⇒ Object

)



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 387

def create(employee_id:, active: nil, amount:, description: nil, court_ordered:, garnishment_type: nil, times: nil, recurring: nil, annual_maximum: nil, pay_period_maximum: nil, deduct_as_percentage: nil, total_amount: nil, child_support: nil, request_options: nil)
  Async do
    response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
    req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
    req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
    req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
    req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), active: active, amount: amount, description: description, court_ordered: court_ordered, garnishment_type: garnishment_type, times: times, recurring: recurring, annual_maximum: annual_maximum, pay_period_maximum: pay_period_maximum, deduct_as_percentage: deduct_as_percentage, total_amount: total_amount, child_support: child_support }.compact
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/employees/#{employee_id}/garnishments"
end
    Gusto::Garnishment.from_json(json_object: response.body)
  end
end

#get(garnishment_id:, request_options: nil) ⇒ Object

api.employees.garnishments.get(garnishment_id: “garnishment_id”)



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 427

def get(garnishment_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
    req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
    req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
    req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
    req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
    req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/garnishments/#{garnishment_id}"
end
    Gusto::Garnishment.from_json(json_object: response.body)
  end
end

#list(employee_id:, page: nil, per: nil, request_options: nil) ⇒ Object

api.employees.garnishments.list(employee_id: “employee_id”)



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 313

def list(employee_id:, page: nil, per: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
    req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
    req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
    req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  req.params = { **(request_options&.additional_query_parameters || {}), "page": page, "per": per }.compact
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
    req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/employees/#{employee_id}/garnishments"
end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do | item |
      item = item.to_json
      Gusto::Garnishment.from_json(json_object: item)
    end
  end
end

#list_child_support(request_options: nil) ⇒ Object

api.employees.garnishments.list_child_support



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 532

def list_child_support(request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
    req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
    req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
    req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
    req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
    req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/garnishments/child_support"
end
    Gusto::ChildSupportData.from_json(json_object: response.body)
  end
end

#update(garnishment_id:, active: nil, amount: nil, description: nil, court_ordered: nil, times: nil, recurring: nil, annual_maximum: nil, pay_period_maximum: nil, deduct_as_percentage: nil, total_amount: nil, child_support: nil, version:, request_options: nil) ⇒ Object

)



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 498

def update(garnishment_id:, active: nil, amount: nil, description: nil, court_ordered: nil, times: nil, recurring: nil, annual_maximum: nil, pay_period_maximum: nil, deduct_as_percentage: nil, total_amount: nil, child_support: nil, version:, request_options: nil)
  Async do
    response = @request_client.conn.put do | req |
  unless request_options&.timeout_in_seconds.nil?
    req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
    req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
    req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
    req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), active: active, amount: amount, description: description, court_ordered: court_ordered, times: times, recurring: recurring, annual_maximum: annual_maximum, pay_period_maximum: pay_period_maximum, deduct_as_percentage: deduct_as_percentage, total_amount: total_amount, child_support: child_support, version: version }.compact
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/garnishments/#{garnishment_id}"
end
    Gusto::Garnishment.from_json(json_object: response.body)
  end
end