Class: Fastlane::Helper::RustoredHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/rustored/helper/rustored_helper.rb

Constant Summary collapse

BASE_URL =
'https://public-api.rustore.ru/public/v1'

Class Method Summary collapse

Class Method Details

.clientObject



12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/rustored/helper/rustored_helper.rb', line 12

def self.client
  @client ||= Faraday.new(url: BASE_URL) do |f|
    f.request(:json)
    f.request(:multipart)
    f.response(:json)
  end
end

.publish_aab(token:, package_name:, version_id:, aab_path:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/rustored/helper/rustored_helper.rb', line 20

def self.publish_aab(token:, package_name:, version_id:, aab_path:)
  UI.message("Publishing AAB to Rustore...")

  response = client.post("/application/#{package_name}/version/#{version_id}/aab") do |req|
    req.headers['Public-Token'] = token
    req.body = {
      file: Faraday::UploadIO.new(aab_path, 'application/octet-stream')
    }
  end

  if response.success? && response.body['code'] == 'OK'
    UI.success("AAB published successfully!")
  else
    UI.error("Failed to publish AAB: #{response.status} - #{response.body['message']}")
  end
end

.publish_apk(token:, package_name:, version_id:, services_type:, is_main_apk:, apk_path:) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fastlane/plugin/rustored/helper/rustored_helper.rb', line 37

def self.publish_apk(token:, package_name:, version_id:, services_type:, is_main_apk:, apk_path:)
  UI.message("Publishing APK to Rustore...")

  response = client.post("/application/#{package_name}/version/#{version_id}/apk") do |req|
    req.headers['Public-Token'] = token

    req.params['servicesType'] = services_type
    req.params['isMainApk'] = is_main_apk

    req.body = {
      file: Faraday::UploadIO.new(apk_path, 'application/octet-stream')
    }
  end

  if response.success? && response.body['code'] == 'OK'
    UI.success("APK published successfully!")
  else
    UI.error("Failed to publish APK: #{response.status} - #{response.body['message']}")
  end
end