fastlane 2.149.1 → 2.150.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/deliver/lib/deliver.rb +0 -1
  3. data/deliver/lib/deliver/app_screenshot.rb +26 -25
  4. data/deliver/lib/deliver/options.rb +6 -11
  5. data/deliver/lib/deliver/runner.rb +7 -4
  6. data/deliver/lib/deliver/setup.rb +5 -30
  7. data/deliver/lib/deliver/submit_for_review.rb +124 -87
  8. data/deliver/lib/deliver/upload_metadata.rb +284 -143
  9. data/deliver/lib/deliver/upload_price_tier.rb +15 -8
  10. data/deliver/lib/deliver/upload_screenshots.rb +86 -37
  11. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
  12. data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +3 -11
  13. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +3 -2
  14. data/fastlane/lib/fastlane/actions/download_dsyms.rb +7 -1
  15. data/fastlane/lib/fastlane/actions/google_play_track_release_names.rb +74 -0
  16. data/fastlane/lib/fastlane/actions/slack.rb +1 -1
  17. data/fastlane/lib/fastlane/actions/spm.rb +7 -0
  18. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +1 -32
  19. data/fastlane/lib/fastlane/lane.rb +3 -3
  20. data/fastlane/lib/fastlane/swift_fastlane_function.rb +8 -4
  21. data/fastlane/lib/fastlane/version.rb +1 -1
  22. data/fastlane/swift/ControlCommand.swift +1 -0
  23. data/fastlane/swift/Fastlane.swift +48 -12
  24. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/xcshareddata/xcschemes/FastlaneRunner.xcscheme +3 -9
  25. data/fastlane/swift/LaneFileProtocol.swift +2 -5
  26. data/fastlane/swift/MatchfileProtocol.swift +1 -1
  27. data/fastlane/swift/RubyCommand.swift +29 -6
  28. data/fastlane/swift/RubyCommandable.swift +1 -0
  29. data/fastlane/swift/Runner.swift +85 -13
  30. data/fastlane/swift/ScanfileProtocol.swift +1 -1
  31. data/fastlane/swift/SnapshotfileProtocol.swift +3 -3
  32. data/fastlane/swift/SocketClient.swift +76 -45
  33. data/fastlane/swift/SocketClientDelegateProtocol.swift +1 -1
  34. data/fastlane/swift/SocketResponse.swift +1 -0
  35. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +1 -3
  36. data/fastlane_core/lib/fastlane_core/pkg_file_analyser.rb +7 -0
  37. data/frameit/lib/frameit/device_types.rb +100 -100
  38. data/produce/lib/produce/itunes_connect.rb +20 -20
  39. data/produce/lib/produce/options.rb +3 -3
  40. data/sigh/lib/assets/resign.sh +7 -7
  41. data/snapshot/lib/assets/SnapshotHelper.swift +5 -5
  42. data/snapshot/lib/assets/SnapshotHelperXcode8.swift +3 -3
  43. data/snapshot/lib/snapshot/options.rb +0 -1
  44. data/snapshot/lib/snapshot/reports_generator.rb +8 -1
  45. data/spaceship/lib/spaceship/.DS_Store +0 -0
  46. data/spaceship/lib/spaceship/connect_api.rb +21 -2
  47. data/spaceship/lib/spaceship/connect_api/client.rb +47 -11
  48. data/spaceship/lib/spaceship/connect_api/model.rb +1 -1
  49. data/spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb +109 -0
  50. data/spaceship/lib/spaceship/connect_api/models/app.rb +113 -3
  51. data/spaceship/lib/spaceship/connect_api/models/app_category.rb +94 -0
  52. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +74 -0
  53. data/spaceship/lib/spaceship/connect_api/models/app_info_localization.rb +38 -0
  54. data/spaceship/lib/spaceship/connect_api/models/app_price.rb +22 -0
  55. data/spaceship/lib/spaceship/connect_api/models/app_price_tier.rb +12 -0
  56. data/spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb +81 -0
  57. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +117 -0
  58. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +101 -0
  59. data/spaceship/lib/spaceship/connect_api/models/app_store_review_detail.rb +51 -0
  60. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +182 -0
  61. data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +70 -0
  62. data/spaceship/lib/spaceship/connect_api/models/app_store_version_phased_release.rb +36 -0
  63. data/spaceship/lib/spaceship/connect_api/models/app_store_version_submission.rb +26 -0
  64. data/spaceship/lib/spaceship/connect_api/models/build.rb +4 -0
  65. data/spaceship/lib/spaceship/connect_api/models/idfa_declaration.rb +40 -0
  66. data/spaceship/lib/spaceship/connect_api/models/reset_ratings_request.rb +26 -0
  67. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +10 -3
  68. data/spaceship/lib/spaceship/connect_api/tunes/client.rb +33 -0
  69. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +703 -0
  70. data/spaceship/lib/spaceship/spaceauth_runner.rb +2 -2
  71. data/supply/lib/supply/client.rb +19 -0
  72. data/supply/lib/supply/reader.rb +16 -0
  73. metadata +27 -24
  74. data/deliver/lib/deliver/upload_assets.rb +0 -27
  75. data/scan/lib/scan/.test_command_generator.rb.swp +0 -0
  76. data/snapshot/lib/snapshot/.test_command_generator_base.rb.swp +0 -0
@@ -1,7 +1,7 @@
1
1
  require 'spaceship'
2
2
  require 'spaceship/tunes/tunes'
3
+ require 'fastlane_core/languages'
3
4
  require_relative 'module'
4
- require_relative 'available_default_languages'
5
5
 
6
6
  module Produce
7
7
  class ItunesConnect
@@ -18,24 +18,27 @@ module Produce
18
18
  def create_new_app
19
19
  application = fetch_application
20
20
  if application
21
- UI.success("App '#{Produce.config[:app_identifier]}' already exists (#{application.apple_id}), nothing to do on App Store Connect")
21
+ UI.success("App '#{Produce.config[:app_identifier]}' already exists (#{application.id}), nothing to do on App Store Connect")
22
22
  # Nothing to do here
23
23
  else
24
24
  UI.success("Creating new app '#{Produce.config[:app_name]}' on App Store Connect")
25
25
 
26
26
  platforms = Produce.config[:platforms] || [Produce.config[:platform]]
27
27
 
28
- Produce.config[:bundle_identifier_suffix] = '' unless wildcard_bundle?
29
- generated_app = Spaceship::Tunes::Application.create!(name: Produce.config[:app_name],
30
- primary_language: language,
31
- sku: Produce.config[:sku].to_s, # might be an int
32
- bundle_id: app_identifier,
33
- bundle_id_suffix: Produce.config[:bundle_identifier_suffix],
34
- company_name: Produce.config[:company_name],
35
- platforms: platforms,
36
- itunes_connect_users: Produce.config[:itc_users])
28
+ platforms = platforms.map do |platform|
29
+ Spaceship::ConnectAPI::Platform.map(platform)
30
+ end
37
31
 
38
- UI.crash!("Something went wrong when creating the new app on iTC") if generated_app["adamId"].to_s.empty?
32
+ # Produce.config[:company_name]
33
+ # Produce.config[:itc_users]
34
+ application = Spaceship::ConnectAPI::App.create(
35
+ name: Produce.config[:app_name],
36
+ version_string: Produce.config[:app_version] || "1.0",
37
+ sku: Produce.config[:sku].to_s,
38
+ primary_locale: language,
39
+ bundle_id: app_identifier,
40
+ platforms: platforms
41
+ )
39
42
 
40
43
  application = fetch_application
41
44
  counter = 0
@@ -57,10 +60,10 @@ module Produce
57
60
  application.ensure_version!(Produce.config[:app_version], platform: platform) if Produce.config[:app_version]
58
61
  end
59
62
 
60
- UI.success("Successfully created new app '#{Produce.config[:app_name]}' on App Store Connect with ID #{application.apple_id}")
63
+ UI.success("Successfully created new app '#{Produce.config[:app_name]}' on App Store Connect with ID #{application.id}")
61
64
  end
62
65
 
63
- return Spaceship::Tunes::Application.find(@full_bundle_identifier, mac: platform == "osx").apple_id
66
+ return application.id
64
67
  end
65
68
 
66
69
  private
@@ -70,7 +73,7 @@ module Produce
70
73
  end
71
74
 
72
75
  def fetch_application
73
- Spaceship::Tunes::Application.find(@full_bundle_identifier)
76
+ Spaceship::ConnectAPI::App.find(@full_bundle_identifier)
74
77
  end
75
78
 
76
79
  def wildcard_bundle?
@@ -87,11 +90,8 @@ module Produce
87
90
  def language
88
91
  @language = Produce.config[:language]
89
92
 
90
- converted = Spaceship::Tunes::LanguageConverter.from_itc_readable_to_itc(@language)
91
- @language = converted if converted # overwrite it with the actual value
92
-
93
- unless AvailableDefaultLanguages.all_languages.include?(@language)
94
- UI.user_error!("Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}")
93
+ unless FastlaneCore::Languages::ALL_LANGUAGES.include?(@language)
94
+ UI.user_error!("Please enter one of available languages: #{FastlaneCore::Languages::ALL_LANGUAGES}")
95
95
  end
96
96
 
97
97
  return @language
@@ -54,7 +54,7 @@ module Produce
54
54
  optional: true,
55
55
  default_value: "ios",
56
56
  verify_block: proc do |value|
57
- UI.user_error!("The platform can only be ios or osx") unless %('ios', 'osx').include?(value)
57
+ UI.user_error!("The platform can only be ios or osx") unless %('ios', 'osx', 'tvos').include?(value)
58
58
  end),
59
59
  FastlaneCore::ConfigItem.new(key: :platforms,
60
60
  short_option: "-J",
@@ -64,13 +64,13 @@ module Produce
64
64
  optional: true,
65
65
  type: Array,
66
66
  verify_block: proc do |values|
67
- types = %w(ios osx)
67
+ types = %w(ios osx tvos)
68
68
  UI.user_error!("The platform can only be #{types}") unless (values - types).empty?
69
69
  end),
70
70
  FastlaneCore::ConfigItem.new(key: :language,
71
71
  short_option: "-m",
72
72
  env_name: "PRODUCE_LANGUAGE",
73
- description: "Primary Language (e.g. 'English', 'German')",
73
+ description: "Primary Language (e.g. 'en-US', 'fr-FR')",
74
74
  default_value: "English",
75
75
  verify_block: proc do |language|
76
76
  end),
@@ -620,7 +620,7 @@ function resign {
620
620
  # Start with using what comes in provisioning profile entitlements before patching
621
621
  cp -f "$PROFILE_ENTITLEMENTS" "$PATCHED_ENTITLEMENTS"
622
622
 
623
- log "Removing blacklisted keys from patched profile"
623
+ log "Removing denylisted keys from patched profile"
624
624
  # See https://github.com/facebook/buck/issues/798 and https://github.com/facebook/buck/pull/802/files
625
625
 
626
626
  # Update in https://github.com/facebook/buck/commit/99c0fbc3ab5ecf04d186913374f660683deccdef
@@ -628,7 +628,7 @@ function resign {
628
628
 
629
629
  # Buck changes referenced above are not self-explanatory and do not seem exhaustive or up-to-date
630
630
  # Comments below explain the rules applied to each key in order to make realignment with future Xcode export logic easier
631
- BLACKLISTED_KEYS=(\
631
+ DENYLISTED_KEYS=(\
632
632
  # PP list identifiers inconsistent with app-defined ones and this key does not seem to appear in IPA entitlements, so ignore it
633
633
  "com.apple.developer.icloud-container-development-container-identifiers" \
634
634
  # This key has an invalid generic value in PP (actual value is set by Xcode during export), see dedicated processing a few blocks below
@@ -637,7 +637,7 @@ function resign {
637
637
  "com.apple.developer.icloud-container-identifiers" \
638
638
  # PP enable all available services and not app-defined ones, must use App entitlements value
639
639
  "com.apple.developer.icloud-services" \
640
- # Was already blacklisted in previous version, but has someone ever seen this key in a PP?
640
+ # Was already denylisted in previous version, but has someone ever seen this key in a PP?
641
641
  "com.apple.developer.restricted-resource-mode" \
642
642
  # If actually used by the App, this value will be set in its entitlements
643
643
  "com.apple.developer.nfc.readersession.formats" \
@@ -675,15 +675,15 @@ function resign {
675
675
  "com.apple.developer.default-data-protection" \
676
676
  # PP seem to list the same groups as the App, but use App entitlements value to be sure
677
677
  "com.apple.security.application-groups" \
678
- # Was already blacklisted in previous version, seems to be an artifact from an old Xcode release
678
+ # Was already denylisted in previous version, seems to be an artifact from an old Xcode release
679
679
  "com.apple.developer.maps" \
680
680
  # If actually used by the App, this value will be set in its entitlements
681
681
  "com.apple.external-accessory.wireless-configuration"
682
682
  )
683
683
 
684
- # Blacklisted keys must not be included into new profile, so remove them from patched profile
685
- for KEY in "${BLACKLISTED_KEYS[@]}"; do
686
- log "Removing blacklisted key: $KEY"
684
+ # Denylisted keys must not be included into new profile, so remove them from patched profile
685
+ for KEY in "${DENYLISTED_KEYS[@]}"; do
686
+ log "Removing denylisted key: $KEY"
687
687
  PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
688
688
  done
689
689
 
@@ -218,7 +218,7 @@ open class Snapshot: NSObject {
218
218
 
219
219
  private extension XCUIElementAttributes {
220
220
  var isNetworkLoadingIndicator: Bool {
221
- if hasWhiteListedIdentifier { return false }
221
+ if hasAllowListedIdentifier { return false }
222
222
 
223
223
  let hasOldLoadingIndicatorSize = frame.size == CGSize(width: 10, height: 20)
224
224
  let hasNewLoadingIndicatorSize = frame.size.width.isBetween(46, and: 47) && frame.size.height.isBetween(2, and: 3)
@@ -226,10 +226,10 @@ private extension XCUIElementAttributes {
226
226
  return hasOldLoadingIndicatorSize || hasNewLoadingIndicatorSize
227
227
  }
228
228
 
229
- var hasWhiteListedIdentifier: Bool {
230
- let whiteListedIdentifiers = ["GeofenceLocationTrackingOn", "StandardLocationTrackingOn"]
229
+ var hasAllowListedIdentifier: Bool {
230
+ let allowListedIdentifiers = ["GeofenceLocationTrackingOn", "StandardLocationTrackingOn"]
231
231
 
232
- return whiteListedIdentifiers.contains(identifier)
232
+ return allowListedIdentifiers.contains(identifier)
233
233
  }
234
234
 
235
235
  func isStatusBar(_ deviceWidth: CGFloat) -> Bool {
@@ -279,4 +279,4 @@ private extension CGFloat {
279
279
 
280
280
  // Please don't remove the lines below
281
281
  // They are used to detect outdated configuration files
282
- // SnapshotHelperVersion [1.22]
282
+ // SnapshotHelperVersion [1.23]
@@ -159,8 +159,8 @@ open class Snapshot: NSObject {
159
159
 
160
160
  extension XCUIElement {
161
161
  var isLoadingIndicator: Bool {
162
- let whiteListedLoaders = ["GeofenceLocationTrackingOn", "StandardLocationTrackingOn"]
163
- if whiteListedLoaders.contains(self.identifier) {
162
+ let allowListedLoaders = ["GeofenceLocationTrackingOn", "StandardLocationTrackingOn"]
163
+ if allowListedLoaders.contains(self.identifier) {
164
164
  return false
165
165
  }
166
166
  return self.frame.size == CGSize(width: 10, height: 20)
@@ -169,4 +169,4 @@ extension XCUIElement {
169
169
 
170
170
  // Please don't remove the lines below
171
171
  // They are used to detect outdated configuration files
172
- // SnapshotHelperXcode8Version [1.4]
172
+ // SnapshotHelperXcode8Version [1.5]
@@ -156,7 +156,6 @@ module Snapshot
156
156
  env_name: 'SNAPSHOT_HTML_TEMPLATE',
157
157
  short_option: "-e",
158
158
  description: "A path to screenshots.html template",
159
- default_value: File.join(Snapshot::ROOT, "lib", "snapshot/page.html.erb"),
160
159
  optional: true),
161
160
 
162
161
  # Everything around building
@@ -5,6 +5,14 @@ module Snapshot
5
5
  require 'erb'
6
6
  require 'fastimage'
7
7
 
8
+ def html_path
9
+ if Snapshot.config[:html_template]
10
+ Snapshot.config[:html_template]
11
+ else
12
+ File.join(Snapshot::ROOT, "lib", "snapshot/page.html.erb")
13
+ end
14
+ end
15
+
8
16
  def generate
9
17
  UI.message("Generating HTML Report")
10
18
 
@@ -36,7 +44,6 @@ module Snapshot
36
44
  end
37
45
  end
38
46
 
39
- html_path = Snapshot.config[:html_template]
40
47
  html = ERB.new(File.read(html_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
41
48
 
42
49
  export_path = "#{screens_path}/screenshots.html"
@@ -5,6 +5,7 @@ require 'spaceship/connect_api/token'
5
5
  require 'spaceship/connect_api/provisioning/provisioning'
6
6
  require 'spaceship/connect_api/testflight/testflight'
7
7
  require 'spaceship/connect_api/users/users'
8
+ require 'spaceship/connect_api/tunes/tunes'
8
9
 
9
10
  require 'spaceship/connect_api/models/bundle_id_capability'
10
11
  require 'spaceship/connect_api/models/bundle_id'
@@ -30,11 +31,29 @@ require 'spaceship/connect_api/models/build_delivery'
30
31
  require 'spaceship/connect_api/models/build_beta_detail'
31
32
  require 'spaceship/connect_api/models/pre_release_version'
32
33
 
34
+ require 'spaceship/connect_api/models/age_rating_declaration'
35
+ require 'spaceship/connect_api/models/app_category'
36
+ require 'spaceship/connect_api/models/app_info'
37
+ require 'spaceship/connect_api/models/app_info_localization'
38
+ require 'spaceship/connect_api/models/app_price'
39
+ require 'spaceship/connect_api/models/app_price_tier'
40
+ require 'spaceship/connect_api/models/app_review_attachment'
41
+ require 'spaceship/connect_api/models/app_store_review_detail'
42
+ require 'spaceship/connect_api/models/app_store_version_submission'
43
+ require 'spaceship/connect_api/models/app_screenshot_set'
44
+ require 'spaceship/connect_api/models/app_screenshot'
45
+ require 'spaceship/connect_api/models/app_store_version_localization'
46
+ require 'spaceship/connect_api/models/app_store_version_phased_release'
47
+ require 'spaceship/connect_api/models/app_store_version'
48
+ require 'spaceship/connect_api/models/idfa_declaration'
49
+ require 'spaceship/connect_api/models/reset_ratings_request'
50
+
33
51
  module Spaceship
34
52
  class ConnectAPI
35
53
  extend Spaceship::ConnectAPI::Provisioning
36
54
  extend Spaceship::ConnectAPI::TestFlight
37
55
  extend Spaceship::ConnectAPI::Users
56
+ extend Spaceship::ConnectAPI::Tunes
38
57
 
39
58
  @token = nil
40
59
 
@@ -63,9 +82,9 @@ module Spaceship
63
82
 
64
83
  # Map from fastlane input and Spaceship::TestFlight platform values
65
84
  case platform.to_sym
66
- when :appletvos
85
+ when :appletvos, :tvos
67
86
  return Spaceship::ConnectAPI::Platform::TV_OS
68
- when :osx
87
+ when :osx, :macos
69
88
  return Spaceship::ConnectAPI::Platform::MAC_OS
70
89
  when :ios
71
90
  return Spaceship::ConnectAPI::Platform::IOS
@@ -141,21 +141,57 @@ module Spaceship
141
141
  def handle_errors(response)
142
142
  # Example error format
143
143
  # {
144
- # "errors" : [ {
145
- # "id" : "ce8c391e-f858-411b-a14b-5aa26e0915f2",
146
- # "status" : "400",
147
- # "code" : "PARAMETER_ERROR.INVALID",
148
- # "title" : "A parameter has an invalid value",
149
- # "detail" : "'uploadedDate3' is not a valid field name",
150
- # "source" : {
151
- # "parameter" : "sort"
144
+ # "errors":[
145
+ # {
146
+ # "id":"cbfd8674-4802-4857-bfe8-444e1ea36e32",
147
+ # "status":"409",
148
+ # "code":"STATE_ERROR",
149
+ # "title":"The request cannot be fulfilled because of the state of another resource.",
150
+ # "detail":"Submit for review errors found.",
151
+ # "meta":{
152
+ # "associatedErrors":{
153
+ # "/v1/appScreenshots/":[
154
+ # {
155
+ # "id":"23d1734f-b81f-411a-98e4-6d3e763d54ed",
156
+ # "status":"409",
157
+ # "code":"STATE_ERROR.SCREENSHOT_REQUIRED.APP_WATCH_SERIES_4",
158
+ # "title":"App screenshot missing (APP_WATCH_SERIES_4)."
159
+ # },
160
+ # {
161
+ # "id":"db993030-0a93-48e9-9fd7-7e5676633431",
162
+ # "status":"409",
163
+ # "code":"STATE_ERROR.SCREENSHOT_REQUIRED.APP_WATCH_SERIES_4",
164
+ # "title":"App screenshot missing (APP_WATCH_SERIES_4)."
165
+ # }
166
+ # ],
167
+ # "/v1/builds/d710b6fa-5235-4fe4-b791-2b80d6818db0":[
168
+ # {
169
+ # "id":"e421fe6f-0e3b-464b-89dc-ba437e7bb77d",
170
+ # "status":"409",
171
+ # "code":"ENTITY_ERROR.ATTRIBUTE.REQUIRED",
172
+ # "title":"The provided entity is missing a required attribute",
173
+ # "detail":"You must provide a value for the attribute 'usesNonExemptEncryption' with this request",
174
+ # "source":{
175
+ # "pointer":"/data/attributes/usesNonExemptEncryption"
176
+ # }
177
+ # }
178
+ # ]
179
+ # }
180
+ # }
152
181
  # }
153
- # } ]
182
+ # ]
154
183
  # }
155
184
 
156
185
  return response.body['errors'].map do |error|
157
- "#{error['title']} - #{error['detail']}"
158
- end.join(" ")
186
+ messages = [[error['title'], error['detail']].compact.join(" - ")]
187
+
188
+ meta = error["meta"] || {}
189
+ associated_errors = meta["associatedErrors"] || {}
190
+
191
+ messages + associated_errors.values.flatten.map do |associated_error|
192
+ [[associated_error["title"], associated_error["detail"]].compact.join(" - ")]
193
+ end
194
+ end.flatten.join("\n")
159
195
  end
160
196
 
161
197
  private
@@ -15,7 +15,7 @@ module Spaceship
15
15
  end
16
16
 
17
17
  def update_attributes(attributes)
18
- attributes.each do |key, value|
18
+ (attributes || []).each do |key, value|
19
19
  method = "#{key}=".to_sym
20
20
  self.send(method, value) if self.respond_to?(method)
21
21
  end
@@ -0,0 +1,109 @@
1
+ require_relative '../model'
2
+ module Spaceship
3
+ class ConnectAPI
4
+ class AgeRatingDeclaration
5
+ include Spaceship::ConnectAPI::Model
6
+
7
+ # Rating
8
+ attr_accessor :alcohol_tobacco_or_drug_use_or_references
9
+ attr_accessor :gambling_simulated
10
+ attr_accessor :medical_or_treatment_information
11
+ attr_accessor :profanity_or_crude_humor
12
+ attr_accessor :sexual_content_graphic_and_nudity
13
+ attr_accessor :horror_or_fear_themes
14
+ attr_accessor :mature_or_suggestive_themes
15
+ attr_accessor :violence_cartoon_or_fantasy
16
+ attr_accessor :violence_realistic_prolonged_graphic_or_sadistic
17
+ attr_accessor :violence_realistic
18
+
19
+ # boolean
20
+ attr_accessor :gambling_and_contests
21
+ attr_accessor :unrestricted_web_access
22
+
23
+ # KidsAge
24
+ attr_accessor :kids_age_band
25
+
26
+ module Rating
27
+ NONE = "NONE"
28
+ INFREQUENT_OR_MILD = "INFREQUENT_OR_MILD"
29
+ FREQUENT_OR_INTENSE = "FREQUENT_OR_INTENSE"
30
+ end
31
+
32
+ module KidsAge
33
+ FIVE_AND_UNDER = "FIVE_AND_UNDER"
34
+ SIX_TO_EIGHT = "SIX_TO_EIGHT"
35
+ NINE_TO_ELEVEN = "NINE_TO_ELEVEN"
36
+ end
37
+
38
+ attr_mapping({
39
+ "alcoholTobaccoOrDrugUseOrReferences" => "alcohol_tobacco_or_drug_use_or_references",
40
+ "gamblingAndContests" => "gambling_and_contests",
41
+ "gamblingSimulated" => "gambling_simulated",
42
+ "medicalOrTreatmentInformation" => "medical_or_treatment_information",
43
+ "profanityOrCrudeHumor" => "profanity_or_crude_humor",
44
+ "sexualContentGraphicAndNudity" => "sexual_content_graphic_and_nudity",
45
+ "sexualContentOrNudity" => "sexual_content_or_nudity",
46
+ "horrorOrFearThemes" => "horror_or_fear_themes",
47
+ "matureOrSuggestiveThemes" => "mature_or_suggestive_themes",
48
+ "unrestrictedWebAccess" => "unrestricted_web_access",
49
+ "violenceCartoonOrFantasy" => "violence_cartoon_or_fantasy",
50
+ "violenceRealisticProlongedGraphicOrSadistic" => "violence_realistic_prolonged_graphic_or_sadistic",
51
+ "violenceRealistic" => "violence_realistic",
52
+ "kidsAgeBand" => "kids_age_band"
53
+ })
54
+
55
+ def self.type
56
+ return "ageRatingDeclarations"
57
+ end
58
+
59
+ LEGACY_AGE_RATING_ITC_MAP = {
60
+ "CARTOON_FANTASY_VIOLENCE" => "violenceCartoonOrFantasy",
61
+ "REALISTIC_VIOLENCE" => "violenceRealistic",
62
+ "PROLONGED_GRAPHIC_SADISTIC_REALISTIC_VIOLENCE" => "violenceRealisticProlongedGraphicOrSadistic",
63
+ "PROFANITY_CRUDE_HUMOR" => "profanityOrCrudeHumor",
64
+ "MATURE_SUGGESTIVE" => "matureOrSuggestiveThemes",
65
+ "HORROR" => "horrorOrFearThemes",
66
+ "MEDICAL_TREATMENT_INFO" => "medicalOrTreatmentInformation",
67
+ "ALCOHOL_TOBACCO_DRUGS" => "alcoholTobaccoOrDrugUseOrReferences",
68
+ "GAMBLING" => "gamblingSimulated",
69
+ "SEXUAL_CONTENT_NUDITY" => "sexualContentOrNudity",
70
+ "GRAPHIC_SEXUAL_CONTENT_NUDITY" => "sexualContentGraphicAndNudity",
71
+ "UNRESTRICTED_WEB_ACCESS" => "unrestrictedWebAccess",
72
+ "GAMBLING_CONTESTS" => "gamblingAndContests"
73
+ }
74
+
75
+ LEGACY_RATING_VALUE_ITC_MAP = {
76
+ 0 => Rating::NONE,
77
+ 1 => Rating::INFREQUENT_OR_MILD,
78
+ 2 => Rating::FREQUENT_OR_INTENSE
79
+ }
80
+
81
+ LEGACY_BOOLEAN_VALUE_ITC_MAP = {
82
+ 0 => false,
83
+ 1 => true
84
+ }
85
+
86
+ def self.map_key_from_itc(key)
87
+ key = key.gsub("MZGenre.", "")
88
+ return nil if key.empty?
89
+ LEGACY_AGE_RATING_ITC_MAP[key] || key
90
+ end
91
+
92
+ def self.map_value_from_itc(key, value)
93
+ if ["gamblingAndContests", "unrestrictedWebAccess"].include?(key)
94
+ return LEGACY_BOOLEAN_VALUE_ITC_MAP[value]
95
+ else
96
+ return LEGACY_RATING_VALUE_ITC_MAP[value]
97
+ end
98
+ end
99
+
100
+ #
101
+ # API
102
+ #
103
+
104
+ def update(attributes: nil)
105
+ Spaceship::ConnectAPI.patch_age_rating_declaration(age_rating_declaration_id: id, attributes: attributes)
106
+ end
107
+ end
108
+ end
109
+ end