Class: NewDemoApiClient::ProductClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/product/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ NewDemoApiClient::ProductClient

Parameters:



20
21
22
# File 'lib/test_sdk/product/client.rb', line 20

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::RequestClient (readonly)



16
17
18
# File 'lib/test_sdk/product/client.rb', line 16

def request_client
  @request_client
end

Instance Method Details

#get_cohorts(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil) ⇒ Array<NewDemoApiClient::CohortsResponse>

Get the product cohorts for the company associated with the deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.product.get_cohorts(
  group_id: 1,
  deal_id: 1,
  user_type: BUSINESS,
  metric: "metric"
)

Parameters:

Returns:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/test_sdk/product/client.rb', line 141

def get_cohorts(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "user_type": user_type,
      "metric": metric,
      "freq": freq
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}/data/cohorts"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    NewDemoApiClient::CohortsResponse.from_json(json_object: item)
  end
end

#get_concentration(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil) ⇒ NewDemoApiClient::ConcentrationResponse

Get the product concentration for the company associated with the deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.product.get_concentration(
  group_id: 1,
  deal_id: 1,
  user_type: BUSINESS,
  metric: "metric"
)

Parameters:

Returns:



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/test_sdk/product/client.rb', line 189

def get_concentration(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "user_type": user_type,
      "metric": metric,
      "freq": freq
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}/data/concentration"
  end
  NewDemoApiClient::ConcentrationResponse.from_json(json_object: response.body)
end

#get_growth_accounting(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil) ⇒ Array<NewDemoApiClient::GrowthAccountingResponse>

Get the product growth accounting for the company associated with the deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.product.get_growth_accounting(
  group_id: 1,
  deal_id: 1,
  user_type: BUSINESS,
  metric: "metric"
)

Parameters:

Returns:



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

def get_growth_accounting(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "user_type": user_type,
      "metric": metric,
      "freq": freq
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}/data/growth-accounting"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    NewDemoApiClient::GrowthAccountingResponse.from_json(json_object: item)
  end
end

#get_user_accounting(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil) ⇒ Array<NewDemoApiClient::UserAccountingResponse>

Get the product user accounting for the company associated with the deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.product.get_user_accounting(
  group_id: 1,
  deal_id: 1,
  user_type: BUSINESS,
  metric: "metric"
)

Parameters:

Returns:



45
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
# File 'lib/test_sdk/product/client.rb', line 45

def get_user_accounting(group_id:, deal_id:, user_type:, metric:, freq: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "user_type": user_type,
      "metric": metric,
      "freq": freq
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}/data/user-accounting"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    NewDemoApiClient::UserAccountingResponse.from_json(json_object: item)
  end
end