Class: GustoEmbedded::Companies
- Inherits:
-
Object
- Object
- GustoEmbedded::Companies
- Extended by:
- T::Sig
- Defined in:
- lib/gusto_embedded/companies.rb
Instance Method Summary collapse
- #accept_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
- #create_admin(company_id, request_body, x_gusto_api_version = nil) ⇒ Object
- #create_partner_managed(security, request_body, x_gusto_api_version = nil) ⇒ Object
- #finish_onboarding(company_uuid, x_gusto_api_version = nil) ⇒ Object
- #get(company_id, x_gusto_api_version = nil) ⇒ Object
- #get_custom_fields(company_id, page = nil, per = nil, x_gusto_api_version = nil) ⇒ Object
- #get_onboarding_status(company_uuid, additional_steps = nil, x_gusto_api_version = nil) ⇒ Object
-
#initialize(sdk_config) ⇒ Companies
constructor
A new instance of Companies.
- #list_admins(company_id, page = nil, per = nil, x_gusto_api_version = nil) ⇒ Object
- #migrate(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
- #retrieve_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
- #update(company_id, request_body, x_gusto_api_version = nil) ⇒ Object
Constructor Details
#initialize(sdk_config) ⇒ Companies
Returns a new instance of Companies.
17 18 19 |
# File 'lib/gusto_embedded/companies.rb', line 17 def initialize(sdk_config) @sdk_configuration = sdk_config end |
Instance Method Details
#accept_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/gusto_embedded/companies.rb', line 262 def accept_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) # accept_terms_of_service - Accept terms of service for a company user # Accept the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms). # The user must have a role in the company in order to accept the Terms of Service. # # scope: `terms_of_services:write` request = ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceRequest.new( company_uuid: company_uuid, request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceRequest, base_url, '/v1/partner_managed_companies/{company_uuid}/accept_terms_of_service', request ) headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceResponseBody) res.object = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#create_admin(company_id, request_body, x_gusto_api_version = nil) ⇒ Object
387 388 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 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/gusto_embedded/companies.rb', line 387 def create_admin(company_id, request_body, x_gusto_api_version = nil) # create_admin - Create an admin for the company # Creates a new admin for a company. # If the email matches an existing user, this will create an admin account for the current user. Otherwise, this will create a new user. # # scope: `company_admin:write` request = ::GustoEmbedded::Operations::PostV1CompaniesCompanyIdAdminsRequest.new( company_id: company_id, request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::PostV1CompaniesCompanyIdAdminsRequest, base_url, '/v1/companies/{company_id}/admins', request ) headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PostV1CompaniesCompanyIdAdminsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::Admin) res.admin = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#create_partner_managed(security, request_body, x_gusto_api_version = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gusto_embedded/companies.rb', line 23 def create_partner_managed(security, request_body, x_gusto_api_version = nil) # create_partner_managed - Create a partner managed company # Create a partner managed company. When you successfully call the API, it does the following: # * Creates a new company in Gusto # * Creates a new user using the provided email if the user does not already exist. # * Makes the user the primary payroll administrator of the new company. # # In response, you will receive oauth access tokens for the created company. # # IMPORTANT: the returned access and refresh tokens are reserved for this company only. They cannot be used to access other companies AND previously granted tokens cannot be used to access this company. # # > 📘 System Access Authentication # > # > this endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) request = ::GustoEmbedded::Operations::PostV1PartnerManagedCompaniesRequest.new( request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/v1/partner_managed_companies" headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PostV1PartnerManagedCompaniesResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Operations::PostV1PartnerManagedCompaniesResponseBody) res.object = out end elsif r.status == 401 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#finish_onboarding(company_uuid, x_gusto_api_version = nil) ⇒ Object
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/gusto_embedded/companies.rb', line 550 def finish_onboarding(company_uuid, x_gusto_api_version = nil) # finish_onboarding - Finish company onboarding # Finalize a given company's onboarding process. # # ### Approve a company in demo # After a company is finished onboarding, Gusto requires an additional step to review and approve that company. The company onboarding status is `"onboarding_completed": false`, until the API call is made to finish company onboarding. # In production environments, this step is required for risk-analysis purposes. # # We provide the endpoint `PUT '/v1/companies/{company_uuid}/approve'` to facilitate company approvals in the demo environment. # # ```shell # PUT '/v1/companies/89771af8-b964-472e-8064-554dfbcb56d9/approve' # # # Response: Company object, with company_status: 'Approved' # ``` # # scope: `companies:write` request = ::GustoEmbedded::Operations::GetV1CompanyFinishOnboardingRequest.new( company_uuid: company_uuid, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::GetV1CompanyFinishOnboardingRequest, base_url, '/v1/companies/{company_uuid}/finish_onboarding', request ) headers = Utils.get_headers(request) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.put(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::GetV1CompanyFinishOnboardingResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::CompanyOnboardingStatus) res.company_onboarding_status = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#get(company_id, x_gusto_api_version = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/gusto_embedded/companies.rb', line 87 def get(company_id, x_gusto_api_version = nil) # get - Get a company # Get a company. # The employees:read scope is required to return home_address and non-work locations. # The company_admin:read scope is required to return primary_payroll_admin. # The signatories:read scope is required to return primary_signatory. # # scope: `companies:read` request = ::GustoEmbedded::Operations::GetV1CompaniesRequest.new( company_id: company_id, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::GetV1CompaniesRequest, base_url, '/v1/companies/{company_id}', request ) headers = Utils.get_headers(request) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::GetV1CompaniesResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::Company) res.company = out end elsif r.status == 404 end res end |
#get_custom_fields(company_id, page = nil, per = nil, x_gusto_api_version = nil) ⇒ Object
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/gusto_embedded/companies.rb', line 613 def get_custom_fields(company_id, page = nil, per = nil, x_gusto_api_version = nil) # get_custom_fields - Get the custom fields of a company # Returns a list of the custom fields of the company. Useful when you need to know the schema of custom fields for an entire company # # scope: `companies:read` request = ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdCustomFieldsRequest.new( company_id: company_id, page: page, per: per, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdCustomFieldsRequest, base_url, '/v1/companies/{company_id}/custom_fields', request ) headers = Utils.get_headers(request) query_params = Utils.get_query_params(::GustoEmbedded::Operations::GetV1CompaniesCompanyIdCustomFieldsRequest, request) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdCustomFieldsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::CompanyCustomFieldList) res.company_custom_field_list = out end elsif r.status == 404 end res end |
#get_onboarding_status(company_uuid, additional_steps = nil, x_gusto_api_version = nil) ⇒ Object
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/gusto_embedded/companies.rb', line 500 def get_onboarding_status(company_uuid, additional_steps = nil, x_gusto_api_version = nil) # get_onboarding_status - Get the company's onboarding status # Get company's onboarding status. # The data returned helps inform the required onboarding steps and respective completion status. # # scope: `company_onboarding_status:read` request = ::GustoEmbedded::Operations::GetV1CompanyOnboardingStatusRequest.new( company_uuid: company_uuid, additional_steps: additional_steps, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::GetV1CompanyOnboardingStatusRequest, base_url, '/v1/companies/{company_uuid}/onboarding_status', request ) headers = Utils.get_headers(request) query_params = Utils.get_query_params(::GustoEmbedded::Operations::GetV1CompanyOnboardingStatusRequest, request) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::GetV1CompanyOnboardingStatusResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::CompanyOnboardingStatus) res.company_onboarding_status = out end elsif r.status == 404 end res end |
#list_admins(company_id, page = nil, per = nil, x_gusto_api_version = nil) ⇒ Object
450 451 452 453 454 455 456 457 458 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 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/gusto_embedded/companies.rb', line 450 def list_admins(company_id, page = nil, per = nil, x_gusto_api_version = nil) # list_admins - Get all the admins at a company # Returns a list of all the admins at a company # # scope: `company_admin:read` request = ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdAdminsRequest.new( company_id: company_id, page: page, per: per, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdAdminsRequest, base_url, '/v1/companies/{company_id}/admins', request ) headers = Utils.get_headers(request) query_params = Utils.get_query_params(::GustoEmbedded::Operations::GetV1CompaniesCompanyIdAdminsRequest, request) headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers req.params = query_params security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::GetV1CompaniesCompanyIdAdminsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), T::Array[::GustoEmbedded::Shared::Admin]) res.admin_list = out end elsif r.status == 404 end res end |
#migrate(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/gusto_embedded/companies.rb', line 198 def migrate(company_uuid, request_body, x_gusto_api_version = nil) # migrate - Migrate company to embedded payroll # Migrate an existing Gusto customer to your embedded payroll product. # # To use this endpoint, the customer will need to connect their Gusto account to your application using [OAuth2](https://docs.gusto.com/embedded-payroll/docs/oauth2) then view and [accept the Embedded Payroll Terms of Service](https://docs.gusto.com/embedded-payroll/reference/post-partner-managed-companies-company_uuid-accept_terms_of_service). # # scope: `partner_managed_companies:write` request = ::GustoEmbedded::Operations::PutV1PartnerManagedCompaniesCompanyUuidMigrateRequest.new( company_uuid: company_uuid, request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::PutV1PartnerManagedCompaniesCompanyUuidMigrateRequest, base_url, '/v1/partner_managed_companies/{company_uuid}/migrate', request ) headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.put(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PutV1PartnerManagedCompaniesCompanyUuidMigrateResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Operations::PutV1PartnerManagedCompaniesCompanyUuidMigrateResponseBody) res.object = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#retrieve_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/gusto_embedded/companies.rb', line 325 def retrieve_terms_of_service(company_uuid, request_body, x_gusto_api_version = nil) # retrieve_terms_of_service - Retrieve terms of service status for a company user # Retrieve the user acceptance status of the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms). # # scope: `terms_of_services:read` request = ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceRequest.new( company_uuid: company_uuid, request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceRequest, base_url, '/v1/partner_managed_companies/{company_uuid}/retrieve_terms_of_service', request ) headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Operations::PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceResponseBody) res.object = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |
#update(company_id, request_body, x_gusto_api_version = nil) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/gusto_embedded/companies.rb', line 136 def update(company_id, request_body, x_gusto_api_version = nil) # update - Update a company # Update a company. # # scope: `companies:write` request = ::GustoEmbedded::Operations::PutV1CompaniesRequest.new( company_id: company_id, request_body: request_body, x_gusto_api_version: x_gusto_api_version ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::GustoEmbedded::Operations::PutV1CompaniesRequest, base_url, '/v1/companies/{company_id}', request ) headers = Utils.get_headers(request) req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.put(url) do |req| req.headers = headers security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil Utils.configure_request_security(req, security) if !security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::GustoEmbedded::Operations::PutV1CompaniesResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::Company) res.company = out end elsif r.status == 404 elsif r.status == 422 if Utils.match_content_type(content_type, 'application/json') out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::GustoEmbedded::Shared::UnprocessableEntityErrorObject) res.unprocessable_entity_error_object = out end end res end |