Class: NewDemoApiClient::ContributionResponse

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

Class Method Summary collapse

Instance Method Summary collapse

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

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.

  • cac (Float) (defaults to: OMIT)

    The customer acquisition cost (CAC) for the cohort.

  • ltv (Float) (defaults to: OMIT)

    The revenue lifetime value (LTV) for the cohort.

  • ltv_cac (Float) (defaults to: OMIT)

    The LTV to CAC ratio for the cohort for the period.

  • gmltv (Float) (defaults to: OMIT)

    The gross-margin lifetime value, which is the cumululative gross profit, for the cohort for the period.

  • gmltv_cac (Float) (defaults to: OMIT)

    The gmLTV to CAC ratio for the cohort for the period. This related to the contribution margin.

  • contribution (Float) (defaults to: OMIT)

    The contribution (gmLTV - CAC) for the cohort for the period.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#cacFloat (readonly)

Returns The customer acquisition cost (CAC) for the cohort.

Returns:

  • (Float)

    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

#cohortString (readonly)

Returns The date of the cohort.

Returns:

  • (String)

    The date of the cohort.



13
14
15
# File 'lib/test_sdk/types/contribution_response.rb', line 13

def cohort
  @cohort
end

#cohort_sizeInteger (readonly)

Returns The number of users in the cohort.

Returns:

  • (Integer)

    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

#contributionFloat (readonly)

Returns The contribution (gmLTV - CAC) for the cohort for the period.

Returns:

  • (Float)

    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

#gmltvFloat (readonly)

Returns The gross-margin lifetime value, which is the cumululative gross profit, for the cohort for the period.

Returns:

  • (Float)

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

Returns The gmLTV to CAC ratio for the cohort for the period. This related to the contribution margin.

Returns:

  • (Float)

    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

#ltvFloat (readonly)

Returns The revenue lifetime value (LTV) for the cohort.

Returns:

  • (Float)

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

Returns The LTV to CAC ratio for the cohort for the period.

Returns:

  • (Float)

    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

#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.



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


113
114
115
# File 'lib/test_sdk/types/contribution_response.rb', line 113

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