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



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)



33
34
35
# File 'lib/test_sdk/types/contribution_response.rb', line 33

def additional_properties
  @additional_properties
end

#cacFloat (readonly)



19
20
21
# File 'lib/test_sdk/types/contribution_response.rb', line 19

def cac
  @cac
end

#cohortString (readonly)



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

def cohort
  @cohort
end

#cohort_sizeInteger (readonly)



17
18
19
# File 'lib/test_sdk/types/contribution_response.rb', line 17

def cohort_size
  @cohort_size
end

#contributionFloat (readonly)



31
32
33
# File 'lib/test_sdk/types/contribution_response.rb', line 31

def contribution
  @contribution
end

#gmltvFloat (readonly)



26
27
28
# File 'lib/test_sdk/types/contribution_response.rb', line 26

def gmltv
  @gmltv
end

#gmltv_cacFloat (readonly)



29
30
31
# File 'lib/test_sdk/types/contribution_response.rb', line 29

def gmltv_cac
  @gmltv_cac
end

#ltvFloat (readonly)



21
22
23
# File 'lib/test_sdk/types/contribution_response.rb', line 21

def ltv
  @ltv
end

#ltv_cacFloat (readonly)



23
24
25
# File 'lib/test_sdk/types/contribution_response.rb', line 23

def ltv_cac
  @ltv_cac
end

#periodInteger (readonly)



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