Class: Schematic::Insights::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



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

def initialize(client:)
  @client = client
end

Instance Method Details

#get_activity(request_options: {}, **params) ⇒ Schematic::Insights::Types::GetActivityResponse

Examples:

client.insights.get_activity(limit: 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):

  • :limit (Integer, nil)

Returns:



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

def get_activity(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["limit"] = params[:limit] if params.key?(:limit)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/activity",
    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::Insights::Types::GetActivityResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_environment_feature_usage_time_series(request_options: {}, **params) ⇒ Schematic::Insights::Types::GetEnvironmentFeatureUsageTimeSeriesResponse

Examples:

client.insights.get_environment_feature_usage_time_series(
  end_time: "2024-01-15T09:30:00Z",
  feature_id: "feature_id",
  granularity: "daily",
  start_time: "2024-01-15T09:30:00Z"
)

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

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/schematic/insights/client.rb', line 73

def get_environment_feature_usage_time_series(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["end_time"] = params[:end_time] if params.key?(:end_time)
  query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
  query_params["granularity"] = params[:granularity] if params.key?(:granularity)
  query_params["start_time"] = params[:start_time] if params.key?(:start_time)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/feature-usage-timeseries",
    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::Insights::Types::GetEnvironmentFeatureUsageTimeSeriesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_environment_trait_usage_time_series(request_options: {}, **params) ⇒ Schematic::Insights::Types::GetEnvironmentTraitUsageTimeSeriesResponse

Examples:

client.insights.get_environment_trait_usage_time_series(
  end_time: "2024-01-15T09:30:00Z",
  feature_id: "feature_id",
  granularity: "daily",
  start_time: "2024-01-15T09:30:00Z"
)

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

Returns:



242
243
244
245
246
247
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/insights/client.rb', line 242

def get_environment_trait_usage_time_series(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["end_time"] = params[:end_time] if params.key?(:end_time)
  query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
  query_params["granularity"] = params[:granularity] if params.key?(:granularity)
  query_params["start_time"] = params[:start_time] if params.key?(:start_time)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/trait-usage-timeseries",
    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::Insights::Types::GetEnvironmentTraitUsageTimeSeriesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_plan_growth(request_options: {}, **params) ⇒ Schematic::Insights::Types::GetPlanGrowthResponse

Examples:

client.insights.get_plan_growth(months: 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):

  • :months (Integer, nil)

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/schematic/insights/client.rb', line 115

def get_plan_growth(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["months"] = params[:months] if params.key?(:months)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/plan-growth",
    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::Insights::Types::GetPlanGrowthResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_summary(request_options: {}, **_params) ⇒ Schematic::Insights::Types::GetSummaryResponse

Examples:

client.insights.get_summary

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)

Returns:



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/schematic/insights/client.rb', line 153

def get_summary(request_options: {}, **_params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/summary",
    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::Insights::Types::GetSummaryResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_top_features_by_usage(request_options: {}, **params) ⇒ Schematic::Insights::Types::GetTopFeaturesByUsageResponse

Examples:

client.insights.get_top_features_by_usage(
  end_time: "2024-01-15T09:30:00Z",
  limit: 1000000,
  start_time: "2024-01-15T09:30:00Z"
)

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

  • :end_time (String)
  • :limit (Integer, nil)
  • :start_time (String)

Returns:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/schematic/insights/client.rb', line 193

def get_top_features_by_usage(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["end_time"] = params[:end_time] if params.key?(:end_time)
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["start_time"] = params[:start_time] if params.key?(:start_time)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "insights/top-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::Insights::Types::GetTopFeaturesByUsageResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end