googlepub 0.0.3 → 0.0.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGRlN2I3ZjJhZDEzZWYwODRmOTdjMjI5ZjlkNWEyNzAzYjQyMWY2ZA==
4
+ MmJmNWJjYTA3ODI3NzJmMTFhYzUzNmYyZjQzNmQ5NzhlNGJmZDA3MQ==
5
5
  data.tar.gz: !binary |-
6
- MjdkNGE3NTVlZmJkZTg1NTUyM2I5MWJjZjFmMGRiNmQ2MTk5ZjFhZQ==
6
+ ZWJlOTIxMTY4YzFjNzhjNjUwNWE0MDBiMDMwOTU1MjhmY2NlNDkwYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWI2YjY0NWZjYTI5OTE3YjRhOGEyYjZiYjVhMzM2ZmY2ZTI3ZGJjNThmMDg5
10
- NmE4YjQxMjczZTEzZTM4ZDQ2ZWE0NzFjNjMzOWJlOTI0ZGY2NzZiZWJjYTU4
11
- Mjk5YTZjOGJjMDk3M2QzZjhjZjE0NWQyNjRlNGU2MGZhYjU2YWU=
9
+ ZDIwM2YxODUyNmY0ZDUyN2JjMDAwMmFiMTdiMDQ5NDlmZTU3MDQyZDc4YzUw
10
+ YTg3NTg0MzY0MjhjOTQ4YWUxOGRkMjcxYmNlYTFhZmMzODViZjg5OGE5N2Ex
11
+ NzI1NWI4MTA0MWQzMjE2YTM5ZTIzZjlhOTY1MDc0ZTJlY2M5MGQ=
12
12
  data.tar.gz: !binary |-
13
- YmE2ZWVkMzYwMGExYjAxNjIxMTllNzdlOTI5NGQ3M2VjNzQ1ZTUxYTZhOGZl
14
- OGU1MmFjMGE2MTA1MDFmMTY1ZGE1M2JlMzY4ZjYxYTBkNmIyOWNjODBiYzg2
15
- NmMzNmY1MmY2ZWUwN2E3ZmRhN2M2MzI0MmEwMDkwOWE5NTMzNjI=
13
+ YWNkNTFhMWMzNzM3NjdjZTcxZjM2YTBmMWJhYjlkODcxM2I2YmZkOGQ1YWJk
14
+ MWZkZWY5YjdlYzFkMDA3OGMxMTZmY2U0MDkxMDVjNTFhOWRlYzgyZjFlYTU4
15
+ YTRiOGMzZjBiMzVlZWI4OTE3YTI5Yzc4NGQ1NmM5YWU3NzI1NjQ=
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # googlepub
2
2
 
3
3
  ## The gem to automate everything for GooglePlay Developer Console with a Single Command i.e. googlepub
4
- This gem uses the Google Publishing API.Go for it. A single command for everything. Have issues/problems/Feature requests/advices Please add them as Issues. I'll get back to you ASAP.
4
+ Store Listing, APK, In-App Purchases, this does it all. This gem uses the Google Publishing API.
5
+ Have issues/problems/Feature requests/advices Please add them as Issues. I'll get back to you ASAP.
6
+
5
7
  ## Set up Googlepub
6
8
  In your terminal:
7
9
  `[sudo] gem install googlepub`
@@ -26,28 +28,41 @@ To enable googlepub to access Google Play you have to follow these steps:
26
28
  * Choose Release Manager from the dropdown and confirm
27
29
 
28
30
  ## Issuer
29
- Copy and paste the email address which looks like *9083982039lnwdnlwk-23929ojkn@developer.gserviceaccount.com* and pass it as the -i or --iss option with the command or paste it when asked for or set as ENV['ISS']
31
+ Copy the email address which looks like *9083982039lnwdnlwk-23929ojkn@developer.gserviceaccount.com* and
32
+ -paste it in a file named "issfile" in the working Directory (Without any quotes around the String) or
33
+ -pass it as the -i or --iss option with the command as "[ISS]" or
34
+ -paste it when asked for as "[ISS]" or
35
+ -set as ENV['ISS']
30
36
 
31
37
 
32
38
  ## Keyfile
33
- Store your p12 file in a secure place, for ease open it in any editor and copy and pass the key as -k or --key option with the command or paste it when asked for or set as ENV['KEY']
39
+ Store your p12 file in a secure place, for ease open it in any editor and copy the key and
40
+ -store in a file named "keyfile" in the working Directory (Without any quotes around the String) or
41
+ -pass as -k or --key option with the command as "[key]" or
42
+ -paste it when asked for "[key]" or
43
+ -set as ENV['KEY']
34
44
 
35
45
  ## Package
36
- The SKU of you App eg. "com.keshav.goel". Pass is as -p or --package option with the command or when asked for or set as ENV['PACKAGE']
46
+ The SKU of you App eg. "com.keshav.goel".
47
+ -Pass is as -p or --package option with the command or
48
+ -when asked for while execution or
49
+ -set as ENV['PACKAGE']
37
50
 
38
51
  ##Main commands
39
52
  apk
40
53
  metadata
54
+ inapps
41
55
 
42
56
  ## Options
43
57
 
44
58
  ### With sub command metadata:
59
+ -l, --language [LANGUAGE] The ISO language code (default: "en-US")
45
60
  -k, --key [KEY] Key for the Account from Google Developer Console (ENV['KEY'])
46
- -i, --iss [KEY] ISS for the Account from Google Developer Console (ENV['ISS'])
61
+ -i, --iss [ISSUER] ISS for the Account from Google Developer Console (ENV['ISS'])
47
62
  -p, --package [PACKAGE] Package to update on the Google Developer Console (ENV['PACKAGE'])
48
63
  --store Specify that Store Listing details are to be Updated.
49
64
  -t, --title [TITLE] Name for your App
50
- -f, --full [FULLDESCRIPTION] Full Description for your App
65
+ -f, --full [FULLDESCRIPTION] Full Description for your App/Description for your In-App
51
66
  -s, --short [SHORTDESCRIPTION] Short Description for your App
52
67
  -v, --video [VIDEO] Youtube Video URL
53
68
  --details Specify that the details are to be updated (Website, Email and Phone)
@@ -55,39 +70,41 @@ metadata
55
70
  -e, --email [EMAIL] Email for Contact
56
71
  --phone [PHONE] Phone for Contact
57
72
  --screenshots Specify that Screenshots are to be updated for Contact
58
- --featureGraphic [FEATUREGRAPHIC]
59
- featureGraphic for your App eg: "path/to/file"
60
- --icon [ICON] icon for your App eg: "path/to/file"
61
- --phoneScreenshots [PHONE SCREENSHOTS]
62
- phoneScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
63
- --promoGraphic [PROMOGRAPHIC]
64
- promoGraphic for your App eg: "path/to/file"
65
- --sevenInchScreenshots [SEVENINCHSCREENS]
66
- sevenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
67
- --tenInchScreenshots [TENINCHSCREENS]
68
- tenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
69
- --tvBanner [TVBANNER] tvBanner for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
70
- --tvScreenshots [TVSCREENS] tvScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
71
- --wearScreenshots [WEARSCREENS]
72
- wearScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
73
- --version display googlepub version
74
- -h, --help display this help message
73
+ --featureGraphic [PATH] featureGraphic for your App eg: "path/to/file"
74
+ --icon [PATH] icon for your App eg: "path/to/file"
75
+ --phoneScreenshots [PATH] phoneScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
76
+ --promoGraphic [PATH] promoGraphic for your App eg: "path/to/file"
77
+ --sevenInch [PATH] sevenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
78
+ --tenInch [PATH] tenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
79
+ --tvBanner [PATH] tvBanner for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
80
+ --tv [PATH] tvScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
81
+ --wear [PATH] wearScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."
82
+ --version Display googlepub version
83
+ -h, --help Display this help message
84
+
75
85
 
76
86
  ### With sub command apk:
77
87
  --file [FILE] APK file to upload eg: "path/to/file"
78
- --track [TRACK] Track to which APK file is to be uploaded eg: "beta"
79
- --version display googlepub version
80
- -h, --help display this help message
88
+ --track [TRACK] Track to which APK file is to be uploaded eg: "beta"
89
+ --apkversion [Version] Code Version of your APK you want to deploy
90
+ -h, --help Display this help message
91
+
92
+ ### With sub command inapps:
93
+ --sku [SKU] The SKU of the In-App you wish to edit
94
+ -f, --full [FULLDESCRIPTION] Full Description for your App/Description for your In-App
95
+ --price [PRICE] Price for the In-App in Decimal(eg: 5.99), Will convert to Millionth by self
96
+ --curr [CURR] 3 letter Currency code, as defined by ISO 4217 for your SKU (USD by default)
97
+ --status [STATUS] Status for your In-App, "active" or "inactive"
98
+ -h, --help Display this help message
99
+ (Note: New In-App support Coming Soon!)
100
+
101
+ **Note: When using inapps sub-command, access_token file created is not deleted(unlike apk and metadata). The access_token saved in the file is reused for multiple In-App activity(Untill its Expiry or another Edit for APK or Metadata).**
81
102
 
82
103
  #Example:
83
104
  googlepub metadata -l "en-US" -p "com.keshav.goel" --store -t "Title" -s "Short Description" -f "fullDescription" --icon "icon.png"
84
105
 
85
106
  googlepub apk -p "com.keshav.goel" --file "file.apk" --track "beta"
86
107
 
87
- * **If ENV['KEY'] or -k/--key is not passed, the command will ask for key pass it as "-----KEY---"**
88
- * **If ENV['ISS'] or -i/-iss is not passed, the command will ask for iss pass it as"iss@account.com"**
89
- * **If ENV['PACKAGE'] or -p/--package is not passed, the command will ask for package pass it as "com.keshav.goel"**
90
-
91
- ### In-App purchase support coming in a few days.
108
+ googlepub inapps -p "com.keshav.goel" --sku "com.keshav.inapp.12" --title "InApp 12" --fullDescription "Description" --price 1990000
92
109
 
93
110
  ##### For any issues/problems please add an Issue to the repo.
data/googlepub.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.version = Googlepub::VERSION
6
6
  s.date = '2015-10-25'
7
7
  s.summary = "GooglePlay App Publisher!"
8
- s.description = "Automate everything related to Google App Publishing, APK, Stor Listing and In-App Purchses."
9
- s.authors = ["Keshav Goel"]
8
+ s.description = "CLI googlepub. Automate everything related to Google App Publishing, APK, Store Listing and In-App Purchases."
9
+ s.author = ["Keshav Goel"]
10
10
  s.email = 'keshu_gl@yahoo.com'
11
11
  s.require_paths = ['lib']
12
12
  s.executables = ['googlepub']
data/lib/googlepub.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/googlepub/metadata.rb')
2
2
  require File.expand_path(File.dirname(__FILE__) + '/googlepub/apk.rb')
3
+ require File.expand_path(File.dirname(__FILE__) + '/googlepub/inapps.rb')
3
4
 
4
5
  module Googlepub
5
6
 
6
7
  ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
7
8
 
8
- VERSION = "0.0.3"
9
+ VERSION = "0.0.4"
9
10
 
10
11
  def self.call_metadata(options = {})
11
12
  @pack = Googlepub::Metadata.new(options["language"])
@@ -75,4 +76,21 @@ module Googlepub
75
76
 
76
77
  end
77
78
 
79
+ def self.call_inapps(options = {})
80
+ if !options["sku"]
81
+ puts "SKU (Product Id) of the In-App Purchase (eg: \"com.keshav.inapp.001\"):"
82
+ @sku = gets.chomp
83
+ else
84
+ @sku = options["sku"]
85
+ end
86
+ @iap = Googlepub::Inapps.new(@sku, options["language"])
87
+ @iap.find_inapp
88
+ if options["price"] || options["title"] || options["description"]
89
+ @iap.edit_inapp(options)
90
+ else
91
+ puts "No option passed to Edit the In-App"
92
+ end
93
+
94
+ end
95
+
78
96
  end
data/lib/googlepub/apk.rb CHANGED
@@ -1,6 +1,3 @@
1
- require "base64"
2
- require 'jwt'
3
- require 'jwt/json'
4
1
  require 'httparty'
5
2
  require 'httmultiparty'
6
3
  require 'colorize'
@@ -15,7 +12,7 @@ module Googlepub
15
12
  @edit_id = ENV['EDIT_ID']
16
13
  @access_token = ENV['ACCESS_TOKEN']
17
14
  @package = ENV['PACKAGE']
18
- if !@edit_id || !@access_token || @package
15
+ if !@edit_id || !@access_token || !@package
19
16
  p "Invalid call".red
20
17
  end
21
18
  if !File.new(@file)
@@ -10,20 +10,6 @@ module Googlepub
10
10
  class Auth
11
11
 
12
12
  def initialize(options = {})
13
- if !options["key"] && !ENV['KEY']
14
- puts "Please provide the key for the Account on Google Developer Console (use option -k or --key for ease): "
15
- key = gets.chomp
16
- key = eval %Q{#{key}}
17
- else
18
- key = options["key"] || ENV['KEY']
19
- end
20
- if !options["iss"] && !ENV['ISS']
21
- puts "Please provide the ISS for the account on Google Developer Console (use -i or -iss for ease): "
22
- iss = gets.chomp
23
- iss = eval %Q{#{iss}}
24
- else
25
- iss = options["iss"] || ENV['ISS']
26
- end
27
13
  if !options["package"] && !ENV['PACKAGE']
28
14
  puts "Please provide the package you want to EDIT on (Use option -p or --package for ease): "
29
15
  package = gets.chomp
@@ -31,15 +17,41 @@ module Googlepub
31
17
  else
32
18
  package = options["package"] || ENV['PACKAGE']
33
19
  end
34
- if (!key || !iss || !package)
35
- puts "Invalid Arguments!".red
36
- end
37
- @key = key
38
- @iss = iss
39
20
  @package = package
40
- ENV['KEY'] = key
41
- ENV['ISS'] = iss
42
21
  ENV['PACKAGE'] = package
22
+ does_accesstoken_exists
23
+ if !ENV['ACCESS_TOKEN']
24
+ find_key_and_iss
25
+ if !options["key"] && !ENV['KEY']
26
+ puts "Please provide the key for the Account on Google Developer Console (use option -k or --key for ease): "
27
+ @key = gets.chomp
28
+ @key = eval %Q{#{@key}}
29
+ else
30
+ @key = options["key"] || ENV['KEY']
31
+ end
32
+ ENV['KEY'] = @key
33
+
34
+ if !options["iss"] && !ENV['ISS']
35
+ puts "Please provide the ISS for the account on Google Developer Console (use -i or -iss for ease): "
36
+ @iss = gets.chomp
37
+ @iss = eval %Q{#{@iss}}
38
+ else
39
+ @iss = options["iss"] || ENV['ISS']
40
+ end
41
+ ENV['ISS'] = @iss
42
+
43
+ if (!@key || !@iss || !@package)
44
+ puts "Invalid Arguments!".red
45
+ end
46
+
47
+ self.new_access_token
48
+ else
49
+ @access_token = ENV['ACCESS_TOKEN']
50
+ end
51
+
52
+ end
53
+
54
+ def new_access_token
43
55
  header = {"alg" => "RS256","typ" => "JWT"}
44
56
  claim_set = {
45
57
  "iss"=>@iss,
@@ -69,10 +81,10 @@ module Googlepub
69
81
  access_token = response.parsed_response["access_token"] #Access Token valid for 60 minutes
70
82
  ENV['ACCESS_TOKEN'] = access_token
71
83
  @access_token = access_token
72
- puts "Access Token: #{access_token}".green
73
- if @package
74
- self.edit()
75
- end
84
+ accessfile = File.new("access_token", "w")
85
+ accessfile.write(@access_token)
86
+ accessfile.close
87
+ puts "Access Token: #{@access_token}".green
76
88
  end
77
89
 
78
90
  ################# A new EDIT ##########################
@@ -93,7 +105,7 @@ module Googlepub
93
105
  end
94
106
 
95
107
  ##################### Validate Edit ##########################
96
- def validate
108
+ def validate_edit
97
109
  response_validate = HTTParty.post("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}:validate?access_token=#{@access_token}", :body =>{}).parsed_response
98
110
  if response_validate["id"] == @edit_id
99
111
  puts "Validated: Good to Go".green
@@ -105,7 +117,7 @@ module Googlepub
105
117
  end
106
118
 
107
119
  ###################### Commit the Edit ##########################
108
- def commit
120
+ def commit_edit
109
121
  response_commit = HTTParty.post("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}:commit?access_token=#{@access_token}", :body =>{}).parsed_response
110
122
  if response_commit["id"] == @edit_id
111
123
  puts "Committed!".green
@@ -116,6 +128,52 @@ module Googlepub
116
128
  end
117
129
  end
118
130
 
131
+ def find_key_and_iss
132
+ keyfile = Dir["keyfile"][0]
133
+ if keyfile
134
+ file = File.open("#{keyfile}", 'r')
135
+ if file.size != 0
136
+ @key = eval %Q{"#{file.read}"}
137
+ ENV['KEY'] = @key
138
+ end
139
+ end
140
+
141
+ issfile = Dir["issfile"][0]
142
+ if issfile
143
+ file = File.open("#{issfile}", 'r')
144
+ if file.size != 0
145
+ @iss = eval %Q{"#{file.read}"}
146
+ ENV['ISS'] = @iss
147
+ end
148
+ end
149
+
150
+ end
151
+
152
+ def does_accesstoken_exists
153
+ accessfile = Dir["access_token"][0]
154
+ if accessfile
155
+ file = File.open("#{accessfile}", 'r')
156
+ if file.size != 0
157
+ @access_token = eval %Q{"#{file.read}"}
158
+ validate_token_or_generate
159
+ end
160
+ end
161
+ end
162
+
163
+ def validate_token_or_generate
164
+ response_validate = HTTParty.get("https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=#{@access_token}").parsed_response
165
+ if response_validate["issued_to"] && response_validate["expires_in"] >=300
166
+ ENV['ACCESS_TOKEN'] = @access_token
167
+ puts "Using Access Token: #{ENV['ACCESS_TOKEN']}"
168
+ else
169
+ @access_token = nil
170
+ accessfile = Dir["access_token"][0]
171
+ if accessfile
172
+ File.delete("access_token")
173
+ end
174
+ end
175
+ end
176
+
119
177
  end
120
178
 
121
179
  end
@@ -1,91 +1,55 @@
1
- require "base64"
2
- require 'jwt'
3
- require 'jwt/json'
4
1
  require 'httparty'
5
- require 'getoptlong'
6
2
  require 'httmultiparty'
7
- require 'yaml'
8
- require 'auth'
9
3
  require 'colorize'
10
4
 
11
- class inapps
12
- def initialize(sku, price, title, description, type = "managedUser", currency = "USD", language = "en-US", status = "active", trial = nil)
13
- @sku = sku
14
- @price = price
15
- @title = title
16
- @description = description
17
- @type = type
18
- @currency = currency
19
- @language = language
20
- @status = status
21
- @package = ENV['PACKAGE']
22
- @access_token = ENV['ACCESS_TOKEN']
23
- @edit_id = ENV['EDIT_ID']
24
- @trial = trail
25
- end
26
-
27
- def newinapp
28
- if type == "managedUser"
29
- new_iap = {"packageName"=>@package, "sku"=>@sku, "status"=>@status, "purchaseType"=>"#{@type}",
30
- "defaultPrice"=>{"priceMicros"=>@price, "currency"=>"#{@currency}"}, "listings"=>{"#{@language}"=>{"title"=>@title,
31
- "description"=>@description }}, "defaultLanguage"=>"#{@language}"}
32
- elsif type == "subscription"
33
- new_iap = {"packageName"=>@package, "sku"=>@sku, "status"=>@status, "purchaseType"=>"#{@type}",
34
- "defaultPrice"=>{"priceMicros"=>@price, "currency"=>"#{@currency}"}, "listings"=>{"#{@language}"=>{"title"=>@title,
35
- "description"=>@description }}, "defaultLanguage"=>"#{@language}", "subscriptionPeriod" => "#{@period}", "trialPeriod" => "#{@trial}"}
36
- end
37
-
38
- resp = HTTParty.post("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/inappproducts?autoConvertMissingPrices=true&access_token=#{@access_token}", :headers => { 'Content-Type' => 'application/json' },
39
- :body => new_iap.to_json).parsed_response
40
-
41
- if !resp["listings"]["en-US"]["title"]
42
- puts "Unable to create: Response -> #{resp}".red
43
- else
44
- puts "Made IAP #{i}".green
5
+ module Googlepub
6
+
7
+ class Inapps
8
+ def initialize(sku, language)
9
+ @sku = sku
10
+ @language = language
11
+ @package = ENV['PACKAGE']
12
+ @access_token = ENV['ACCESS_TOKEN']
13
+ if !@access_token || !@package
14
+ p "Invalid call".red
15
+ exit 1
16
+ end
45
17
  end
46
- puts "Successfully Done: New IAP Creation".green
47
- end
48
18
 
49
- def find_inapp
50
- @inapps = HTTParty.get("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/inappproducts/#{@sku}?access_token=#{@access_token}").parsed_response
51
- if !@inapps || !inapps["listings"]["#{@language}"]["title"]
52
- puts "In-app: #{@sku} Not Found!".red
53
- exit 1
54
- else
55
- puts "Inapp: #{@sku} found, Name:#{@inapps["listings"]["#{@language}"]["title"]}, Price: #{@inapps["defaultPrice"]["priceMicros"]}".green
19
+ def find_inapp
20
+ @inapp = HTTParty.get("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/inappproducts/#{@sku}?access_token=#{@access_token}").parsed_response
21
+ if !@inapp || !@inapp["listings"][@language]["title"]
22
+ puts "In-app: #{@sku} Not Found!".red
23
+ exit 1
24
+ else
25
+ puts "In-App: #{@sku} found, Name:#{@inapp["listings"][@language]["title"]}, Price: #{@inapp["defaultPrice"]["priceMicros"]}".green
26
+ end
56
27
  end
57
- end
58
-
59
- def edit_inapp(action)
60
- if action = "name"
61
- ####### Change the Ttitle ##########
62
- @inapps["listings"]["#{@language}"]["title"] = name
63
28
 
64
- ############# Put the request ###########
65
- changed_response = HTTParty.put("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/inappproducts/#{@sku}?access_token=#{@access_token}",
66
- :headers => { 'Content-Type' => 'application/json' }, :body => @inapps.to_json).parsed_response
67
- if changed_response["listings"]["#{@language}"]["title"] != name
68
- puts "Unable to Change name, Response -> #{changed_response}".red
69
- exit 3
70
- end
71
- puts "Done: Name Change".green
72
- end
73
-
74
- if action = "price"
75
- ################# Changing the price ######################
76
- new_iap = {"packageName"=>@package, "sku"=>@sku, "status"=>@status, "purchaseType"=>@type,
77
- "defaultPrice"=>{"priceMicros"=>@price, "currency"=>@currency}, "listings"=>{"#{@language}"=>{"title"=>@inapps["listings"]["#{@language}"]["title"],
78
- "description"=>@inapps["listings"]["#{@language}"]["description"] }}, "defaultLanguage"=>"#{@language}"}
79
-
80
- ##################### Putting the the request back ###############
29
+ def edit_inapp(options = {})
30
+ p "Going to Edit the In-App"
31
+ new_iap = {"packageName"=>@package, "sku"=>@sku, "status"=>options["status"] || @inapp["status"], "purchaseType"=>@inapp["purchaseType"],
32
+ "defaultPrice"=>{"priceMicros"=>options["price"] || @inapp["defaultPrice"]["priceMicros"], "currency"=>options["currency"] || @inapp["defaultPrice"]["currency"]}, "listings"=>{@language=>{"title"=>options["title"] || @inapp["listings"][@language]["title"],
33
+ "description"=>options["fullDescription"] || @inapp["listings"][@language]["description"] }}, "defaultLanguage"=>@language}
81
34
 
82
35
  resp = HTTParty.put("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/inappproducts/#{@sku}?autoConvertMissingPrices=true&access_token=#{@access_token}", :headers => { 'Content-Type' => 'application/json' },
83
36
  :body => new_iap.to_json).parsed_response
84
-
85
- if resp["defaultPrice"]["priceMicros"] != price
37
+ if options["title"] && resp["listings"][@language]["title"] != options["title"]
38
+ puts "Unable to Change name, Response -> #{resp}".red
39
+ exit 3
40
+ elsif options["title"] && resp["listings"][@language]["title"] == options["title"]
41
+ puts "Done: Name Change".green
42
+ end
43
+
44
+ if options["price"] && resp["defaultPrice"]["priceMicros"] != options["price"]
86
45
  puts "Unable to change price, Response -> #{resp}".red
87
46
  exit 3
88
- end
89
- puts "Done: Price Change".green
47
+ elsif options["price"] && resp["defaultPrice"]["priceMicros"] == options["price"]
48
+ puts "Done: Price Change".green
49
+ end
50
+
90
51
  end
52
+
91
53
  end
54
+
55
+ end
@@ -1,6 +1,3 @@
1
- require "base64"
2
- require 'jwt'
3
- require 'jwt/json'
4
1
  require 'httparty'
5
2
  require 'httmultiparty'
6
3
  require 'colorize'
@@ -15,7 +12,7 @@ module Googlepub
15
12
  @access_token = ENV['ACCESS_TOKEN']
16
13
  @package = ENV['PACKAGE']
17
14
  if !@edit_id || !@access_token || !@package
18
- p "Missing Something, Invalid call".red
15
+ p "Missing Authorization, Invalid call".red
19
16
  end
20
17
  get_listing
21
18
  get_details
@@ -13,15 +13,17 @@ Googlepub it gem for Google Android Publisheing API.
13
13
  Abilities:
14
14
  1) Store Listing
15
15
  2) APK - All tracks
16
- 3) In-App Purchases (Managed and Subscriptions) (Coming Soon)
16
+ 3) In-App Purchases (Managed and Subscriptions)
17
17
 
18
18
  Usage:
19
19
  googlepub COMMAND [OPTIONS]
20
20
  Main commands:
21
- apk. metadata
21
+ apk. metadata, inapps
22
22
  Example:
23
23
  googlepub metadata -l "en-US" -p "com.keshav.goel" --store -t "Title" -s "Short Description" -f "fullDescription" --icon "icon.png"
24
24
  googlepub apk -p "com.keshav.goel" --file "file.apk" --track "beta"
25
+ googlepub inapps -p "com.keshav.goel" --sku "com.keshav.inapp.12" --title "InApp 12" --fullDescription "Description" --price 1990000
26
+
25
27
  Dependencies:
26
28
  Ruby, HTTP
27
29
 
@@ -35,9 +37,14 @@ Email: keshu_gl@yahoo.com
35
37
  cmd = ARGV.shift
36
38
  @command = cmd && cmd.to_sym
37
39
  @auth = Googlepub::Auth.new(@options)
38
- run
39
- @auth.validate
40
- @auth.commit
40
+ if @command != :inapps
41
+ @auth.edit
42
+ run
43
+ @auth.validate_edit
44
+ @auth.commit_edit
45
+ else
46
+ run
47
+ end
41
48
  end
42
49
 
43
50
  def run
@@ -45,6 +52,7 @@ Email: keshu_gl@yahoo.com
45
52
  case @command
46
53
  when :apk then puts Googlepub.call_apk(@options)
47
54
  when :metadata then puts Googlepub.call_metadata(@options)
55
+ when :inapps then puts Googlepub.call_inapps(@options)
48
56
  else
49
57
  puts "Please provide command to Excute - 'apk' or 'metadata'"
50
58
  exit (1)
@@ -61,13 +69,16 @@ Email: keshu_gl@yahoo.com
61
69
 
62
70
  private
63
71
  def parse_options
64
- @options = {"language" => "en-US"}
72
+ @options = {"language" => "en-US", "currency" => "USD"}
65
73
  @option_parser = OptionParser.new do |opts|
66
- opts.on('-k', '--key [KEY]', "Key for the Account from Google Developer Console (ENV['KEY'])") do |l|
74
+ opts.on('-l', '--language [LANGUAGE]', 'The ISO language code (default: "en-US")') do |l|
67
75
  @options["language"] = l
68
76
  end
77
+ opts.on('-k', '--key [KEY]', "Key for the Account from Google Developer Console (ENV['KEY'])") do |l|
78
+ @options["key"] = l
79
+ end
69
80
  opts.on('-i', '--iss [ISSUER]', "ISS for the Account from Google Developer Console (ENV['ISS'])") do |l|
70
- @options["language"] = l
81
+ @options["iss"] = l
71
82
  end
72
83
  opts.on('-p', '--package [PACKAGE]', "Package to update on the Google Developer Console (ENV['PACKAGE'])") do |pa|
73
84
  @options["package"] = pa
@@ -78,7 +89,7 @@ Email: keshu_gl@yahoo.com
78
89
  opts.on('-t', '--title [TITLE]', 'Name for your App') do |k|
79
90
  @options["title"] = k
80
91
  end
81
- opts.on('-f', '--full [FULLDESCRIPTION]', 'Full Description for your App') do |t|
92
+ opts.on('-f', '--full [FULLDESCRIPTION]', 'Full Description for your App/Description for your In-App') do |t|
82
93
  @options["fullDescription"] = t
83
94
  end
84
95
  opts.on('-s', '--short [SHORTDESCRIPTION]', 'Short Description for your App') do |d|
@@ -102,44 +113,59 @@ Email: keshu_gl@yahoo.com
102
113
  opts.on('--screenshots', 'Specify that Screenshots are to be updated for Contact') do |r|
103
114
  @options["screenshots"] = r
104
115
  end
105
- opts.on('--featureGraphic [FEATUREGRAPHIC]', 'featureGraphic for your App eg: "path/to/file"') do |r|
116
+ opts.on('--featureGraphic [PATH]', 'featureGraphic for your App eg: "path/to/file"') do |r|
106
117
  @options["featureGraphic"] = r
107
118
  end
108
- opts.on('--icon [ICON]', 'icon for your App eg: "path/to/file"') do |z|
119
+ opts.on('--icon [PATH]', 'icon for your App eg: "path/to/file"') do |z|
109
120
  @options["icon"] = z
110
121
  end
111
- opts.on('--phoneScreenshots [PHONE SCREENSHOTS]', 'phoneScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
122
+ opts.on('--phoneScreenshots [PATH]', 'phoneScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
112
123
  @options["phoneScreenshots"] = r
113
124
  end
114
- opts.on('--promoGraphic [PROMOGRAPHIC]', 'promoGraphic for your App eg: "path/to/file"') do |r|
125
+ opts.on('--promoGraphic [PATH]', 'promoGraphic for your App eg: "path/to/file"') do |r|
115
126
  @options["promoGraphic"] = r
116
127
  end
117
- opts.on('--sevenInchScreenshots [SEVENINCHSCREENS]', 'sevenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
128
+ opts.on('--sevenInch [PATH]', 'sevenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
118
129
  @options["sevenInchScreenshots"] = r
119
130
  end
120
- opts.on('--tenInchScreenshots [TENINCHSCREENS]', 'tenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
131
+ opts.on('--tenInch [PATH]', 'tenInchScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
121
132
  @options["tenInchScreenshots"] = r
122
133
  end
123
- opts.on('--tvBanner [TVBANNER]', 'tvBanner for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
134
+ opts.on('--tvBanner [PATH]', 'tvBanner for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
124
135
  @options["tvBanner"] = r
125
136
  end
126
- opts.on('--tvScreenshots [TVSCREENS]', 'tvScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
137
+ opts.on('--tv [PATH]', 'tvScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
127
138
  @options["tvScreenshots"] = r
128
139
  end
129
- opts.on('--wearScreenshots [WEARSCREENS]', 'wearScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
140
+ opts.on('--wear [PATH]', 'wearScreenshots for your App (comma separated) eg: "path/to/file1,path/to/file1,.."') do |r|
130
141
  @options["wearScreenshots"] = r
131
142
  end
132
- opts.on('--file [FILE]', 'APK file to upload eg: "path/to/file"') do |r|
143
+ opts.on('--file [PATHTOFILE]', 'APK file to upload eg: "path/to/file"') do |r|
133
144
  @options["file"] = r
134
145
  end
135
- opts.on('--track [TRACK]', ' Track to which APK file is to be uploaded eg: "beta"') do |r|
136
- @options["file"] = r
146
+ opts.on('--track [TRACK]', 'Track to which APK file is to be uploaded eg: "beta"') do |r|
147
+ @options["track"] = r
148
+ end
149
+ opts.on('--apkversion [Version]', 'Code Version of your APK you want to deploy') do |r|
150
+ @options["status"] = r.downcase
151
+ end
152
+ opts.on('--sku [SKU]', 'The SKU of the In-App you wish to edit') do |r|
153
+ @options["sku"] = r
154
+ end
155
+ opts.on('--price [PRICE]', 'Price for the In-App in Decimal(eg: 5.99), Will convert to Millionth by self') do |r|
156
+ @options["price"] = r
157
+ end
158
+ opts.on('--curr [CURR]', '3 letter Currency code, as defined by ISO 4217 for your SKU (USD by default)') do |r|
159
+ @options["currency"] = r.upcase
160
+ end
161
+ opts.on('--status [STATUS]', 'Status for your In-App, "active" or "inactive"') do |r|
162
+ @options["status"] = r.downcase
137
163
  end
138
- opts.on_tail('-v', '--version', 'display googlepub version') do
164
+ opts.on_tail('--version', 'Display googlepub version') do
139
165
  puts "Googlepub version #{Googlepub::VERSION}"
140
166
  exit
141
167
  end
142
- opts.on_tail('-h', '--help', 'display this help message') do
168
+ opts.on_tail('-h', '--help', 'Display this help message') do
143
169
  usage
144
170
  end
145
171
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlepub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keshav Goel
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Automate everything related to Google App Publishing, APK, Stor Listing
98
- and In-App Purchses.
97
+ description: CLI googlepub. Automate everything related to Google App Publishing,
98
+ APK, Store Listing and In-App Purchases.
99
99
  email: keshu_gl@yahoo.com
100
100
  executables:
101
101
  - googlepub