Class: TrophyApiClient::PatchPointsTriggersRequestItem

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type: OMIT, points: OMIT, status: OMIT, user_attributes: OMIT, metric_id: OMIT, metric_threshold: OMIT, event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, block_if_out_of_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PatchPointsTriggersRequestItem

Parameters:

  • id (String)

    The UUID of the trigger to update.

  • type (TrophyApiClient::PatchPointsTriggersRequestItemType) (defaults to: OMIT)

    Updated trigger type. Can only be changed when the trigger is inactive. Required fields for the new type must be provided.

  • points (Integer) (defaults to: OMIT)

    Updated points value.

  • status (TrophyApiClient::PatchPointsTriggersRequestItemStatus) (defaults to: OMIT)

    Updated status.

  • user_attributes (Array<TrophyApiClient::PatchPointsTriggersRequestItemUserAttributesItem>) (defaults to: OMIT)

    Updated user attribute filters. Set to null to clear.

  • metric_id (String) (defaults to: OMIT)

    Updated metric ID. Only permitted for metric triggers.

  • metric_threshold (Integer) (defaults to: OMIT)

    Updated metric threshold. Only permitted for metric triggers.

  • event_attributes (Array<TrophyApiClient::PatchPointsTriggersRequestItemEventAttributesItem>) (defaults to: OMIT)

    Updated event attribute filters. Only permitted for metric triggers. Set to null to clear.

  • achievement_id (String) (defaults to: OMIT)

    Updated achievement ID. Only permitted for achievement triggers.

  • streak_length (Integer) (defaults to: OMIT)

    Updated streak length. Only permitted for streak triggers.

  • time_unit (TrophyApiClient::PatchPointsTriggersRequestItemTimeUnit) (defaults to: OMIT)

    Updated time unit. Only permitted for time triggers.

  • time_interval (Integer) (defaults to: OMIT)

    Updated time interval. Only permitted for time triggers.

  • block_if_out_of_points (Boolean) (defaults to: OMIT)

    Updated block-if-out-of-points setting.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 66

def initialize(id:, type: OMIT, points: OMIT, status: OMIT, user_attributes: OMIT, metric_id: OMIT,
               metric_threshold: OMIT, event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, block_if_out_of_points: OMIT, additional_properties: nil)
  @id = id
  @type = type if type != OMIT
  @points = points if points != OMIT
  @status = status if status != OMIT
  @user_attributes = user_attributes if user_attributes != OMIT
  @metric_id = metric_id if metric_id != OMIT
  @metric_threshold = metric_threshold if metric_threshold != OMIT
  @event_attributes = event_attributes if event_attributes != OMIT
  @achievement_id = achievement_id if achievement_id != OMIT
  @streak_length = streak_length if streak_length != OMIT
  @time_unit = time_unit if time_unit != OMIT
  @time_interval = time_interval if time_interval != OMIT
  @block_if_out_of_points = block_if_out_of_points if block_if_out_of_points != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "type": type,
    "points": points,
    "status": status,
    "userAttributes": user_attributes,
    "metricId": metric_id,
    "metricThreshold": metric_threshold,
    "eventAttributes": event_attributes,
    "achievementId": achievement_id,
    "streakLength": streak_length,
    "timeUnit": time_unit,
    "timeInterval": time_interval,
    "blockIfOutOfPoints": block_if_out_of_points
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#achievement_idString (readonly)

Returns Updated achievement ID. Only permitted for achievement triggers.

Returns:

  • (String)

    Updated achievement ID. Only permitted for achievement triggers.



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

def achievement_id
  @achievement_id
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



42
43
44
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 42

def additional_properties
  @additional_properties
end

#block_if_out_of_pointsBoolean (readonly)

Returns Updated block-if-out-of-points setting.

Returns:

  • (Boolean)

    Updated block-if-out-of-points setting.



40
41
42
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 40

def block_if_out_of_points
  @block_if_out_of_points
end

#event_attributesArray<TrophyApiClient::PatchPointsTriggersRequestItemEventAttributesItem> (readonly)

Returns Updated event attribute filters. Only permitted for metric triggers. Set to null to clear.

Returns:



30
31
32
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 30

def event_attributes
  @event_attributes
end

#idString (readonly)

Returns The UUID of the trigger to update.

Returns:

  • (String)

    The UUID of the trigger to update.



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

def id
  @id
end

#metric_idString (readonly)

Returns Updated metric ID. Only permitted for metric triggers.

Returns:

  • (String)

    Updated metric ID. Only permitted for metric triggers.



25
26
27
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 25

def metric_id
  @metric_id
end

#metric_thresholdInteger (readonly)

Returns Updated metric threshold. Only permitted for metric triggers.

Returns:

  • (Integer)

    Updated metric threshold. Only permitted for metric triggers.



27
28
29
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 27

def metric_threshold
  @metric_threshold
end

#pointsInteger (readonly)

Returns Updated points value.

Returns:

  • (Integer)

    Updated points value.



19
20
21
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 19

def points
  @points
end

#statusTrophyApiClient::PatchPointsTriggersRequestItemStatus (readonly)

Returns Updated status.



21
22
23
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 21

def status
  @status
end

#streak_lengthInteger (readonly)

Returns Updated streak length. Only permitted for streak triggers.

Returns:

  • (Integer)

    Updated streak length. Only permitted for streak triggers.



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

def streak_length
  @streak_length
end

#time_intervalInteger (readonly)

Returns Updated time interval. Only permitted for time triggers.

Returns:

  • (Integer)

    Updated time interval. Only permitted for time triggers.



38
39
40
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 38

def time_interval
  @time_interval
end

#time_unitTrophyApiClient::PatchPointsTriggersRequestItemTimeUnit (readonly)

Returns Updated time unit. Only permitted for time triggers.

Returns:



36
37
38
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 36

def time_unit
  @time_unit
end

#typeTrophyApiClient::PatchPointsTriggersRequestItemType (readonly)

Returns Updated trigger type. Can only be changed when the trigger is inactive. Required fields for the new type must be provided.

Returns:



17
18
19
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 17

def type
  @type
end

#user_attributesArray<TrophyApiClient::PatchPointsTriggersRequestItemUserAttributesItem> (readonly)

Returns Updated user attribute filters. Set to null to clear.

Returns:



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

def user_attributes
  @user_attributes
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PatchPointsTriggersRequestItem

Deserialize a JSON object to an instance of PatchPointsTriggersRequestItem

Parameters:

  • json_object (String)

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 105

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  type = parsed_json["type"]
  points = parsed_json["points"]
  status = parsed_json["status"]
  user_attributes = parsed_json["userAttributes"]&.map do |item|
    item = item.to_json
    TrophyApiClient::PatchPointsTriggersRequestItemUserAttributesItem.from_json(json_object: item)
  end
  metric_id = parsed_json["metricId"]
  metric_threshold = parsed_json["metricThreshold"]
  event_attributes = parsed_json["eventAttributes"]&.map do |item|
    item = item.to_json
    TrophyApiClient::PatchPointsTriggersRequestItemEventAttributesItem.from_json(json_object: item)
  end
  achievement_id = parsed_json["achievementId"]
  streak_length = parsed_json["streakLength"]
  time_unit = parsed_json["timeUnit"]
  time_interval = parsed_json["timeInterval"]
  block_if_out_of_points = parsed_json["blockIfOutOfPoints"]
  new(
    id: id,
    type: type,
    points: points,
    status: status,
    user_attributes: user_attributes,
    metric_id: metric_id,
    metric_threshold: metric_threshold,
    event_attributes: event_attributes,
    achievement_id: achievement_id,
    streak_length: streak_length,
    time_unit: time_unit,
    time_interval: time_interval,
    block_if_out_of_points: block_if_out_of_points,
    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)


158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 158

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.type&.is_a?(TrophyApiClient::PatchPointsTriggersRequestItemType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.points&.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
  obj.status&.is_a?(TrophyApiClient::PatchPointsTriggersRequestItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
  obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
  obj.metric_threshold&.is_a?(Integer) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.")
  obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
  obj.achievement_id&.is_a?(String) != false || raise("Passed value for field obj.achievement_id is not the expected type, validation failed.")
  obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
  obj.time_unit&.is_a?(TrophyApiClient::PatchPointsTriggersRequestItemTimeUnit) != false || raise("Passed value for field obj.time_unit is not the expected type, validation failed.")
  obj.time_interval&.is_a?(Integer) != false || raise("Passed value for field obj.time_interval is not the expected type, validation failed.")
  obj.block_if_out_of_points&.is_a?(Boolean) != false || raise("Passed value for field obj.block_if_out_of_points is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PatchPointsTriggersRequestItem to a JSON object

Returns:

  • (String)


148
149
150
# File 'lib/trophy_api_client/types/patch_points_triggers_request_item.rb', line 148

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