Class: Gusto::Payroll::AsyncExternalPayrollsClient
- Inherits:
-
Object
- Object
- Gusto::Payroll::AsyncExternalPayrollsClient
- 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::AsyncExternalPayrollsClient constructor
Constructor Details
#initialize(request_client:) ⇒ Gusto::Payroll::AsyncExternalPayrollsClient
110 111 112 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 110 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::AsyncRequestClient (readonly)
105 106 107 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 105 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
)
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 175 def create(company_uuid:, check_date:, payment_period_start_date:, payment_period_end_date:, 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 || {}), 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 end |
#get(company_uuid:, request_options: nil) ⇒ Object
api.payroll.external_payrolls.get(company_uuid: “company_uuid”)
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/fern_gusto/payroll/external_payrolls/client.rb', line 126 def get(company_uuid:, 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/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 end |