Class: Spaceship::ConnectAPI::AgeRatingDeclaration

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb

Defined Under Namespace

Modules: KidsAge, Rating

Constant Summary collapse

LEGACY_AGE_RATING_ITC_MAP =
{
  "CARTOON_FANTASY_VIOLENCE" => "violenceCartoonOrFantasy",
  "REALISTIC_VIOLENCE" => "violenceRealistic",
  "PROLONGED_GRAPHIC_SADISTIC_REALISTIC_VIOLENCE" => "violenceRealisticProlongedGraphicOrSadistic",
  "PROFANITY_CRUDE_HUMOR" => "profanityOrCrudeHumor",
  "MATURE_SUGGESTIVE" => "matureOrSuggestiveThemes",
  "HORROR" => "horrorOrFearThemes",
  "MEDICAL_TREATMENT_INFO" => "medicalOrTreatmentInformation",
  "ALCOHOL_TOBACCO_DRUGS" => "alcoholTobaccoOrDrugUseOrReferences",
  "GAMBLING" => "gamblingSimulated",
  "SEXUAL_CONTENT_NUDITY" => "sexualContentOrNudity",
  "GRAPHIC_SEXUAL_CONTENT_NUDITY" => "sexualContentGraphicAndNudity",
  "UNRESTRICTED_WEB_ACCESS" => "unrestrictedWebAccess",
  "GAMBLING_CONTESTS" => "gamblingAndContests"
}
LEGACY_RATING_VALUE_ITC_MAP =
{
  0 => Rating::NONE,
  1 => Rating::INFREQUENT_OR_MILD,
  2 => Rating::FREQUENT_OR_INTENSE
}
LEGACY_BOOLEAN_VALUE_ITC_MAP =
{
  0 => false,
  1 => true
}

Instance Attribute Summary collapse

Attributes included from Model

#id, #reverse_attr_map

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #reverse_attr_mapping, #to_json, #update_attributes

Instance Attribute Details

#alcohol_tobacco_or_drug_use_or_referencesObject

Rating



8
9
10
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 8

def alcohol_tobacco_or_drug_use_or_references
  @alcohol_tobacco_or_drug_use_or_references
end

#contestsObject

Returns the value of attribute contests.



9
10
11
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 9

def contests
  @contests
end

#gamblingObject

Boolean



22
23
24
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 22

def gambling
  @gambling
end

#gambling_and_contestsObject

Deprecated as of App Store Connect API 1.3



30
31
32
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 30

def gambling_and_contests
  @gambling_and_contests
end

#gambling_simulatedObject

Returns the value of attribute gambling_simulated.



10
11
12
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 10

def gambling_simulated
  @gambling_simulated
end

#horror_or_fear_themesObject

Returns the value of attribute horror_or_fear_themes.



15
16
17
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 15

def horror_or_fear_themes
  @horror_or_fear_themes
end

#kids_age_bandObject

KidsAge



27
28
29
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 27

def kids_age_band
  @kids_age_band
end

#mature_or_suggestive_themesObject

Returns the value of attribute mature_or_suggestive_themes.



16
17
18
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 16

def mature_or_suggestive_themes
  @mature_or_suggestive_themes
end

#medical_or_treatment_informationObject

Returns the value of attribute medical_or_treatment_information.



11
12
13
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 11

def medical_or_treatment_information
  @medical_or_treatment_information
end

#profanity_or_crude_humorObject

Returns the value of attribute profanity_or_crude_humor.



12
13
14
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 12

def profanity_or_crude_humor
  @profanity_or_crude_humor
end

#seventeen_plusObject

Returns the value of attribute seventeen_plus.



23
24
25
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 23

def seventeen_plus
  @seventeen_plus
end

#sexual_content_graphic_and_nudityObject

Returns the value of attribute sexual_content_graphic_and_nudity.



13
14
15
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 13

def sexual_content_graphic_and_nudity
  @sexual_content_graphic_and_nudity
end

#sexual_content_or_nudityObject

Returns the value of attribute sexual_content_or_nudity.



14
15
16
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 14

def sexual_content_or_nudity
  @sexual_content_or_nudity
end

#unrestricted_web_accessObject

Returns the value of attribute unrestricted_web_access.



24
25
26
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 24

def unrestricted_web_access
  @unrestricted_web_access
end

#violence_cartoon_or_fantasyObject

Returns the value of attribute violence_cartoon_or_fantasy.



17
18
19
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 17

def violence_cartoon_or_fantasy
  @violence_cartoon_or_fantasy
end

#violence_realisticObject

Returns the value of attribute violence_realistic.



19
20
21
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 19

def violence_realistic
  @violence_realistic
end

#violence_realistic_prolonged_graphic_or_sadisticObject

Returns the value of attribute violence_realistic_prolonged_graphic_or_sadistic.



18
19
20
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 18

def violence_realistic_prolonged_graphic_or_sadistic
  @violence_realistic_prolonged_graphic_or_sadistic
end

Class Method Details

.map_deprecation_if_possible(attributes) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 97

def self.map_deprecation_if_possible(attributes)
  attributes = attributes.dup
  messages = []
  errors = []

  value = attributes.delete('gamblingAndContests')
  return attributes, messages, errors if value.nil?

  messages << "Age Rating 'gamblingAndContests' has been deprecated and split into 'gambling' and 'contests'"

  attributes['gambling'] = value
  if value == true
    errors << "'gamblingAndContests' could not be mapped to 'contests' - 'contests' requires a value of 'NONE', 'INFREQUENT_OR_MILD', or 'FREQUENT_OR_INTENSE'"
    attributes['contests'] = value
  else
    attributes['contests'] = 'NONE'
  end

  return attributes, messages, errors
end

.map_key_from_itc(key) ⇒ Object



118
119
120
121
122
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 118

def self.map_key_from_itc(key)
  key = key.gsub("MZGenre.", "")
  return nil if key.empty?
  LEGACY_AGE_RATING_ITC_MAP[key] || key
end

.map_value_from_itc(key, value) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 124

def self.map_value_from_itc(key, value)
  if ["gamblingAndContests", "unrestrictedWebAccess"].include?(key)
    new_value = LEGACY_BOOLEAN_VALUE_ITC_MAP[value]
    return value if new_value.nil?
    return new_value
  else
    return LEGACY_RATING_VALUE_ITC_MAP[value] || value
  end

  return value
end

.typeObject



66
67
68
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 66

def self.type
  return "ageRatingDeclarations"
end

Instance Method Details

#update(client: nil, attributes: nil) ⇒ Object

API



140
141
142
143
144
# File 'spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb', line 140

def update(client: nil, attributes: nil)
  client ||= Spaceship::ConnectAPI
  attributes = reverse_attr_mapping(attributes)
  client.patch_age_rating_declaration(age_rating_declaration_id: id, attributes: attributes)
end