Skip to content

Commit

Permalink
API to remove a release from review (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 authored May 15, 2024
1 parent 2556deb commit 0c0c4ab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
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

0 comments on commit 0c0c4ab

Please sign in to comment.