Class: Schematic::Catalogs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/catalogs/client.rb

Instance Method Summary collapse

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

Examples:

client.catalogs.add_credit_bundle(
  catalog_id: "catalog_id",
  credit_bundle_id: "credit_bundle_id"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)
  • :credit_bundle_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


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: request_options[: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: 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

Examples:

client.catalogs.add_plan(
  catalog_id: "catalog_id",
  plan_id: "plan_id"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)
  • :plan_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


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: request_options[: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: 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

Examples:

client.catalogs.create_catalog(name: "name")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



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: request_options[:base_url],
    method: "POST",
    path: "catalogs",
    body: Schematic::Catalogs::Types::CreateCatalogRequestBody.new(params).to_h,
    request_options: 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

Examples:

client.catalogs.delete_catalog(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "DELETE",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}",
    request_options: 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

Examples:

client.catalogs.get_catalog(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}",
    request_options: 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

Examples:

client.catalogs.get_configuration(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/configuration",
    request_options: 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

Examples:

client.catalogs.get_credit_bundles_in_catalog(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/credit-bundles",
    request_options: 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

Examples:

client.catalogs.get_derived_features(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/features",
    request_options: 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

Examples:

client.catalogs.get_plans_in_catalog(catalog_id: "catalog_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/plans",
    request_options: 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

Examples:

client.catalogs.list_catalogs(
  is_default: true,
  q: "q",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :is_default (Boolean, nil)
  • :q (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



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: request_options[:base_url],
    method: "GET",
    path: "catalogs",
    query: query_params,
    request_options: 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

Examples:

client.catalogs.remove_credit_bundle(
  catalog_id: "catalog_id",
  credit_bundle_id: "credit_bundle_id"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)
  • :credit_bundle_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


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: request_options[: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: 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

Examples:

client.catalogs.remove_plan(
  catalog_id: "catalog_id",
  plan_id: "plan_id"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)
  • :plan_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


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: request_options[: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: 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

Examples:

client.catalogs.update_catalog(catalog_id: "catalog_id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "PUT",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}",
    body: body,
    request_options: 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

Examples:

client.catalogs.update_configuration(catalog_id: "catalog_id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :catalog_id (String)

Returns:



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: request_options[:base_url],
    method: "PUT",
    path: "catalogs/#{URI.encode_uri_component(params[:catalog_id].to_s)}/configuration",
    body: body,
    request_options: 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