Class: Gusto::Payroll::ExternalPayrollsClient
- Inherits:
-
Object
- Object
- Gusto::Payroll::ExternalPayrollsClient
- Defined in:
- lib/fern_gusto/payroll/external_payrolls/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_uuid:, check_date:, payment_period_start_date:, payment_period_end_date:, request_options: nil) ⇒ Object
).
-
#get(company_uuid:, request_options: nil) ⇒ Object
api.payroll.external_payrolls.get(company_uuid: “company_uuid”).
- #initialize(request_client:) ⇒ Gusto::Payroll::ExternalPayrollsClient constructor
Constructor Details
#initialize(request_client:) ⇒ Gusto::Payroll::ExternalPayrollsClient
19 20 21 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 19 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
14 15 16 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 14 def request_client @request_client end |
Instance Method Details
#create(company_uuid:, check_date:, payment_period_start_date:, payment_period_end_date:, request_options: nil) ⇒ Object
)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 82 def create(company_uuid:, check_date:, payment_period_start_date:, payment_period_end_date:, 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 || {}), check_date: check_date, payment_period_start_date: payment_period_start_date, payment_period_end_date: payment_period_end_date }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_uuid}/external_payrolls" end Gusto::ExternalPayrolls::ExternalPayroll.from_json(json_object: response.body) end |
#get(company_uuid:, request_options: nil) ⇒ Object
api.payroll.external_payrolls.get(company_uuid: “company_uuid”)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 35 def get(company_uuid:, 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/companies/#{company_uuid}/external_payrolls" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::ExternalPayrolls::ExternalPayrollBasic.from_json(json_object: item) end end |