Class: NewDemoApiClient::CohortsResponse
- Inherits:
-
Object
- Object
- NewDemoApiClient::CohortsResponse
- Defined in:
- lib/test_sdk/types/cohorts_response.rb
Overview
The basic cohort metrics for the user count and amount.
The "amount" is a generic term for the metric being measured, such as revenue or
gtv.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#active_users ⇒ Integer
readonly
The number of active users in the period.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#amount ⇒ Float
readonly
The active amount, such as revenue or gtv, in the period for the cohort.
-
#amount_retention ⇒ Float
readonly
The amount retention rate, defined as amount / cohort size amount.
-
#cohort ⇒ String
readonly
The date of the cohort.
-
#cohort_size ⇒ Integer
readonly
The number of users in the cohort.
-
#cohort_size_amount ⇒ Float
readonly
The size denominated in the metric amount of the cohort.
-
#logo_retention ⇒ Float
readonly
The logo retention rate, defined as active / cohort size.
-
#ltv ⇒ Float
readonly
The cumulative lifetime value in terms of the metric amount up until the period, on average per user in the cohort.
-
#period ⇒ Integer
readonly
The period of the cohort.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::CohortsResponse
Deserialize a JSON object to an instance of CohortsResponse.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(cohort:, period:, cohort_size:, cohort_size_amount:, active_users:, logo_retention: OMIT, amount: OMIT, amount_retention: OMIT, ltv: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CohortsResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CohortsResponse to a JSON object.
Constructor Details
#initialize(cohort:, period:, cohort_size:, cohort_size_amount:, active_users:, logo_retention: OMIT, amount: OMIT, amount_retention: OMIT, ltv: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CohortsResponse
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 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 50 def initialize(cohort:, period:, cohort_size:, cohort_size_amount:, active_users:, logo_retention: OMIT, amount: OMIT, amount_retention: OMIT, ltv: OMIT, additional_properties: nil) @cohort = cohort @period = period @cohort_size = cohort_size @cohort_size_amount = cohort_size_amount @active_users = active_users @logo_retention = logo_retention if logo_retention != OMIT @amount = amount if amount != OMIT @amount_retention = amount_retention if amount_retention != OMIT @ltv = ltv if ltv != OMIT @additional_properties = additional_properties @_field_set = { "cohort": cohort, "period": period, "cohort_size": cohort_size, "cohort_size_amount": cohort_size_amount, "active_users": active_users, "logo_retention": logo_retention, "amount": amount, "amount_retention": amount_retention, "ltv": ltv }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#active_users ⇒ Integer (readonly)
Returns The number of active users in the period.
20 21 22 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 20 def active_users @active_users end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
31 32 33 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 31 def additional_properties @additional_properties end |
#amount ⇒ Float (readonly)
Returns The active amount, such as revenue or gtv, in the period for the cohort.
24 25 26 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 24 def amount @amount end |
#amount_retention ⇒ Float (readonly)
Returns The amount retention rate, defined as amount / cohort size amount.
26 27 28 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 26 def amount_retention @amount_retention end |
#cohort ⇒ String (readonly)
Returns The date of the cohort.
12 13 14 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 12 def cohort @cohort end |
#cohort_size ⇒ Integer (readonly)
Returns The number of users in the cohort.
16 17 18 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 16 def cohort_size @cohort_size end |
#cohort_size_amount ⇒ Float (readonly)
Returns The size denominated in the metric amount of the cohort.
18 19 20 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 18 def cohort_size_amount @cohort_size_amount end |
#logo_retention ⇒ Float (readonly)
Returns The logo retention rate, defined as active / cohort size.
22 23 24 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 22 def logo_retention @logo_retention end |
#ltv ⇒ Float (readonly)
Returns The cumulative lifetime value in terms of the metric amount up until the period, on average per user in the cohort.
29 30 31 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 29 def ltv @ltv end |
#period ⇒ Integer (readonly)
Returns The period of the cohort. 0 is the first period.
14 15 16 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 14 def period @period end |
Class Method Details
.from_json(json_object:) ⇒ NewDemoApiClient::CohortsResponse
Deserialize a JSON object to an instance of CohortsResponse
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 81 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) cohort = parsed_json["cohort"] period = parsed_json["period"] cohort_size = parsed_json["cohort_size"] cohort_size_amount = parsed_json["cohort_size_amount"] active_users = parsed_json["active_users"] logo_retention = parsed_json["logo_retention"] amount = parsed_json["amount"] amount_retention = parsed_json["amount_retention"] ltv = parsed_json["ltv"] new( cohort: cohort, period: period, cohort_size: cohort_size, cohort_size_amount: cohort_size_amount, active_users: active_users, logo_retention: logo_retention, amount: amount, amount_retention: amount_retention, ltv: ltv, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 120 def self.validate_raw(obj:) obj.cohort.is_a?(String) != false || raise("Passed value for field obj.cohort is not the expected type, validation failed.") obj.period.is_a?(Integer) != false || raise("Passed value for field obj.period is not the expected type, validation failed.") obj.cohort_size.is_a?(Integer) != false || raise("Passed value for field obj.cohort_size is not the expected type, validation failed.") obj.cohort_size_amount.is_a?(Float) != false || raise("Passed value for field obj.cohort_size_amount is not the expected type, validation failed.") obj.active_users.is_a?(Integer) != false || raise("Passed value for field obj.active_users is not the expected type, validation failed.") obj.logo_retention&.is_a?(Float) != false || raise("Passed value for field obj.logo_retention is not the expected type, validation failed.") obj.amount&.is_a?(Float) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") obj.amount_retention&.is_a?(Float) != false || raise("Passed value for field obj.amount_retention is not the expected type, validation failed.") obj.ltv&.is_a?(Float) != false || raise("Passed value for field obj.ltv is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CohortsResponse to a JSON object
110 111 112 |
# File 'lib/test_sdk/types/cohorts_response.rb', line 110 def to_json(*_args) @_field_set&.to_json end |