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
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/schematic/catalogs/client.rb', line 302 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
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/schematic/catalogs/client.rb', line 428 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/schematic/catalogs/client.rb', line 66 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
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/schematic/catalogs/client.rb', line 168 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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/schematic/catalogs/client.rb', line 99 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
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/schematic/catalogs/client.rb', line 200 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
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/schematic/catalogs/client.rb', line 269 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
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/schematic/catalogs/client.rb', line 363 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
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/schematic/catalogs/client.rb', line 395 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
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 |
# File 'lib/schematic/catalogs/client.rb', line 26 def list_catalogs(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[is_default q limit offset] 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) params.except(*query_param_names) 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
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/schematic/catalogs/client.rb', line 333 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
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/schematic/catalogs/client.rb', line 459 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
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/schematic/catalogs/client.rb', line 131 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 = ["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
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 |
# File 'lib/schematic/catalogs/client.rb', line 232 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 = ["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 |