fastlane-plugin-rustore_developer 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,198 +1,198 @@
1
- require 'fastlane_core/ui/ui'
2
- require "base64"
3
-
4
- module Fastlane
5
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
-
7
- module Helper
8
- class RustoreDeveloperHelper
9
-
10
- BASE_URL = 'https://public-api.rustore.ru'
11
-
12
- def self.getTimestamp()
13
- return DateTime.now.to_s()
14
- # return '2023-08-23T09:00:32.939+03:00'
15
- end
16
-
17
- def self.getSignatureEncoded(company_id, timestamp, key_path)
18
- private_key = OpenSSL::PKey.read(File.read(key_path))
19
- data = company_id + timestamp
20
- signature = private_key.sign("SHA512", data)
21
- encoded = Base64.strict_encode64(signature)
22
- return encoded
23
- end
24
-
25
- def self.getAccessToken(company_id, key_path)
26
- UI.important("Getting access token ...")
27
- timestamp = getTimestamp()
28
- sign = getSignatureEncoded(company_id, timestamp, key_path)
29
- uri = URI(BASE_URL + '/public/auth/')
30
- http = Net::HTTP.new(uri.host, uri.port)
31
- http.use_ssl = true
32
- req = Net::HTTP::Post.new(uri.path)
33
- req["Content-Type"] = "application/json"
34
- data = {'companyId': company_id, 'timestamp': timestamp, 'signature': sign}
35
- req.body = data.to_json
36
- res = http.request(req)
37
- result_json = JSON.parse(res.body)
38
- token = result_json['body']['jwe'] if result_json['code'] == 'OK'
39
-
40
- if token.nil?
41
- UI.error("Cannot retrieve access token, please check your credentials.\n#{result_json['message']}")
42
- else
43
- UI.success 'Got access token'
44
- # UI.message token
45
- end
46
-
47
- return token
48
- end
49
-
50
- def self.createVersion(token, package_name, publish_type = 'INSTANTLY', app_type = 'MAIN', whats_new)
51
- UI.important("Creating draft version of '#{package_name}' ...")
52
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version")
53
- p uri
54
- http = Net::HTTP.new(uri.host, uri.port)
55
- http.use_ssl = true
56
- req = Net::HTTP::Post.new(uri.path)
57
- req["Content-Type"] = "application/json"
58
- req["Public-Token"] = token
59
- data = {'publishType': publish_type, 'appType': app_type, 'whatsNew': whats_new}
60
- req.body = data.to_json
61
- # puts req.body
62
- res = http.request(req)
63
- # puts res.body
64
- result_json = JSON.parse(res.body)
65
- version = result_json['body'] if result_json['code'] == 'OK'
66
- if version.nil?
67
- UI.error("#{result_json['message']}")
68
- else
69
- UI.success "Created new version: #{version}"
70
- end
71
- return version
72
- end
73
-
74
- def self.deleteDraft(token, package_name, version_id)
75
- UI.important("Deleting draft version #{version_id} ...")
76
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}")
77
- p uri
78
- http = Net::HTTP.new(uri.host, uri.port)
79
- http.use_ssl = true
80
- req = Net::HTTP::Delete.new(uri.path)
81
- req["Public-Token"] = token
82
- req["Content-Type"] = "application/json"
83
- res = http.request(req)
84
- result_json = JSON.parse(res.body)
85
- if result_json['code'] != 'OK'
86
- UI.error("#{result_json['message']}")
87
- return false
88
- else
89
- UI.success "Successfully deleted"
90
- return true
91
- end
92
- end
93
-
94
- def self.getStatus(token, package_name, version_id, page = 0, size = 10)
95
- # METHOD_URL = BASE_URL + "/public/v1/application/#{package_name}/version"
96
- if version_id.nil?
97
- UI.important("Getting status of \'#{package_name}\' versions on page #{page} ...")
98
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?page=#{page}&size=#{size}")
99
- else
100
- UI.important("Getting status of \'#{package_name}\' version #{version_id} ...")
101
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?id=#{version_id}")
102
- end
103
- p uri
104
- http = Net::HTTP.new(uri.host, uri.port)
105
- http.use_ssl = true
106
- req = Net::HTTP::Get.new(uri.path)
107
- req["Public-Token"] = token
108
- req["Content-Type"] = "application/json"
109
- res = http.request(req)
110
- result_json = JSON.parse(res.body)
111
- if result_json['code'] == 'OK'
112
- content = result_json['body']['content']
113
- totalVersions = result_json['body']['totalElements']
114
- totalPages = result_json['body']['totalPages']
115
- end
116
-
117
- if content.nil?
118
- UI.error("#{result_json['message']}")
119
- else
120
- if version_id.nil?
121
- UI.success "Got #{totalVersions} versions in #{totalPages} pages"
122
- else
123
- UI.success "Got version info"
124
- end
125
- end
126
-
127
- return content
128
- end
129
-
130
- def self.getStatusAll(token, package_name, page = 0, size = 100)
131
- self.getStatus(token, package_name, nil, page, size)
132
- end
133
-
134
- def self.uploadAPK(token, package_name, version_id, apk_path, is_main = true, service_type = 'Unknown')
135
- UI.important("Uploading APK #{apk_path} ...")
136
- # uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk?isMainApk=#{is_main}&servicesType=#{service_type}")
137
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk")
138
- p uri
139
- http = Net::HTTP.new(uri.host, uri.port)
140
- http.use_ssl = true
141
- req = Net::HTTP::Post.new(uri.path)
142
- req["Public-Token"] = token
143
- req.set_content_type("multipart/form-data")
144
- req.set_form([['file', File.open(apk_path)],['isMainApk', is_main.to_s],['servicesType', service_type]], 'multipart/form-data')
145
- res = http.request(req)
146
- result_json = JSON.parse(res.body)
147
- if result_json['code'] != 'OK'
148
- UI.error("#{result_json['message']}")
149
- return false
150
- else
151
- UI.success "APK uploaded"
152
- return true
153
- end
154
- end
155
-
156
- def self.commitVersion(token, package_name, version_id, priority_update = 0)
157
- UI.important("Committing version #{version_id} ...")
158
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/commit?priorityUpdate=#{priority_update}")
159
- http = Net::HTTP.new(uri.host, uri.port)
160
- http.use_ssl = true
161
- req = Net::HTTP::Post.new(uri.path)
162
- req["Public-Token"] = token
163
- puts req.body
164
- res = http.request(req)
165
- puts res.body
166
- result_json = JSON.parse(res.body)
167
- if result_json['code'] != 'OK'
168
- UI.error("#{result_json['message']}")
169
- return false
170
- else
171
- UI.success "Successfully committed"
172
- return true
173
- end
174
- end
175
-
176
- def self.publishVersion(token, package_name, version_id)
177
- UI.important("Publishing version #{version_id} ...")
178
- uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/publish")
179
- http = Net::HTTP.new(uri.host, uri.port)
180
- http.use_ssl = true
181
- req = Net::HTTP::Post.new(uri.path)
182
- req["Public-Token"] = token
183
- puts req.body
184
- res = http.request(req)
185
- puts res.body
186
- result_json = JSON.parse(res.body)
187
- if result_json['code'] != 'OK'
188
- return false
189
- UI.error("#{result_json['message']}")
190
- else
191
- UI.success "Successfully published"
192
- return true
193
- end
194
- end
195
- end
196
-
197
- end
198
- end
1
+ require 'fastlane_core/ui/ui'
2
+ require "base64"
3
+
4
+ module Fastlane
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
+
7
+ module Helper
8
+ class RustoreDeveloperHelper
9
+
10
+ BASE_URL = 'https://public-api.rustore.ru'
11
+
12
+ def self.getTimestamp()
13
+ return DateTime.now.to_s()
14
+ # return '2023-08-23T09:00:32.939+03:00'
15
+ end
16
+
17
+ def self.getSignatureEncoded(company_id, timestamp, key_path)
18
+ private_key = OpenSSL::PKey.read(File.read(key_path))
19
+ data = company_id + timestamp
20
+ signature = private_key.sign("SHA512", data)
21
+ encoded = Base64.strict_encode64(signature)
22
+ return encoded
23
+ end
24
+
25
+ def self.getAccessToken(company_id, key_path)
26
+ UI.important("Getting access token ...")
27
+ timestamp = getTimestamp()
28
+ sign = getSignatureEncoded(company_id, timestamp, key_path)
29
+ uri = URI(BASE_URL + '/public/auth/')
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = true
32
+ req = Net::HTTP::Post.new(uri.path)
33
+ req["Content-Type"] = "application/json"
34
+ data = {'companyId': company_id, 'timestamp': timestamp, 'signature': sign}
35
+ req.body = data.to_json
36
+ res = http.request(req)
37
+ result_json = JSON.parse(res.body)
38
+ token = result_json['body']['jwe'] if result_json['code'] == 'OK'
39
+
40
+ if token.nil?
41
+ UI.error("Cannot retrieve access token, please check your credentials.\n#{result_json['message']}")
42
+ else
43
+ UI.success 'Got access token'
44
+ # UI.message token
45
+ end
46
+
47
+ return token
48
+ end
49
+
50
+ def self.createVersion(token, package_name, publish_type = 'INSTANTLY', app_type = 'MAIN', whats_new)
51
+ UI.important("Creating draft version of '#{package_name}' ...")
52
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version")
53
+ p uri
54
+ http = Net::HTTP.new(uri.host, uri.port)
55
+ http.use_ssl = true
56
+ req = Net::HTTP::Post.new(uri.path)
57
+ req["Content-Type"] = "application/json"
58
+ req["Public-Token"] = token
59
+ data = {'publishType': publish_type, 'appType': app_type, 'whatsNew': whats_new}
60
+ req.body = data.to_json
61
+ # puts req.body
62
+ res = http.request(req)
63
+ # puts res.body
64
+ result_json = JSON.parse(res.body)
65
+ version = result_json['body'] if result_json['code'] == 'OK'
66
+ if version.nil?
67
+ UI.error("#{result_json['message']}")
68
+ else
69
+ UI.success "Created new version: #{version}"
70
+ end
71
+ return version
72
+ end
73
+
74
+ def self.deleteDraft(token, package_name, version_id)
75
+ UI.important("Deleting draft version #{version_id} ...")
76
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}")
77
+ p uri
78
+ http = Net::HTTP.new(uri.host, uri.port)
79
+ http.use_ssl = true
80
+ req = Net::HTTP::Delete.new(uri.path)
81
+ req["Public-Token"] = token
82
+ req["Content-Type"] = "application/json"
83
+ res = http.request(req)
84
+ result_json = JSON.parse(res.body)
85
+ if result_json['code'] != 'OK'
86
+ UI.error("#{result_json['message']}")
87
+ return false
88
+ else
89
+ UI.success "Successfully deleted"
90
+ return true
91
+ end
92
+ end
93
+
94
+ def self.getStatus(token, package_name, version_id, page = 0, size = 10)
95
+ # METHOD_URL = BASE_URL + "/public/v1/application/#{package_name}/version"
96
+ if version_id.nil?
97
+ UI.important("Getting status of \'#{package_name}\' versions on page #{page} ...")
98
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?page=#{page}&size=#{size}")
99
+ else
100
+ UI.important("Getting status of \'#{package_name}\' version #{version_id} ...")
101
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version?id=#{version_id}")
102
+ end
103
+ p uri
104
+ http = Net::HTTP.new(uri.host, uri.port)
105
+ http.use_ssl = true
106
+ req = Net::HTTP::Get.new(uri.path)
107
+ req["Public-Token"] = token
108
+ req["Content-Type"] = "application/json"
109
+ res = http.request(req)
110
+ result_json = JSON.parse(res.body)
111
+ if result_json['code'] == 'OK'
112
+ content = result_json['body']['content']
113
+ totalVersions = result_json['body']['totalElements']
114
+ totalPages = result_json['body']['totalPages']
115
+ end
116
+
117
+ if content.nil?
118
+ UI.error("#{result_json['message']}")
119
+ else
120
+ if version_id.nil?
121
+ UI.success "Got #{totalVersions} versions in #{totalPages} pages"
122
+ else
123
+ UI.success "Got version info"
124
+ end
125
+ end
126
+
127
+ return content
128
+ end
129
+
130
+ def self.getStatusAll(token, package_name, page = 0, size = 100)
131
+ self.getStatus(token, package_name, nil, page, size)
132
+ end
133
+
134
+ def self.uploadAPK(token, package_name, version_id, apk_path, is_main = true, service_type = 'Unknown')
135
+ UI.important("Uploading APK #{apk_path} ...")
136
+ # uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk?isMainApk=#{is_main}&servicesType=#{service_type}")
137
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/apk")
138
+ p uri
139
+ http = Net::HTTP.new(uri.host, uri.port)
140
+ http.use_ssl = true
141
+ req = Net::HTTP::Post.new(uri.path)
142
+ req["Public-Token"] = token
143
+ req.set_content_type("multipart/form-data")
144
+ req.set_form([['file', File.open(apk_path)],['isMainApk', is_main.to_s],['servicesType', service_type]], 'multipart/form-data')
145
+ res = http.request(req)
146
+ result_json = JSON.parse(res.body)
147
+ if result_json['code'] != 'OK'
148
+ UI.error("#{result_json['message']}")
149
+ return false
150
+ else
151
+ UI.success "APK uploaded"
152
+ return true
153
+ end
154
+ end
155
+
156
+ def self.commitVersion(token, package_name, version_id, priority_update = 0)
157
+ UI.important("Committing version #{version_id} ...")
158
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/commit?priorityUpdate=#{priority_update}")
159
+ http = Net::HTTP.new(uri.host, uri.port)
160
+ http.use_ssl = true
161
+ req = Net::HTTP::Post.new(uri.path)
162
+ req["Public-Token"] = token
163
+ puts req.body
164
+ res = http.request(req)
165
+ puts res.body
166
+ result_json = JSON.parse(res.body)
167
+ if result_json['code'] != 'OK'
168
+ UI.error("#{result_json['message']}")
169
+ return false
170
+ else
171
+ UI.success "Successfully committed"
172
+ return true
173
+ end
174
+ end
175
+
176
+ def self.publishVersion(token, package_name, version_id)
177
+ UI.important("Publishing version #{version_id} ...")
178
+ uri = URI(BASE_URL + "/public/v1/application/#{package_name}/version/#{version_id}/publish")
179
+ http = Net::HTTP.new(uri.host, uri.port)
180
+ http.use_ssl = true
181
+ req = Net::HTTP::Post.new(uri.path)
182
+ req["Public-Token"] = token
183
+ puts req.body
184
+ res = http.request(req)
185
+ puts res.body
186
+ result_json = JSON.parse(res.body)
187
+ if result_json['code'] != 'OK'
188
+ return false
189
+ UI.error("#{result_json['message']}")
190
+ else
191
+ UI.success "Successfully published"
192
+ return true
193
+ end
194
+ end
195
+ end
196
+
197
+ end
198
+ end
@@ -1,5 +1,5 @@
1
- module Fastlane
2
- module RustoreDeveloper
3
- VERSION = "0.2.10"
4
- end
5
- end
1
+ module Fastlane
2
+ module RustoreDeveloper
3
+ VERSION = "0.2.11"
4
+ end
5
+ end
@@ -1,16 +1,16 @@
1
- require 'fastlane/plugin/rustore_developer/version'
2
-
3
- module Fastlane
4
- module RustoreDeveloper
5
- # Return all .rb files inside the "actions" and "helper" directory
6
- def self.all_classes
7
- Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
- end
9
- end
10
- end
11
-
12
- # By default we want to import all available actions and helpers
13
- # A plugin can contain any number of actions and plugins
14
- Fastlane::RustoreDeveloper.all_classes.each do |current|
15
- require current
16
- end
1
+ require 'fastlane/plugin/rustore_developer/version'
2
+
3
+ module Fastlane
4
+ module RustoreDeveloper
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::RustoreDeveloper.all_classes.each do |current|
15
+ require current
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-rustore_developer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - RimiX2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler