Skip to content

Commit e8fe2a9

Browse files
authored
[spaceship] Use new app store statuses to filter app versions and app infos (fastlane#21895)
* [spaceship] Use new app store statuses to filter app versions and app infos * [spaceship] Filter app infos using state attribute * Remove developer removed from state from filter * Add PROCESSING_FOR_DISTRIBUTION to filter live app store versions * Update submit_for_review_spec to use app_version_state * Renaming attribute in docs * Add attribute to fixtures * Add a fixture and test for app info
1 parent 3c3a937 commit e8fe2a9

File tree

10 files changed

+205
-41
lines changed

10 files changed

+205
-41
lines changed

deliver/lib/deliver/submit_for_review.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def create_review_submission(options, app, version, platform)
5151
10.times do
5252
version_with_latest_info = Spaceship::ConnectAPI::AppStoreVersion.get(app_store_version_id: version.id)
5353

54-
if version_with_latest_info.app_store_state == Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::READY_FOR_REVIEW
54+
if version_with_latest_info.app_version_state == Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::READY_FOR_REVIEW
5555
break
5656
end
5757

58-
UI.message("Waiting for the state of the version to become #{Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::READY_FOR_REVIEW}...")
58+
UI.message("Waiting for the state of the version to become #{Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::READY_FOR_REVIEW}...")
5959

6060
sleep(15)
6161
end

deliver/spec/submit_for_review_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
let(:ready_for_review_version) do
1515
double('ready_for_review_version',
1616
id: '1',
17-
app_store_state: "READY_FOR_REVIEW",
17+
app_version_state: "READY_FOR_REVIEW",
1818
version_string: "1.0.0")
1919
end
2020
let(:prepare_for_submission_version) do
2121
double('prepare_for_submission_version',
2222
id: '1',
23-
app_store_state: "PREPARE_FOR_SUBMISSION",
23+
app_version_state: "PREPARE_FOR_SUBMISSION",
2424
version_string: "1.0.0")
2525
end
2626
let(:selected_build) { double('selected_build') }

spaceship/docs/AppStoreConnect.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ You can then go ahead and modify app metadata on the version objects:
114114
v = app.get_edit_app_store_version
115115

116116
# Access information
117-
v.app_store_state # => "Waiting for Review"
117+
v.app_version_state # => "Waiting for Review"
118118
v.version_string # => "0.9.14"
119119

120-
# Build is not always available in all app_store_state, e.g. not available in `Prepare for Submission`
120+
# Build is not always available in all app_version_state, e.g. not available in `Prepare for Submission`
121121
build_number = v.build.nil? ? nil : v.build.version
122122

123123
# Update app metadata
@@ -162,6 +162,7 @@ Available options:
162162
attr_accessor :platform
163163
attr_accessor :version_string
164164
attr_accessor :app_store_state
165+
attr_accessor :app_version_state
165166
attr_accessor :store_icon
166167
attr_accessor :watch_store_icon
167168
attr_accessor :copyright

spaceship/lib/spaceship/connect_api/models/app.rb

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -116,34 +116,29 @@ def update(client: nil, attributes: nil, app_price_tier_id: nil, territory_ids:
116116
def fetch_live_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
117117
client ||= Spaceship::ConnectAPI
118118
states = [
119-
Spaceship::ConnectAPI::AppInfo::AppStoreState::READY_FOR_SALE,
120-
Spaceship::ConnectAPI::AppInfo::AppStoreState::PENDING_APPLE_RELEASE,
121-
Spaceship::ConnectAPI::AppInfo::AppStoreState::PENDING_DEVELOPER_RELEASE,
122-
Spaceship::ConnectAPI::AppInfo::AppStoreState::PROCESSING_FOR_APP_STORE,
123-
Spaceship::ConnectAPI::AppInfo::AppStoreState::IN_REVIEW,
124-
Spaceship::ConnectAPI::AppInfo::AppStoreState::DEVELOPER_REMOVED_FROM_SALE
119+
Spaceship::ConnectAPI::AppInfo::State::READY_FOR_DISTRIBUTION,
120+
Spaceship::ConnectAPI::AppInfo::State::PENDING_RELEASE,
121+
Spaceship::ConnectAPI::AppInfo::State::IN_REVIEW
125122
]
126123

127124
resp = client.get_app_infos(app_id: id, includes: includes)
128125
return resp.to_models.select do |model|
129-
states.include?(model.app_store_state)
126+
states.include?(model.state)
130127
end.first
131128
end
132129

133130
def fetch_edit_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
134131
client ||= Spaceship::ConnectAPI
135132
states = [
136-
Spaceship::ConnectAPI::AppInfo::AppStoreState::PREPARE_FOR_SUBMISSION,
137-
Spaceship::ConnectAPI::AppInfo::AppStoreState::DEVELOPER_REJECTED,
138-
Spaceship::ConnectAPI::AppInfo::AppStoreState::REJECTED,
139-
Spaceship::ConnectAPI::AppInfo::AppStoreState::METADATA_REJECTED,
140-
Spaceship::ConnectAPI::AppInfo::AppStoreState::WAITING_FOR_REVIEW,
141-
Spaceship::ConnectAPI::AppInfo::AppStoreState::INVALID_BINARY
133+
Spaceship::ConnectAPI::AppInfo::State::PREPARE_FOR_SUBMISSION,
134+
Spaceship::ConnectAPI::AppInfo::State::DEVELOPER_REJECTED,
135+
Spaceship::ConnectAPI::AppInfo::State::REJECTED,
136+
Spaceship::ConnectAPI::AppInfo::State::WAITING_FOR_REVIEW
142137
]
143138

144139
resp = client.get_app_infos(app_id: id, includes: includes)
145140
return resp.to_models.select do |model|
146-
states.include?(model.app_store_state)
141+
states.include?(model.state)
147142
end.first
148143
end
149144

@@ -182,11 +177,11 @@ def reject_version_if_possible!(client: nil, platform: nil)
182177
client ||= Spaceship::ConnectAPI
183178
platform ||= Spaceship::ConnectAPI::Platform::IOS
184179
filter = {
185-
appStoreState: [
186-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_APPLE_RELEASE,
187-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE,
188-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::IN_REVIEW,
189-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::WAITING_FOR_REVIEW
180+
appVersionState: [
181+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PENDING_APPLE_RELEASE,
182+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PENDING_DEVELOPER_RELEASE,
183+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::IN_REVIEW,
184+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::WAITING_FOR_REVIEW
190185
].join(","),
191186
platform: platform
192187
}
@@ -240,9 +235,9 @@ def get_live_app_store_version(client: nil, platform: nil, includes: Spaceship::
240235
client ||= Spaceship::ConnectAPI
241236
platform ||= Spaceship::ConnectAPI::Platform::IOS
242237
filter = {
243-
appStoreState: [
244-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::READY_FOR_SALE,
245-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::DEVELOPER_REMOVED_FROM_SALE
238+
appVersionState: [
239+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::READY_FOR_DISTRIBUTION,
240+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PROCESSING_FOR_DISTRIBUTION
246241
].join(","),
247242
platform: platform
248243
}
@@ -253,13 +248,13 @@ def get_edit_app_store_version(client: nil, platform: nil, includes: Spaceship::
253248
client ||= Spaceship::ConnectAPI
254249
platform ||= Spaceship::ConnectAPI::Platform::IOS
255250
filter = {
256-
appStoreState: [
257-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PREPARE_FOR_SUBMISSION,
258-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::DEVELOPER_REJECTED,
259-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::REJECTED,
260-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::METADATA_REJECTED,
261-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::WAITING_FOR_REVIEW,
262-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::INVALID_BINARY
251+
appVersionState: [
252+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PREPARE_FOR_SUBMISSION,
253+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::DEVELOPER_REJECTED,
254+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::REJECTED,
255+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::METADATA_REJECTED,
256+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::WAITING_FOR_REVIEW,
257+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::INVALID_BINARY
263258
].join(","),
264259
platform: platform
265260
}
@@ -274,7 +269,7 @@ def get_in_review_app_store_version(client: nil, platform: nil, includes: Spaces
274269
client ||= Spaceship::ConnectAPI
275270
platform ||= Spaceship::ConnectAPI::Platform::IOS
276271
filter = {
277-
appStoreState: Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::IN_REVIEW,
272+
appVersionState: Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::IN_REVIEW,
278273
platform: platform
279274
}
280275
return get_app_store_versions(client: client, filter: filter, includes: includes).first
@@ -284,9 +279,9 @@ def get_pending_release_app_store_version(client: nil, platform: nil, includes:
284279
client ||= Spaceship::ConnectAPI
285280
platform ||= Spaceship::ConnectAPI::Platform::IOS
286281
filter = {
287-
appStoreState: [
288-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_APPLE_RELEASE,
289-
Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
282+
appVersionState: [
283+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PENDING_APPLE_RELEASE,
284+
Spaceship::ConnectAPI::AppStoreVersion::AppVersionState::PENDING_DEVELOPER_RELEASE
290285
].join(','),
291286
platform: platform
292287
}

spaceship/spec/connect_api/fixtures/testflight/apps.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@
10621062
"platform" : "IOS",
10631063
"versionString" : "1.0",
10641064
"appStoreState" : "PREPARE_FOR_SUBMISSION",
1065+
"appVersionState" : "PREPARE_FOR_SUBMISSION",
10651066
"copyright" : null,
10661067
"releaseType" : "AFTER_APPROVAL",
10671068
"earliestReleaseDate" : null,
@@ -1147,6 +1148,7 @@
11471148
"platform" : "IOS",
11481149
"versionString" : "1.0",
11491150
"appStoreState" : "PREPARE_FOR_SUBMISSION",
1151+
"appVersionState" : "PREPARE_FOR_SUBMISSION",
11501152
"copyright" : null,
11511153
"releaseType" : "AFTER_APPROVAL",
11521154
"earliestReleaseDate" : null,
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"data": [
3+
{
4+
"type": "appInfos",
5+
"id": "1111-11111",
6+
"attributes": {
7+
"appStoreState": "READY_FOR_SALE",
8+
"state": "READY_FOR_DISTRIBUTION",
9+
"appStoreAgeRating": "FOUR_PLUS",
10+
"brazilAgeRating": "L",
11+
"brazilAgeRatingV2": "SELF_RATED_L",
12+
"kidsAgeBand": null
13+
},
14+
"relationships": {
15+
"ageRatingDeclaration": {
16+
"links": {
17+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/ageRatingDeclaration",
18+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/ageRatingDeclaration"
19+
}
20+
},
21+
"appInfoLocalizations": {
22+
"links": {
23+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/appInfoLocalizations",
24+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/appInfoLocalizations"
25+
}
26+
},
27+
"primaryCategory": {
28+
"links": {
29+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/primaryCategory",
30+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/primaryCategory"
31+
}
32+
},
33+
"primarySubcategoryOne": {
34+
"links": {
35+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/primarySubcategoryOne",
36+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/primarySubcategoryOne"
37+
}
38+
},
39+
"primarySubcategoryTwo": {
40+
"links": {
41+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/primarySubcategoryTwo",
42+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/primarySubcategoryTwo"
43+
}
44+
},
45+
"secondaryCategory": {
46+
"links": {
47+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/secondaryCategory",
48+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/secondaryCategory"
49+
}
50+
},
51+
"secondarySubcategoryOne": {
52+
"links": {
53+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/secondarySubcategoryOne",
54+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/secondarySubcategoryOne"
55+
}
56+
},
57+
"secondarySubcategoryTwo": {
58+
"links": {
59+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/relationships/secondarySubcategoryTwo",
60+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111/secondarySubcategoryTwo"
61+
}
62+
}
63+
},
64+
"links": {
65+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-11111"
66+
}
67+
},
68+
{
69+
"type": "appInfos",
70+
"id": "1111-2222",
71+
"attributes": {
72+
"appStoreState": "PREPARE_FOR_SUBMISSION",
73+
"state": "PREPARE_FOR_SUBMISSION",
74+
"appStoreAgeRating": "FOUR_PLUS",
75+
"brazilAgeRating": "L",
76+
"brazilAgeRatingV2": "SELF_RATED_L",
77+
"kidsAgeBand": null
78+
},
79+
"relationships": {
80+
"ageRatingDeclaration": {
81+
"links": {
82+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/ageRatingDeclaration",
83+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/ageRatingDeclaration"
84+
}
85+
},
86+
"appInfoLocalizations": {
87+
"links": {
88+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/appInfoLocalizations",
89+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/appInfoLocalizations"
90+
}
91+
},
92+
"primaryCategory": {
93+
"links": {
94+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/primaryCategory",
95+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/primaryCategory"
96+
}
97+
},
98+
"primarySubcategoryOne": {
99+
"links": {
100+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/primarySubcategoryOne",
101+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/primarySubcategoryOne"
102+
}
103+
},
104+
"primarySubcategoryTwo": {
105+
"links": {
106+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/primarySubcategoryTwo",
107+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/primarySubcategoryTwo"
108+
}
109+
},
110+
"secondaryCategory": {
111+
"links": {
112+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/secondaryCategory",
113+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/secondaryCategory"
114+
}
115+
},
116+
"secondarySubcategoryOne": {
117+
"links": {
118+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/secondarySubcategoryOne",
119+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/secondarySubcategoryOne"
120+
}
121+
},
122+
"secondarySubcategoryTwo": {
123+
"links": {
124+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/relationships/secondarySubcategoryTwo",
125+
"related": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222/secondarySubcategoryTwo"
126+
}
127+
}
128+
},
129+
"links": {
130+
"self": "https://appstoreconnect.apple.com/iris/v1/appInfos/1111-2222"
131+
}
132+
}
133+
],
134+
"links": {
135+
"self": "https://appstoreconnect.apple.com/iris/v1/apps/123456789/appInfos"
136+
}
137+
}

spaceship/spec/connect_api/fixtures/tunes/review_submission.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"isWatchOnly" : false,
6262
"createdDate" : "2021-01-01T10:10:10-07:00",
6363
"releaseType" : "MANUAL",
64-
"appStoreState" : "READY_FOR_REVIEW"
64+
"appStoreState" : "READY_FOR_REVIEW",
65+
"appVersionState" : "READY_FOR_REVIEW"
6566
},
6667
"relationships" : {
6768
"appStoreVersionLocalizations" : {

spaceship/spec/connect_api/fixtures/tunes/review_submission_items.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"isWatchOnly" : false,
4747
"createdDate" : "2021-01-01T10:10:10-07:00",
4848
"releaseType" : "MANUAL",
49-
"appStoreState" : "READY_FOR_REVIEW"
49+
"appStoreState" : "READY_FOR_REVIEW",
50+
"appVersionState" : "READY_FOR_REVIEW"
5051
},
5152
"relationships" : {
5253
"appStoreVersionLocalizations" : {

spaceship/spec/connect_api/models/app_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@
8686
expect(model.bundle_id).to eq("com.joshholtz.FastlaneTest")
8787
end
8888

89+
it('fetches live app info') do
90+
ConnectAPIStubbing::Tunes.stub_get_app_infos
91+
app = Spaceship::ConnectAPI::App.new("123456789", [])
92+
93+
info = app.fetch_live_app_info(includes: nil)
94+
expect(info.id).to eq("1111-11111")
95+
expect(info.app_store_age_rating).to eq("FOUR_PLUS")
96+
expect(info.app_store_state).to eq("READY_FOR_SALE")
97+
expect(info.state).to eq("READY_FOR_DISTRIBUTION")
98+
end
99+
100+
it('fetches edit app info') do
101+
ConnectAPIStubbing::Tunes.stub_get_app_infos
102+
app = Spaceship::ConnectAPI::App.new("123456789", [])
103+
104+
info = app.fetch_edit_app_info(includes: nil)
105+
expect(info.id).to eq("1111-2222")
106+
expect(info.app_store_age_rating).to eq("FOUR_PLUS")
107+
expect(info.app_store_state).to eq("PREPARE_FOR_SUBMISSION")
108+
expect(info.state).to eq("PREPARE_FOR_SUBMISSION")
109+
end
110+
89111
it 'creates beta group' do
90112
app = Spaceship::ConnectAPI::App.find("com.joshholtz.FastlaneTest")
91113

spaceship/spec/connect_api/tunes/tunes_stubbing.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ def stub_request(*args)
1414
WebMock::API.stub_request(*args)
1515
end
1616

17+
def stub_get_app_infos
18+
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/123456789/appInfos").
19+
to_return(status: 200, body: read_fixture_file('app_infos.json'), headers: { 'Content-Type' => 'application/json' })
20+
end
21+
1722
def stub_app_store_version_release_request
1823
stub_request(:post, "https://appstoreconnect.apple.com/iris/v1/appStoreVersionReleaseRequests").
1924
to_return(status: 200, body: read_fixture_file('app_store_version_release_request.json'), headers: { 'Content-Type' => 'application/json' })

0 commit comments

Comments
 (0)