Class: Gusto::Companies::AsyncLocationsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::AsyncLocationsClient
- Defined in:
- lib/fern_gusto/companies/locations/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
).
-
#get(location_id:, request_options: nil) ⇒ Object
api.companies.locations.get(location_id: “location_id”).
-
#get_minimum_wages(location_uuid:, effective_date: nil, request_options: nil) ⇒ Object
api.companies.locations.get_minimum_wages(location_uuid: “location_uuid”, effective_date: “2020-01-31”).
- #initialize(request_client:) ⇒ Gusto::Companies::AsyncLocationsClient constructor
-
#update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::AsyncLocationsClient
218 219 220 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 218 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::AsyncRequestClient (readonly)
213 214 215 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 213 def request_client @request_client end |
Instance Method Details
#create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
)
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 293 def create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: 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 || {}), phone_number: phone_number, street_1: street1, street_2: street2, city: city, state: state, zip: zip, country: country, mailing_address: mailing_address, filing_address: filing_address }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/locations" end Gusto::Locations::Location.from_json(json_object: response.body) end end |
#get(location_id:, request_options: nil) ⇒ Object
api.companies.locations.get(location_id: “location_id”)
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 234 def get(location_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/locations/#{location_id}" end Gusto::Locations::Location.from_json(json_object: response.body) end end |
#get_minimum_wages(location_uuid:, effective_date: nil, request_options: nil) ⇒ Object
api.companies.locations.get_minimum_wages(location_uuid: “location_uuid”, effective_date: “2020-01-31”)
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 389 def get_minimum_wages(location_uuid:, effective_date: 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 || {}), "effective_date": effective_date }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/locations/#{location_uuid}/minimum_wages" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::MinimumWage.from_json(json_object: item) end end end |
#update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
)
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 353 def update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: 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, phone_number: phone_number, street_1: street1, street_2: street2, city: city, state: state, zip: zip, country: country, mailing_address: mailing_address, filing_address: filing_address }.compact req.url "#{@request_client.get_url(request_options: )}/v1/locations/#{location_id}" end Gusto::Locations::Location.from_json(json_object: response.body) end end |