Class: Fastlane::Helper::RustoreDeveloperHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::RustoreDeveloperHelper
- Defined in:
- lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb
Constant Summary collapse
- BASE_URL =
'https://public-api.rustore.ru'
Class Method Summary collapse
- .commitVersion(token, package_name, version_id, priority_update = 0) ⇒ Object
- .createVersion(token, package_name, publish_type = 'INSTANTLY', app_type = 'MAIN', whats_new) ⇒ Object
- .deleteDraft(token, package_name, version_id) ⇒ Object
- .getAccessToken(key_id, key_path) ⇒ Object
- .getSignatureEncoded(key_id, timestamp, key_path) ⇒ Object
- .getStatus(token, package_name, version_id, page = 0, size = 10) ⇒ Object
- .getStatusAll(token, package_name, page = 0, size = 100) ⇒ Object
- .getTimestamp ⇒ Object
- .publishVersion(token, package_name, version_id) ⇒ Object
- .uploadAPK(token, package_name, version_id, apk_path, is_main = true, service_type = 'Unknown') ⇒ Object
Class Method Details
.commitVersion(token, package_name, version_id, priority_update = 0) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 157 def self.commitVersion(token, package_name, version_id, priority_update = 0) UI.important("Committing version #{version_id} ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/commit?priorityUpdate=#{priority_update}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path) req["Public-Token"] = token puts(req.body) res = http.request(req) puts(res.body) result_json = JSON.parse(res.body) if result_json['code'] == 'OK' UI.success("Successfully committed") return true else UI.error((result_json['message']).to_s) return false end end |
.createVersion(token, package_name, publish_type = 'INSTANTLY', app_type = 'MAIN', whats_new) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 49 def self.createVersion(token, package_name, publish_type = 'INSTANTLY', app_type = 'MAIN', whats_new) UI.important("Creating draft version of '#{package_name}' ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version") # p uri http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path) req["Content-Type"] = "application/json" req["Public-Token"] = token data = { publishType: publish_type, appType: app_type, whatsNew: whats_new } req.body = data.to_json # puts req.body res = http.request(req) # puts res.body result_json = JSON.parse(res.body) version = result_json['body'] if result_json['code'] == 'OK' if version.nil? UI.error((result_json['message']).to_s) else UI.success("Created new version: #{version}") end return version end |
.deleteDraft(token, package_name, version_id) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 73 def self.deleteDraft(token, package_name, version_id) UI.important("Deleting draft version #{version_id} ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}") # p uri http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Delete.new(uri.path) req["Public-Token"] = token req["Content-Type"] = "application/json" res = http.request(req) result_json = JSON.parse(res.body) if result_json['code'] == 'OK' UI.success("Successfully deleted") return true else UI.error((result_json['message']).to_s) return false end end |
.getAccessToken(key_id, key_path) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 24 def self.getAccessToken(key_id, key_path) UI.important("Getting access token ...") = getTimestamp sign = getSignatureEncoded(key_id, , key_path) uri = URI(BASE_URL + '/public/auth/') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path) req["Content-Type"] = "application/json" data = { keyId: key_id, timestamp: , signature: sign } req.body = data.to_json res = http.request(req) result_json = JSON.parse(res.body) token = result_json['body']['jwe'] if result_json['code'] == 'OK' if token.nil? UI.error("Cannot retrieve access token, please check your credentials.\n#{result_json['message']}") else UI.success('Got access token') UI.(token) end return token end |
.getSignatureEncoded(key_id, timestamp, key_path) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 16 def self.getSignatureEncoded(key_id, , key_path) private_key = OpenSSL::PKey.read(File.read(key_path)) data = key_id + signature = private_key.sign("SHA512", data) encoded = Base64.strict_encode64(signature) return encoded end |
.getStatus(token, package_name, version_id, page = 0, size = 10) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 93 def self.getStatus(token, package_name, version_id, page = 0, size = 10) # METHOD_URL = BASE_URL + "/public/v1/application/#{package_name}/version" p(size) if version_id.nil? UI.important("Getting status of \'#{package_name}\' versions on page #{page} ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?page=#{page}&size=#{size}") else UI.important("Getting status of \'#{package_name}\' version #{version_id} ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?ids=#{version_id}") end # p(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Get.new(uri) req["Public-Token"] = token req["Accept"] = "application/json" res = http.request(req) p(req) result_json = JSON.parse(res.body) if result_json['code'] == 'OK' content = result_json['body']['content'] totalVersions = result_json['body']['totalElements'] totalPages = result_json['body']['totalPages'] end if content.nil? UI.error((result_json['message']).to_s) else if version_id.nil? UI.success("Got #{totalVersions} versions in #{totalPages} pages") else UI.success("Got version info") end end return content end |
.getStatusAll(token, package_name, page = 0, size = 100) ⇒ Object
131 132 133 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 131 def self.getStatusAll(token, package_name, page = 0, size = 100) self.getStatus(token, package_name, nil, page, size) end |
.getTimestamp ⇒ Object
11 12 13 14 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 11 def self.getTimestamp return DateTime.now.to_s # return '2023-08-23T09:00:32.939+03:00' end |
.publishVersion(token, package_name, version_id) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 177 def self.publishVersion(token, package_name, version_id) UI.important("Publishing version #{version_id} ...") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/publish") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path) req["Public-Token"] = token puts(req.body) res = http.request(req) puts(res.body) result_json = JSON.parse(res.body) if result_json['code'] == 'OK' UI.success("Successfully published") return true else return false UI.error((result_json['message']).to_s) end end |
.uploadAPK(token, package_name, version_id, apk_path, is_main = true, service_type = 'Unknown') ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/fastlane/plugin/rustore_developer/helper/rustore_developer_helper.rb', line 135 def self.uploadAPK(token, package_name, version_id, apk_path, is_main = true, service_type = 'Unknown') UI.important("Uploading APK #{apk_path} ...") # uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk?isMainApk=#{is_main}&servicesType=#{service_type}") uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk") # p uri http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path) req["Public-Token"] = token req.set_content_type("multipart/form-data") req.set_form([['file', File.open(apk_path)], ['isMainApk', is_main.to_s], ['servicesType', service_type]], 'multipart/form-data') res = http.request(req) result_json = JSON.parse(res.body) if result_json['code'] == 'OK' UI.success("APK uploaded") return true else UI.error((result_json['message']).to_s) return false end end |