Class: TrophyApiClient::NotificationPreferences

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

Overview

Notification preferences for each notification type.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(achievement_completed: OMIT, recap: OMIT, reactivation: OMIT, streak_reminder: OMIT, additional_properties: nil) ⇒ TrophyApiClient::NotificationPreferences

Parameters:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 32

def initialize(achievement_completed: OMIT, recap: OMIT, reactivation: OMIT, streak_reminder: OMIT,
               additional_properties: nil)
  @achievement_completed = achievement_completed if achievement_completed != OMIT
  @recap = recap if recap != OMIT
  @reactivation = reactivation if reactivation != OMIT
  @streak_reminder = streak_reminder if streak_reminder != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "achievement_completed": achievement_completed,
    "recap": recap,
    "reactivation": reactivation,
    "streak_reminder": streak_reminder
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#achievement_completedArray<TrophyApiClient::NotificationChannel> (readonly)

Returns Channels to receive achievement completion notifications on.

Returns:



11
12
13
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 11

def achievement_completed
  @achievement_completed
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#reactivationArray<TrophyApiClient::NotificationChannel> (readonly)

Returns Channels to receive reactivation notifications on.

Returns:



15
16
17
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 15

def reactivation
  @reactivation
end

#recapArray<TrophyApiClient::NotificationChannel> (readonly)

Returns Channels to receive recap notifications on.

Returns:



13
14
15
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 13

def recap
  @recap
end

#streak_reminderArray<TrophyApiClient::NotificationChannel> (readonly)

Returns Channels to receive streak reminder notifications on.

Returns:



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

def streak_reminder
  @streak_reminder
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::NotificationPreferences

Deserialize a JSON object to an instance of NotificationPreferences

Parameters:

  • json_object (String)

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 53

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  achievement_completed = parsed_json["achievement_completed"]
  recap = parsed_json["recap"]
  reactivation = parsed_json["reactivation"]
  streak_reminder = parsed_json["streak_reminder"]
  new(
    achievement_completed: achievement_completed,
    recap: recap,
    reactivation: reactivation,
    streak_reminder: streak_reminder,
    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)


82
83
84
85
86
87
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 82

def self.validate_raw(obj:)
  obj.achievement_completed&.is_a?(Array) != false || raise("Passed value for field obj.achievement_completed is not the expected type, validation failed.")
  obj.recap&.is_a?(Array) != false || raise("Passed value for field obj.recap is not the expected type, validation failed.")
  obj.reactivation&.is_a?(Array) != false || raise("Passed value for field obj.reactivation is not the expected type, validation failed.")
  obj.streak_reminder&.is_a?(Array) != false || raise("Passed value for field obj.streak_reminder is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of NotificationPreferences to a JSON object

Returns:

  • (String)


72
73
74
# File 'lib/trophy_api_client/types/notification_preferences.rb', line 72

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