Class: Gusto::Companies::AsyncBenefitsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::AsyncBenefitsClient
- 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::AsyncBenefitsClient 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::AsyncBenefitsClient
440 441 442 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 440 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::AsyncRequestClient (readonly)
435 436 437 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 435 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”)
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 513 def create(company_id:, benefit_type: nil, active: nil, description:, responsible_for_employer_taxes: nil, responsible_for_employee_w2: nil, request_options: nil) Async do 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 end |
#delete(company_benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.delete(company_benefit_id: “company_benefit_id”)
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 643 def delete(company_benefit_id:, request_options: nil) Async do 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 end |
#get(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get(benefit_id: “benefit_id”)
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 552 def get(benefit_id:, request_options: nil) Async do 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 end |
#get_requirements(benefit_id:, request_options: nil) ⇒ Object
api.companies.benefits.get_requirements(benefit_id: “benefit_id”)
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 836 def get_requirements(benefit_id:, request_options: nil) Async do 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 end |
#get_summary(company_benefit_id:, start_date: nil, end_date: nil, detailed: nil, request_options: nil) ⇒ Object
)
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 689 def get_summary(company_benefit_id:, start_date: nil, end_date: nil, detailed: nil, request_options: nil) Async do 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 end |
#list(request_options: nil) ⇒ Object
api.companies.benefits.list
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 459 def list(request_options: nil) Async do 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 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”)
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 731 def list_employee_benefits(company_benefit_id:, page: nil, per: nil, request_options: nil) Async do 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 end |
#update(company_benefit_id:, version:, active: nil, description: nil, request_options: nil) ⇒ Object
)
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 605 def update(company_benefit_id:, version:, active: nil, description: nil, request_options: nil) Async do 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 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” }])
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
# File 'lib/fern_gusto/companies/benefits/client.rb', line 797 def update_employee_benefits(company_benefit_id:, employee_benefits: nil, request_options: nil) Async do 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 end |