Class: Fastlane::Helper::ApkgoClient
- Inherits:
-
Object
- Object
- Fastlane::Helper::ApkgoClient
- Defined in:
- lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb
Overview
ApkgoClient talks to the apkgo cloud Open API (‘/openapi/v1`).
The flow is deliberately three steps because the APK bytes never transit the apkgo cloud server — they go straight to object storage:
1. POST /uploads/tickets → a direct-to-storage upload ticket
2. upload the APK to that storage (qiniu multipart, or dev PUT)
3. POST /uploads → register the job around the stored object
4. GET /uploads/{id} → poll until terminal
Constant Summary collapse
- TERMINAL_STATUSES =
Job lifecycle states (mirrors the backend’s domain.UploadStatus).
%w[completed failed cancelled].freeze
Instance Method Summary collapse
-
#create_job(body) ⇒ Object
create_job registers the upload job around an already-stored object.
-
#get_job(job_id) ⇒ Object
get_job fetches a job with its per-store results and live progress.
-
#initialize(host:, api_key:) ⇒ ApkgoClient
constructor
A new instance of ApkgoClient.
-
#request_ticket(file_name) ⇒ Object
request_ticket asks the server for a direct-upload ticket for ‘file_name`.
-
#upload_to_storage(ticket, apk_path) ⇒ Object
upload_to_storage places the APK bytes where the ticket points.
Constructor Details
#initialize(host:, api_key:) ⇒ ApkgoClient
Returns a new instance of ApkgoClient.
25 26 27 28 |
# File 'lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb', line 25 def initialize(host:, api_key:) @host = host.to_s.sub(%r{/+\z}, "") @api_key = api_key end |
Instance Method Details
#create_job(body) ⇒ Object
create_job registers the upload job around an already-stored object.
50 51 52 |
# File 'lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb', line 50 def create_job(body) api_post("/openapi/v1/uploads", body) end |
#get_job(job_id) ⇒ Object
get_job fetches a job with its per-store results and live progress.
55 56 57 |
# File 'lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb', line 55 def get_job(job_id) api_get("/openapi/v1/uploads/#{job_id}") end |
#request_ticket(file_name) ⇒ Object
request_ticket asks the server for a direct-upload ticket for ‘file_name`. The server chooses the object key; we never get to.
32 33 34 |
# File 'lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb', line 32 def request_ticket(file_name) api_post("/openapi/v1/uploads/tickets", { file_name: file_name }) end |
#upload_to_storage(ticket, apk_path) ⇒ Object
upload_to_storage places the APK bytes where the ticket points. Returns nothing; raises on any non-2xx.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fastlane/plugin/apkgo/helper/apkgo_helper.rb', line 38 def upload_to_storage(ticket, apk_path) case ticket["provider"] when "qiniu" qiniu_form_upload(ticket, apk_path) when "direct" direct_put(ticket, apk_path) else UI.user_error!("apkgo: 未知的上传 provider: #{ticket['provider'].inspect}") end end |