Class: Schematic::Accounts::Client
- Inherits:
-
Object
- Object
- Schematic::Accounts::Client
- Defined in:
- lib/schematic/accounts/client.rb
Instance Method Summary collapse
- #count_account_members(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountAccountMembersResponse
- #count_api_keys(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountApiKeysResponse
- #count_audit_logs(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountAuditLogsResponse
- #create_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CreateApiKeyResponse
- #create_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CreateEnvironmentResponse
- #delete_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::DeleteApiKeyResponse
- #delete_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::DeleteEnvironmentResponse
- #get_account_member(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetAccountMemberResponse
- #get_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetApiKeyResponse
- #get_audit_log(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetAuditLogResponse
- #get_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetEnvironmentResponse
- #get_onboarding_state(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::GetOnboardingStateResponse
- #get_who_am_i(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::GetWhoAmIResponse
- #initialize(client:) ⇒ void constructor
- #list_account_members(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListAccountMembersResponse
- #list_api_keys(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListApiKeysResponse
- #list_audit_logs(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListAuditLogsResponse
- #list_environments(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListEnvironmentsResponse
- #quickstart(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::QuickstartResponse
- #update_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateApiKeyResponse
- #update_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateEnvironmentResponse
- #update_onboarding_state(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateOnboardingStateResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/accounts/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#count_account_members(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountAccountMembersResponse
124 125 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 |
# File 'lib/schematic/accounts/client.rb', line 124 def count_account_members(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["ids"] = params[:ids] if params.key?(:ids) query_params["q"] = params[:q] if params.key?(:q) query_params["role"] = params[:role] if params.key?(:role) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "account-members/count", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::CountAccountMembersResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#count_api_keys(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountApiKeysResponse
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/schematic/accounts/client.rb', line 370 def count_api_keys(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["environment_id"] = params[:environment_id] if params.key?(:environment_id) query_params["require_environment"] = params[:require_environment] if params.key?(:require_environment) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "api-keys/count", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::CountApiKeysResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#count_audit_logs(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CountAuditLogsResponse
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 547 548 549 550 |
# File 'lib/schematic/accounts/client.rb', line 520 def count_audit_logs(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["actor_type"] = params[:actor_type] if params.key?(:actor_type) query_params["end_time"] = params[:end_time] if params.key?(:end_time) query_params["environment_id"] = params[:environment_id] if params.key?(:environment_id) query_params["q"] = params[:q] if params.key?(:q) query_params["start_time"] = params[:start_time] if params.key?(:start_time) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "audit-log/count", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::CountAuditLogsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CreateApiKeyResponse
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/schematic/accounts/client.rb', line 216 def create_api_key(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "api-keys", body: Schematic::Accounts::Types::CreateApiKeyRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::CreateApiKeyResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::CreateEnvironmentResponse
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/schematic/accounts/client.rb', line 614 def create_environment(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "environments", body: Schematic::Accounts::Types::CreateEnvironmentRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::CreateEnvironmentResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::DeleteApiKeyResponse
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/schematic/accounts/client.rb', line 327 def delete_api_key(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "api-keys/#{URI.encode_uri_component(params[:api_key_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::DeleteApiKeyResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::DeleteEnvironmentResponse
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
# File 'lib/schematic/accounts/client.rb', line 725 def delete_environment(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "environments/#{URI.encode_uri_component(params[:environment_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::DeleteEnvironmentResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_account_member(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetAccountMemberResponse
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/schematic/accounts/client.rb', line 79 def get_account_member(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "account-members/#{URI.encode_uri_component(params[:account_member_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetAccountMemberResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetApiKeyResponse
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/schematic/accounts/client.rb', line 252 def get_api_key(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "api-keys/#{URI.encode_uri_component(params[:api_key_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetApiKeyResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_audit_log(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetAuditLogResponse
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/schematic/accounts/client.rb', line 471 def get_audit_log(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "audit-log/#{URI.encode_uri_component(params[:audit_log_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetAuditLogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::GetEnvironmentResponse
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/schematic/accounts/client.rb', line 650 def get_environment(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "environments/#{URI.encode_uri_component(params[:environment_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetEnvironmentResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_onboarding_state(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::GetOnboardingStateResponse
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/schematic/accounts/client.rb', line 759 def get_onboarding_state(request_options: {}, **_params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "onboarding-state", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetOnboardingStateResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_who_am_i(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::GetWhoAmIResponse
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File 'lib/schematic/accounts/client.rb', line 860 def get_who_am_i(request_options: {}, **_params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "whoami", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::GetWhoAmIResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_account_members(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListAccountMembersResponse
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 |
# File 'lib/schematic/accounts/client.rb', line 36 def list_account_members(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["ids"] = params[:ids] if params.key?(:ids) query_params["q"] = params[:q] if params.key?(:q) query_params["role"] = params[:role] if params.key?(:role) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "account-members", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::ListAccountMembersResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_api_keys(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListApiKeysResponse
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/schematic/accounts/client.rb', line 175 def list_api_keys(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["environment_id"] = params[:environment_id] if params.key?(:environment_id) query_params["require_environment"] = params[:require_environment] if params.key?(:require_environment) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "api-keys", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::ListApiKeysResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_audit_logs(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListAuditLogsResponse
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/schematic/accounts/client.rb', line 426 def list_audit_logs(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["actor_type"] = params[:actor_type] if params.key?(:actor_type) query_params["end_time"] = params[:end_time] if params.key?(:end_time) query_params["environment_id"] = params[:environment_id] if params.key?(:environment_id) query_params["q"] = params[:q] if params.key?(:q) query_params["start_time"] = params[:start_time] if params.key?(:start_time) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "audit-log", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::ListAuditLogsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_environments(request_options: {}, **params) ⇒ Schematic::Accounts::Types::ListEnvironmentsResponse
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 |
# File 'lib/schematic/accounts/client.rb', line 571 def list_environments(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["ids"] = params[:ids] if params.key?(:ids) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "environments", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::ListEnvironmentsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#quickstart(request_options: {}, **_params) ⇒ Schematic::Accounts::Types::QuickstartResponse
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
# File 'lib/schematic/accounts/client.rb', line 827 def quickstart(request_options: {}, **_params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "quickstart", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::QuickstartResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_api_key(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateApiKeyResponse
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 |
# File 'lib/schematic/accounts/client.rb', line 287 def update_api_key(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Accounts::Types::UpdateApiKeyRequestBody.new(params).to_h non_body_param_names = %w[api_key_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "api-keys/#{URI.encode_uri_component(params[:api_key_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::UpdateApiKeyResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_environment(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateEnvironmentResponse
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/schematic/accounts/client.rb', line 685 def update_environment(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Accounts::Types::UpdateEnvironmentRequestBody.new(params).to_h non_body_param_names = %w[environment_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "environments/#{URI.encode_uri_component(params[:environment_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::UpdateEnvironmentResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_onboarding_state(request_options: {}, **params) ⇒ Schematic::Accounts::Types::UpdateOnboardingStateResponse
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
# File 'lib/schematic/accounts/client.rb', line 792 def update_onboarding_state(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "onboarding-state", body: Schematic::Accounts::Types::UpdateOnboardingStateRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Accounts::Types::UpdateOnboardingStateResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |