Class: Schematic::Catalogs::Client
- Inherits:
-
Object
- Object
- Schematic::Catalogs::Client
- Defined in:
- lib/schematic/catalogs/client.rb
Instance Method Summary collapse
- #add_credit_bundle(request_options: {}, **params) ⇒ untyped
- #add_plan(request_options: {}, **params) ⇒ untyped
- #create_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::CreateCatalogResponse
- #delete_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::DeleteCatalogResponse
- #get_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetCatalogResponse
- #get_configuration(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetConfigurationResponse
- #get_credit_bundles_in_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetCreditBundlesInCatalogResponse
- #get_derived_features(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetDerivedFeaturesResponse
- #get_plans_in_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetPlansInCatalogResponse
- #initialize(client:) ⇒ void constructor
- #list_catalogs(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::ListCatalogsResponse
- #remove_credit_bundle(request_options: {}, **params) ⇒ untyped
- #remove_plan(request_options: {}, **params) ⇒ untyped
- #update_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::UpdateCatalogResponse
- #update_configuration(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::UpdateConfigurationResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/catalogs/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_credit_bundle(request_options: {}, **params) ⇒ untyped
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/schematic/catalogs/client.rb', line 335 def add_credit_bundle(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/credit-bundles/#{URI.encode_uri_component(params[:credit_bundle_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#add_plan(request_options: {}, **params) ⇒ untyped
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/schematic/catalogs/client.rb', line 479 def add_plan(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/plans/#{URI.encode_uri_component(params[:plan_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#create_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::CreateCatalogResponse
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/schematic/catalogs/client.rb', line 75 def create_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "catalogs", body: Schematic::Catalogs::Types::CreateCatalogRequestBody.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::Catalogs::Types::CreateCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::DeleteCatalogResponse
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/schematic/catalogs/client.rb', line 186 def delete_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "catalogs/#{URI.encode_uri_component(params[:catalog_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::Catalogs::Types::DeleteCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetCatalogResponse
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/schematic/catalogs/client.rb', line 111 def get_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "catalogs/#{URI.encode_uri_component(params[:catalog_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::Catalogs::Types::GetCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_configuration(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetConfigurationResponse
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/schematic/catalogs/client.rb', line 221 def get_configuration(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/configuration", 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::Catalogs::Types::GetConfigurationResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_credit_bundles_in_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetCreditBundlesInCatalogResponse
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/schematic/catalogs/client.rb', line 296 def get_credit_bundles_in_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/credit-bundles", 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::Catalogs::Types::GetCreditBundlesInCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_derived_features(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetDerivedFeaturesResponse
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/schematic/catalogs/client.rb', line 405 def get_derived_features(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/features", 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::Catalogs::Types::GetDerivedFeaturesResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_plans_in_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::GetPlansInCatalogResponse
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/schematic/catalogs/client.rb', line 440 def get_plans_in_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/plans", 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::Catalogs::Types::GetPlansInCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_catalogs(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::ListCatalogsResponse
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 |
# File 'lib/schematic/catalogs/client.rb', line 34 def list_catalogs(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["is_default"] = params[:is_default] if params.key?(:is_default) query_params["q"] = params[:q] if params.key?(:q) 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: "catalogs", 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::Catalogs::Types::ListCatalogsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#remove_credit_bundle(request_options: {}, **params) ⇒ untyped
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/schematic/catalogs/client.rb', line 372 def remove_credit_bundle(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/credit-bundles/#{URI.encode_uri_component(params[:credit_bundle_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#remove_plan(request_options: {}, **params) ⇒ untyped
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/schematic/catalogs/client.rb', line 516 def remove_plan(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/plans/#{URI.encode_uri_component(params[:plan_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#update_catalog(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::UpdateCatalogResponse
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 |
# File 'lib/schematic/catalogs/client.rb', line 146 def update_catalog(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Catalogs::Types::UpdateCatalogRequestBody.new(params).to_h non_body_param_names = %w[catalog_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "catalogs/#{URI.encode_uri_component(params[:catalog_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::Catalogs::Types::UpdateCatalogResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_configuration(request_options: {}, **params) ⇒ Schematic::Catalogs::Types::UpdateConfigurationResponse
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/schematic/catalogs/client.rb', line 256 def update_configuration(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Catalogs::Types::UpdateCatalogConfigurationRequestBody.new(params).to_h non_body_param_names = %w[catalog_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/configuration", 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::Catalogs::Types::UpdateConfigurationResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |