Class: NewDemoApiClient::CohortsResponse

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • cohort (String)

    The date of the cohort.

  • period (Integer)

    The period of the cohort. 0 is the first period.

  • cohort_size (Integer)

    The number of users in the cohort.

  • cohort_size_amount (Float)

    The size denominated in the metric amount of the cohort.

  • active_users (Integer)

    The number of active users in the period.

  • logo_retention (Float) (defaults to: OMIT)

    The logo retention rate, defined as active / cohort size.

  • amount (Float) (defaults to: OMIT)

    The active amount, such as revenue or gtv, in the period for the cohort.

  • amount_retention (Float) (defaults to: OMIT)

    The amount retention rate, defined as amount / cohort size amount.

  • ltv (Float) (defaults to: OMIT)

    The cumulative lifetime value in terms of the metric amount up until the period, on average per user in the cohort.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_usersInteger (readonly)

Returns The number of active users in the period.

Returns:

  • (Integer)

    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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#amountFloat (readonly)

Returns The active amount, such as revenue or gtv, in the period for the cohort.

Returns:

  • (Float)

    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_retentionFloat (readonly)

Returns The amount retention rate, defined as amount / cohort size amount.

Returns:

  • (Float)

    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

#cohortString (readonly)

Returns The date of the cohort.

Returns:

  • (String)

    The date of the cohort.



12
13
14
# File 'lib/test_sdk/types/cohorts_response.rb', line 12

def cohort
  @cohort
end

#cohort_sizeInteger (readonly)

Returns The number of users in the cohort.

Returns:

  • (Integer)

    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_amountFloat (readonly)

Returns The size denominated in the metric amount of the cohort.

Returns:

  • (Float)

    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_retentionFloat (readonly)

Returns The logo retention rate, defined as active / cohort size.

Returns:

  • (Float)

    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

#ltvFloat (readonly)

Returns The cumulative lifetime value in terms of the metric amount up until the period, on average per user in the cohort.

Returns:

  • (Float)

    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

#periodInteger (readonly)

Returns The period of the cohort. 0 is the first period.

Returns:

  • (Integer)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


110
111
112
# File 'lib/test_sdk/types/cohorts_response.rb', line 110

def to_json(*_args)
  @_field_set&.to_json
end