fastlane 2.129.0 → 2.134.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +66 -66
  3. data/cert/lib/cert/module.rb +2 -0
  4. data/cert/lib/cert/options.rb +6 -0
  5. data/cert/lib/cert/runner.rb +17 -11
  6. data/fastlane/lib/fastlane.rb +4 -1
  7. data/fastlane/lib/fastlane/actions/.download_dsyms.rb.swp +0 -0
  8. data/fastlane/lib/fastlane/actions/.hockey.rb.swp +0 -0
  9. data/fastlane/lib/fastlane/actions/actions_helper.rb +4 -0
  10. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +11 -3
  11. data/fastlane/lib/fastlane/actions/carthage.rb +11 -3
  12. data/fastlane/lib/fastlane/actions/cocoapods.rb +24 -2
  13. data/fastlane/lib/fastlane/actions/copy_artifacts.rb +1 -1
  14. data/fastlane/lib/fastlane/actions/danger.rb +7 -0
  15. data/fastlane/lib/fastlane/actions/deploygate.rb +1 -1
  16. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +23 -4
  17. data/fastlane/lib/fastlane/actions/download_dsyms.rb +59 -10
  18. data/fastlane/lib/fastlane/actions/ensure_env_vars.rb +58 -0
  19. data/fastlane/lib/fastlane/actions/get_version_number.rb +12 -3
  20. data/fastlane/lib/fastlane/actions/gradle.rb +11 -1
  21. data/fastlane/lib/fastlane/actions/onesignal.rb +59 -29
  22. data/fastlane/lib/fastlane/actions/pod_push.rb +10 -1
  23. data/fastlane/lib/fastlane/actions/register_devices.rb +38 -22
  24. data/fastlane/lib/fastlane/actions/resign.rb +2 -2
  25. data/fastlane/lib/fastlane/actions/slather.rb +1 -0
  26. data/fastlane/lib/fastlane/actions/sonar.rb +16 -0
  27. data/fastlane/lib/fastlane/actions/testfairy.rb +1 -1
  28. data/fastlane/lib/fastlane/actions/update_fastlane.rb +9 -49
  29. data/fastlane/lib/fastlane/actions/update_keychain_access_groups.rb +94 -0
  30. data/fastlane/lib/fastlane/commands_generator.rb +16 -0
  31. data/fastlane/lib/fastlane/environment_printer.rb +7 -1
  32. data/fastlane/lib/fastlane/fast_file.rb +10 -4
  33. data/fastlane/lib/fastlane/helper/crashlytics_helper.rb +1 -1
  34. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +2 -0
  35. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +3 -0
  36. data/fastlane/lib/fastlane/setup/setup_android.rb +1 -1
  37. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +122 -34
  38. data/fastlane/lib/fastlane/swift_fastlane_function.rb +72 -3
  39. data/fastlane/lib/fastlane/swift_runner_upgrader.rb +4 -0
  40. data/fastlane/lib/fastlane/version.rb +1 -1
  41. data/fastlane/swift/Actions.swift +15 -0
  42. data/fastlane/swift/Deliverfile.swift +1 -1
  43. data/fastlane/swift/DeliverfileProtocol.swift +121 -1
  44. data/fastlane/swift/Fastlane.swift +3925 -30
  45. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +9 -0
  46. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  47. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  48. data/fastlane/swift/Gymfile.swift +1 -1
  49. data/fastlane/swift/GymfileProtocol.swift +91 -9
  50. data/fastlane/swift/Matchfile.swift +1 -1
  51. data/fastlane/swift/MatchfileProtocol.swift +65 -1
  52. data/fastlane/swift/Plugins.swift +15 -0
  53. data/fastlane/swift/Precheckfile.swift +1 -1
  54. data/fastlane/swift/PrecheckfileProtocol.swift +15 -2
  55. data/fastlane/swift/Scanfile.swift +1 -1
  56. data/fastlane/swift/ScanfileProtocol.swift +109 -1
  57. data/fastlane/swift/Screengrabfile.swift +1 -1
  58. data/fastlane/swift/ScreengrabfileProtocol.swift +39 -2
  59. data/fastlane/swift/Snapshotfile.swift +1 -1
  60. data/fastlane/swift/SnapshotfileProtocol.swift +71 -1
  61. data/fastlane/swift/upgrade_manifest.json +1 -1
  62. data/fastlane_core/lib/fastlane_core/command_executor.rb +1 -1
  63. data/fastlane_core/lib/fastlane_core/device_manager.rb +1 -1
  64. data/fastlane_core/lib/fastlane_core/helper.rb +1 -1
  65. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +1 -3
  66. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +3 -2
  67. data/frameit/lib/frameit/screenshot.rb +4 -0
  68. data/gym/lib/gym/generators/build_command_generator.rb +5 -1
  69. data/gym/lib/gym/options.rb +16 -16
  70. data/gym/lib/gym/runner.rb +33 -5
  71. data/match/lib/match/generator.rb +1 -0
  72. data/match/lib/match/importer.rb +2 -2
  73. data/match/lib/match/module.rb +2 -0
  74. data/match/lib/match/nuke.rb +5 -5
  75. data/match/lib/match/options.rb +17 -0
  76. data/match/lib/match/runner.rb +10 -6
  77. data/match/lib/match/storage/git_storage.rb +8 -2
  78. data/match/lib/match/storage/google_cloud_storage.rb +85 -33
  79. data/produce/lib/produce/service.rb +7 -1
  80. data/scan/lib/scan/error_handler.rb +9 -4
  81. data/scan/lib/scan/runner.rb +1 -1
  82. data/sigh/lib/sigh/download_all.rb +48 -8
  83. data/sigh/lib/sigh/runner.rb +13 -5
  84. data/snapshot/lib/snapshot/commands_generator.rb +2 -2
  85. data/snapshot/lib/snapshot/options.rb +5 -0
  86. data/snapshot/lib/snapshot/reports_generator.rb +3 -0
  87. data/snapshot/lib/snapshot/simulator_launchers/launcher_configuration.rb +2 -0
  88. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb +1 -1
  89. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +16 -1
  90. data/snapshot/lib/snapshot/update.rb +4 -2
  91. data/spaceship/lib/spaceship/client.rb +3 -3
  92. data/spaceship/lib/spaceship/connect_api/models/app.rb +6 -6
  93. data/spaceship/lib/spaceship/connect_api/models/build.rb +3 -3
  94. data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +1 -1
  95. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +1 -1
  96. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +1 -1
  97. data/spaceship/lib/spaceship/connect_api/models/device.rb +1 -1
  98. data/spaceship/lib/spaceship/connect_api/models/profile.rb +1 -1
  99. data/spaceship/lib/spaceship/portal/.certificate.rb.swp +0 -0
  100. data/spaceship/lib/spaceship/portal/provisioning_profile.rb +1 -1
  101. data/spaceship/lib/spaceship/tunes/app_version.rb +4 -0
  102. data/spaceship/lib/spaceship/tunes/application.rb +4 -0
  103. data/spaceship/lib/spaceship/tunes/availability.rb +40 -8
  104. data/spaceship/lib/spaceship/tunes/b2b_organization.rb +50 -0
  105. data/spaceship/lib/spaceship/tunes/iap_family_details.rb +10 -2
  106. data/spaceship/lib/spaceship/tunes/tunes_client.rb +26 -1
  107. metadata +55 -46
@@ -155,27 +155,35 @@ module Sigh
155
155
  case Sigh.config[:platform].to_s
156
156
  when 'ios', 'tvos'
157
157
  if profile_type == Spaceship.provisioning_profile.Development
158
- certificates = Spaceship.certificate.development.all
158
+ certificates = Spaceship.certificate.development.all +
159
+ Spaceship.certificate.apple_development.all
159
160
  elsif profile_type == Spaceship.provisioning_profile.InHouse
161
+ # Enterprise accounts don't have access to Apple Distribution certificates
160
162
  certificates = Spaceship.certificate.in_house.all
161
163
  # handles case where the desired certificate type is adhoc but the account is an enterprise account
162
164
  # the apple dev portal api has a weird quirk in it where if you query for distribution certificates
163
165
  # for enterprise accounts, you get nothing back even if they exist.
164
166
  elsif profile_type == Spaceship.provisioning_profile.AdHoc && Spaceship.client && Spaceship.client.in_house?
167
+ # Enterprise accounts don't have access to Apple Distribution certificates
165
168
  certificates = Spaceship.certificate.in_house.all
166
169
  else
167
- certificates = Spaceship.certificate.production.all # Ad hoc or App Store
170
+ # Ad hoc or App Store
171
+ certificates = Spaceship.certificate.production.all +
172
+ Spaceship.certificate.apple_distribution.all
168
173
  end
169
174
 
170
175
  when 'macos'
171
176
  if profile_type == Spaceship.provisioning_profile.Development
172
- certificates = Spaceship.certificate.mac_development.all
177
+ certificates = Spaceship.certificate.mac_development.all +
178
+ Spaceship.certificate.apple_development.all
173
179
  elsif profile_type == Spaceship.provisioning_profile.AppStore
174
- certificates = Spaceship.certificate.mac_app_distribution.all
180
+ certificates = Spaceship.certificate.mac_app_distribution.all +
181
+ Spaceship.certificate.apple_distribution.all
175
182
  elsif profile_type == Spaceship.provisioning_profile.Direct
176
183
  certificates = Spaceship.certificate.developer_id_application.all
177
184
  else
178
- certificates = Spaceship.certificate.mac_app_distribution.all
185
+ certificates = Spaceship.certificate.mac_app_distribution.all +
186
+ Spaceship.certificate.apple_distribution.all
179
187
  end
180
188
  end
181
189
 
@@ -56,10 +56,10 @@ module Snapshot
56
56
  command :update do |c|
57
57
  c.syntax = 'fastlane snapshot update'
58
58
  c.description = "Updates your SnapshotHelper.swift to the latest version"
59
-
59
+ c.option('--force', 'Disables confirmation prompts')
60
60
  c.action do |args, options|
61
61
  require 'snapshot/update'
62
- Snapshot::Update.new.update
62
+ Snapshot::Update.new.update(force: options.force)
63
63
  end
64
64
  end
65
65
 
@@ -116,6 +116,11 @@ module Snapshot
116
116
  description: "Enabling this option will configure the Simulator's system language",
117
117
  default_value: false,
118
118
  is_string: false),
119
+ FastlaneCore::ConfigItem.new(key: :dark_mode,
120
+ env_name: 'SNAPSHOT_DARK_MODE',
121
+ description: "Enabling this option will configure the Simulator to be in dark mode (false for light, true for dark)",
122
+ optional: true,
123
+ type: Boolean),
119
124
  FastlaneCore::ConfigItem.new(key: :app_identifier,
120
125
  env_name: 'SNAPSHOT_APP_IDENTIFIER',
121
126
  short_option: "-a",
@@ -77,6 +77,9 @@ module Snapshot
77
77
  {
78
78
  # snapshot in Xcode 9 saves screenshots with the SIMULATOR_DEVICE_NAME
79
79
  # which includes spaces
80
+ 'iPhone 11 Pro Max' => "iPhone 11 Pro Max",
81
+ 'iPhone 11 Pro' => "iPhone 11 Pro",
82
+ 'iPhone 11' => "iPhone 11",
80
83
  'iPhone XS Max' => "iPhone XS Max",
81
84
  'iPhone XS' => "iPhone XS",
82
85
  'iPhone XR' => "iPhone XR",
@@ -8,6 +8,7 @@ module Snapshot
8
8
  attr_accessor :clean
9
9
  attr_accessor :erase_simulator
10
10
  attr_accessor :localize_simulator
11
+ attr_accessor :dark_mode
11
12
  attr_accessor :reinstall_app
12
13
  attr_accessor :app_identifier
13
14
 
@@ -32,6 +33,7 @@ module Snapshot
32
33
  @clean = snapshot_config[:clean]
33
34
  @erase_simulator = snapshot_config[:erase_simulator]
34
35
  @localize_simulator = snapshot_config[:localize_simulator]
36
+ @dark_mode = snapshot_config[:dark_mode]
35
37
  @reinstall_app = snapshot_config[:reinstall_app]
36
38
  @app_identifier = snapshot_config[:app_identifier]
37
39
  @number_of_retries = snapshot_config[:number_of_retries]
@@ -190,7 +190,7 @@ module Snapshot
190
190
  hash[name] = ["No tests were executed"]
191
191
  else
192
192
  tests = Array(summary.data.first[:tests])
193
- hash[name] = tests.map { |test| Array(test[:failures]).map { |failure| failure[:failure_message] } }.flatten
193
+ hash[name] = tests.flat_map { |test| Array(test[:failures]).map { |failure| failure[:failure_message] } }
194
194
  end
195
195
  end
196
196
  end
@@ -55,11 +55,14 @@ module Snapshot
55
55
  Fixes::HardwareKeyboardFix.patch
56
56
 
57
57
  device_types.each do |type|
58
- if launcher_config.erase_simulator || launcher_config.localize_simulator
58
+ if launcher_config.erase_simulator || launcher_config.localize_simulator || !launcher_config.dark_mode.nil?
59
59
  erase_simulator(type)
60
60
  if launcher_config.localize_simulator
61
61
  localize_simulator(type, language, locale)
62
62
  end
63
+ unless launcher_config.dark_mode.nil?
64
+ interface_style(type, launcher_config.dark_mode)
65
+ end
63
66
  elsif launcher_config.reinstall_app
64
67
  # no need to reinstall if device has been erased
65
68
  uninstall_app(type)
@@ -124,6 +127,18 @@ module Snapshot
124
127
  end
125
128
  end
126
129
 
130
+ def interface_style(device_type, dark_mode)
131
+ device_udid = TestCommandGenerator.device_udid(device_type)
132
+ if device_udid
133
+ plist = {
134
+ UserInterfaceStyleMode: (dark_mode ? 2 : 1)
135
+ }
136
+ UI.message("Setting interface style #{device_type} (UserInterfaceStyleMode=#{dark_mode})")
137
+ plist_path = "#{ENV['HOME']}/Library/Developer/CoreSimulator/Devices/#{device_udid}/data/Library/Preferences/com.apple.uikitservices.userInterfaceStyleMode.plist"
138
+ File.write(plist_path, Plist::Emit.dump(plist))
139
+ end
140
+ end
141
+
127
142
  def copy_simulator_logs(device_names, language, locale, launch_arguments)
128
143
  return unless launcher_config.output_simulator_logs
129
144
 
@@ -11,7 +11,7 @@ module Snapshot
11
11
  paths.reject { |p| p.include?("snapshot/lib/assets/") }
12
12
  end
13
13
 
14
- def update
14
+ def update(force: false)
15
15
  paths = self.class.find_helper
16
16
  UI.user_error!("Couldn't find any SnapshotHelper files in current directory") if paths.count == 0
17
17
 
@@ -22,7 +22,9 @@ module Snapshot
22
22
  UI.message("The underlying API will not change. You can always migrate manually by looking at")
23
23
  UI.message("https://github.com/fastlane/fastlane/blob/master/snapshot/lib/assets/SnapshotHelper.swift")
24
24
 
25
- return 1 unless UI.confirm("Overwrite configuration files?")
25
+ if !force && !UI.confirm("Overwrite configuration files?")
26
+ return 1
27
+ end
26
28
 
27
29
  paths.each do |path|
28
30
  UI.message("Updating '#{path}'...")
@@ -619,8 +619,8 @@ module Spaceship
619
619
  def with_retry(tries = 5, &_block)
620
620
  return yield
621
621
  rescue \
622
- Faraday::Error::ConnectionFailed,
623
- Faraday::Error::TimeoutError, # New Faraday version: Faraday::TimeoutError => ex
622
+ Faraday::ConnectionFailed,
623
+ Faraday::TimeoutError,
624
624
  BadGatewayError,
625
625
  AppleTimeoutError,
626
626
  GatewayTimeoutError => ex
@@ -738,7 +738,7 @@ module Spaceship
738
738
  raise InternalServerError, "Received an internal server error from App Store Connect / Developer Portal, please try again later"
739
739
  elsif body.to_s.include?("Gateway Timeout - In read")
740
740
  raise GatewayTimeoutError, "Received a gateway timeout error from App Store Connect / Developer Portal, please try again later"
741
- elsif (body["resultString"] || "").include?("Program License Agreement")
741
+ elsif (body["userString"] || "").include?("Program License Agreement")
742
742
  raise ProgramLicenseAgreementUpdated, "#{body['userString']} Please manually log into your Apple Developer account to review and accept the updated agreement."
743
743
  end
744
744
  end
@@ -32,7 +32,7 @@ module Spaceship
32
32
 
33
33
  def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
34
34
  resps = Spaceship::ConnectAPI.get_apps(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
35
- return resps.map(&:to_models).flatten
35
+ return resps.flat_map(&:to_models)
36
36
  end
37
37
 
38
38
  def self.find(bundle_id)
@@ -54,7 +54,7 @@ module Spaceship
54
54
  filter[:apps] = id
55
55
 
56
56
  resps = Spaceship::ConnectAPI.get_beta_testers(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
57
- return resps.map(&:to_models).flatten
57
+ return resps.flat_map(&:to_models)
58
58
  end
59
59
 
60
60
  #
@@ -66,7 +66,7 @@ module Spaceship
66
66
  filter[:app] = id
67
67
 
68
68
  resps = Spaceship::ConnectAPI.get_builds(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
69
- return resps.map(&:to_models).flatten
69
+ return resps.flat_map(&:to_models)
70
70
  end
71
71
 
72
72
  def get_build_deliveries(filter: {}, includes: nil, limit: nil, sort: nil)
@@ -74,7 +74,7 @@ module Spaceship
74
74
  filter[:app] = id
75
75
 
76
76
  resps = Spaceship::ConnectAPI.get_build_deliveries(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
77
- return resps.map(&:to_models).flatten
77
+ return resps.flat_map(&:to_models)
78
78
  end
79
79
 
80
80
  def get_beta_app_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
@@ -82,7 +82,7 @@ module Spaceship
82
82
  filter[:app] = id
83
83
 
84
84
  resps = Spaceship::ConnectAPI.get_beta_app_localizations(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
85
- return resps.map(&:to_models).flatten
85
+ return resps.flat_map(&:to_models)
86
86
  end
87
87
 
88
88
  def get_beta_groups(filter: {}, includes: nil, limit: nil, sort: nil)
@@ -90,7 +90,7 @@ module Spaceship
90
90
  filter[:app] = id
91
91
 
92
92
  resps = Spaceship::ConnectAPI.get_beta_groups(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
93
- return resps.map(&:to_models).flatten
93
+ return resps.flat_map(&:to_models)
94
94
  end
95
95
  end
96
96
  end
@@ -109,7 +109,7 @@ module Spaceship
109
109
  sort: sort,
110
110
  limit: limit
111
111
  ).all_pages
112
- models = resps.map(&:to_models).flatten
112
+ models = resps.flat_map(&:to_models)
113
113
 
114
114
  # Filtering after models are fetched since there is no way to do this in a query param filter
115
115
  if platform
@@ -138,7 +138,7 @@ module Spaceship
138
138
  sort: sort,
139
139
  limit: limit
140
140
  ).all_pages
141
- return resps.map(&:to_models).flatten
141
+ return resps.flat_map(&:to_models)
142
142
  end
143
143
 
144
144
  def get_build_beta_details(filter: {}, includes: nil, limit: nil, sort: nil)
@@ -148,7 +148,7 @@ module Spaceship
148
148
  sort: sort,
149
149
  limit: limit
150
150
  ).all_pages
151
- return resps.map(&:to_models).flatten
151
+ return resps.flat_map(&:to_models)
152
152
  end
153
153
 
154
154
  def post_beta_app_review_submission
@@ -29,7 +29,7 @@ module Spaceship
29
29
  filter: { app: app_id, cfBundleShortVersionString: version, cfBundleVersion: build_number },
30
30
  limit: 1
31
31
  ).all_pages
32
- return resps.map(&:to_models).flatten
32
+ return resps.flat_map(&:to_models)
33
33
  end
34
34
  end
35
35
  end
@@ -35,7 +35,7 @@ module Spaceship
35
35
 
36
36
  def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
37
37
  resps = Spaceship::ConnectAPI.get_bundle_ids(filter: filter, includes: includes).all_pages
38
- return resps.map(&:to_models).flatten
38
+ return resps.flat_map(&:to_models)
39
39
  end
40
40
 
41
41
  def self.get(bundle_id_id: nil, includes: nil)
@@ -41,7 +41,7 @@ module Spaceship
41
41
 
42
42
  def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
43
43
  resps = Spaceship::ConnectAPI.get_certificates(filter: filter, includes: includes).all_pages
44
- return resps.map(&:to_models).flatten
44
+ return resps.flat_map(&:to_models)
45
45
  end
46
46
  end
47
47
  end
@@ -46,7 +46,7 @@ module Spaceship
46
46
 
47
47
  def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
48
48
  resps = Spaceship::ConnectAPI.get_devices(filter: filter, includes: includes).all_pages
49
- return resps.map(&:to_models).flatten
49
+ return resps.flat_map(&:to_models)
50
50
  end
51
51
  end
52
52
  end
@@ -53,7 +53,7 @@ module Spaceship
53
53
 
54
54
  def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
55
55
  resps = Spaceship::ConnectAPI.get_profiles(filter: filter, includes: includes).all_pages
56
- return resps.map(&:to_models).flatten
56
+ return resps.flat_map(&:to_models)
57
57
  end
58
58
  end
59
59
  end
@@ -457,7 +457,7 @@ module Spaceship
457
457
  devices.map(&:id),
458
458
  mac: mac?,
459
459
  sub_platform: tvos? ? 'tvOS' : nil,
460
- template_name: template_name
460
+ template_name: is_template_profile ? template.purpose_name : nil
461
461
  )
462
462
  end
463
463
 
@@ -192,6 +192,9 @@ module Spaceship
192
192
  # @return (Hash) Represents the trailers of this app version (read-only)
193
193
  attr_reader :trailers
194
194
 
195
+ # @return (Hash) A hash representing all in-app purchases that can get submitted with this version
196
+ attr_reader :in_app_purchases
197
+
195
198
  # @return (Hash) Represents the phased_release hash (read-only)
196
199
  # For now, please use the `toggle_phased_release` method and call `.save!`
197
200
  # as the API will probably change in the future
@@ -233,6 +236,7 @@ module Spaceship
233
236
  'supportsAppleWatch' => :supports_apple_watch,
234
237
  'versionId' => :version_id,
235
238
  'version.value' => :version,
239
+ 'submittableAddOns.value' => :in_app_purchases,
236
240
  'phasedRelease' => :phased_release,
237
241
 
238
242
  # GeoJson
@@ -158,6 +158,10 @@ module Spaceship
158
158
  client.get_resolution_center(apple_id, platform)
159
159
  end
160
160
 
161
+ def reply_resolution_center(app_id, platform, thread_id, version_id, version_number, from, message_body)
162
+ client.post_resolution_center(app_id, platform, thread_id, version_id, version_number, from, message_body)
163
+ end
164
+
161
165
  def ratings(version_id: '', storefront: '')
162
166
  attrs = client.get_ratings(apple_id, platform, version_id, storefront)
163
167
  attrs[:application] = self
@@ -1,5 +1,6 @@
1
1
  require_relative 'territory'
2
2
  require_relative 'b2b_user'
3
+ require_relative 'b2b_organization'
3
4
  module Spaceship
4
5
  module Tunes
5
6
  class Availability < TunesBase
@@ -27,6 +28,9 @@ module Spaceship
27
28
  # @return (Array of Spaceship::Tunes::B2bUser objects) A list of users
28
29
  attr_accessor :b2b_users
29
30
 
31
+ # @return (Array of Spaceship::Tunes::B2bOrganization objects) A list of b2b orgs
32
+ attr_accessor :b2b_organizations
33
+
30
34
  attr_mapping(
31
35
  'theWorld' => :include_future_territories,
32
36
  'preOrder.clearedForPreOrder.value' => :cleared_for_preorder,
@@ -47,12 +51,12 @@ module Spaceship
47
51
  # Base::DataHash sets values for paths that don't exist
48
52
  obj = self.new(
49
53
  'preOrder' => {
50
- 'clearedForPreOrder' => {
51
- 'value' => false
52
- },
53
- 'appAvailableDate' => {
54
- 'value' => nil
55
- }
54
+ 'clearedForPreOrder' => {
55
+ 'value' => false
56
+ },
57
+ 'appAvailableDate' => {
58
+ 'value' => nil
59
+ }
56
60
  }
57
61
  )
58
62
 
@@ -66,8 +70,8 @@ module Spaceship
66
70
  obj.include_future_territories = params.fetch(:include_future_territories, true)
67
71
  obj.cleared_for_preorder = params.fetch(:cleared_for_preorder, false)
68
72
  obj.app_available_date = params.fetch(:app_available_date, nil)
69
- obj.b2b_unavailable = params.fetch(:b2b_unavailable, false)
70
- obj.b2b_app_enabled = params.fetch(:b2b_app_enabled, false)
73
+ obj.b2b_unavailable = params.fetch(:b2b_unavailable, false)
74
+ obj.b2b_app_enabled = params.fetch(:b2b_app_enabled, false)
71
75
  obj.educational_discount = params.fetch(:educational_discount, true)
72
76
  return obj
73
77
  end
@@ -80,6 +84,10 @@ module Spaceship
80
84
  @b2b_users || raw_data['b2bUsers'].map { |user| B2bUser.new(user) }
81
85
  end
82
86
 
87
+ def b2b_organizations
88
+ @b2b_organizations || raw_data['b2bOrganizations'].map { |user| B2bOrganization.new(user) }
89
+ end
90
+
83
91
  def b2b_app_enabled
84
92
  @b2b_app_enabled.nil? ? raw_data['b2bAppEnabled'] : @b2b_app_enabled
85
93
  end
@@ -127,6 +135,30 @@ module Spaceship
127
135
 
128
136
  return self
129
137
  end
138
+
139
+ # Updates users for b2b enabled apps
140
+ def update_dep_organizations(organization_list = [])
141
+ raise "Cannot add dep organizations if b2b is not enabled" unless b2b_app_enabled
142
+
143
+ added_orgs = b2b_organizations
144
+
145
+ # Returns if list is unchanged
146
+ return self if (added_orgs - organization_list) == (organization_list - added_orgs)
147
+
148
+ orgs_to_add = organization_list.reject { |organization| added_orgs.include?(organization) }
149
+ orgs_to_remove = added_orgs.nil? ? organization_list : added_orgs.reject { |organization| organization_list.include?(organization) }
150
+
151
+ @b2b_organizations = b2b_organizations.reject { |organization| orgs_to_remove.include?(organization) }
152
+ @b2b_organizations.concat(orgs_to_add)
153
+ @b2b_organizations.concat(orgs_to_remove.map do |organization|
154
+ B2bOrganization.from_id_info(dep_id: organization.dep_customer_id,
155
+ dep_name: organization.name,
156
+ dep_org_id: organization.dep_organization_id,
157
+ type: false)
158
+ end)
159
+
160
+ return self
161
+ end
130
162
  end
131
163
  end
132
164
  end
@@ -0,0 +1,50 @@
1
+ require_relative 'tunes_base'
2
+ module Spaceship
3
+ module Tunes
4
+ class B2bOrganization < TunesBase
5
+ # @return (String) add or remove
6
+ attr_accessor :type
7
+
8
+ # @return (String) customer id
9
+ attr_accessor :dep_customer_id
10
+
11
+ # @return (String) organization id
12
+ attr_accessor :dep_organization_id
13
+
14
+ # @return (String) organization name
15
+ attr_accessor :name
16
+
17
+ # enum for types
18
+ class TYPE
19
+ ADD = "ADD"
20
+ REMOVE = "REMOVE"
21
+ NO_CHANGE = "NO_CHANGE"
22
+ end
23
+
24
+ attr_mapping(
25
+ 'value.type' => :type,
26
+ 'value.depCustomerId' => :dep_customer_id,
27
+ 'value.organizationId' => :dep_organization_id,
28
+ 'value.name' => :name
29
+ )
30
+
31
+ def self.from_id_info(dep_id: nil, dep_org_id: nil, dep_name: nil, type: TYPE::NO_CHANGE)
32
+ self.new({ "value" => { "type" => type, "depCustomerId" => dep_id, "organizationId" => dep_org_id, "name" => dep_name } })
33
+ end
34
+
35
+ def ==(other)
36
+ other.class == self.class && other.state == self.state
37
+ end
38
+
39
+ def state
40
+ return [type, dep_customer_id, name]
41
+ end
42
+
43
+ alias eql? ==
44
+
45
+ def hash
46
+ state.hash
47
+ end
48
+ end
49
+ end
50
+ end