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

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:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/schematic/insights/client.rb', line 23

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

  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

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:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/schematic/insights/client.rb', line 64

def get_environment_feature_usage_time_series(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[end_time feature_id granularity start_time]
  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)
  params.except(*query_param_names)

  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

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:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/schematic/insights/client.rb', line 219

def get_environment_trait_usage_time_series(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[end_time feature_id granularity start_time]
  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)
  params.except(*query_param_names)

  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

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:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/schematic/insights/client.rb', line 105

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

  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

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:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/schematic/insights/client.rb', line 142

def get_summary(request_options: {}, **params)
  Schematic::Internal::Types::Utils.normalize_keys(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

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:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/schematic/insights/client.rb', line 176

def get_top_features_by_usage(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[end_time limit start_time]
  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)
  params.except(*query_param_names)

  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