fastlane-plugin-amazon_app_submission 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a0973749b49a3b53f7cfde27b869f789befd6909ce53d7de52329b501d42ab3f
4
+ data.tar.gz: 9b6ca51c1f57dcfbebb2086bfe2a8780d78c710b107c75f55257b2ceed978057
5
+ SHA512:
6
+ metadata.gz: f38478b00c63058c819306b62f9fdbe332f1d833ea45d9de4217e64e60b7d7210f855c3fa8c6c72382457f35ab077b7249c00598eb923e7ea4e68577056f5214
7
+ data.tar.gz: 4edba88cce969fd122755d5c9821fc90ad25147291b3ed54a2b0d6cd249e8406326de014ea2033b0d0d19d947029e953ab59592c04bdba154cec2ace9e4fb796
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Ugroupmedia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # amazon-app-store-submission
@@ -0,0 +1,97 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/amazon_app_submission_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class AmazonAppSubmissionAction < Action
7
+ def self.run(params)
8
+ UI.message("The amazon_app_submission plugin is working!")
9
+
10
+ token = Helper::AmazonAppSubmissionHelper.get_token(params[:client_id], params[:client_secret])
11
+
12
+ if token.nil?
13
+ UI.message("Cannot retrieve token, please check your client ID and client secret")
14
+ else
15
+ UI.message("the token is #{token}")
16
+ end
17
+
18
+ current_edit_id, edit_eTag = Helper::AmazonAppSubmissionHelper.open_edit(token, params[:app_id])
19
+
20
+ if current_edit_id.nil?
21
+ Helper::AmazonAppSubmissionHelper.create_new_edit(token, params[:app_id])
22
+ current_edit_id, edit_eTag = Helper::AmazonAppSubmissionHelper.open_edit(token, params[:app_id])
23
+ end
24
+
25
+ current_apk_id = Helper::AmazonAppSubmissionHelper.get_current_apk_id(token, params[:app_id], current_edit_id)
26
+
27
+ current_apk_eTag = Helper::AmazonAppSubmissionHelper.get_current_apk_etag(token, params[:app_id], current_edit_id, current_apk_id)
28
+
29
+ replace_apk_response_code = Helper::AmazonAppSubmissionHelper.replaceExistingApk(token, params[:app_id], current_edit_id, current_apk_id, current_apk_eTag, params[:apk_path])
30
+
31
+ if replace_apk_response_code === 200
32
+ Helper::AmazonAppSubmissionHelper.commit_edit(token, params[:app_id], current_edit_id, edit_eTag)
33
+ end
34
+
35
+ end
36
+
37
+ def self.description
38
+ "test"
39
+ end
40
+
41
+ def self.authors
42
+ ["mohammedhemaid"]
43
+ end
44
+
45
+ def self.return_value
46
+ # If your method provides a return value, you can describe here what it doesmmed
47
+ end
48
+
49
+ def self.details
50
+ # Optional:
51
+ "test"
52
+ end
53
+
54
+ def self.available_options
55
+ [
56
+ FastlaneCore::ConfigItem.new(key: :client_id,
57
+ env_name: "AMAZON_APP_SUBMISSION_CLIENT_ID",
58
+ description: "Amazon App Submission Client ID",
59
+ optional: false,
60
+ type: String),
61
+
62
+ FastlaneCore::ConfigItem.new(key: :client_secret,
63
+ env_name: "AMAZON_APP_SUBMISSION_CLIENT_SECRET",
64
+ description: "Amazon App Submission Client Secret",
65
+ optional: false,
66
+ type: String),
67
+
68
+ FastlaneCore::ConfigItem.new(key: :app_id,
69
+ env_name: "AMAZON_APP_SUBMISSION_APP_ID",
70
+ description: "Amazon App Submission APP ID",
71
+ optional: false,
72
+ type: String),
73
+
74
+ FastlaneCore::ConfigItem.new(key: :apk_path,
75
+ env_name: "AMAZON_APP_SUBMISSION_APK_PATH",
76
+ description: "Amazon App Submission APK Path",
77
+ optional: false,
78
+ type: String)
79
+
80
+ # FastlaneCore::ConfigItem.new(key: :your_option,
81
+ # env_name: "AMAZON_APP_SUBMISSION_YOUR_OPTION",
82
+ # description: "A description of your option",
83
+ # optional: false,
84
+ # type: String)
85
+ ]
86
+ end
87
+
88
+ def self.is_supported?(platform)
89
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
90
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
91
+ #
92
+ # [:ios, :mac, :android].include?(platform)
93
+ true
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,206 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class AmazonAppSubmissionHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::AmazonAppSubmissionHelper.your_method`
10
+ #
11
+
12
+ BASE_URL = 'https://developer.amazon.com/api/appstore'
13
+
14
+ def self.get_token(client_id, client_secret)
15
+ UI.important("Fetching app access token")
16
+
17
+ UI.important("client_id #{client_id}")
18
+ UI.important("client_secret #{client_secret}")
19
+
20
+ uri = URI('https://api.amazon.com/auth/o2/token')
21
+ http = Net::HTTP.new(uri.host, uri.port)
22
+ http.use_ssl = true
23
+ req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
24
+ req.body = {client_id: client_id, grant_type: 'client_credentials',
25
+ client_secret: client_secret, scope: "appstore::apps:readwrite" }.to_json
26
+
27
+ res = http.request(req)
28
+ result_json = JSON.parse(res.body)
29
+
30
+ auth_token = "Bearer #{result_json['access_token']}"
31
+
32
+ return auth_token
33
+ end
34
+
35
+ def self.create_new_edit(token, app_id)
36
+
37
+ create_edit_path = "/v1/applications/#{app_id}/edits"
38
+ create_edit_url = BASE_URL + create_edit_path
39
+
40
+ uri = URI(create_edit_url)
41
+ http = Net::HTTP.new(uri.host, uri.port)
42
+ http.use_ssl = true
43
+ req = Net::HTTP::Post.new(
44
+ uri.path,
45
+ 'Content-Type' => 'application/json',
46
+ 'Authorization' => token
47
+ )
48
+
49
+ res = http.request(req)
50
+ current_edit = JSON.parse(res.body)
51
+
52
+ return current_edit['id']
53
+ end
54
+
55
+ def self.open_edit(token, app_id)
56
+
57
+ get_edit_path = "/v1/applications/#{app_id}/edits"
58
+ get_edit_url = BASE_URL + get_edit_path
59
+
60
+ uri = URI(get_edit_url)
61
+ http = Net::HTTP.new(uri.host, uri.port)
62
+ http.use_ssl = true
63
+ req = Net::HTTP::Get.new(
64
+ uri.path,
65
+ 'Authorization' => token,
66
+ 'Content-Type' => 'application/json'
67
+ )
68
+
69
+ res = http.request(req)
70
+ current_edit = JSON.parse(res.body)
71
+
72
+ UI.message("eTag #{res.header['ETag']}")
73
+
74
+ return current_edit['id'], res.header['ETag']
75
+ end
76
+
77
+ def self.get_current_apk_etag(token, app_id, edit_id, apk_id)
78
+
79
+ get_apks_etag = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}"
80
+ get_apks_etag_url = BASE_URL + get_apks_etag
81
+
82
+ uri = URI(get_apks_etag_url)
83
+ http = Net::HTTP.new(uri.host, uri.port)
84
+ http.use_ssl = true
85
+ req = Net::HTTP::Get.new(
86
+ uri.path,
87
+ 'Authorization' => token,
88
+ 'Content-Type' => 'application/json'
89
+ )
90
+
91
+ res = http.request(req)
92
+ return res.header['ETag']
93
+ end
94
+
95
+ def self.get_current_apk_id(token, app_id, edit_id)
96
+
97
+ get_apks_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks"
98
+ get_apks_url = BASE_URL + get_apks_path
99
+
100
+ uri = URI(get_apks_url)
101
+ http = Net::HTTP.new(uri.host, uri.port)
102
+ http.use_ssl = true
103
+ req = Net::HTTP::Get.new(
104
+ uri.path,
105
+ 'Authorization' => token,
106
+ 'Content-Type' => 'application/json'
107
+ )
108
+
109
+ res = http.request(req)
110
+ if !res.body.nil?
111
+ apks = JSON.parse(res.body)
112
+ firstAPK = apks[0]
113
+ apk_id = firstAPK['id']
114
+ return apk_id
115
+ end
116
+ end
117
+
118
+ def self.replaceExistingApk(token, app_id, edit_id, apk_id, eTag, apk_path)
119
+
120
+ replace_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}/replace"
121
+ local_apk = File.open(apk_path, "r").read
122
+
123
+ replace_apk_url = BASE_URL + replace_apk_path
124
+ uri = URI(replace_apk_url)
125
+ http = Net::HTTP.new(uri.host, uri.port)
126
+ http.use_ssl = true
127
+ http.write_timeout = 10000
128
+ req = Net::HTTP::Put.new(
129
+ uri.path,
130
+ 'Authorization' => token,
131
+ 'Content-Type' => 'application/vnd.android.package-archive',
132
+ 'If-Match' => eTag
133
+ )
134
+
135
+ req.body = local_apk
136
+ res = http.request(req)
137
+ return res.code
138
+ end
139
+
140
+ def self.delete_apk(token, app_id, edit_id, apk_id, eTag)
141
+
142
+ delete_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}"
143
+ delete_apk_url = BASE_URL + delete_apk_path
144
+
145
+ UI.message("delete_apk_url #{delete_apk_url}")
146
+
147
+ uri = URI(delete_apk_url)
148
+ http = Net::HTTP.new(uri.host, uri.port)
149
+ http.use_ssl = true
150
+ req = Net::HTTP::Delete.new(
151
+ uri.path,
152
+ 'Authorization' => token,
153
+ 'Content-Type' => 'application/vnd.android.package-archive',
154
+ 'If-Match' => eTag
155
+ )
156
+
157
+ res = http.request(req)
158
+ result_json = JSON.parse(res.body)
159
+ end
160
+
161
+ def self.uploadNewApk(token, app_id, edit_id, apk_path)
162
+
163
+ add_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/upload"
164
+ add_apk_url = BASE_URL + add_apk_path
165
+ local_apk = File.open(apk_path, 'r').read
166
+
167
+ uri = URI(add_apk_url)
168
+ http = Net::HTTP.new(uri.host, uri.port)
169
+ http.use_ssl = true
170
+ http.write_timeout = 10000
171
+ http.read_timeout = 10000
172
+ req = Net::HTTP::Post.new(
173
+ uri.path,
174
+ 'Authorization' => token,
175
+ 'Content-Type' => 'application/vnd.android.package-archive'
176
+ )
177
+
178
+ req.body = local_apk
179
+ res = http.request(req)
180
+ result_json = JSON.parse(res.body)
181
+ end
182
+
183
+ def self.commit_edit(token, app_id, edit_id, eTag)
184
+
185
+ commit_edit_path = "/v1/applications/#{app_id}/edits/#{edit_id}/commit"
186
+ commit_edit_url = BASE_URL + commit_edit_path
187
+
188
+ uri = URI(commit_edit_url)
189
+ http = Net::HTTP.new(uri.host, uri.port)
190
+ http.use_ssl = true
191
+ req = Net::HTTP::Post.new(
192
+ uri.path,
193
+ 'Authorization' => token,
194
+ 'If-Match' => eTag
195
+ )
196
+
197
+ res = http.request(req)
198
+ result_json = JSON.parse(res.body)
199
+ end
200
+
201
+ def self.show_message
202
+ UI.message("Hello from the amazon_app_submission plugin helper!")
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module AmazonAppSubmission
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/amazon_app_submission/version'
2
+
3
+ module Fastlane
4
+ module AmazonAppSubmission
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::AmazonAppSubmission.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-amazon_app_submission
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mohammedhemaid
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.206.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.206.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email: mohammed.hemaid@outlook.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/amazon_app_submission.rb
162
+ - lib/fastlane/plugin/amazon_app_submission/actions/amazon_app_submission_action.rb
163
+ - lib/fastlane/plugin/amazon_app_submission/helper/amazon_app_submission_helper.rb
164
+ - lib/fastlane/plugin/amazon_app_submission/version.rb
165
+ homepage:
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '2.5'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.0.3.1
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: This is the first version of the Amazon App Submission
188
+ test_files: []