Class: NewDemoApiClient::ContributionResponse
- Inherits:
-
Object
- Object
- NewDemoApiClient::ContributionResponse
- Defined in:
- lib/test_sdk/types/contribution_response.rb
Overview
Represents the cohortized contribution for the Unit Economics for the specified
user type.
This approach assumes all acquisition spend was toward the specified user type.
This is the core input to deriving certain unit-economic aggregate metrics.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#cac ⇒ Float
readonly
The customer acquisition cost (CAC) for the cohort.
-
#cohort ⇒ String
readonly
The date of the cohort.
-
#cohort_size ⇒ Integer
readonly
The number of users in the cohort.
-
#contribution ⇒ Float
readonly
The contribution (gmLTV - CAC) for the cohort for the period.
-
#gmltv ⇒ Float
readonly
The gross-margin lifetime value, which is the cumululative gross profit, for the cohort for the period.
-
#gmltv_cac ⇒ Float
readonly
The gmLTV to CAC ratio for the cohort for the period.
-
#ltv ⇒ Float
readonly
The revenue lifetime value (LTV) for the cohort.
-
#ltv_cac ⇒ Float
readonly
The LTV to CAC ratio for the cohort for the period.
-
#period ⇒ Integer
readonly
The period of the cohort.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::ContributionResponse
Deserialize a JSON object to an instance of ContributionResponse.
-
.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:, cac: OMIT, ltv: OMIT, ltv_cac: OMIT, gmltv: OMIT, gmltv_cac: OMIT, contribution: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::ContributionResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ContributionResponse to a JSON object.
Constructor Details
#initialize(cohort:, period:, cohort_size:, cac: OMIT, ltv: OMIT, ltv_cac: OMIT, gmltv: OMIT, gmltv_cac: OMIT, contribution: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::ContributionResponse
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/test_sdk/types/contribution_response.rb', line 53 def initialize(cohort:, period:, cohort_size:, cac: OMIT, ltv: OMIT, ltv_cac: OMIT, gmltv: OMIT, gmltv_cac: OMIT, contribution: OMIT, additional_properties: nil) @cohort = cohort @period = period @cohort_size = cohort_size @cac = cac if cac != OMIT @ltv = ltv if ltv != OMIT @ltv_cac = ltv_cac if ltv_cac != OMIT @gmltv = gmltv if gmltv != OMIT @gmltv_cac = gmltv_cac if gmltv_cac != OMIT @contribution = contribution if contribution != OMIT @additional_properties = additional_properties @_field_set = { "cohort": cohort, "period": period, "cohort_size": cohort_size, "cac": cac, "ltv": ltv, "ltv_cac": ltv_cac, "gmltv": gmltv, "gmltv_cac": gmltv_cac, "contribution": contribution }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
33 34 35 |
# File 'lib/test_sdk/types/contribution_response.rb', line 33 def additional_properties @additional_properties end |
#cac ⇒ Float (readonly)
Returns The customer acquisition cost (CAC) for the cohort.
19 20 21 |
# File 'lib/test_sdk/types/contribution_response.rb', line 19 def cac @cac end |
#cohort ⇒ String (readonly)
Returns The date of the cohort.
13 14 15 |
# File 'lib/test_sdk/types/contribution_response.rb', line 13 def cohort @cohort end |
#cohort_size ⇒ Integer (readonly)
Returns The number of users in the cohort.
17 18 19 |
# File 'lib/test_sdk/types/contribution_response.rb', line 17 def cohort_size @cohort_size end |
#contribution ⇒ Float (readonly)
Returns The contribution (gmLTV - CAC) for the cohort for the period.
31 32 33 |
# File 'lib/test_sdk/types/contribution_response.rb', line 31 def contribution @contribution end |
#gmltv ⇒ Float (readonly)
Returns The gross-margin lifetime value, which is the cumululative gross profit, for the cohort for the period.
26 27 28 |
# File 'lib/test_sdk/types/contribution_response.rb', line 26 def gmltv @gmltv end |
#gmltv_cac ⇒ Float (readonly)
Returns The gmLTV to CAC ratio for the cohort for the period. This related to the contribution margin.
29 30 31 |
# File 'lib/test_sdk/types/contribution_response.rb', line 29 def gmltv_cac @gmltv_cac end |
#ltv ⇒ Float (readonly)
Returns The revenue lifetime value (LTV) for the cohort.
21 22 23 |
# File 'lib/test_sdk/types/contribution_response.rb', line 21 def ltv @ltv end |
#ltv_cac ⇒ Float (readonly)
Returns The LTV to CAC ratio for the cohort for the period.
23 24 25 |
# File 'lib/test_sdk/types/contribution_response.rb', line 23 def ltv_cac @ltv_cac end |
#period ⇒ Integer (readonly)
Returns The period of the cohort. 0 is the first period.
15 16 17 |
# File 'lib/test_sdk/types/contribution_response.rb', line 15 def period @period end |
Class Method Details
.from_json(json_object:) ⇒ NewDemoApiClient::ContributionResponse
Deserialize a JSON object to an instance of ContributionResponse
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/test_sdk/types/contribution_response.rb', line 84 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"] cac = parsed_json["cac"] ltv = parsed_json["ltv"] ltv_cac = parsed_json["ltv_cac"] gmltv = parsed_json["gmltv"] gmltv_cac = parsed_json["gmltv_cac"] contribution = parsed_json["contribution"] new( cohort: cohort, period: period, cohort_size: cohort_size, cac: cac, ltv: ltv, ltv_cac: ltv_cac, gmltv: gmltv, gmltv_cac: gmltv_cac, contribution: contribution, 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.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/test_sdk/types/contribution_response.rb', line 123 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.cac&.is_a?(Float) != false || raise("Passed value for field obj.cac 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.") obj.ltv_cac&.is_a?(Float) != false || raise("Passed value for field obj.ltv_cac is not the expected type, validation failed.") obj.gmltv&.is_a?(Float) != false || raise("Passed value for field obj.gmltv is not the expected type, validation failed.") obj.gmltv_cac&.is_a?(Float) != false || raise("Passed value for field obj.gmltv_cac is not the expected type, validation failed.") obj.contribution&.is_a?(Float) != false || raise("Passed value for field obj.contribution is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ContributionResponse to a JSON object
113 114 115 |
# File 'lib/test_sdk/types/contribution_response.rb', line 113 def to_json(*_args) @_field_set&.to_json end |