Class: Schematic::Licenses::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



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

def initialize(client:)
  @client = client
end

Instance Method Details

#count_licenses(request_options: {}, **params) ⇒ Schematic::Licenses::Types::CountLicensesResponse

Examples:

client.licenses.count_licenses(
  feature_ids: ["feature_ids"],
  ids: ["ids"],
  name: "name",
  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_ids (String, nil)
  • :ids (String, nil)
  • :name (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



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/licenses/client.rb', line 124

def count_licenses(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["feature_ids"] = params[:feature_ids] if params.key?(:feature_ids)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["name"] = params[:name] if params.key?(:name)
  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: "licenses/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::Licenses::Types::CountLicensesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_single_license(request_options: {}, **params) ⇒ Schematic::Licenses::Types::GetSingleLicenseResponse

Examples:

client.licenses.get_single_license(license_id: "license_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):

  • :license_id (String)

Returns:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/schematic/licenses/client.rb', line 79

def get_single_license(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: "licenses/#{URI.encode_uri_component(params[:license_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::Licenses::Types::GetSingleLicenseResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_licenses(request_options: {}, **params) ⇒ Schematic::Licenses::Types::ListLicensesResponse

Examples:

client.licenses.list_licenses(
  feature_ids: ["feature_ids"],
  ids: ["ids"],
  name: "name",
  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_ids (String, nil)
  • :ids (String, nil)
  • :name (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



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/licenses/client.rb', line 36

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