Class: Gusto::Employees::GarnishmentsClient

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::GarnishmentsClient

Parameters:



24
25
26
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 24

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientGusto::RequestClient (readonly)



19
20
21
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 19

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

)



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 120

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)
  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

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

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



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 158

def get(garnishment_id:, request_options: nil)
  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

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

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 48

def list(employee_id:, page: nil, per: nil, request_options: nil)
  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

#list_child_support(request_options: nil) ⇒ Object

api.employees.garnishments.list_child_support



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 259

def list_child_support(request_options: nil)
  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

#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

)



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/fern_gusto/employees/garnishments/client.rb', line 227

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)
  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