codes 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/bin/codes +4 -2
- data/lib/codes/itunes_connect.rb +14 -3
- data/lib/codes/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41463a8ab83d8ef546b17a89107ce4817f88209a
|
4
|
+
data.tar.gz: 11191fc9f73a91fb350fd8d6900cacf3098401cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f06a2d26fc55d66265e4597a2a793af7d83cae5a848c018fa12cd645ae37eb12b87799b9bd6356734d7bd760154c0ff7f00f7e1ef7d6960732bcbcfc15dfb341
|
7
|
+
data.tar.gz: 88320906261aed0ef5f3af73c2a11570aecd5fb67fcefb883ea627b31eb12413621a71e6b28a9a86fd110df6898f468720f2b9fdb9cc25b3f312cce01388e651
|
data/README.md
CHANGED
@@ -80,6 +80,12 @@ Will generate 3 promo codes for the the App with the Bundle Identifier `com.exam
|
|
80
80
|
|
81
81
|
If you don't pass any paramaters, `codes` will generate a single promo code and print it on the command line.
|
82
82
|
|
83
|
+
## Generate URLs
|
84
|
+
|
85
|
+
codes 5 --urls
|
86
|
+
|
87
|
+
If specified, includes a full URL for each code that can be used to redeem that code.
|
88
|
+
|
83
89
|
![assets/codes.gif](assets/codes.gif)
|
84
90
|
|
85
91
|
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
|
data/bin/codes
CHANGED
@@ -26,10 +26,11 @@ class CodesApplication
|
|
26
26
|
global_option '-a', '--app_identifier STRING', 'The bundle ID to download promo codes for'
|
27
27
|
global_option '-i', '--apple_id STRING', 'The App ID to download promo codes for'
|
28
28
|
global_option '-o', '--output_file STRING', 'The name of the file that should be written to disk. If the file exists, the new codes will be appended.'
|
29
|
+
global_option '-x', '--urls', 'If specified, includes a full URL for each code that can be used to redeem that code.'
|
29
30
|
|
30
31
|
|
31
32
|
command :download do |c|
|
32
|
-
c.syntax = "
|
33
|
+
c.syntax = "codes download [num]"
|
33
34
|
c.description = "Download [num] new promo codes from iTunes Connect"
|
34
35
|
|
35
36
|
c.action do |args, options|
|
@@ -37,8 +38,9 @@ class CodesApplication
|
|
37
38
|
number_of_codes = count(args)
|
38
39
|
apple_id = apple_id(options)
|
39
40
|
app_identifier = bundle_id(options, apple_id)
|
41
|
+
urls = options.x || options.urls
|
40
42
|
|
41
|
-
Codes::CodesRunner.run(number_of_codes: number_of_codes, app_identifier: app_identifier, apple_id: apple_id, output_file_path: options.output_file)
|
43
|
+
Codes::CodesRunner.run(number_of_codes: number_of_codes, app_identifier: app_identifier, apple_id: apple_id, output_file_path: options.output_file, urls: urls)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
data/lib/codes/itunes_connect.rb
CHANGED
@@ -3,7 +3,8 @@ require 'fastlane_core/itunes_connect/itunes_connect'
|
|
3
3
|
module Codes
|
4
4
|
class ItunesConnect < FastlaneCore::ItunesConnect
|
5
5
|
|
6
|
-
PROMO_URL = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/LCAppPage/viewPromoCodes?adamId="
|
6
|
+
PROMO_URL = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/LCAppPage/viewPromoCodes?adamId=[[app_id]]&platform=[[platform]]"
|
7
|
+
CODE_URL = "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemLandingPage?code=[[code]]"
|
7
8
|
|
8
9
|
def run(args)
|
9
10
|
number_of_codes = args[:number_of_codes]
|
@@ -21,11 +22,14 @@ module Codes
|
|
21
22
|
raise "Could not find app using the following information: #{args}. Maybe the app is not in the store. Pass the Apple ID of the app as well!".red
|
22
23
|
end
|
23
24
|
|
25
|
+
app = FastlaneCore::ItunesSearchApi.fetch(app_id)
|
26
|
+
platform = (app['kind'] == "mac-software" ? "osx" : "ios")
|
27
|
+
|
24
28
|
# Use Pathname because it correctly handles the distinction between relative paths vs. absolute paths
|
25
29
|
output_file_path = Pathname.new(args[:output_file_path]) if args[:output_file_path]
|
26
30
|
output_file_path ||= Pathname.new(File.join(Dir.getwd, "#{app_identifier || app_id}_codes.txt"))
|
27
31
|
raise "Insufficient permissions to write to output file".red if File.exists?(output_file_path) and not File.writable?(output_file_path)
|
28
|
-
visit PROMO_URL
|
32
|
+
visit PROMO_URL.gsub("[[app_id]]", app_id.to_s).gsub("[[platform]]", platform)
|
29
33
|
|
30
34
|
begin
|
31
35
|
text_fields = wait_for_elements("input[type=text]")
|
@@ -45,11 +49,18 @@ module Codes
|
|
45
49
|
|
46
50
|
codes = download_codes download_url
|
47
51
|
|
52
|
+
if args[:urls]
|
53
|
+
codes = codes.split("\n").map do |code|
|
54
|
+
code +" - "+ CODE_URL.gsub("[[code]]", code)
|
55
|
+
end
|
56
|
+
codes = codes.join("\n") + "\n"
|
57
|
+
end
|
58
|
+
|
48
59
|
bytes_written = File.write(output_file_path.to_s, codes, mode: "a+")
|
49
60
|
Helper.log.warn "Could not write your codes to the codes.txt file, but you can still access them from iTunes Connect later" if bytes_written == 0
|
50
61
|
Helper.log.info "Added generated codes to '#{output_file_path.to_s}'".green unless bytes_written == 0
|
51
62
|
|
52
|
-
Helper.log.info "Your codes were
|
63
|
+
Helper.log.info "Your codes were successfully downloaded:".green
|
53
64
|
puts codes
|
54
65
|
end
|
55
66
|
|
data/lib/codes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|