fastlane-plugin-huawei_appgallery_connect 1.0.1 → 1.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44e2a92f0fd3533438a85c05db67fb92bede709ec85c24d6fbb42fdfc67df709
4
- data.tar.gz: 62a88a91bbd6cb152eca59681b49ffc3403a42f3db111695b3c2ef58ac21d422
3
+ metadata.gz: b6f398ea6efa63723dd321360132b68c1a120b47ef13ed83ad93af2d3c94cc4b
4
+ data.tar.gz: d6bf21ea4de080bd5484f4ee06bd26279be483c15b4308bf5b30a75c47e1f634
5
5
  SHA512:
6
- metadata.gz: fbf2dcf0b3e1a7bd63c2f6b5146fbd7b2674254e58fad9c8b2a4d75d3e1c63142aeca309bb6de057b1e43a1bdc5bdb8205afbe52b3f5f83410eb193612702f74
7
- data.tar.gz: 3b709b637bef4a6f0808d97a68fda4923fdd86d3506359628b4b9c0f182cfdc11bc2e566111df84fae77f4d3333541953a0c648d4ea799a3604477bacbe6d517
6
+ metadata.gz: 6071a5b8ba6c6172b644c38fc90e910e3338172299d7df581d0367e579724e9bd875b6a4307c6a72f13688e67485b902e3a49852061bbe3b659a3eaceaa51dfe
7
+ data.tar.gz: 4448629f51054b2edabb54465f8f7da46e228a8d40efb881c384fa348b444770f993a932104f890070f1e937f486d12462ec78551b4c3fbff50fe1b38f5048e1
@@ -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
@@ -115,7 +115,19 @@ module Fastlane
115
115
  description: "Release time in UTC format for app release on a specific date. The format is yyyy-MM-dd'T'HH:mm:ssZZ)",
116
116
  optional: true,
117
117
  conflicting_options: [:phase_wise_release],
118
- type: String)
118
+ type: String),
119
+
120
+ FastlaneCore::ConfigItem.new(key: :apk_lang,
121
+ env_name: "HUAWEI_APPGALLERY_CONNECT_APK_LANGUAGE",
122
+ description: "Language type. For details, please refer to https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-reference-langtype",
123
+ optional: true,
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)
119
131
  ]
120
132
  end
121
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,19 @@ 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!("Failed to get app info")
45
+ end
34
46
 
35
- result_json = JSON.parse(res.body)
36
47
  end
37
48
 
38
49
  def self.update_appinfo(client_id, token, app_id, privacy_policy_url)
@@ -49,7 +60,10 @@ module Fastlane
49
60
  request.body = {privacyPolicy: privacy_policy_url}.to_json
50
61
 
51
62
  response = http.request(request)
52
-
63
+ if !response.kind_of? Net::HTTPSuccess
64
+ UI.user_error!("Cannot update app info, please check API Token / Permissions (status code: #{response.code})")
65
+ return false
66
+ end
53
67
  result_json = JSON.parse(response.body)
54
68
 
55
69
  if result_json['ret']['code'] == 0
@@ -73,6 +87,11 @@ module Fastlane
73
87
 
74
88
  response = http.request(request)
75
89
 
90
+ if !response.kind_of? Net::HTTPSuccess
91
+ UI.user_error!("Cannot obtain upload url, please check API Token / Permissions (status code: #{response.code})")
92
+ return false
93
+ end
94
+
76
95
  result_json = JSON.parse(response.body)
77
96
 
78
97
  if result_json['uploadUrl'].nil?
@@ -87,26 +106,15 @@ module Fastlane
87
106
  http = Net::HTTP.new(uri.host, uri.port)
88
107
  http.use_ssl = true
89
108
  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
109
+
110
+ form_data = [['file', File.open(apk_path.to_s)],['authCode', result_json['authCode']],['fileCount', '1']]
111
+ request.set_form form_data, 'multipart/form-data'
108
112
 
109
113
  result = http.request(request)
114
+ if !result.kind_of? Net::HTTPSuccess
115
+ UI.user_error!("Cannot upload app, please check API Token / Permissions (status code: #{result.code})")
116
+ return false
117
+ end
110
118
  result_json = JSON.parse(result.body)
111
119
 
112
120
  if result_json['result']['result_code'].to_i == 0
@@ -121,7 +129,7 @@ module Fastlane
121
129
  request["client_id"] = client_id
122
130
  request["Authorization"] = "Bearer #{token}"
123
131
 
124
- data = {fileType: 5, lang: "en-GB", files: [{
132
+ data = {fileType: 5, files: [{
125
133
 
126
134
  fileName: "release.apk",
127
135
  fileDestUrl: result_json['result']['UploadFileRsp']['fileInfoList'][0]['fileDestUlr'],
@@ -131,13 +139,17 @@ module Fastlane
131
139
 
132
140
  request.body = data
133
141
  response = http.request(request)
134
-
142
+ if !response.kind_of? Net::HTTPSuccess
143
+ UI.user_error!("Cannot save app info, please check API Token / Permissions (status code: #{response.code})")
144
+ return false
145
+ end
135
146
  result_json = JSON.parse(response.body)
136
147
 
137
148
  if result_json['ret']['code'] == 0
138
149
  UI.success("App information saved.")
139
150
  return true
140
151
  else
152
+ UI.user_error!(result_json)
141
153
  UI.user_error!("Failed to save app information")
142
154
  return false
143
155
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module HuaweiAppgalleryConnect
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.6"
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.1
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreejan Shrestha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2020-05-02 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