Class: Gusto::Companies::BenefitsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::BenefitsClient
- Defined in:
- lib/fern_gusto/companies/benefits/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_id:, benefit_type: nil, active: nil, description:, responsible_for_employer_taxes: nil, responsible_for_employee_w2: nil, request_options: nil) ⇒ Object
api.companies.benefits.create(company_id: “company_id”, description: “description”).
-
#delete(company_benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.delete(company_benefit_id: “company_benefit_id”).
-
#get(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get(benefit_id: “benefit_id”).
-
#get_requirements(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get_requirements(benefit_id: “benefit_id”).
-
#get_summary(company_benefit_id:, start_date: nil, end_date: nil, detailed: nil, request_options: nil) ⇒ Object
).
- #initialize(request_client:) ⇒ Gusto::Companies::BenefitsClient constructor
-
#list(request_options: nil) ⇒ Object
api.companies.benefits.list.
-
#list_employee_benefits(company_benefit_id:, page: nil, per: nil, request_options: nil) ⇒ Object
api.companies.benefits.list_employee_benefits(company_benefit_id: “company_benefit_id”).
-
#update(company_benefit_id:, version:, active: nil, description: nil, request_options: nil) ⇒ Object
).
-
#update_employee_benefits(company_benefit_id:, employee_benefits: nil, request_options: nil) ⇒ Object
api.companies.benefits.update_employee_benefits(company_benefit_id: “company_benefit_id”, employee_benefits: [{ version: “09j3d29jqdpj92109j9j2d90dq”, active: true, employee_deduction: “250.00”, employee_uuid: “8f9f3f68-8fd3-499d-ade7-4a052e56494e” }]).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::BenefitsClient
30 31 32 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 30 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
25 26 27 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 25 def request_client @request_client end |
Instance Method Details
#create(company_id:, benefit_type: nil, active: nil, description:, responsible_for_employer_taxes: nil, responsible_for_employee_w2: nil, request_options: nil) ⇒ Object
api.companies.benefits.create(company_id: “company_id”, description: “description”)
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 101 def create(company_id:, benefit_type: nil, active: nil, description:, responsible_for_employer_taxes: nil, responsible_for_employee_w2: nil, request_options: nil) response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), benefit_type: benefit_type, active: active, description: description, responsible_for_employer_taxes: responsible_for_employer_taxes, responsible_for_employee_w2: responsible_for_employee_w2 }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/company_benefits" end Gusto::CompanyBenefit.from_json(json_object: response.body) end |
#delete(company_benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.delete(company_benefit_id: “company_benefit_id”)
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 225 def delete(company_benefit_id:, request_options: nil) response = @request_client.conn.delete do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/company_benefits/#{company_benefit_id}" end end |
#get(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get(benefit_id: “benefit_id”)
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 138 def get(benefit_id:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/benefits/#{benefit_id}" end Gusto::SupportedBenefit.from_json(json_object: response.body) end |
#get_requirements(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get_requirements(benefit_id: “benefit_id”)
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 410 def get_requirements(benefit_id:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/benefits/#{benefit_id}/requirements" end Gusto::CompanyBenefits::BenefitTypeRequirements.from_json(json_object: response.body) end |
#get_summary(company_benefit_id:, start_date: nil, end_date: nil, detailed: nil, request_options: nil) ⇒ Object
)
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 269 def get_summary(company_benefit_id:, start_date: nil, end_date: nil, detailed: nil, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "start_date": start_date, "end_date": end_date, "detailed": detailed }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/company_benefits/#{company_benefit_id}/summary" end Gusto::CompanyBenefits::BenefitSummary.from_json(json_object: response.body) end |
#list(request_options: nil) ⇒ Object
api.companies.benefits.list
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 49 def list(request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/benefits" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::SupportedBenefit.from_json(json_object: item) end end |
#list_employee_benefits(company_benefit_id:, page: nil, per: nil, request_options: nil) ⇒ Object
api.companies.benefits.list_employee_benefits(company_benefit_id: “company_benefit_id”)
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 309 def list_employee_benefits(company_benefit_id:, page: nil, per: nil, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "page": page, "per": per }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/company_benefits/#{company_benefit_id}/employee_benefits" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::EmployeeBenefit.from_json(json_object: item) end end |
#update(company_benefit_id:, version:, active: nil, description: nil, request_options: nil) ⇒ Object
)
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 189 def update(company_benefit_id:, version:, active: nil, description: nil, request_options: nil) response = @request_client.conn.put do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), version: version, active: active, description: description }.compact req.url "#{@request_client.get_url(request_options: )}/v1/company_benefits/#{company_benefit_id}" end Gusto::CompanyBenefit.from_json(json_object: response.body) end |
#update_employee_benefits(company_benefit_id:, employee_benefits: nil, request_options: nil) ⇒ Object
api.companies.benefits.update_employee_benefits(company_benefit_id: “company_benefit_id”, employee_benefits: [{ version: “09j3d29jqdpj92109j9j2d90dq”, active: true, employee_deduction: “250.00”, employee_uuid: “8f9f3f68-8fd3-499d-ade7-4a052e56494e” }])
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 373 def update_employee_benefits(company_benefit_id:, employee_benefits: nil, request_options: nil) response = @request_client.conn.put do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), employee_benefits: employee_benefits }.compact req.url "#{@request_client.get_url(request_options: )}/v1/company_benefits/#{company_benefit_id}/employee_benefits" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::EmployeeBenefit.from_json(json_object: item) end end |