fastlane-plugin-huawei_appgallery_connect 1.0.3 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bbbefce5843731853e8e9864098eb692109b1e380e0eebfc24c7854a99c2689
4
- data.tar.gz: 4d92d585819bd4cc980808f5871f122e2277256cbd65dc62131bbddb31777921
3
+ metadata.gz: 79a30fb2371ebc8ab4cc531106ef519b8f719e03301ff088ac8027faf7380cfc
4
+ data.tar.gz: 86e5123da933da795f7d1fa4b727ca962ee9ead672d410df82215891772d1421
5
5
  SHA512:
6
- metadata.gz: 1f57ed7961c15b5c5910291ae651d59aa5134275f8a41b6204fdb9ababeac82cdf87f67c731152f67723514ab31935ebf8d7264ba8b0b8f10dcb2a0a7301bdfe
7
- data.tar.gz: ef2e81eeef5091ecf91c96a3e90ca93d2e4f98c544dd229ad8a83121a01d025abfc1a8c767ba708a5d6a5c2ca560be54ce532e7828df8f34867fae39d2a5761a
6
+ metadata.gz: 330981b0a6bb87e589f50fd7ba8ef5ef96dc2220cd938cdf25c06b3dfa69e259eb7516576a6803b00eff3331940684b37eb4140de628317c80f71fc279df1576
7
+ data.tar.gz: dfb4001f685be16e8146de6b2c6777d14663d64a825a200fbf13a831be356c8cb8c40274ee0447e4b62bccc3f2e224d711d5021bbffd16c8dca498c67d550bce
@@ -15,11 +15,9 @@ module Fastlane
15
15
  Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url])
16
16
  end
17
17
 
18
- apk_lang = params[:apk_lang] == nil ? 'en-US' : params[:apk_lang]
18
+ upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path])
19
19
 
20
- upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path], apk_lang)
21
-
22
- if upload_app
20
+ if upload_app && params[:submit_for_review] != false
23
21
  Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
24
22
  end
25
23
  end
@@ -123,7 +121,13 @@ module Fastlane
123
121
  env_name: "HUAWEI_APPGALLERY_CONNECT_APK_LANGUAGE",
124
122
  description: "Language type. For details, please refer to https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-reference-langtype",
125
123
  optional: true,
126
- type: String)
124
+ type: String),
125
+
126
+ FastlaneCore::ConfigItem.new(key: :submit_for_review,
127
+ env_name: "HUAWEI_APPGALLERY_SUBMIT_FOR_REVIEW",
128
+ description: "Should submit the app for review. The default value is true. If set false will only upload the app, and you can submit for review from the console",
129
+ optional: true,
130
+ type: Boolean)
127
131
  ]
128
132
  end
129
133
 
@@ -0,0 +1,76 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/huawei_appgallery_connect_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ ANDROID_APPGALLERY_APP_INFO = :ANDROID_APPGALLERY_APP_INFO
8
+ end
9
+ class HuaweiAppgalleryConnectGetAppInfoAction < Action
10
+
11
+ def self.run(params)
12
+ token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
13
+
14
+ if token.nil?
15
+ UI.message("Cannot retrieve token, please check your client ID and client secret")
16
+ else
17
+ appInfo = Helper::HuaweiAppgalleryConnectHelper.get_app_info(token, params[:client_id],params[:app_id])
18
+ Actions.lane_context[SharedValues::ANDROID_APPGALLERY_APP_INFO] = appInfo
19
+ return appInfo
20
+ end
21
+ end
22
+
23
+ def self.description
24
+ "Huawei AppGallery Connect Plugin"
25
+ end
26
+
27
+ def self.authors
28
+ ["Shreejan Shrestha"]
29
+ end
30
+
31
+ def self.return_value
32
+ # If your method provides a return value, you can describe here what it does
33
+ end
34
+
35
+ def self.details
36
+ # Optional:
37
+ "Fastlane plugin to get Android app to Huawei AppGallery Connect information"
38
+ end
39
+
40
+ def self.available_options
41
+ [
42
+ FastlaneCore::ConfigItem.new(key: :client_id,
43
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_ID",
44
+ description: "Huawei AppGallery Connect Client ID",
45
+ optional: false,
46
+ type: String),
47
+
48
+ FastlaneCore::ConfigItem.new(key: :client_secret,
49
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET",
50
+ description: "Huawei AppGallery Connect Client Secret",
51
+ optional: false,
52
+ type: String),
53
+
54
+ FastlaneCore::ConfigItem.new(key: :app_id,
55
+ env_name: "HUAWEI_APPGALLERY_CONNECT_APP_ID",
56
+ description: "Huawei AppGallery Connect App ID",
57
+ optional: false,
58
+ type: String),
59
+
60
+ ]
61
+ end
62
+
63
+ def self.is_supported?(platform)
64
+ [:android].include?(platform)
65
+ true
66
+ end
67
+
68
+ def self.example_code
69
+ [
70
+ 'app_info = huawei_appgallery_connect_get_app_info'
71
+ ]
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -31,8 +31,20 @@ module Fastlane
31
31
  request["client_id"] = client_id
32
32
  request["Authorization"] = "Bearer #{token}"
33
33
  response = http.request(request)
34
+ if !response.kind_of? Net::HTTPSuccess
35
+ UI.user_error!("Cannot obtain app info, please check API Token / Permissions (status code: #{response.code})")
36
+ return false
37
+ end
38
+ result_json = JSON.parse(response.body)
39
+
40
+ if result_json['ret']['code'] == 0
41
+ UI.success("Successfully getting app info")
42
+ return result_json['appInfo']
43
+ else
44
+ UI.user_error!(result_json)
45
+ UI.user_error!("Failed to get app info")
46
+ end
34
47
 
35
- result_json = JSON.parse(res.body)
36
48
  end
37
49
 
38
50
  def self.update_appinfo(client_id, token, app_id, privacy_policy_url)
@@ -49,18 +61,22 @@ module Fastlane
49
61
  request.body = {privacyPolicy: privacy_policy_url}.to_json
50
62
 
51
63
  response = http.request(request)
52
-
64
+ if !response.kind_of? Net::HTTPSuccess
65
+ UI.user_error!("Cannot update app info, please check API Token / Permissions (status code: #{response.code})")
66
+ return false
67
+ end
53
68
  result_json = JSON.parse(response.body)
54
69
 
55
70
  if result_json['ret']['code'] == 0
56
71
  UI.success("Successfully updated app info")
57
72
  else
73
+ UI.user_error!(result_json)
58
74
  UI.user_error!("Failed to update app info")
59
75
  end
60
76
  end
61
77
 
62
78
 
63
- def self.upload_app(token, client_id, app_id, apk_path, apk_lang)
79
+ def self.upload_app(token, client_id, app_id, apk_path)
64
80
  UI.message("Fetching upload URL")
65
81
 
66
82
  uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=apk")
@@ -73,6 +89,11 @@ module Fastlane
73
89
 
74
90
  response = http.request(request)
75
91
 
92
+ if !response.kind_of? Net::HTTPSuccess
93
+ UI.user_error!("Cannot obtain upload url, please check API Token / Permissions (status code: #{response.code})")
94
+ return false
95
+ end
96
+
76
97
  result_json = JSON.parse(response.body)
77
98
 
78
99
  if result_json['uploadUrl'].nil?
@@ -87,26 +108,15 @@ module Fastlane
87
108
  http = Net::HTTP.new(uri.host, uri.port)
88
109
  http.use_ssl = true
89
110
  request = Net::HTTP::Post.new(uri)
90
- request['Content-Type'] = "multipart/form-data, boundary=#{boundary}"
91
-
92
- post_body = []
93
- # add the auth code
94
- post_body << "--#{boundary}\r\n"
95
- post_body << "Content-Disposition: form-data; name=\"authCode\"\r\n\r\n"
96
- post_body << result_json['authCode']
97
- # add the file count
98
- post_body << "\r\n--#{boundary}\r\n"
99
- post_body << "Content-Disposition: form-data; name=\"fileCount\"\r\n\r\n"
100
- post_body << "1"
101
- # add the apk
102
- post_body << "\r\n--#{boundary}\r\n"
103
- post_body << "Content-Disposition: form-data; name=\"file\"; filename=\"release.apk\"\r\n"
104
- post_body << "Content-Type: multipart/form-data\r\n\r\n"
105
- post_body << File.read(apk_path).encode('utf-8')
106
- post_body << "\r\n--#{boundary}--\r\n"
107
- request.body = post_body.join
111
+
112
+ form_data = [['file', File.open(apk_path.to_s)],['authCode', result_json['authCode']],['fileCount', '1']]
113
+ request.set_form form_data, 'multipart/form-data'
108
114
 
109
115
  result = http.request(request)
116
+ if !result.kind_of? Net::HTTPSuccess
117
+ UI.user_error!("Cannot upload app, please check API Token / Permissions (status code: #{result.code})")
118
+ return false
119
+ end
110
120
  result_json = JSON.parse(result.body)
111
121
 
112
122
  if result_json['result']['result_code'].to_i == 0
@@ -121,7 +131,7 @@ module Fastlane
121
131
  request["client_id"] = client_id
122
132
  request["Authorization"] = "Bearer #{token}"
123
133
 
124
- data = {fileType: 5, lang: apk_lang, files: [{
134
+ data = {fileType: 5, files: [{
125
135
 
126
136
  fileName: "release.apk",
127
137
  fileDestUrl: result_json['result']['UploadFileRsp']['fileInfoList'][0]['fileDestUlr'],
@@ -131,13 +141,17 @@ module Fastlane
131
141
 
132
142
  request.body = data
133
143
  response = http.request(request)
134
-
144
+ if !response.kind_of? Net::HTTPSuccess
145
+ UI.user_error!("Cannot save app info, please check API Token / Permissions (status code: #{response.code})")
146
+ return false
147
+ end
135
148
  result_json = JSON.parse(response.body)
136
149
 
137
150
  if result_json['ret']['code'] == 0
138
151
  UI.success("App information saved.")
139
152
  return true
140
153
  else
154
+ UI.user_error!(result_json)
141
155
  UI.user_error!("Failed to save app information")
142
156
  return false
143
157
  end
@@ -203,12 +217,18 @@ module Fastlane
203
217
 
204
218
  response = http.request(request)
205
219
 
220
+ if !response.kind_of? Net::HTTPSuccess
221
+ UI.user_error!("Cannot submit app for review (status code: #{response.code}, body: #{response.body})")
222
+ return false
223
+ end
224
+
206
225
  result_json = JSON.parse(response.body)
207
226
 
208
227
  if result_json['ret']['code'] == 0
209
228
  UI.success("Successfully submitted app for review")
210
229
  else
211
- UI.user_error!("Failed to submit app for review")
230
+ UI.user_error!(result_json)
231
+ UI.user_error!("Failed to submit app for review.")
212
232
  end
213
233
 
214
234
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module HuaweiAppgalleryConnect
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-huawei_appgallery_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreejan Shrestha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -146,6 +146,7 @@ files:
146
146
  - README.md
147
147
  - lib/fastlane/plugin/huawei_appgallery_connect.rb
148
148
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb
149
+ - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_info.rb
149
150
  - lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
150
151
  - lib/fastlane/plugin/huawei_appgallery_connect/version.rb
151
152
  homepage: https://github.com/shr3jn/fastlane-plugin-huawei_appgallery_connect