fastlane 2.126.0.beta.20190623200100 → 2.126.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +76 -76
- data/fastlane/lib/fastlane/actions/.slack.rb.swp +0 -0
- data/fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp +0 -0
- data/fastlane/lib/fastlane/actions/app_store_build_number.rb +1 -2
- data/fastlane/lib/fastlane/actions/oclint.rb +9 -2
- data/fastlane/lib/fastlane/actions/reset_simulator_contents.rb +34 -27
- data/fastlane/lib/fastlane/lane_manager_base.rb +4 -1
- data/fastlane/lib/fastlane/version.rb +1 -1
- data/fastlane/swift/Deliverfile.swift +1 -1
- data/fastlane/swift/DeliverfileProtocol.swift +3 -1
- data/fastlane/swift/Fastlane.swift +19 -5
- data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/fastlane/swift/Gymfile.swift +1 -1
- data/fastlane/swift/Matchfile.swift +1 -1
- data/fastlane/swift/Precheckfile.swift +1 -1
- data/fastlane/swift/Scanfile.swift +1 -1
- data/fastlane/swift/ScanfileProtocol.swift +3 -1
- data/fastlane/swift/Screengrabfile.swift +1 -1
- data/fastlane/swift/Snapshotfile.swift +1 -1
- data/fastlane_core/lib/fastlane_core/.build_watcher.rb.swp +0 -0
- data/fastlane_core/lib/fastlane_core/build_watcher.rb +2 -2
- data/pilot/lib/pilot/.build_manager.rb.swp +0 -0
- data/pilot/lib/pilot/.manager.rb.swp +0 -0
- data/pilot/lib/pilot/.tester_manager.rb.swp +0 -0
- data/pilot/lib/pilot/build_manager.rb +9 -14
- data/pilot/lib/pilot/manager.rb +2 -2
- data/pilot/lib/pilot/tester_exporter.rb +3 -3
- data/pilot/lib/pilot/tester_manager.rb +2 -2
- data/scan/lib/scan/options.rb +7 -1
- data/scan/lib/scan/test_command_generator.rb +1 -1
- data/snapshot/lib/assets/SnapshotHelper.swift +10 -4
- data/spaceship/lib/spaceship/connect_api.rb +42 -0
- data/spaceship/lib/spaceship/connect_api/.DS_Store +0 -0
- data/spaceship/lib/spaceship/connect_api/client.rb +178 -0
- data/spaceship/lib/spaceship/connect_api/model.rb +1 -15
- data/spaceship/lib/spaceship/connect_api/models/app.rb +97 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_app_localization.rb +28 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_app_review_detail.rb +32 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb +26 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_build_localization.rb +20 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_build_metric.rb +24 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_group.rb +41 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +56 -0
- data/spaceship/lib/spaceship/connect_api/models/beta_tester_metric.rb +43 -0
- data/spaceship/lib/spaceship/connect_api/models/build.rb +144 -0
- data/spaceship/lib/spaceship/connect_api/models/build_beta_detail.rb +56 -0
- data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +36 -0
- data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +46 -0
- data/spaceship/lib/spaceship/connect_api/models/bundle_id_capability.rb +37 -0
- data/spaceship/lib/spaceship/connect_api/models/certificate.rb +48 -0
- data/spaceship/lib/spaceship/connect_api/models/device.rb +53 -0
- data/spaceship/lib/spaceship/connect_api/models/pre_release_version.rb +20 -0
- data/spaceship/lib/spaceship/connect_api/models/profile.rb +60 -0
- data/spaceship/lib/spaceship/connect_api/models/user.rb +50 -0
- data/spaceship/lib/spaceship/connect_api/provisioning/client.rb +59 -0
- data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +48 -0
- data/spaceship/lib/spaceship/connect_api/response.rb +1 -1
- data/spaceship/lib/spaceship/connect_api/testflight/client.rb +18 -538
- data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +314 -19
- data/spaceship/lib/spaceship/connect_api/token.rb +13 -1
- data/spaceship/lib/spaceship/connect_api/users/client.rb +33 -0
- data/spaceship/lib/spaceship/connect_api/users/users.rb +16 -0
- data/spaceship/lib/spaceship/test_flight/build.rb +2 -2
- data/spaceship/lib/spaceship/test_flight/build_trains.rb +5 -56
- metadata +64 -48
- data/spaceship/lib/spaceship/connect_api/testflight/base.rb +0 -41
- data/spaceship/lib/spaceship/connect_api/testflight/models/app.rb +0 -99
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_localization.rb +0 -30
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_detail.rb +0 -34
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_app_review_submission.rb +0 -28
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_build_localization.rb +0 -22
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_build_metric.rb +0 -26
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_group.rb +0 -43
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_tester.rb +0 -58
- data/spaceship/lib/spaceship/connect_api/testflight/models/beta_tester_metric.rb +0 -45
- data/spaceship/lib/spaceship/connect_api/testflight/models/build.rb +0 -146
- data/spaceship/lib/spaceship/connect_api/testflight/models/build_beta_detail.rb +0 -58
- data/spaceship/lib/spaceship/connect_api/testflight/models/build_delivery.rb +0 -38
- data/spaceship/lib/spaceship/connect_api/testflight/models/pre_release_version.rb +0 -22
- data/spaceship/lib/spaceship/connect_api/testflight/models/user.rb +0 -52
Binary file
|
@@ -51,6 +51,7 @@ protocol ScanfileProtocol: class {
|
|
51
51
|
var slackOnlyOnFailure: Bool { get }
|
52
52
|
var destination: String? { get }
|
53
53
|
var customReportFileName: String? { get }
|
54
|
+
var xcodebuildCommand: String { get }
|
54
55
|
var failBuild: Bool { get }
|
55
56
|
}
|
56
57
|
|
@@ -107,9 +108,10 @@ extension ScanfileProtocol {
|
|
107
108
|
var slackOnlyOnFailure: Bool { return false }
|
108
109
|
var destination: String? { return nil }
|
109
110
|
var customReportFileName: String? { return nil }
|
111
|
+
var xcodebuildCommand: String { return "env NSUnbufferedIO=YES xcodebuild" }
|
110
112
|
var failBuild: Bool { return true }
|
111
113
|
}
|
112
114
|
|
113
115
|
// Please don't remove the lines below
|
114
116
|
// They are used to detect outdated files
|
115
|
-
// FastlaneRunnerAPIVersion [0.9.
|
117
|
+
// FastlaneRunnerAPIVersion [0.9.11]
|
Binary file
|
@@ -47,12 +47,12 @@ module FastlaneCore
|
|
47
47
|
watched_app_version = remove_version_leading_zeros(version: watched_app_version)
|
48
48
|
watched_build_version = remove_version_leading_zeros(version: watched_build_version)
|
49
49
|
|
50
|
-
build_deliveries = Spaceship::ConnectAPI::
|
50
|
+
build_deliveries = Spaceship::ConnectAPI::BuildDelivery.all(app_id: app_id, version: watched_app_version, build_number: watched_build_version)
|
51
51
|
build_delivery = build_deliveries.first
|
52
52
|
|
53
53
|
# Get processed builds when no longer in build deliveries
|
54
54
|
if build_delivery.nil?
|
55
|
-
matched_builds = Spaceship::ConnectAPI::
|
55
|
+
matched_builds = Spaceship::ConnectAPI::Build.all(
|
56
56
|
app_id: app_id,
|
57
57
|
version: watched_app_version,
|
58
58
|
build_number: watched_build_version,
|
Binary file
|
Binary file
|
Binary file
|
@@ -100,14 +100,14 @@ module Pilot
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# Get latest uploaded build if no build specified
|
103
|
-
build ||= Spaceship::ConnectAPI::
|
103
|
+
build ||= Spaceship::ConnectAPI::Build.all(app_id: app.id, sort: "-uploadedDate", limit: 1).first
|
104
104
|
|
105
105
|
# Verify the build has all the includes that we need
|
106
106
|
# and fetch a new build if not
|
107
107
|
if build && (!build.app || !build.build_beta_detail || !build.pre_release_version)
|
108
108
|
UI.important("Build did include information for app, build beta detail and pre release version")
|
109
109
|
UI.important("Fetching a new build with all the information needed")
|
110
|
-
build = Spaceship::ConnectAPI::
|
110
|
+
build = Spaceship::ConnectAPI::Build.get(build_id: build.id)
|
111
111
|
end
|
112
112
|
|
113
113
|
# Error out if no build
|
@@ -328,8 +328,7 @@ module Pilot
|
|
328
328
|
uses_non_exempt_encryption = options[:uses_non_exempt_encryption]
|
329
329
|
attributes = { usesNonExemptEncryption: uses_non_exempt_encryption }
|
330
330
|
|
331
|
-
|
332
|
-
client.patch_builds(build_id: uploaded_build.id, attributes: attributes)
|
331
|
+
Spaceship::ConnectAPI.patch_builds(build_id: uploaded_build.id, attributes: attributes)
|
333
332
|
|
334
333
|
UI.important("Export compliance has been set to '#{uses_non_exempt_encryption}'. Need to wait for build to finishing processing again...")
|
335
334
|
UI.important("Set 'ITSAppUsesNonExemptEncryption' in the 'Info.plist' to skip this step and speed up the submission")
|
@@ -350,8 +349,7 @@ module Pilot
|
|
350
349
|
attributes[:demoAccountRequired] = info[:demo_account_required] if info.key?(:demo_account_required)
|
351
350
|
attributes[:notes] = info[:notes] if info.key?(:notes)
|
352
351
|
|
353
|
-
|
354
|
-
client.patch_beta_app_review_detail(app_id: build.app.id, attributes: attributes)
|
352
|
+
Spaceship::ConnectAPI.patch_beta_app_review_detail(app_id: build.app.id, attributes: attributes)
|
355
353
|
end
|
356
354
|
|
357
355
|
def update_localized_app_review(build, info_by_lang, default_info: nil)
|
@@ -392,12 +390,11 @@ module Pilot
|
|
392
390
|
attributes[:tvOsPrivacyPolicy] = info[:tv_os_privacy_policy_url] if info.key?(:tv_os_privacy_policy_url)
|
393
391
|
attributes[:description] = info[:description] if info.key?(:description)
|
394
392
|
|
395
|
-
client = Spaceship::ConnectAPI::TestFlight.client
|
396
393
|
if localization
|
397
|
-
|
394
|
+
Spaceship::ConnectAPI.patch_beta_app_localizations(localization_id: localization.id, attributes: attributes)
|
398
395
|
else
|
399
396
|
attributes[:locale] = locale if locale
|
400
|
-
|
397
|
+
Spaceship::ConnectAPI.post_beta_app_localizations(app_id: app.id, attributes: attributes)
|
401
398
|
end
|
402
399
|
end
|
403
400
|
|
@@ -435,12 +432,11 @@ module Pilot
|
|
435
432
|
attributes = {}
|
436
433
|
attributes[:whatsNew] = self.class.sanitize_changelog(info[:whats_new]) if info.key?(:whats_new)
|
437
434
|
|
438
|
-
client = Spaceship::ConnectAPI::TestFlight.client
|
439
435
|
if localization
|
440
|
-
|
436
|
+
Spaceship::ConnectAPI.patch_beta_build_localizations(localization_id: localization.id, attributes: attributes)
|
441
437
|
else
|
442
438
|
attributes[:locale] = locale if locale
|
443
|
-
|
439
|
+
Spaceship::ConnectAPI.post_beta_build_localizations(build_id: build.id, attributes: attributes)
|
444
440
|
end
|
445
441
|
end
|
446
442
|
|
@@ -450,8 +446,7 @@ module Pilot
|
|
450
446
|
attributes = {}
|
451
447
|
attributes[:autoNotifyEnabled] = info[:auto_notify_enabled] if info.key?(:auto_notify_enabled)
|
452
448
|
|
453
|
-
|
454
|
-
client.patch_build_beta_details(build_beta_details_id: build_beta_detail.id, attributes: attributes)
|
449
|
+
Spaceship::ConnectAPI.patch_build_beta_details(build_beta_details_id: build_beta_detail.id, attributes: attributes)
|
455
450
|
end
|
456
451
|
end
|
457
452
|
# rubocop:enable Metrics/ClassLength
|
data/pilot/lib/pilot/manager.rb
CHANGED
@@ -29,7 +29,7 @@ module Pilot
|
|
29
29
|
def app
|
30
30
|
@app_id ||= fetch_app_id
|
31
31
|
|
32
|
-
@app ||= Spaceship::ConnectAPI::
|
32
|
+
@app ||= Spaceship::ConnectAPI::App.get(app_id: @app_id)
|
33
33
|
unless @app
|
34
34
|
UI.user_error!("Could not find app with #{(config[:apple_id] || config[:app_identifier])}")
|
35
35
|
end
|
@@ -48,7 +48,7 @@ module Pilot
|
|
48
48
|
config[:app_identifier] = fetch_app_identifier
|
49
49
|
|
50
50
|
if config[:app_identifier]
|
51
|
-
@app ||= Spaceship::ConnectAPI::
|
51
|
+
@app ||= Spaceship::ConnectAPI::App.find(config[:app_identifier])
|
52
52
|
UI.user_error!("Couldn't find app '#{config[:app_identifier]}' on the account of '#{config[:username]}' on App Store Connect") unless @app
|
53
53
|
@app_id ||= @app.id
|
54
54
|
end
|
@@ -15,7 +15,7 @@ module Pilot
|
|
15
15
|
if app
|
16
16
|
testers = app.get_beta_testers(includes: "apps,betaTesterMetrics,betaGroups")
|
17
17
|
else
|
18
|
-
testers = Spaceship::ConnectAPI::
|
18
|
+
testers = Spaceship::ConnectAPI::BetaTester.all(includes: "apps,betaTesterMetrics,betaGroups")
|
19
19
|
end
|
20
20
|
|
21
21
|
file = config[:testers_file_path]
|
@@ -41,13 +41,13 @@ module Pilot
|
|
41
41
|
|
42
42
|
def find_app(apple_id: nil, app_identifier: nil)
|
43
43
|
if app_identifier
|
44
|
-
app = Spaceship::ConnectAPI::
|
44
|
+
app = Spaceship::ConnectAPI::App.find(app_identifier)
|
45
45
|
UI.user_error!("Could not find an app by #{app_identifier}") unless app
|
46
46
|
return app
|
47
47
|
end
|
48
48
|
|
49
49
|
if apple_id
|
50
|
-
app = Spaceship::ConnectAPI::
|
50
|
+
app = Spaceship::ConnectAPI::App.get(app_id: apple_id)
|
51
51
|
UI.user_error!("Could not find an app by #{apple_id}") unless app
|
52
52
|
return app
|
53
53
|
end
|
@@ -83,13 +83,13 @@ module Pilot
|
|
83
83
|
|
84
84
|
def find_app(apple_id: nil, app_identifier: nil)
|
85
85
|
if app_identifier
|
86
|
-
app = Spaceship::ConnectAPI::
|
86
|
+
app = Spaceship::ConnectAPI::App.find(app_identifier)
|
87
87
|
UI.user_error!("Could not find an app by #{app_identifier}") unless app
|
88
88
|
return app
|
89
89
|
end
|
90
90
|
|
91
91
|
if apple_id
|
92
|
-
app = Spaceship::ConnectAPI::
|
92
|
+
app = Spaceship::ConnectAPI::App.get(app_id: apple_id)
|
93
93
|
UI.user_error!("Could not find an app by #{apple_id}") unless app
|
94
94
|
return app
|
95
95
|
end
|
data/scan/lib/scan/options.rb
CHANGED
@@ -375,7 +375,13 @@ module Scan
|
|
375
375
|
deprecated: "Use `--output_files` instead",
|
376
376
|
conflicting_options: [:output_files],
|
377
377
|
optional: true,
|
378
|
-
is_string: true)
|
378
|
+
is_string: true),
|
379
|
+
FastlaneCore::ConfigItem.new(key: :xcodebuild_command,
|
380
|
+
env_name: "GYM_XCODE_BUILD_COMMAND",
|
381
|
+
description: "Allows for override of the default `xcodebuild` command",
|
382
|
+
type: String,
|
383
|
+
optional: true,
|
384
|
+
default_value: "env NSUnbufferedIO=YES xcodebuild")
|
379
385
|
|
380
386
|
]
|
381
387
|
end
|
@@ -175,12 +175,18 @@ open class Snapshot: NSObject {
|
|
175
175
|
|
176
176
|
let window = app.windows.firstMatch
|
177
177
|
let screenshot = window.screenshot()
|
178
|
-
guard
|
179
|
-
|
178
|
+
guard var simulator = ProcessInfo().environment["SIMULATOR_DEVICE_NAME"], let screenshotsDir = screenshotsDirectory else { return }
|
179
|
+
|
180
180
|
do {
|
181
|
+
// The simulator name contains "Clone X of " inside the screenshot file when running parallelized UI Tests on concurrent devices
|
182
|
+
let regex = try NSRegularExpression(pattern: "Clone [0-1]+ of ")
|
183
|
+
let range = NSMakeRange(0, simulator.count)
|
184
|
+
simulator = regex.stringByReplacingMatches(in: simulator, range: range, withTemplate: "")
|
185
|
+
|
186
|
+
let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png")
|
181
187
|
try screenshot.pngRepresentation.write(to: path)
|
182
188
|
} catch let error {
|
183
|
-
NSLog("Problem writing screenshot: \(name) to \(
|
189
|
+
NSLog("Problem writing screenshot: \(name) to \(screenshotsDir)/\(simulator)-\(name).png")
|
184
190
|
NSLog(error.localizedDescription)
|
185
191
|
}
|
186
192
|
#endif
|
@@ -295,4 +301,4 @@ private extension CGFloat {
|
|
295
301
|
|
296
302
|
// Please don't remove the lines below
|
297
303
|
// They are used to detect outdated configuration files
|
298
|
-
// SnapshotHelperVersion [1.
|
304
|
+
// SnapshotHelperVersion [1.17]
|
@@ -2,4 +2,46 @@ require 'spaceship/connect_api/model'
|
|
2
2
|
require 'spaceship/connect_api/response'
|
3
3
|
require 'spaceship/connect_api/token'
|
4
4
|
|
5
|
+
require 'spaceship/connect_api/provisioning/provisioning'
|
5
6
|
require 'spaceship/connect_api/testflight/testflight'
|
7
|
+
require 'spaceship/connect_api/users/users'
|
8
|
+
|
9
|
+
require 'spaceship/connect_api/models/bundle_id_capability'
|
10
|
+
require 'spaceship/connect_api/models/bundle_id'
|
11
|
+
require 'spaceship/connect_api/models/certificate'
|
12
|
+
require 'spaceship/connect_api/models/device'
|
13
|
+
require 'spaceship/connect_api/models/profile'
|
14
|
+
|
15
|
+
require 'spaceship/connect_api/models/user'
|
16
|
+
|
17
|
+
require 'spaceship/connect_api/models/app'
|
18
|
+
require 'spaceship/connect_api/models/beta_app_localization'
|
19
|
+
require 'spaceship/connect_api/models/beta_build_localization'
|
20
|
+
require 'spaceship/connect_api/models/beta_build_metric'
|
21
|
+
require 'spaceship/connect_api/models/beta_app_review_detail'
|
22
|
+
require 'spaceship/connect_api/models/beta_app_review_submission'
|
23
|
+
require 'spaceship/connect_api/models/beta_group'
|
24
|
+
require 'spaceship/connect_api/models/beta_tester'
|
25
|
+
require 'spaceship/connect_api/models/beta_tester_metric'
|
26
|
+
require 'spaceship/connect_api/models/build'
|
27
|
+
require 'spaceship/connect_api/models/build_delivery'
|
28
|
+
require 'spaceship/connect_api/models/build_beta_detail'
|
29
|
+
require 'spaceship/connect_api/models/pre_release_version'
|
30
|
+
|
31
|
+
module Spaceship
|
32
|
+
class ConnectAPI
|
33
|
+
extend Spaceship::ConnectAPI::Provisioning
|
34
|
+
extend Spaceship::ConnectAPI::TestFlight
|
35
|
+
extend Spaceship::ConnectAPI::Users
|
36
|
+
|
37
|
+
@token = nil
|
38
|
+
|
39
|
+
class << self
|
40
|
+
attr_writer(:token)
|
41
|
+
end
|
42
|
+
|
43
|
+
class << self
|
44
|
+
attr_reader :token
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
Binary file
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require_relative '../client'
|
2
|
+
require_relative './response'
|
3
|
+
|
4
|
+
module Spaceship
|
5
|
+
class ConnectAPI
|
6
|
+
class Client < Spaceship::Client
|
7
|
+
attr_accessor :token
|
8
|
+
|
9
|
+
#####################################################
|
10
|
+
# @!group Client Init
|
11
|
+
#####################################################
|
12
|
+
|
13
|
+
# Instantiates a client with cookie session or a JWT token.
|
14
|
+
def initialize(cookie: nil, current_team_id: nil, token: nil)
|
15
|
+
if token.nil?
|
16
|
+
super(cookie: cookie, current_team_id: current_team_id)
|
17
|
+
else
|
18
|
+
options = {
|
19
|
+
request: {
|
20
|
+
timeout: (ENV["SPACESHIP_TIMEOUT"] || 300).to_i,
|
21
|
+
open_timeout: (ENV["SPACESHIP_TIMEOUT"] || 300).to_i
|
22
|
+
}
|
23
|
+
}
|
24
|
+
@token = token
|
25
|
+
@current_team_id = current_team_id
|
26
|
+
|
27
|
+
hostname = "https://api.appstoreconnect.apple.com/v1/"
|
28
|
+
|
29
|
+
@client = Faraday.new(hostname, options) do |c|
|
30
|
+
c.response(:json, content_type: /\bjson$/)
|
31
|
+
c.response(:xml, content_type: /\bxml$/)
|
32
|
+
c.response(:plist, content_type: /\bplist$/)
|
33
|
+
c.use(FaradayMiddleware::RelsMiddleware)
|
34
|
+
c.adapter(Faraday.default_adapter)
|
35
|
+
c.headers["Authorization"] = "Bearer #{token.text}"
|
36
|
+
|
37
|
+
if ENV['SPACESHIP_DEBUG']
|
38
|
+
# for debugging only
|
39
|
+
# This enables tracking of networking requests using Charles Web Proxy
|
40
|
+
c.proxy = "https://127.0.0.1:8888"
|
41
|
+
c.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
42
|
+
elsif ENV["SPACESHIP_PROXY"]
|
43
|
+
c.proxy = ENV["SPACESHIP_PROXY"]
|
44
|
+
c.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if ENV["SPACESHIP_PROXY_SSL_VERIFY_NONE"]
|
45
|
+
end
|
46
|
+
|
47
|
+
if ENV["DEBUG"]
|
48
|
+
puts("To run spaceship through a local proxy, use SPACESHIP_DEBUG")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.hostname
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Helpers
|
60
|
+
#
|
61
|
+
|
62
|
+
def web_session?
|
63
|
+
return @token.nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_params(filter: nil, includes: nil, limit: nil, sort: nil, cursor: nil)
|
67
|
+
params = {}
|
68
|
+
|
69
|
+
filter = filter.delete_if { |k, v| v.nil? } if filter
|
70
|
+
|
71
|
+
params[:filter] = filter if filter && !filter.empty?
|
72
|
+
params[:include] = includes if includes
|
73
|
+
params[:limit] = limit if limit
|
74
|
+
params[:sort] = sort if sort
|
75
|
+
params[:cursor] = cursor if cursor
|
76
|
+
|
77
|
+
return params
|
78
|
+
end
|
79
|
+
|
80
|
+
def get(url_or_path, params = nil)
|
81
|
+
response = request(:get) do |req|
|
82
|
+
req.url(url_or_path)
|
83
|
+
req.options.params_encoder = Faraday::NestedParamsEncoder
|
84
|
+
req.params = params if params
|
85
|
+
req.headers['Content-Type'] = 'application/json'
|
86
|
+
end
|
87
|
+
handle_response(response)
|
88
|
+
end
|
89
|
+
|
90
|
+
def post(url_or_path, body)
|
91
|
+
response = request(:post) do |req|
|
92
|
+
req.url(url_or_path)
|
93
|
+
req.body = body.to_json
|
94
|
+
req.headers['Content-Type'] = 'application/json'
|
95
|
+
end
|
96
|
+
handle_response(response)
|
97
|
+
end
|
98
|
+
|
99
|
+
def patch(url_or_path, body)
|
100
|
+
response = request(:patch) do |req|
|
101
|
+
req.url(url_or_path)
|
102
|
+
req.body = body.to_json
|
103
|
+
req.headers['Content-Type'] = 'application/json'
|
104
|
+
end
|
105
|
+
handle_response(response)
|
106
|
+
end
|
107
|
+
|
108
|
+
def delete(url_or_path, params = nil, body = nil)
|
109
|
+
response = request(:delete) do |req|
|
110
|
+
req.url(url_or_path)
|
111
|
+
req.options.params_encoder = Faraday::NestedParamsEncoder if params
|
112
|
+
req.params = params if params
|
113
|
+
req.body = body.to_json if body
|
114
|
+
req.headers['Content-Type'] = 'application/json' if body
|
115
|
+
end
|
116
|
+
handle_response(response)
|
117
|
+
end
|
118
|
+
|
119
|
+
protected
|
120
|
+
|
121
|
+
def handle_response(response)
|
122
|
+
if (200...300).cover?(response.status) && (response.body.nil? || response.body.empty?)
|
123
|
+
return
|
124
|
+
end
|
125
|
+
|
126
|
+
raise InternalServerError, "Server error got #{response.status}" if (500...600).cover?(response.status)
|
127
|
+
|
128
|
+
unless response.body.kind_of?(Hash)
|
129
|
+
raise UnexpectedResponse, response.body
|
130
|
+
end
|
131
|
+
|
132
|
+
raise UnexpectedResponse, response.body['error'] if response.body['error']
|
133
|
+
|
134
|
+
raise UnexpectedResponse, handle_errors(response) if response.body['errors']
|
135
|
+
|
136
|
+
raise UnexpectedResponse, "Temporary App Store Connect error: #{response.body}" if response.body['statusCode'] == 'ERROR'
|
137
|
+
|
138
|
+
return Spaceship::ConnectAPI::Response.new(body: response.body, status: response.status, client: self)
|
139
|
+
end
|
140
|
+
|
141
|
+
def handle_errors(response)
|
142
|
+
# Example error format
|
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"
|
152
|
+
# }
|
153
|
+
# } ]
|
154
|
+
# }
|
155
|
+
|
156
|
+
return response.body['errors'].map do |error|
|
157
|
+
"#{error['title']} - #{error['detail']}"
|
158
|
+
end.join(" ")
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def local_variable_get(binding, name)
|
164
|
+
if binding.respond_to?(:local_variable_get)
|
165
|
+
binding.local_variable_get(name)
|
166
|
+
else
|
167
|
+
binding.eval(name.to_s)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def provider_id
|
172
|
+
return team_id if self.provider.nil?
|
173
|
+
self.provider.provider_id
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
# rubocop:enable Metrics/ClassLength
|
178
|
+
end
|