Class: TrophyApiClient::BaseStreakResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/base_streak_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length:, frequency:, started: OMIT, period_start: OMIT, period_end: OMIT, expires: OMIT, freezes: OMIT, max_freezes: OMIT, freeze_auto_earn_interval: OMIT, freeze_auto_earn_amount: OMIT, additional_properties: nil) ⇒ TrophyApiClient::BaseStreakResponse

Parameters:

  • length (Integer)

    The length of the user’s current streak.

  • frequency (TrophyApiClient::StreakFrequency)

    The frequency of the streak.

  • started (String) (defaults to: OMIT)

    The date the streak started.

  • period_start (String) (defaults to: OMIT)

    The start date of the current streak period.

  • period_end (String) (defaults to: OMIT)

    The end date of the current streak period.

  • expires (String) (defaults to: OMIT)

    The date the streak will expire if the user does not increment a metric.

  • freezes (Integer) (defaults to: OMIT)

    The number of available streak freezes. Only present if the organization has enabled streak freezes.

  • max_freezes (Integer) (defaults to: OMIT)

    The maximum number of streak freezes a user can have. Only present if the organization has enabled streak freezes.

  • freeze_auto_earn_interval (Integer) (defaults to: OMIT)

    The interval at which the user will earn streak freezes, in days. Only present if the organization has enabled streak freeze auto-earn.

  • freeze_auto_earn_amount (Integer) (defaults to: OMIT)

    The amount of streak freezes the user will earn per interval. Only present if the organization has enabled streak freeze auto-earn.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 57

def initialize(length:, frequency:, started: OMIT, period_start: OMIT, period_end: OMIT, expires: OMIT,
               freezes: OMIT, max_freezes: OMIT, freeze_auto_earn_interval: OMIT, freeze_auto_earn_amount: OMIT, additional_properties: nil)
  @length = length
  @frequency = frequency
  @started = started if started != OMIT
  @period_start = period_start if period_start != OMIT
  @period_end = period_end if period_end != OMIT
  @expires = expires if expires != OMIT
  @freezes = freezes if freezes != OMIT
  @max_freezes = max_freezes if max_freezes != OMIT
  @freeze_auto_earn_interval = freeze_auto_earn_interval if freeze_auto_earn_interval != OMIT
  @freeze_auto_earn_amount = freeze_auto_earn_amount if freeze_auto_earn_amount != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "length": length,
    "frequency": frequency,
    "started": started,
    "periodStart": period_start,
    "periodEnd": period_end,
    "expires": expires,
    "freezes": freezes,
    "maxFreezes": max_freezes,
    "freezeAutoEarnInterval": freeze_auto_earn_interval,
    "freezeAutoEarnAmount": freeze_auto_earn_amount
  }.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



34
35
36
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 34

def additional_properties
  @additional_properties
end

#expiresString (readonly)

Returns The date the streak will expire if the user does not increment a metric.

Returns:

  • (String)

    The date the streak will expire if the user does not increment a metric.



20
21
22
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 20

def expires
  @expires
end

#freeze_auto_earn_amountInteger (readonly)

Returns The amount of streak freezes the user will earn per interval. Only present if the organization has enabled streak freeze auto-earn.

Returns:

  • (Integer)

    The amount of streak freezes the user will earn per interval. Only present if the organization has enabled streak freeze auto-earn.



32
33
34
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 32

def freeze_auto_earn_amount
  @freeze_auto_earn_amount
end

#freeze_auto_earn_intervalInteger (readonly)

Returns The interval at which the user will earn streak freezes, in days. Only present if the organization has enabled streak freeze auto-earn.

Returns:

  • (Integer)

    The interval at which the user will earn streak freezes, in days. Only present if the organization has enabled streak freeze auto-earn.



29
30
31
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 29

def freeze_auto_earn_interval
  @freeze_auto_earn_interval
end

#freezesInteger (readonly)

Returns The number of available streak freezes. Only present if the organization has enabled streak freezes.

Returns:

  • (Integer)

    The number of available streak freezes. Only present if the organization has enabled streak freezes.



23
24
25
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 23

def freezes
  @freezes
end

#frequencyTrophyApiClient::StreakFrequency (readonly)

Returns The frequency of the streak.

Returns:



12
13
14
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 12

def frequency
  @frequency
end

#lengthInteger (readonly)

Returns The length of the user’s current streak.

Returns:

  • (Integer)

    The length of the user’s current streak.



10
11
12
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 10

def length
  @length
end

#max_freezesInteger (readonly)

Returns The maximum number of streak freezes a user can have. Only present if the organization has enabled streak freezes.

Returns:

  • (Integer)

    The maximum number of streak freezes a user can have. Only present if the organization has enabled streak freezes.



26
27
28
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 26

def max_freezes
  @max_freezes
end

#period_endString (readonly)

Returns The end date of the current streak period.

Returns:

  • (String)

    The end date of the current streak period.



18
19
20
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 18

def period_end
  @period_end
end

#period_startString (readonly)

Returns The start date of the current streak period.

Returns:

  • (String)

    The start date of the current streak period.



16
17
18
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 16

def period_start
  @period_start
end

#startedString (readonly)

Returns The date the streak started.

Returns:

  • (String)

    The date the streak started.



14
15
16
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 14

def started
  @started
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::BaseStreakResponse

Deserialize a JSON object to an instance of BaseStreakResponse

Parameters:

  • json_object (String)

Returns:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 90

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  length = parsed_json["length"]
  frequency = parsed_json["frequency"]
  started = parsed_json["started"]
  period_start = parsed_json["periodStart"]
  period_end = parsed_json["periodEnd"]
  expires = parsed_json["expires"]
  freezes = parsed_json["freezes"]
  max_freezes = parsed_json["maxFreezes"]
  freeze_auto_earn_interval = parsed_json["freezeAutoEarnInterval"]
  freeze_auto_earn_amount = parsed_json["freezeAutoEarnAmount"]
  new(
    length: length,
    frequency: frequency,
    started: started,
    period_start: period_start,
    period_end: period_end,
    expires: expires,
    freezes: freezes,
    max_freezes: max_freezes,
    freeze_auto_earn_interval: freeze_auto_earn_interval,
    freeze_auto_earn_amount: freeze_auto_earn_amount,
    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)


131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 131

def self.validate_raw(obj:)
  obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.")
  obj.frequency.is_a?(TrophyApiClient::StreakFrequency) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.")
  obj.started&.is_a?(String) != false || raise("Passed value for field obj.started is not the expected type, validation failed.")
  obj.period_start&.is_a?(String) != false || raise("Passed value for field obj.period_start is not the expected type, validation failed.")
  obj.period_end&.is_a?(String) != false || raise("Passed value for field obj.period_end is not the expected type, validation failed.")
  obj.expires&.is_a?(String) != false || raise("Passed value for field obj.expires is not the expected type, validation failed.")
  obj.freezes&.is_a?(Integer) != false || raise("Passed value for field obj.freezes is not the expected type, validation failed.")
  obj.max_freezes&.is_a?(Integer) != false || raise("Passed value for field obj.max_freezes is not the expected type, validation failed.")
  obj.freeze_auto_earn_interval&.is_a?(Integer) != false || raise("Passed value for field obj.freeze_auto_earn_interval is not the expected type, validation failed.")
  obj.freeze_auto_earn_amount&.is_a?(Integer) != false || raise("Passed value for field obj.freeze_auto_earn_amount is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BaseStreakResponse to a JSON object

Returns:

  • (String)


121
122
123
# File 'lib/trophy_api_client/types/base_streak_response.rb', line 121

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