Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review submission cancellation #30

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class AppleAppV1 < Hanami::API
status(204)
end

patch "cancel_submission" do
json(DOMAIN.cancel_review_submission(**env[:app_store_connect_params].merge(params)))
end

patch "start" do
DOMAIN.start_release(**env[:app_store_connect_params].merge(params))
status(204)
Expand Down
18 changes: 18 additions & 0 deletions lib/app_store/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def self.prepare_release(**params) = new(**params).prepare_release(**params.slic

def self.create_review_submission(**params) = new(**params).create_review_submission(**params.slice(:build_number, :version))

def self.cancel_review_submission(**params) = new(**params).cancel_review_submission(**params.slice(:build_number, :version))

def self.release(**params) = new(**params).release(**params.slice(:build_number))

def self.start_release(**params) = new(**params).start_release(**params.slice(:build_number))
Expand Down Expand Up @@ -244,6 +246,22 @@ def submit_review(submission, edit_version)
end
end

def cancel_review_submission(build_number:, version:)
execute do
edit_version = app
.get_app_store_versions(includes: "build", filter: INFLIGHT_RELEASE_FILTERS)
.find { |v| v.build&.version == build_number.to_s && v.version_string == version }
raise VersionNotFoundError unless edit_version

sub = app.get_in_progress_review_submission(platform: IOS_PLATFORM)

raise SubmissionNotFoundError unless sub
sub.cancel_submission

version_data(app.get_edit_app_store_version(includes: VERSION_DATA_INCLUDES))
end
end

# no of api calls: 2
def release(build_number: nil)
execute do
Expand Down
12 changes: 12 additions & 0 deletions lib/app_store/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def as_json
end
end

class SubmissionNotFoundError < StandardError
MSG = "No in progress review submission found"

def initialize(msg = MSG)
super
end

def as_json
AppStore.error_as_json(:submission, :not_found, MSG)
end
end

class BuildMismatchError < StandardError
MSG = "The build on the release in app store does not match the build number"

Expand Down
Loading