fastlane-plugin-huawei_appgallery_connect 1.0.4 → 1.0.9

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: 84afdec450a7cf11208dcad9dae2fa62ad089a3a0907c3df4c81f3dd4488814d
4
- data.tar.gz: de7053fd3678df52953178b2d2f0bac8994e0ad6a3f4176cb473cbee4781766b
3
+ metadata.gz: 62bb6d84620a12414a3f6fd792adba9b3ad8f88f3258a17b382748a985ad3d4b
4
+ data.tar.gz: 159575bc63002b88227b152dd21bd5a0dba5ed52dd88345c989fab4c6eb6be50
5
5
  SHA512:
6
- metadata.gz: 439ba5077088030af209b3e875afa3ecca3fe871b2a15c60501570a29b89469eef609cda6c504c8ea8d460a2a5d2f3d86d7c2d759c1b585e29e76bb8bcc4ee11
7
- data.tar.gz: 994abf9690ff654d51023ab4da43ef3459197a015246d3b9310962037cc29172a2e2f651e935b6a2f5a12d3342b417db14284af4dabd31c063044c989da796be
6
+ metadata.gz: 1d8974e5e6bc637023efa2ef172d1a9b5fe2c17b783714f5d49090b15dd0b7de291bc6920990ff12a5f9c81cd6fbbbbb6d8e240ec2abd5ed5bfa5fc8b67ccac0
7
+ data.tar.gz: 368c05e3a4aef7172aebada81fc17a1d71905b2e838de39f882068fcb8d5587bebd439ea909f8059d2c49332e45954c2ad26519e10a3097162b69510e8ef0bd0
@@ -17,7 +17,7 @@ module Fastlane
17
17
 
18
18
  upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path])
19
19
 
20
- if upload_app
20
+ if upload_app && params[:submit_for_review] != false
21
21
  Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
22
22
  end
23
23
  end
@@ -121,7 +121,13 @@ module Fastlane
121
121
  env_name: "HUAWEI_APPGALLERY_CONNECT_APK_LANGUAGE",
122
122
  description: "Language type. For details, please refer to https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-reference-langtype",
123
123
  optional: true,
124
- 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)
125
131
  ]
126
132
  end
127
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
@@ -0,0 +1,101 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/huawei_appgallery_connect_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class HuaweiAppgalleryConnectAction < Action
7
+ def self.run(params)
8
+ token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
9
+
10
+ if token.nil?
11
+ UI.message("Cannot retrieve token, please check your client ID and client secret")
12
+ else
13
+
14
+ Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
15
+ end
16
+ end
17
+
18
+ def self.description
19
+ "Huawei AppGallery Connect Plugin"
20
+ end
21
+
22
+ def self.authors
23
+ ["Shreejan Shrestha"]
24
+ end
25
+
26
+ def self.return_value
27
+ # If your method provides a return value, you can describe here what it does
28
+ end
29
+
30
+ def self.details
31
+ # Optional:
32
+ "Fastlane plugin to upload Android app to Huawei AppGallery Connect"
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(key: :client_id,
38
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_ID",
39
+ description: "Huawei AppGallery Connect Client ID",
40
+ optional: false,
41
+ type: String),
42
+
43
+ FastlaneCore::ConfigItem.new(key: :client_secret,
44
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET",
45
+ description: "Huawei AppGallery Connect Client Secret",
46
+ optional: false,
47
+ type: String),
48
+
49
+ FastlaneCore::ConfigItem.new(key: :app_id,
50
+ env_name: "HUAWEI_APPGALLERY_CONNECT_APP_ID",
51
+ description: "Huawei AppGallery Connect App ID",
52
+ optional: false,
53
+ type: String),
54
+
55
+ FastlaneCore::ConfigItem.new(key: :phase_wise_release,
56
+ env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE",
57
+ description: "Phase wise release",
58
+ optional: true,
59
+ conflicting_options: [:release_time],
60
+ type: Boolean),
61
+
62
+ FastlaneCore::ConfigItem.new(key: :phase_release_start_time,
63
+ env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE_START_TIME",
64
+ description: "Start time of the validity period of the release by phase. The value is UTC time in the following format: yyyy-MM-dd 'T' HH:mm:ssZZ",
65
+ optional: true,
66
+ type: String),
67
+
68
+ FastlaneCore::ConfigItem.new(key: :phase_release_end_time,
69
+ env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE_END_TIME",
70
+ description: "End time of the validity period of the release by phase. The value is UTC time in the following format: yyyy-MM-dd 'T' HH:mm:ssZZ",
71
+ optional: true,
72
+ type: String),
73
+
74
+ FastlaneCore::ConfigItem.new(key: :phase_release_percent,
75
+ env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE_PERCENT",
76
+ description: "Percentage of the release by phase. The value must be accurate to two decimal places and does not contain the percent sign (%)",
77
+ optional: true,
78
+ type: String),
79
+
80
+ FastlaneCore::ConfigItem.new(key: :phase_release_description,
81
+ env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE_DESCRIPTION",
82
+ description: "Phase-based release description. (Max 500 characters)",
83
+ optional: true,
84
+ type: String),
85
+
86
+ FastlaneCore::ConfigItem.new(key: :release_time,
87
+ env_name: "HUAWEI_APPGALLERY_CONNECT_RELEASE_TIME",
88
+ description: "Release time in UTC format for app release on a specific date. The format is yyyy-MM-dd'T'HH:mm:ssZZ)",
89
+ optional: true,
90
+ conflicting_options: [:phase_wise_release],
91
+ type: String)
92
+ ]
93
+ end
94
+
95
+ def self.is_supported?(platform)
96
+ [:android].include?(platform)
97
+ true
98
+ end
99
+ end
100
+ end
101
+ 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,12 +61,16 @@ 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
@@ -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
@@ -131,7 +141,10 @@ 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
@@ -204,12 +217,18 @@ module Fastlane
204
217
 
205
218
  response = http.request(request)
206
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
+
207
225
  result_json = JSON.parse(response.body)
208
226
 
209
227
  if result_json['ret']['code'] == 0
210
228
  UI.success("Successfully submitted app for review")
211
229
  else
212
- 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.")
213
232
  end
214
233
 
215
234
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module HuaweiAppgalleryConnect
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.9"
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.4
4
+ version: 1.0.9
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-26 00:00:00.000000000 Z
11
+ date: 2020-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -146,6 +146,8 @@ 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
150
+ - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_submit_for_review.rb
149
151
  - lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
150
152
  - lib/fastlane/plugin/huawei_appgallery_connect/version.rb
151
153
  homepage: https://github.com/shr3jn/fastlane-plugin-huawei_appgallery_connect