fastlane 2.163.0 → 2.168.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -80
  3. data/cert/lib/cert/options.rb +1 -1
  4. data/cert/lib/cert/runner.rb +2 -2
  5. data/deliver/lib/deliver/app_screenshot.rb +6 -2
  6. data/deliver/lib/deliver/queue_worker.rb +14 -29
  7. data/deliver/lib/deliver/upload_metadata.rb +7 -2
  8. data/deliver/lib/deliver/upload_screenshots.rb +3 -5
  9. data/fastlane/lib/fastlane/actions/.download_dsyms.rb.swp +0 -0
  10. data/fastlane/lib/fastlane/actions/actions_helper.rb +1 -1
  11. data/fastlane/lib/fastlane/actions/add_git_tag.rb +9 -2
  12. data/fastlane/lib/fastlane/actions/appledoc.rb +1 -1
  13. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +5 -1
  14. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +9 -0
  15. data/fastlane/lib/fastlane/actions/import_from_git.rb +9 -1
  16. data/fastlane/lib/fastlane/actions/is_ci.rb +1 -1
  17. data/fastlane/lib/fastlane/actions/register_devices.rb +4 -1
  18. data/fastlane/lib/fastlane/actions/set_changelog.rb +31 -3
  19. data/fastlane/lib/fastlane/actions/slather.rb +2 -2
  20. data/fastlane/lib/fastlane/actions/spm.rb +6 -0
  21. data/fastlane/lib/fastlane/actions/update_fastlane.rb +29 -8
  22. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +3 -3
  23. data/fastlane/lib/fastlane/cli_tools_distributor.rb +2 -2
  24. data/fastlane/lib/fastlane/fast_file.rb +74 -23
  25. data/fastlane/lib/fastlane/features.rb +1 -1
  26. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +2 -0
  27. data/fastlane/lib/fastlane/swift_fastlane_function.rb +1 -1
  28. data/fastlane/lib/fastlane/version.rb +1 -1
  29. data/fastlane/swift/Deliverfile.swift +1 -1
  30. data/fastlane/swift/DeliverfileProtocol.swift +1 -1
  31. data/fastlane/swift/Fastfile.swift +1 -1
  32. data/fastlane/swift/Fastlane.swift +37 -16
  33. data/fastlane/swift/Gymfile.swift +1 -1
  34. data/fastlane/swift/GymfileProtocol.swift +1 -1
  35. data/fastlane/swift/LaneFileProtocol.swift +2 -2
  36. data/fastlane/swift/MainProcess.swift +2 -0
  37. data/fastlane/swift/Matchfile.swift +1 -1
  38. data/fastlane/swift/MatchfileProtocol.swift +8 -4
  39. data/fastlane/swift/Precheckfile.swift +1 -1
  40. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  41. data/fastlane/swift/Runner.swift +1 -1
  42. data/fastlane/swift/Scanfile.swift +1 -1
  43. data/fastlane/swift/ScanfileProtocol.swift +5 -1
  44. data/fastlane/swift/Screengrabfile.swift +1 -1
  45. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  46. data/fastlane/swift/Snapshotfile.swift +1 -1
  47. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  48. data/fastlane/swift/SocketClient.swift +1 -1
  49. data/fastlane_core/lib/fastlane_core/cert_checker.rb +12 -7
  50. data/fastlane_core/lib/fastlane_core/device_manager.rb +8 -4
  51. data/fastlane_core/lib/fastlane_core/helper.rb +11 -3
  52. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +3 -3
  53. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +1 -1
  54. data/fastlane_core/lib/fastlane_core/provisioning_profile.rb +3 -1
  55. data/fastlane_core/lib/fastlane_core/ui/disable_colors.rb +8 -0
  56. data/gym/lib/gym/code_signing_mapping.rb +1 -1
  57. data/match/lib/match/importer.rb +33 -21
  58. data/match/lib/match/module.rb +1 -1
  59. data/match/lib/match/nuke.rb +9 -5
  60. data/match/lib/match/options.rb +8 -2
  61. data/pilot/lib/pilot/build_manager.rb +9 -3
  62. data/scan/lib/scan/detect_values.rb +8 -9
  63. data/scan/lib/scan/module.rb +4 -0
  64. data/scan/lib/scan/options.rb +9 -0
  65. data/scan/lib/scan/runner.rb +4 -3
  66. data/sigh/lib/assets/resign.sh +1 -1
  67. data/sigh/lib/sigh/runner.rb +4 -4
  68. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +2 -1
  69. data/snapshot/lib/snapshot/test_command_generator.rb +1 -1
  70. data/snapshot/lib/snapshot/test_command_generator_base.rb +3 -1
  71. data/snapshot/lib/snapshot/test_command_generator_xcode_8.rb +1 -1
  72. data/spaceship/lib/spaceship/connect_api.rb +2 -0
  73. data/spaceship/lib/spaceship/connect_api/client.rb +7 -4
  74. data/spaceship/lib/spaceship/connect_api/models/.app.rb.swp +0 -0
  75. data/spaceship/lib/spaceship/connect_api/models/.app_screenshot.rb.swp +0 -0
  76. data/spaceship/lib/spaceship/connect_api/models/.build.rb.swp +0 -0
  77. data/spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb +3 -2
  78. data/spaceship/lib/spaceship/connect_api/models/app.rb +127 -51
  79. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +15 -10
  80. data/spaceship/lib/spaceship/connect_api/models/app_info_localization.rb +6 -4
  81. data/spaceship/lib/spaceship/connect_api/models/app_preview.rb +15 -11
  82. data/spaceship/lib/spaceship/connect_api/models/app_preview_set.rb +13 -9
  83. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +9 -7
  84. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +15 -11
  85. data/spaceship/lib/spaceship/connect_api/models/app_store_review_attachment.rb +7 -5
  86. data/spaceship/lib/spaceship/connect_api/models/app_store_review_detail.rb +6 -4
  87. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +54 -36
  88. data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +21 -14
  89. data/spaceship/lib/spaceship/connect_api/models/app_store_version_submission.rb +3 -2
  90. data/spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb +3 -2
  91. data/spaceship/lib/spaceship/connect_api/models/beta_feedback.rb +6 -4
  92. data/spaceship/lib/spaceship/connect_api/models/beta_group.rb +12 -2
  93. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +12 -8
  94. data/spaceship/lib/spaceship/connect_api/models/build.rb +24 -16
  95. data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +3 -2
  96. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +9 -6
  97. data/spaceship/lib/spaceship/connect_api/models/bundle_id_capability.rb +6 -4
  98. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +12 -8
  99. data/spaceship/lib/spaceship/connect_api/models/custom_app_organization.rb +43 -0
  100. data/spaceship/lib/spaceship/connect_api/models/custom_app_user.rb +41 -0
  101. data/spaceship/lib/spaceship/connect_api/models/device.rb +6 -4
  102. data/spaceship/lib/spaceship/connect_api/models/idfa_declaration.rb +6 -4
  103. data/spaceship/lib/spaceship/connect_api/models/profile.rb +12 -8
  104. data/spaceship/lib/spaceship/connect_api/models/reset_ratings_request.rb +3 -2
  105. data/spaceship/lib/spaceship/connect_api/models/sandbox_tester.rb +9 -6
  106. data/spaceship/lib/spaceship/connect_api/models/territory.rb +3 -2
  107. data/spaceship/lib/spaceship/connect_api/models/user.rb +6 -4
  108. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +9 -6
  109. data/spaceship/lib/spaceship/connect_api/spaceship.rb +7 -4
  110. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +12 -0
  111. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +71 -0
  112. data/spaceship/lib/spaceship/tunes/iap_detail.rb +1 -1
  113. data/spaceship/lib/spaceship/tunes/tunes_client.rb +2 -2
  114. data/supply/lib/supply.rb +1 -1
  115. data/supply/lib/supply/options.rb +1 -1
  116. data/supply/lib/supply/uploader.rb +4 -3
  117. metadata +24 -20
  118. data/fastlane/lib/fastlane/actions/.register_device.rb.swp +0 -0
  119. data/fastlane/lib/fastlane/actions/.register_devices.rb.swp +0 -0
@@ -139,7 +139,7 @@ module Sigh
139
139
  # Skip certificates that failed to download
140
140
  next unless current_cert[:downloaded]
141
141
  file = Tempfile.new('cert')
142
- file.write(current_cert[:downloaded])
142
+ file.write(current_cert[:downloaded].force_encoding('UTF-8'))
143
143
  file.close
144
144
  if FastlaneCore::CertChecker.installed?(file.path)
145
145
  installed = true
@@ -303,7 +303,7 @@ module Sigh
303
303
  end
304
304
 
305
305
  if Sigh.config[:cert_owner_name]
306
- next unless c.owner_name.strip == Sigh.config[:cert_owner_name].strip
306
+ next unless c.display_name.strip == Sigh.config[:cert_owner_name].strip
307
307
  end
308
308
 
309
309
  true
@@ -315,7 +315,7 @@ module Sigh
315
315
  certificates = certificates.find_all do |c|
316
316
  file = Tempfile.new('cert')
317
317
  raw_data = Base64.decode64(c.certificate_content)
318
- file.write(raw_data)
318
+ file.write(raw_data.force_encoding("UTF-8"))
319
319
  file.close
320
320
 
321
321
  FastlaneCore::CertChecker.installed?(file.path)
@@ -327,7 +327,7 @@ module Sigh
327
327
  UI.important("Found more than one code signing identity. Choosing the first one. Check out `fastlane sigh --help` to see all available options.")
328
328
  UI.important("Available Code Signing Identities for current filters:")
329
329
  certificates.each do |c|
330
- str = ["\t- Name:", c.owner_name, "- ID:", c.id + " - Expires", c.expires.strftime("%d/%m/%Y")].join(" ")
330
+ str = ["\t- Name:", c.display_name, "- ID:", c.id + " - Expires", c.expires.strftime("%d/%m/%Y")].join(" ")
331
331
  UI.message(str.green)
332
332
  end
333
333
  end
@@ -18,6 +18,7 @@ module Snapshot
18
18
 
19
19
  def initialize(launcher_configuration: nil)
20
20
  @launcher_config = launcher_configuration
21
+ @device_boot_datetime = DateTime.now
21
22
  end
22
23
 
23
24
  def collected_errors
@@ -192,7 +193,7 @@ module Snapshot
192
193
 
193
194
  UI.header("Collecting system logs #{device_name} - #{language}")
194
195
  log_identity = Digest::MD5.hexdigest(components.join("-"))
195
- FastlaneCore::Simulator.copy_logs(device, log_identity, language_folder)
196
+ FastlaneCore::Simulator.copy_logs(device, log_identity, language_folder, @device_boot_datetime)
196
197
  end
197
198
  end
198
199
  end
@@ -13,7 +13,7 @@ module Snapshot
13
13
  parts << "xcodebuild"
14
14
  parts += options(language, locale)
15
15
  parts += destination(devices)
16
- parts += build_settings
16
+ parts += build_settings(language, locale)
17
17
  parts += actions
18
18
  parts += suffix
19
19
  parts += pipe(log_path: log_path)
@@ -40,11 +40,13 @@ module Snapshot
40
40
  return options
41
41
  end
42
42
 
43
- def build_settings
43
+ def build_settings(language, locale)
44
44
  config = Snapshot.config
45
45
 
46
46
  build_settings = []
47
47
  build_settings << "FASTLANE_SNAPSHOT=YES"
48
+ build_settings << "FASTLANE_LANGUAGE=#{language}" if language
49
+ build_settings << "FASTLANE_LOCALE=#{locale}" if locale
48
50
  build_settings << "TEST_TARGET_NAME=#{config[:test_target_name].shellescape}" if config[:test_target_name]
49
51
 
50
52
  return build_settings
@@ -14,7 +14,7 @@ module Snapshot
14
14
  parts << "xcodebuild"
15
15
  parts += options(language, locale)
16
16
  parts += destination(device_type)
17
- parts += build_settings
17
+ parts += build_settings(language, locale)
18
18
  parts += actions
19
19
  parts += suffix
20
20
  parts += pipe(device_type, language, locale)
@@ -31,6 +31,8 @@ require 'spaceship/connect_api/models/beta_tester_metric'
31
31
  require 'spaceship/connect_api/models/build'
32
32
  require 'spaceship/connect_api/models/build_delivery'
33
33
  require 'spaceship/connect_api/models/build_beta_detail'
34
+ require 'spaceship/connect_api/models/custom_app_organization'
35
+ require 'spaceship/connect_api/models/custom_app_user'
34
36
  require 'spaceship/connect_api/models/pre_release_version'
35
37
 
36
38
  require 'spaceship/connect_api/models/age_rating_declaration'
@@ -13,20 +13,23 @@ module Spaceship
13
13
 
14
14
  # Initializes client with Apple's App Store Connect JWT auth key.
15
15
  #
16
- # This method will automatically use the key id, issuer id, and filepath from environment
16
+ # This method will automatically use the arguments from environment
17
17
  # variables if not given.
18
18
  #
19
- # All three parameters are needed to authenticate.
19
+ # The key_id, issuer_id and either filepath or key are needed to authenticate.
20
20
  #
21
21
  # @param key_id (String) (optional): The key id
22
22
  # @param issuer_id (String) (optional): The issuer id
23
23
  # @param filepath (String) (optional): The filepath
24
+ # @param key (String) (optional): The key
25
+ # @param duration (Integer) (optional): How long this session should last
26
+ # @param in_house (Boolean) (optional): Whether this session is an Enterprise one
24
27
  #
25
28
  # @raise InvalidUserCredentialsError: raised if authentication failed
26
29
  #
27
30
  # @return (Spaceship::ConnectAPI::Client) The client the login method was called for
28
- def self.auth(key_id: nil, issuer_id: nil, filepath: nil)
29
- token = Spaceship::ConnectAPI::Token.create(key_id: key_id, issuer_id: issuer_id, filepath: filepath)
31
+ def self.auth(key_id: nil, issuer_id: nil, filepath: nil, key: nil, duration: nil, in_house: nil)
32
+ token = Spaceship::ConnectAPI::Token.create(key_id: key_id, issuer_id: issuer_id, filepath: filepath, key: key, duration: duration, in_house: in_house)
30
33
  return ConnectAPI::Client.new(token: token)
31
34
  end
32
35
 
@@ -105,9 +105,10 @@ module Spaceship
105
105
  # API
106
106
  #
107
107
 
108
- def update(attributes: nil)
108
+ def update(client: nil, attributes: nil)
109
+ client ||= Spaceship::ConnectAPI
109
110
  attributes = reverse_attr_mapping(attributes)
110
- Spaceship::ConnectAPI.patch_age_rating_declaration(age_rating_declaration_id: id, attributes: attributes)
111
+ client.patch_age_rating_declaration(age_rating_declaration_id: id, attributes: attributes)
111
112
  end
112
113
  end
113
114
  end
@@ -18,11 +18,26 @@ module Spaceship
18
18
  attr_accessor :app_store_versions
19
19
  attr_accessor :prices
20
20
 
21
+ # Only available with Apple ID auth
22
+ attr_accessor :distribution_type
23
+ attr_accessor :educationDiscountType
24
+
21
25
  module ContentRightsDeclaration
22
26
  USES_THIRD_PARTY_CONTENT = "USES_THIRD_PARTY_CONTENT"
23
27
  DOES_NOT_USE_THIRD_PARTY_CONTENT = "DOES_NOT_USE_THIRD_PARTY_CONTENT"
24
28
  end
25
29
 
30
+ module DistributionType
31
+ APP_STORE = "APP_STORE"
32
+ CUSTOM = "CUSTOM"
33
+ end
34
+
35
+ module EducationDiscountType
36
+ DISCOUNTED = "DISCOUNTED"
37
+ NOT_APPLICABLE = "NOT_APPLICABLE"
38
+ NOT_DISCOUNTED = "NOT_DISCOUNTED"
39
+ end
40
+
26
41
  self.attr_mapping({
27
42
  "name" => "name",
28
43
  "bundleId" => "bundle_id",
@@ -32,6 +47,8 @@ module Spaceship
32
47
  "removed" => "removed",
33
48
  "isAAG" => "is_aag",
34
49
  "availableInNewTerritories" => "available_in_new_territories",
50
+ "distributionType" => "distribution_type",
51
+ "educationDiscountType" => "education_discount_type",
35
52
 
36
53
  "contentRightsDeclaration" => "content_rights_declaration",
37
54
 
@@ -52,19 +69,22 @@ module Spaceship
52
69
  # Apps
53
70
  #
54
71
 
55
- def self.all(filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil)
56
- resps = Spaceship::ConnectAPI.get_apps(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
72
+ def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil)
73
+ client ||= Spaceship::ConnectAPI
74
+ resps = client.get_apps(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
57
75
  return resps.flat_map(&:to_models)
58
76
  end
59
77
 
60
- def self.find(bundle_id)
61
- return all(filter: { bundleId: bundle_id }).find do |app|
78
+ def self.find(bundle_id, client: nil)
79
+ client ||= Spaceship::ConnectAPI
80
+ return all(client: client, filter: { bundleId: bundle_id }).find do |app|
62
81
  app.bundle_id == bundle_id
63
82
  end
64
83
  end
65
84
 
66
- def self.create(name: nil, version_string: nil, sku: nil, primary_locale: nil, bundle_id: nil, platforms: nil, company_name: nil)
67
- Spaceship::ConnectAPI.post_app(
85
+ def self.create(client: nil, name: nil, version_string: nil, sku: nil, primary_locale: nil, bundle_id: nil, platforms: nil, company_name: nil)
86
+ client ||= Spaceship::ConnectAPI
87
+ client.post_app(
68
88
  name: name,
69
89
  version_string: version_string,
70
90
  sku: sku,
@@ -75,20 +95,23 @@ module Spaceship
75
95
  )
76
96
  end
77
97
 
78
- def self.get(app_id: nil, includes: "appStoreVersions")
79
- return Spaceship::ConnectAPI.get_app(app_id: app_id, includes: includes).first
98
+ def self.get(client: nil, app_id: nil, includes: "appStoreVersions")
99
+ client ||= Spaceship::ConnectAPI
100
+ return client.get_app(app_id: app_id, includes: includes).first
80
101
  end
81
102
 
82
- def update(attributes: nil, app_price_tier_id: nil, territory_ids: nil)
103
+ def update(client: nil, attributes: nil, app_price_tier_id: nil, territory_ids: nil)
104
+ client ||= Spaceship::ConnectAPI
83
105
  attributes = reverse_attr_mapping(attributes)
84
- return Spaceship::ConnectAPI.patch_app(app_id: id, attributes: attributes, app_price_tier_id: app_price_tier_id, territory_ids: territory_ids)
106
+ return client.patch_app(app_id: id, attributes: attributes, app_price_tier_id: app_price_tier_id, territory_ids: territory_ids)
85
107
  end
86
108
 
87
109
  #
88
110
  # App Info
89
111
  #
90
112
 
91
- def fetch_live_app_info(includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
113
+ def fetch_live_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
114
+ client ||= Spaceship::ConnectAPI
92
115
  states = [
93
116
  Spaceship::ConnectAPI::AppInfo::AppStoreState::READY_FOR_SALE,
94
117
  Spaceship::ConnectAPI::AppInfo::AppStoreState::PENDING_APPLE_RELEASE,
@@ -97,13 +120,14 @@ module Spaceship
97
120
  Spaceship::ConnectAPI::AppInfo::AppStoreState::IN_REVIEW
98
121
  ]
99
122
 
100
- resp = Spaceship::ConnectAPI.get_app_infos(app_id: id, includes: includes)
123
+ resp = client.get_app_infos(app_id: id, includes: includes)
101
124
  return resp.to_models.select do |model|
102
125
  states.include?(model.app_store_state)
103
126
  end.first
104
127
  end
105
128
 
106
- def fetch_edit_app_info(includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
129
+ def fetch_edit_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
130
+ client ||= Spaceship::ConnectAPI
107
131
  states = [
108
132
  Spaceship::ConnectAPI::AppInfo::AppStoreState::PREPARE_FOR_SUBMISSION,
109
133
  Spaceship::ConnectAPI::AppInfo::AppStoreState::DEVELOPER_REJECTED,
@@ -113,7 +137,7 @@ module Spaceship
113
137
  Spaceship::ConnectAPI::AppInfo::AppStoreState::INVALID_BINARY
114
138
  ]
115
139
 
116
- resp = Spaceship::ConnectAPI.get_app_infos(app_id: id, includes: includes)
140
+ resp = client.get_app_infos(app_id: id, includes: includes)
117
141
  return resp.to_models.select do |model|
118
142
  states.include?(model.app_store_state)
119
143
  end.first
@@ -123,9 +147,10 @@ module Spaceship
123
147
  # Available Territories
124
148
  #
125
149
 
126
- def fetch_available_territories(filter: {}, includes: nil, limit: nil, sort: nil)
150
+ def fetch_available_territories(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
151
+ client ||= Spaceship::ConnectAPI
127
152
  filter ||= {}
128
- resps = Spaceship::ConnectAPI.get_available_territories(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort).all_pages
153
+ resps = client.get_available_territories(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort).all_pages
129
154
  return resps.flat_map(&:to_models)
130
155
  end
131
156
 
@@ -133,8 +158,9 @@ module Spaceship
133
158
  # App Pricing
134
159
  #
135
160
 
136
- def fetch_app_prices(filter: {}, includes: "priceTier", limit: nil, sort: nil)
137
- resp = Spaceship::ConnectAPI.get_app_prices(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort)
161
+ def fetch_app_prices(client: nil, filter: {}, includes: "priceTier", limit: nil, sort: nil)
162
+ client ||= Spaceship::ConnectAPI
163
+ resp = client.get_app_prices(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort)
138
164
  return resp.to_models
139
165
  end
140
166
 
@@ -142,7 +168,8 @@ module Spaceship
142
168
  # App Store Versions
143
169
  #
144
170
 
145
- def reject_version_if_possible!(platform: nil)
171
+ def reject_version_if_possible!(client: nil, platform: nil)
172
+ client ||= Spaceship::ConnectAPI
146
173
  platform ||= Spaceship::ConnectAPI::Platform::IOS
147
174
  filter = {
148
175
  appStoreState: [
@@ -155,7 +182,7 @@ module Spaceship
155
182
  }
156
183
 
157
184
  # Get the latest version
158
- version = get_app_store_versions(filter: filter, includes: "appStoreVersionSubmission")
185
+ version = get_app_store_versions(client: client, filter: filter, includes: "appStoreVersionSubmission")
159
186
  .sort_by { |v| Gem::Version.new(v.version_string) }
160
187
  .last
161
188
 
@@ -167,46 +194,50 @@ module Spaceship
167
194
  # This will either create a new version or change the version number
168
195
  # from an existing version
169
196
  # @return (Bool) Was something changed?
170
- def ensure_version!(version_string, platform: nil)
197
+ def ensure_version!(version_string, platform: nil, client: nil)
198
+ client ||= Spaceship::ConnectAPI
171
199
  app_store_version = get_edit_app_store_version(platform: platform)
172
200
 
173
201
  if app_store_version
174
202
  if version_string != app_store_version.version_string
175
203
  attributes = { versionString: version_string }
176
- app_store_version.update(attributes: attributes)
204
+ app_store_version.update(client: client, attributes: attributes)
177
205
  return true
178
206
  end
179
207
  return false
180
208
  else
181
209
  attributes = { versionString: version_string, platform: platform }
182
- Spaceship::ConnectAPI.post_app_store_version(app_id: id, attributes: attributes)
210
+ client.post_app_store_version(app_id: id, attributes: attributes)
183
211
 
184
212
  return true
185
213
  end
186
214
  end
187
215
 
188
- def get_latest_app_store_version(platform: nil, includes: nil)
216
+ def get_latest_app_store_version(client: nil, platform: nil, includes: nil)
217
+ client ||= Spaceship::ConnectAPI
189
218
  platform ||= Spaceship::ConnectAPI::Platform::IOS
190
219
  filter = {
191
220
  platform: platform
192
221
  }
193
222
 
194
223
  # Get the latest version
195
- return get_app_store_versions(filter: filter, includes: includes)
224
+ return get_app_store_versions(client: client, filter: filter, includes: includes)
196
225
  .sort_by { |v| Date.parse(v.created_date) }
197
226
  .last
198
227
  end
199
228
 
200
- def get_live_app_store_version(platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
229
+ def get_live_app_store_version(client: nil, platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
230
+ client ||= Spaceship::ConnectAPI
201
231
  platform ||= Spaceship::ConnectAPI::Platform::IOS
202
232
  filter = {
203
233
  appStoreState: Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::READY_FOR_SALE,
204
234
  platform: platform
205
235
  }
206
- return get_app_store_versions(filter: filter, includes: includes).first
236
+ return get_app_store_versions(client: client, filter: filter, includes: includes).first
207
237
  end
208
238
 
209
- def get_edit_app_store_version(platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
239
+ def get_edit_app_store_version(client: nil, platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
240
+ client ||= Spaceship::ConnectAPI
210
241
  platform ||= Spaceship::ConnectAPI::Platform::IOS
211
242
  filter = {
212
243
  appStoreState: [
@@ -221,21 +252,23 @@ module Spaceship
221
252
  }
222
253
 
223
254
  # Get the latest version
224
- return get_app_store_versions(filter: filter, includes: includes)
255
+ return get_app_store_versions(client: client, filter: filter, includes: includes)
225
256
  .sort_by { |v| Gem::Version.new(v.version_string) }
226
257
  .last
227
258
  end
228
259
 
229
- def get_in_review_app_store_version(platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
260
+ def get_in_review_app_store_version(client: nil, platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
261
+ client ||= Spaceship::ConnectAPI
230
262
  platform ||= Spaceship::ConnectAPI::Platform::IOS
231
263
  filter = {
232
264
  appStoreState: Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::IN_REVIEW,
233
265
  platform: platform
234
266
  }
235
- return get_app_store_versions(filter: filter, includes: includes).first
267
+ return get_app_store_versions(client: client, filter: filter, includes: includes).first
236
268
  end
237
269
 
238
- def get_pending_release_app_store_version(platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
270
+ def get_pending_release_app_store_version(client: nil, platform: nil, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES)
271
+ client ||= Spaceship::ConnectAPI
239
272
  platform ||= Spaceship::ConnectAPI::Platform::IOS
240
273
  filter = {
241
274
  appStoreState: [
@@ -244,23 +277,43 @@ module Spaceship
244
277
  ].join(','),
245
278
  platform: platform
246
279
  }
247
- return get_app_store_versions(filter: filter, includes: includes).first
280
+ return get_app_store_versions(client: client, filter: filter, includes: includes).first
248
281
  end
249
282
 
250
- def get_app_store_versions(filter: {}, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES, limit: nil, sort: nil)
251
- resps = Spaceship::ConnectAPI.get_app_store_versions(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort).all_pages
283
+ def get_app_store_versions(client: nil, filter: {}, includes: Spaceship::ConnectAPI::AppStoreVersion::ESSENTIAL_INCLUDES, limit: nil, sort: nil)
284
+ client ||= Spaceship::ConnectAPI
285
+ resps = client.get_app_store_versions(app_id: id, filter: filter, includes: includes, limit: limit, sort: sort).all_pages
252
286
  return resps.flat_map(&:to_models)
253
287
  end
254
288
 
289
+ #
290
+ # B2B
291
+ #
292
+
293
+ def disable_b2b
294
+ update(attributes: {
295
+ distributionType: DistributionType::APP_STORE,
296
+ education_discount_type: EducationDiscountType::NOT_DISCOUNTED
297
+ })
298
+ end
299
+
300
+ def enable_b2b
301
+ update(attributes: {
302
+ distributionType: App::DistributionType::CUSTOM,
303
+ education_discount_type: EducationDiscountType::NOT_APPLICABLE
304
+ })
305
+ end
306
+
255
307
  #
256
308
  # Beta Feedback
257
309
  #
258
310
 
259
- def get_beta_feedback(filter: {}, includes: "tester,build,screenshots", limit: nil, sort: nil)
311
+ def get_beta_feedback(client: nil, filter: {}, includes: "tester,build,screenshots", limit: nil, sort: nil)
312
+ client ||= Spaceship::ConnectAPI
260
313
  filter ||= {}
261
314
  filter["build.app"] = id
262
315
 
263
- resps = Spaceship::ConnectAPI.get_beta_feedback(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
316
+ resps = client.get_beta_feedback(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
264
317
  return resps.flat_map(&:to_models)
265
318
  end
266
319
 
@@ -268,11 +321,12 @@ module Spaceship
268
321
  # Beta Testers
269
322
  #
270
323
 
271
- def get_beta_testers(filter: {}, includes: nil, limit: nil, sort: nil)
324
+ def get_beta_testers(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
325
+ client ||= Spaceship::ConnectAPI
272
326
  filter ||= {}
273
327
  filter[:apps] = id
274
328
 
275
- resps = Spaceship::ConnectAPI.get_beta_testers(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
329
+ resps = client.get_beta_testers(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
276
330
  return resps.flat_map(&:to_models)
277
331
  end
278
332
 
@@ -280,40 +334,45 @@ module Spaceship
280
334
  # Builds
281
335
  #
282
336
 
283
- def get_builds(filter: {}, includes: nil, limit: nil, sort: nil)
337
+ def get_builds(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
338
+ client ||= Spaceship::ConnectAPI
284
339
  filter ||= {}
285
340
  filter[:app] = id
286
341
 
287
- resps = Spaceship::ConnectAPI.get_builds(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
342
+ resps = client.get_builds(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
288
343
  return resps.flat_map(&:to_models)
289
344
  end
290
345
 
291
- def get_build_deliveries(filter: {}, includes: nil, limit: nil, sort: nil)
346
+ def get_build_deliveries(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
347
+ client ||= Spaceship::ConnectAPI
292
348
  filter ||= {}
293
349
  filter[:app] = id
294
350
 
295
- resps = Spaceship::ConnectAPI.get_build_deliveries(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
351
+ resps = client.get_build_deliveries(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
296
352
  return resps.flat_map(&:to_models)
297
353
  end
298
354
 
299
- def get_beta_app_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
355
+ def get_beta_app_localizations(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
356
+ client ||= Spaceship::ConnectAPI
300
357
  filter ||= {}
301
358
  filter[:app] = id
302
359
 
303
- resps = Spaceship::ConnectAPI.get_beta_app_localizations(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
360
+ resps = client.get_beta_app_localizations(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
304
361
  return resps.flat_map(&:to_models)
305
362
  end
306
363
 
307
- def get_beta_groups(filter: {}, includes: nil, limit: nil, sort: nil)
364
+ def get_beta_groups(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
365
+ client ||= Spaceship::ConnectAPI
308
366
  filter ||= {}
309
367
  filter[:app] = id
310
368
 
311
- resps = Spaceship::ConnectAPI.get_beta_groups(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
369
+ resps = client.get_beta_groups(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
312
370
  return resps.flat_map(&:to_models)
313
371
  end
314
372
 
315
- def create_beta_group(group_name: nil, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false)
316
- resps = Spaceship::ConnectAPI.create_beta_group(
373
+ def create_beta_group(client: nil, group_name: nil, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false)
374
+ client ||= Spaceship::ConnectAPI
375
+ resps = client.create_beta_group(
317
376
  app_id: id,
318
377
  group_name: group_name,
319
378
  public_link_enabled: public_link_enabled,
@@ -323,13 +382,30 @@ module Spaceship
323
382
  return resps.flat_map(&:to_models).first
324
383
  end
325
384
 
385
+ #
386
+ # Education
387
+ #
388
+
389
+ def disable_educational_discount
390
+ update(attributes: {
391
+ education_discount_type: EducationDiscountType::NOT_DISCOUNTED
392
+ })
393
+ end
394
+
395
+ def enable_educational_discount
396
+ update(attributes: {
397
+ education_discount_type: EducationDiscountType::DISCOUNTED
398
+ })
399
+ end
400
+
326
401
  #
327
402
  # Users
328
403
  #
329
404
 
330
- def add_users(user_ids: nil)
405
+ def add_users(client: nil, user_ids: nil)
406
+ client ||= Spaceship::ConnectAPI
331
407
  user_ids.each do |user_id|
332
- Spaceship::ConnectAPI.add_user_visible_apps(user_id: user_id, app_ids: [id])
408
+ client.add_user_visible_apps(user_id: user_id, app_ids: [id])
333
409
  end
334
410
  end
335
411
  end