fastlane 2.149.1 → 2.150.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/deliver/lib/deliver.rb +0 -1
- data/deliver/lib/deliver/app_screenshot.rb +26 -25
- data/deliver/lib/deliver/download_screenshots.rb +46 -26
- data/deliver/lib/deliver/options.rb +6 -11
- data/deliver/lib/deliver/runner.rb +7 -21
- data/deliver/lib/deliver/setup.rb +5 -30
- data/deliver/lib/deliver/submit_for_review.rb +170 -86
- data/deliver/lib/deliver/upload_metadata.rb +355 -143
- data/deliver/lib/deliver/upload_price_tier.rb +22 -8
- data/deliver/lib/deliver/upload_screenshots.rb +140 -39
- data/{scan/lib/scan/.test_command_generator.rb.swp → fastlane/lib/fastlane/actions/.hockey.rb.swp} +0 -0
- data/fastlane/lib/fastlane/actions/.slack.rb.swp +0 -0
- data/{snapshot/lib/snapshot/.test_command_generator_base.rb.swp → fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp} +0 -0
- data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
- data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +81 -96
- data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +3 -2
- data/fastlane/lib/fastlane/actions/download_dsyms.rb +7 -1
- data/fastlane/lib/fastlane/actions/google_play_track_release_names.rb +74 -0
- data/fastlane/lib/fastlane/actions/set_changelog.rb +23 -20
- data/fastlane/lib/fastlane/actions/slack.rb +1 -1
- data/fastlane/lib/fastlane/actions/spm.rb +7 -0
- data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +1 -32
- data/fastlane/lib/fastlane/lane.rb +3 -3
- data/fastlane/lib/fastlane/swift_fastlane_function.rb +8 -4
- data/fastlane/lib/fastlane/version.rb +1 -1
- data/fastlane/swift/ControlCommand.swift +1 -0
- data/fastlane/swift/Fastlane.swift +48 -12
- data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/xcshareddata/xcschemes/FastlaneRunner.xcscheme +3 -9
- data/fastlane/swift/LaneFileProtocol.swift +2 -5
- data/fastlane/swift/MatchfileProtocol.swift +1 -1
- data/fastlane/swift/RubyCommand.swift +29 -6
- data/fastlane/swift/RubyCommandable.swift +1 -0
- data/fastlane/swift/Runner.swift +85 -13
- data/fastlane/swift/ScanfileProtocol.swift +1 -1
- data/fastlane/swift/SnapshotfileProtocol.swift +3 -3
- data/fastlane/swift/SocketClient.swift +76 -45
- data/fastlane/swift/SocketClientDelegateProtocol.swift +1 -1
- data/fastlane/swift/SocketResponse.swift +1 -0
- data/fastlane_core/lib/fastlane_core/build_watcher.rb +4 -4
- data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +1 -3
- data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +89 -52
- data/fastlane_core/lib/fastlane_core/pkg_file_analyser.rb +7 -0
- data/frameit/lib/frameit/device_types.rb +100 -100
- data/pilot/lib/pilot/.manager.rb.swp +0 -0
- data/produce/lib/produce/itunes_connect.rb +59 -21
- data/produce/lib/produce/options.rb +3 -3
- data/sigh/lib/assets/resign.sh +7 -7
- data/snapshot/lib/assets/SnapshotHelper.swift +5 -5
- data/snapshot/lib/assets/SnapshotHelperXcode8.swift +3 -3
- data/snapshot/lib/snapshot/options.rb +0 -1
- data/snapshot/lib/snapshot/reports_generator.rb +8 -1
- data/spaceship/lib/spaceship/client.rb +4 -3
- data/spaceship/lib/spaceship/connect_api.rb +25 -2
- data/spaceship/lib/spaceship/connect_api/.DS_Store +0 -0
- data/spaceship/lib/spaceship/connect_api/client.rb +97 -31
- data/spaceship/lib/spaceship/connect_api/file_uploader.rb +98 -0
- data/spaceship/lib/spaceship/connect_api/model.rb +1 -1
- data/spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb +113 -0
- data/spaceship/lib/spaceship/connect_api/models/app.rb +135 -3
- data/spaceship/lib/spaceship/connect_api/models/app_category.rb +94 -0
- data/spaceship/lib/spaceship/connect_api/models/app_info.rb +67 -0
- data/spaceship/lib/spaceship/connect_api/models/app_info_localization.rb +38 -0
- data/spaceship/lib/spaceship/connect_api/models/app_preview.rb +129 -0
- data/spaceship/lib/spaceship/connect_api/models/app_preview_set.rb +71 -0
- data/spaceship/lib/spaceship/connect_api/models/app_price.rb +22 -0
- data/spaceship/lib/spaceship/connect_api/models/app_price_tier.rb +12 -0
- data/spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb +71 -0
- data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +146 -0
- data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +125 -0
- data/spaceship/lib/spaceship/connect_api/models/app_store_review_detail.rb +51 -0
- data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +183 -0
- data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +86 -0
- data/spaceship/lib/spaceship/connect_api/models/app_store_version_phased_release.rb +36 -0
- data/spaceship/lib/spaceship/connect_api/models/app_store_version_submission.rb +26 -0
- data/spaceship/lib/spaceship/connect_api/models/build.rb +4 -0
- data/spaceship/lib/spaceship/connect_api/models/idfa_declaration.rb +40 -0
- data/spaceship/lib/spaceship/connect_api/models/reset_ratings_request.rb +26 -0
- data/spaceship/lib/spaceship/connect_api/models/territory.rb +27 -0
- data/spaceship/lib/spaceship/connect_api/models/user.rb +2 -1
- data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +10 -3
- data/spaceship/lib/spaceship/connect_api/tunes/client.rb +33 -0
- data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +844 -0
- data/spaceship/lib/spaceship/connect_api/users/users.rb +13 -0
- data/spaceship/lib/spaceship/spaceauth_runner.rb +2 -2
- data/supply/lib/supply/client.rb +19 -0
- data/supply/lib/supply/reader.rb +16 -0
- metadata +34 -22
- data/deliver/lib/deliver/upload_assets.rb +0 -27
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
module Spaceship
|
3
|
+
class ConnectAPI
|
4
|
+
class AppInfo
|
5
|
+
include Spaceship::ConnectAPI::Model
|
6
|
+
|
7
|
+
attr_accessor :app_store_state
|
8
|
+
attr_accessor :app_store_age_rating
|
9
|
+
attr_accessor :brazil_age_rating
|
10
|
+
attr_accessor :kids_age_band
|
11
|
+
|
12
|
+
module AppStoreState
|
13
|
+
READY_FOR_SALE = "READY_FOR_SALE"
|
14
|
+
WAITING_FOR_REVIEW = "WAITING_FOR_REVIEW"
|
15
|
+
DEVELOPER_REJECTED = "DEVELOPER_REJECTED"
|
16
|
+
REJECTED = "REJECTED"
|
17
|
+
PREPARE_FOR_SUBMISSION = "PREPARE_FOR_SUBMISSION"
|
18
|
+
METADATA_REJECTED = "METADATA_REJECTED"
|
19
|
+
INVALID_BINARY = "INVALID_BINARY"
|
20
|
+
end
|
21
|
+
|
22
|
+
module AppStoreAgeRating
|
23
|
+
FOUR_PLUS = "FOUR_PLUS"
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_mapping({
|
27
|
+
"appStoreState" => "app_store_state",
|
28
|
+
"appStoreAgeRating" => "app_store_age_rating",
|
29
|
+
"brazilAgeRating" => "brazil_age_rating",
|
30
|
+
"kidsAgeBand" => "kids_age_band"
|
31
|
+
})
|
32
|
+
|
33
|
+
def self.type
|
34
|
+
return "appInfos"
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# API
|
39
|
+
#
|
40
|
+
|
41
|
+
def update(filter: {}, includes: nil, limit: nil, sort: nil)
|
42
|
+
Spaceship::ConnectAPI.patch_app_info(app_info_id: id).first
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_categories(category_id_map: nil)
|
46
|
+
Spaceship::ConnectAPI.patch_app_info_categories(app_info_id: id, category_id_map: category_id_map).first
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
|
50
|
+
Spaceship::ConnectAPI.delete_app_info(app_info_id: id)
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# App Info Localizations
|
55
|
+
#
|
56
|
+
|
57
|
+
def create_app_info_localization(attributes: nil)
|
58
|
+
resp = Spaceship::ConnectAPI.post_app_info_localization(app_info_id: id, attributes: attributes)
|
59
|
+
return resp.to_models.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_app_info_localizations(filter: {}, includes: nil, limit: nil, sort: nil)
|
63
|
+
return Spaceship::ConnectAPI.get_app_info_localizations(app_info_id: id, filter: filter, includes: includes, limit: limit, sort: sort)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
module Spaceship
|
3
|
+
class ConnectAPI
|
4
|
+
class AppInfoLocalization
|
5
|
+
include Spaceship::ConnectAPI::Model
|
6
|
+
|
7
|
+
attr_accessor :locale
|
8
|
+
attr_accessor :name
|
9
|
+
attr_accessor :subtitle
|
10
|
+
attr_accessor :privacy_policy_url
|
11
|
+
attr_accessor :privacy_policy_text
|
12
|
+
|
13
|
+
attr_mapping({
|
14
|
+
"locale" => "locale",
|
15
|
+
"name" => "name",
|
16
|
+
"subtitle" => "subtitle",
|
17
|
+
"privacyPolicyUrl" => "privacy_policy_url",
|
18
|
+
"privacyPolicyText" => "privacy_policy_text"
|
19
|
+
})
|
20
|
+
|
21
|
+
def self.type
|
22
|
+
return "appInfoLocalizations"
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# API
|
27
|
+
#
|
28
|
+
|
29
|
+
def update(attributes: nil)
|
30
|
+
Spaceship::ConnectAPI.patch_app_info_localization(app_info_localization_id: id, attributes: attributes)
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
|
34
|
+
Spaceship::ConnectAPI.delete_app_info_localization(app_info_localization_id: id)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
require_relative '../file_uploader'
|
3
|
+
require 'spaceship/globals'
|
4
|
+
|
5
|
+
require 'digest/md5'
|
6
|
+
|
7
|
+
module Spaceship
|
8
|
+
class ConnectAPI
|
9
|
+
class AppPreview
|
10
|
+
include Spaceship::ConnectAPI::Model
|
11
|
+
|
12
|
+
attr_accessor :file_size
|
13
|
+
attr_accessor :file_name
|
14
|
+
attr_accessor :source_file_checksum
|
15
|
+
attr_accessor :preview_frame_time_code
|
16
|
+
attr_accessor :mime_type
|
17
|
+
attr_accessor :video_url
|
18
|
+
attr_accessor :preview_image
|
19
|
+
attr_accessor :upload_operations
|
20
|
+
attr_accessor :asset_deliver_state
|
21
|
+
attr_accessor :upload
|
22
|
+
|
23
|
+
attr_mapping({
|
24
|
+
"fileSize" => "file_size",
|
25
|
+
"fileName" => "file_name",
|
26
|
+
"sourceFileChecksum" => "source_file_checksum",
|
27
|
+
"previewFrameTimeCode" => "preview_frame_time_code",
|
28
|
+
"mimeType" => "mime_type",
|
29
|
+
"videoUrl" => "video_url",
|
30
|
+
"previewImage" => "preview_image",
|
31
|
+
"uploadOperations" => "upload_operations",
|
32
|
+
"assetDeliveryState" => "asset_delivery_state",
|
33
|
+
"uploaded" => "uploaded"
|
34
|
+
})
|
35
|
+
|
36
|
+
def self.type
|
37
|
+
return "appPreviews"
|
38
|
+
end
|
39
|
+
|
40
|
+
def complete?
|
41
|
+
(asset_delivery_state || {})["state"] == "COMPLETE"
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# API
|
46
|
+
#
|
47
|
+
|
48
|
+
def self.get(app_preview_id: nil)
|
49
|
+
Spaceship::ConnectAPI.get_app_preview(app_preview_id: app_preview_id).first
|
50
|
+
end
|
51
|
+
|
52
|
+
# Creates an AppPreview in an AppPreviewSet
|
53
|
+
# Setting the optional frame_time_code will force polling until video is done processing
|
54
|
+
# @param app_preview_set_id The AppPreviewSet id
|
55
|
+
# @param path The path of the file
|
56
|
+
# @param frame_time_code The time code for the preview still frame (ex: "00:00:07:01")
|
57
|
+
def self.create(app_preview_set_id: nil, path: nil, frame_time_code: nil)
|
58
|
+
require 'faraday'
|
59
|
+
|
60
|
+
filename = File.basename(path)
|
61
|
+
filesize = File.size(path)
|
62
|
+
bytes = File.binread(path)
|
63
|
+
|
64
|
+
post_attributes = {
|
65
|
+
fileSize: filesize,
|
66
|
+
fileName: filename
|
67
|
+
}
|
68
|
+
|
69
|
+
# Create placeholder
|
70
|
+
preview = Spaceship::ConnectAPI.post_app_preview(
|
71
|
+
app_preview_set_id: app_preview_set_id,
|
72
|
+
attributes: post_attributes
|
73
|
+
).to_models.first
|
74
|
+
|
75
|
+
# Upload the file
|
76
|
+
upload_operations = preview.upload_operations
|
77
|
+
Spaceship::ConnectAPI::FileUploader.upload(upload_operations, bytes)
|
78
|
+
|
79
|
+
# Update file uploading complete
|
80
|
+
patch_attributes = {
|
81
|
+
uploaded: true,
|
82
|
+
sourceFileChecksum: Digest::MD5.hexdigest(bytes)
|
83
|
+
}
|
84
|
+
|
85
|
+
begin
|
86
|
+
preview = Spaceship::ConnectAPI.patch_app_preview(
|
87
|
+
app_preview_id: preview.id,
|
88
|
+
attributes: patch_attributes
|
89
|
+
).to_models.first
|
90
|
+
rescue => error
|
91
|
+
puts("Failed to patch app preview. Update may have gone through so verifying") if Spaceship::Globals.verbose?
|
92
|
+
|
93
|
+
preview = Spaceship::ConnectAPI::AppPreview.get(app_preview_id: preview.id)
|
94
|
+
raise error unless preview.complete?
|
95
|
+
end
|
96
|
+
|
97
|
+
# Poll for video processing completion to set still frame time
|
98
|
+
unless frame_time_code.nil?
|
99
|
+
loop do
|
100
|
+
unless preview.video_url.nil?
|
101
|
+
puts("Preview processing complete!") if Spaceship::Globals.verbose?
|
102
|
+
preview = preview.update(attributes: {
|
103
|
+
previewFrameTimeCode: frame_time_code
|
104
|
+
})
|
105
|
+
puts("Updated preview frame time code!") if Spaceship::Globals.verbose?
|
106
|
+
break
|
107
|
+
end
|
108
|
+
|
109
|
+
sleep_time = 30
|
110
|
+
puts("Waiting #{sleep_time} seconds before checking status of processing...") if Spaceship::Globals.verbose?
|
111
|
+
sleep(sleep_time)
|
112
|
+
|
113
|
+
preview = Spaceship::ConnectAPI::AppPreview.get(app_preview_id: preview.id)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
preview
|
118
|
+
end
|
119
|
+
|
120
|
+
def update(attributes: nil)
|
121
|
+
Spaceship::ConnectAPI.patch_app_preview(app_preview_id: id, attributes: attributes)
|
122
|
+
end
|
123
|
+
|
124
|
+
def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
|
125
|
+
Spaceship::ConnectAPI.delete_app_preview(app_preview_id: id)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
require_relative './app_preview'
|
3
|
+
|
4
|
+
module Spaceship
|
5
|
+
class ConnectAPI
|
6
|
+
class AppPreviewSet
|
7
|
+
include Spaceship::ConnectAPI::Model
|
8
|
+
|
9
|
+
attr_accessor :preview_type
|
10
|
+
|
11
|
+
attr_accessor :app_previews
|
12
|
+
|
13
|
+
module PreviewType
|
14
|
+
IPHONE_35 = "IPHONE_35"
|
15
|
+
IPHONE_40 = "IPHONE_40"
|
16
|
+
IPHONE_47 = "IPHONE_47"
|
17
|
+
IPHONE_55 = "IPHONE_55"
|
18
|
+
IPHONE_58 = "IPHONE_58"
|
19
|
+
IPHONE_65 = "IPHONE_65"
|
20
|
+
|
21
|
+
IPAD_97 = "IPAD_97"
|
22
|
+
IPAD_105 = "IPAD_105"
|
23
|
+
IPAD_PRO_3GEN_11 = "IPAD_PRO_3GEN_11"
|
24
|
+
IPAD_PRO_129 = "IPAD_PRO_129"
|
25
|
+
IPAD_PRO_3GEN_129 = "IPAD_PRO_3GEN_129"
|
26
|
+
|
27
|
+
DESKTOP = "DESKTOP"
|
28
|
+
|
29
|
+
ALL = [
|
30
|
+
IPHONE_35,
|
31
|
+
IPHONE_40,
|
32
|
+
IPHONE_47,
|
33
|
+
IPHONE_55,
|
34
|
+
IPHONE_58,
|
35
|
+
IPHONE_65,
|
36
|
+
|
37
|
+
IPAD_97,
|
38
|
+
IPAD_105,
|
39
|
+
IPAD_PRO_3GEN_11,
|
40
|
+
IPAD_PRO_129,
|
41
|
+
IPAD_PRO_3GEN_129,
|
42
|
+
|
43
|
+
DESKTOP
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
attr_mapping({
|
48
|
+
"previewType" => "preview_type",
|
49
|
+
|
50
|
+
"appPreviews" => "app_previews"
|
51
|
+
})
|
52
|
+
|
53
|
+
def self.type
|
54
|
+
return "appPreviewSets"
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# API
|
59
|
+
#
|
60
|
+
|
61
|
+
def self.all(filter: {}, includes: nil, limit: nil, sort: nil)
|
62
|
+
resp = Spaceship::ConnectAPI.get_app_preview_sets(filter: filter, includes: includes, limit: limit, sort: sort)
|
63
|
+
return resp.to_models
|
64
|
+
end
|
65
|
+
|
66
|
+
def upload_preview(path: nil, frame_time_code: nil)
|
67
|
+
return Spaceship::ConnectAPI::AppPreview.create(app_preview_set_id: id, path: path, frame_time_code: frame_time_code)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
module Spaceship
|
3
|
+
class ConnectAPI
|
4
|
+
class AppPrice
|
5
|
+
include Spaceship::ConnectAPI::Model
|
6
|
+
|
7
|
+
attr_accessor :start_date
|
8
|
+
|
9
|
+
attr_accessor :price_tier
|
10
|
+
|
11
|
+
attr_mapping({
|
12
|
+
"startDate" => "start_date",
|
13
|
+
|
14
|
+
"priceTier" => "price_tier"
|
15
|
+
})
|
16
|
+
|
17
|
+
def self.type
|
18
|
+
return "appPrices"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
require_relative '../file_uploader'
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
module Spaceship
|
6
|
+
class ConnectAPI
|
7
|
+
class AppReviewAttachment
|
8
|
+
include Spaceship::ConnectAPI::Model
|
9
|
+
|
10
|
+
attr_accessor :file_name
|
11
|
+
attr_accessor :source_file_checksum
|
12
|
+
attr_accessor :upload_operations
|
13
|
+
attr_accessor :asset_delivery_state
|
14
|
+
attr_accessor :uploaded
|
15
|
+
|
16
|
+
attr_mapping({
|
17
|
+
"fileName" => "file_name",
|
18
|
+
"sourceFileChecksum" => "source_file_checksum",
|
19
|
+
"uploadOperations" => "upload_operations",
|
20
|
+
"assetDeliveryState" => "asset_delivery_state",
|
21
|
+
"uploaded" => "uploaded"
|
22
|
+
})
|
23
|
+
|
24
|
+
def self.type
|
25
|
+
return "appReviewAttachments"
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# API
|
30
|
+
#
|
31
|
+
|
32
|
+
def self.create(app_store_review_detail_id: nil, path: nil)
|
33
|
+
require 'faraday'
|
34
|
+
|
35
|
+
filename = File.basename(path)
|
36
|
+
filesize = File.size(path)
|
37
|
+
bytes = File.binread(path)
|
38
|
+
|
39
|
+
post_attributes = {
|
40
|
+
fileSize: filesize,
|
41
|
+
fileName: filename
|
42
|
+
}
|
43
|
+
|
44
|
+
# Create placeholder
|
45
|
+
attachment = Spaceship::ConnectAPI.post_app_review_attachment(
|
46
|
+
app_store_review_detail_id: app_store_review_detail_id,
|
47
|
+
attributes: post_attributes
|
48
|
+
).to_models.first
|
49
|
+
|
50
|
+
# Upload the file
|
51
|
+
upload_operations = attachment.upload_operations
|
52
|
+
Spaceship::ConnectAPI::FileUploader.upload(upload_operations, bytes)
|
53
|
+
|
54
|
+
# Update file uploading complete
|
55
|
+
patch_attributes = {
|
56
|
+
uploaded: true,
|
57
|
+
sourceFileChecksum: Digest::MD5.hexdigest(bytes)
|
58
|
+
}
|
59
|
+
|
60
|
+
Spaceship::ConnectAPI.patch_app_review_attachment(
|
61
|
+
app_review_attachment_id: attachment.id,
|
62
|
+
attributes: patch_attributes
|
63
|
+
).to_models.first
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
|
67
|
+
Spaceship::ConnectAPI.delete_app_review_attachment(app_review_attachment_id: id)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require_relative '../model'
|
2
|
+
require_relative '../file_uploader'
|
3
|
+
require 'spaceship/globals'
|
4
|
+
|
5
|
+
require 'digest/md5'
|
6
|
+
|
7
|
+
module Spaceship
|
8
|
+
class ConnectAPI
|
9
|
+
class AppScreenshot
|
10
|
+
include Spaceship::ConnectAPI::Model
|
11
|
+
|
12
|
+
attr_accessor :file_name
|
13
|
+
attr_accessor :source_file_checksum
|
14
|
+
attr_accessor :image_asset
|
15
|
+
attr_accessor :asset_token
|
16
|
+
attr_accessor :asset_type
|
17
|
+
attr_accessor :upload_operations
|
18
|
+
attr_accessor :asset_delivery_state
|
19
|
+
attr_accessor :uploaded
|
20
|
+
|
21
|
+
attr_mapping({
|
22
|
+
"fileName" => "file_name",
|
23
|
+
"sourceFileChecksum" => "source_file_checksum",
|
24
|
+
"imageAsset" => "image_asset",
|
25
|
+
"assetToken" => "asset_token",
|
26
|
+
"assetType" => "asset_type",
|
27
|
+
"uploadOperations" => "upload_operations",
|
28
|
+
"assetDeliveryState" => "asset_delivery_state",
|
29
|
+
"uploaded" => "uploaded"
|
30
|
+
})
|
31
|
+
|
32
|
+
def self.type
|
33
|
+
return "appScreenshots"
|
34
|
+
end
|
35
|
+
|
36
|
+
def complete?
|
37
|
+
(asset_delivery_state || {})["state"] == "COMPLETE"
|
38
|
+
end
|
39
|
+
|
40
|
+
def error?
|
41
|
+
(asset_delivery_state || {})["state"] == "FAILED"
|
42
|
+
end
|
43
|
+
|
44
|
+
def error_messages
|
45
|
+
errors = (asset_delivery_state || {})["errors"]
|
46
|
+
(errors || []).map do |error|
|
47
|
+
[error["code"], error["description"]].compact.join(" - ")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# This does not download the source image (exact image that was uploaded)
|
52
|
+
# This downloads a modified version.
|
53
|
+
# This image won't have the same checksums as source_file_checksum.
|
54
|
+
#
|
55
|
+
# There is an open radar for allowing downloading of source file.
|
56
|
+
# https://openradar.appspot.com/radar?id=4980344105205760
|
57
|
+
def image_asset_url(width: nil, height: nil, type: "png")
|
58
|
+
return nil if image_asset.nil?
|
59
|
+
|
60
|
+
template_url = image_asset["templateUrl"]
|
61
|
+
width ||= image_asset["width"]
|
62
|
+
height ||= image_asset["height"]
|
63
|
+
|
64
|
+
return template_url
|
65
|
+
.gsub("{w}", width.to_s)
|
66
|
+
.gsub("{h}", height.to_s)
|
67
|
+
.gsub("{f}", type)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# API
|
72
|
+
#
|
73
|
+
#
|
74
|
+
|
75
|
+
def self.create(app_screenshot_set_id: nil, path: nil, wait_for_processing: true)
|
76
|
+
require 'faraday'
|
77
|
+
|
78
|
+
filename = File.basename(path)
|
79
|
+
filesize = File.size(path)
|
80
|
+
bytes = File.binread(path)
|
81
|
+
|
82
|
+
post_attributes = {
|
83
|
+
fileSize: filesize,
|
84
|
+
fileName: filename
|
85
|
+
}
|
86
|
+
|
87
|
+
# Create placeholder
|
88
|
+
screenshot = Spaceship::ConnectAPI.post_app_screenshot(
|
89
|
+
app_screenshot_set_id: app_screenshot_set_id,
|
90
|
+
attributes: post_attributes
|
91
|
+
).first
|
92
|
+
|
93
|
+
# Upload the file
|
94
|
+
upload_operations = screenshot.upload_operations
|
95
|
+
Spaceship::ConnectAPI::FileUploader.upload(upload_operations, bytes)
|
96
|
+
|
97
|
+
# Update file uploading complete
|
98
|
+
patch_attributes = {
|
99
|
+
uploaded: true,
|
100
|
+
sourceFileChecksum: Digest::MD5.hexdigest(bytes)
|
101
|
+
}
|
102
|
+
|
103
|
+
# Patch screenshot that file upload is complete
|
104
|
+
# Catch error if patch retries due to 504. Origal patch
|
105
|
+
# may go through by return response as 504.
|
106
|
+
begin
|
107
|
+
screenshot = Spaceship::ConnectAPI.patch_app_screenshot(
|
108
|
+
app_screenshot_id: screenshot.id,
|
109
|
+
attributes: patch_attributes
|
110
|
+
).first
|
111
|
+
rescue => error
|
112
|
+
puts("Failed to patch app screenshot. Update may have gone through so verifying") if Spaceship::Globals.verbose?
|
113
|
+
|
114
|
+
screenshot = Spaceship::ConnectAPI.get_app_screenshot(app_screenshot_id: screenshot.id).first
|
115
|
+
raise error unless screenshot.complete?
|
116
|
+
end
|
117
|
+
|
118
|
+
# Wait for processing
|
119
|
+
if wait_for_processing
|
120
|
+
loop do
|
121
|
+
if screenshot.complete?
|
122
|
+
puts("Screenshot processing complete!") if Spaceship::Globals.verbose?
|
123
|
+
break
|
124
|
+
elsif screenshot.error?
|
125
|
+
messages = ["Error processing screenshot '#{screenshot.file_name}'"] + screenshot.error_messages
|
126
|
+
raise messages.join(". ")
|
127
|
+
end
|
128
|
+
|
129
|
+
# Poll every 2 seconds
|
130
|
+
sleep_time = 2
|
131
|
+
puts("Waiting #{sleep_time} seconds before checking status of processing...") if Spaceship::Globals.verbose?
|
132
|
+
sleep(sleep_time)
|
133
|
+
|
134
|
+
screenshot = Spaceship::ConnectAPI.get_app_screenshot(app_screenshot_id: screenshot.id).first
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
return screenshot
|
139
|
+
end
|
140
|
+
|
141
|
+
def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
|
142
|
+
Spaceship::ConnectAPI.delete_app_screenshot(app_screenshot_id: id)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|