Class: Schematic::Features::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/schematic/features/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#check_flag(request_options: {}, **params) ⇒ Schematic::Features::Types::CheckFlagResponse

Examples:

client.features.check_flag(key: "key")

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):

  • :key (String)

Returns:



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
# File 'lib/schematic/features/client.rb', line 621

def check_flag(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[key]
  body_params = params.except(*path_param_names)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "flags/#{URI.encode_uri_component(params[:key].to_s)}/check",
    body: Schematic::Types::CheckFlagRequestBody.new(body_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::Features::Types::CheckFlagResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#check_flags(request_options: {}, **params) ⇒ Schematic::Features::Types::CheckFlagsResponse

Examples:

client.features.check_flags

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:



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/schematic/features/client.rb', line 659

def check_flags(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: "flags/check",
    body: Schematic::Types::CheckFlagRequestBody.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::Features::Types::CheckFlagsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#check_flags_bulk(request_options: {}, **params) ⇒ Schematic::Features::Types::CheckFlagsBulkResponse

Examples:

client.features.check_flags_bulk(contexts: [{}])

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:



694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/schematic/features/client.rb', line 694

def check_flags_bulk(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: "flags/check-bulk",
    body: Schematic::Features::Types::CheckFlagsBulkRequestBody.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::Features::Types::CheckFlagsBulkResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#count_features(request_options: {}, **params) ⇒ Schematic::Features::Types::CountFeaturesResponse

Examples:

client.features.count_features(
  boolean_require_event: true,
  feature_type: ["boolean"],
  ids: ["ids"],
  managed_by: "metronome",
  plan_version_id: "plan_version_id",
  q: "q",
  without_company_override_for: "without_company_override_for",
  without_plan_entitlement_for: "without_plan_entitlement_for",
  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):

  • :boolean_require_event (Boolean, nil)
  • :feature_type (Schematic::Types::FeatureType, nil)
  • :ids (String, nil)
  • :managed_by (Schematic::Types::BillingProviderType, nil)
  • :plan_version_id (String, nil)
  • :q (String, nil)
  • :without_company_override_for (String, nil)
  • :without_plan_entitlement_for (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/schematic/features/client.rb', line 304

def count_features(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["boolean_require_event"] = params[:boolean_require_event] if params.key?(:boolean_require_event)
  query_params["feature_type"] = params[:feature_type] if params.key?(:feature_type)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["managed_by"] = params[:managed_by] if params.key?(:managed_by)
  query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["without_company_override_for"] = params[:without_company_override_for] if params.key?(:without_company_override_for)
  query_params["without_plan_entitlement_for"] = params[:without_plan_entitlement_for] if params.key?(:without_plan_entitlement_for)
  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: "features/count",
    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::Features::Types::CountFeaturesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#count_flags(request_options: {}, **params) ⇒ Schematic::Features::Types::CountFlagsResponse

Examples:

client.features.count_flags(
  feature_id: "feature_id",
  ids: ["ids"],
  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):

  • :feature_id (String, nil)
  • :ids (String, nil)
  • :q (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
# File 'lib/schematic/features/client.rb', line 740

def count_flags(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  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: "flags/count",
    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::Features::Types::CountFlagsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#create_feature(request_options: {}, **params) ⇒ Schematic::Features::Types::CreateFeatureResponse

Examples:

client.features.create_feature(
  description: "description",
  feature_type: "boolean",
  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:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/schematic/features/client.rb', line 97

def create_feature(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: "features",
    body: Schematic::Features::Types::CreateFeatureRequestBody.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::Features::Types::CreateFeatureResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#create_flag(request_options: {}, **params) ⇒ Schematic::Features::Types::CreateFlagResponse

Examples:

client.features.create_flag(
  default_value: true,
  description: "description",
  flag_type: "boolean",
  key: "key",
  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:



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/schematic/features/client.rb', line 410

def create_flag(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: "flags",
    body: Schematic::Types::CreateFlagRequestBody.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::Features::Types::CreateFlagResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_feature(request_options: {}, **params) ⇒ Schematic::Features::Types::DeleteFeatureResponse

Examples:

client.features.delete_feature(feature_id: "feature_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):

  • :feature_id (String)

Returns:



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/schematic/features/client.rb', line 208

def delete_feature(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: "features/#{URI.encode_uri_component(params[:feature_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::Features::Types::DeleteFeatureResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_flag(request_options: {}, **params) ⇒ Schematic::Features::Types::DeleteFlagResponse

Examples:

client.features.delete_flag(flag_id: "flag_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):

  • :flag_id (String)

Returns:



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/schematic/features/client.rb', line 527

def delete_flag(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: "flags/#{URI.encode_uri_component(params[:flag_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::Features::Types::DeleteFlagResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_feature(request_options: {}, **params) ⇒ Schematic::Features::Types::GetFeatureResponse

Examples:

client.features.get_feature(feature_id: "feature_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):

  • :feature_id (String)

Returns:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/schematic/features/client.rb', line 133

def get_feature(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: "features/#{URI.encode_uri_component(params[:feature_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::Features::Types::GetFeatureResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_flag(request_options: {}, **params) ⇒ Schematic::Features::Types::GetFlagResponse

Examples:

client.features.get_flag(flag_id: "flag_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):

  • :flag_id (String)

Returns:



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/schematic/features/client.rb', line 446

def get_flag(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: "flags/#{URI.encode_uri_component(params[:flag_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::Features::Types::GetFlagResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_features(request_options: {}, **params) ⇒ Schematic::Features::Types::ListFeaturesResponse

Examples:

client.features.list_features(
  boolean_require_event: true,
  feature_type: ["boolean"],
  ids: ["ids"],
  managed_by: "metronome",
  plan_version_id: "plan_version_id",
  q: "q",
  without_company_override_for: "without_company_override_for",
  without_plan_entitlement_for: "without_plan_entitlement_for",
  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):

  • :boolean_require_event (Boolean, nil)
  • :feature_type (Schematic::Types::FeatureType, nil)
  • :ids (String, nil)
  • :managed_by (Schematic::Types::BillingProviderType, nil)
  • :plan_version_id (String, nil)
  • :q (String, nil)
  • :without_company_override_for (String, nil)
  • :without_plan_entitlement_for (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



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
# File 'lib/schematic/features/client.rb', line 46

def list_features(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["boolean_require_event"] = params[:boolean_require_event] if params.key?(:boolean_require_event)
  query_params["feature_type"] = params[:feature_type] if params.key?(:feature_type)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["managed_by"] = params[:managed_by] if params.key?(:managed_by)
  query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["without_company_override_for"] = params[:without_company_override_for] if params.key?(:without_company_override_for)
  query_params["without_plan_entitlement_for"] = params[:without_plan_entitlement_for] if params.key?(:without_plan_entitlement_for)
  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: "features",
    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::Features::Types::ListFeaturesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_flags(request_options: {}, **params) ⇒ Schematic::Features::Types::ListFlagsResponse

Examples:

client.features.list_flags(
  feature_id: "feature_id",
  ids: ["ids"],
  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):

  • :feature_id (String, nil)
  • :ids (String, nil)
  • :q (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/schematic/features/client.rb', line 362

def list_flags(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  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: "flags",
    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::Features::Types::ListFlagsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update_feature(request_options: {}, **params) ⇒ Schematic::Features::Types::UpdateFeatureResponse

Examples:

client.features.update_feature(feature_id: "feature_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):

  • :feature_id (String)

Returns:



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
# File 'lib/schematic/features/client.rb', line 168

def update_feature(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request_data = Schematic::Features::Types::UpdateFeatureRequestBody.new(params).to_h
  non_body_param_names = %w[feature_id]
  body = request_data.except(*non_body_param_names)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "features/#{URI.encode_uri_component(params[:feature_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::Features::Types::UpdateFeatureResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update_flag(request_options: {}, **params) ⇒ Schematic::Features::Types::UpdateFlagResponse

Examples:

client.features.update_flag(
  flag_id: "flag_id",
  default_value: true,
  description: "description",
  flag_type: "boolean",
  key: "key",
  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)

Options Hash (**params):

  • :flag_id (String)

Returns:



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/schematic/features/client.rb', line 488

def update_flag(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[flag_id]
  body_params = params.except(*path_param_names)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "flags/#{URI.encode_uri_component(params[:flag_id].to_s)}",
    body: Schematic::Types::CreateFlagRequestBody.new(body_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::Features::Types::UpdateFlagResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update_flag_rules(request_options: {}, **params) ⇒ Schematic::Features::Types::UpdateFlagRulesResponse

Examples:

client.features.update_flag_rules(
  flag_id: "flag_id",
  rules: [{
    condition_groups: [{
      conditions: [{
        condition_type: "base_plan",
        operator: "eq",
        resource_ids: ["resource_ids"]
      }]
    }],
    conditions: [{
      condition_type: "base_plan",
      operator: "eq",
      resource_ids: ["resource_ids"]
    }],
    name: "name",
    priority: 1000000,
    value: true
  }]
)

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):

  • :flag_id (String)

Returns:



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
# File 'lib/schematic/features/client.rb', line 581

def update_flag_rules(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request_data = Schematic::Features::Types::UpdateFlagRulesRequestBody.new(params).to_h
  non_body_param_names = %w[flag_id]
  body = request_data.except(*non_body_param_names)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "flags/#{URI.encode_uri_component(params[:flag_id].to_s)}/rules",
    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::Features::Types::UpdateFlagRulesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_feature_for_billing_product(request_options: {}, **params) ⇒ Schematic::Features::Types::UpsertFeatureForBillingProductResponse

Examples:

client.features.upsert_feature_for_billing_product(
  billing_provider: "metronome",
  description: "description",
  external_resource_id: "external_resource_id",
  feature_type: "boolean",
  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:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/schematic/features/client.rb', line 248

def upsert_feature_for_billing_product(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: "features/billing-linked",
    body: Schematic::Features::Types::CreateBillingLinkedFeatureRequestBody.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::Features::Types::UpsertFeatureForBillingProductResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end