Class: Googlepub::Metadata
- Inherits:
-
Object
- Object
- Googlepub::Metadata
- Defined in:
- lib/googlepub/metadata.rb
Instance Method Summary collapse
- #edit_details(website, email, phone) ⇒ Object
- #edit_listings(title, fullDescription, shortDescription, video) ⇒ Object
- #get_details ⇒ Object
- #get_listing ⇒ Object
- #imagefile(typefile, filename) ⇒ Object
-
#initialize(language) ⇒ Metadata
constructor
A new instance of Metadata.
Constructor Details
#initialize(language) ⇒ Metadata
Returns a new instance of Metadata.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/googlepub/metadata.rb', line 9 def initialize(language) @language = language @edit_id = ENV['EDIT_ID'] @access_token = ENV['ACCESS_TOKEN'] @package = ENV['PACKAGE'] if !@edit_id || !@access_token || !@package p "Missing Authorization, Invalid call".red end get_listing get_details end |
Instance Method Details
#edit_details(website, email, phone) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/googlepub/metadata.rb', line 51 def edit_details (website, email, phone) details = { "defaultLanguage"=> @language, "contactWebsite" => website || @details["contactWebsite"], "contactEmail" => email || @details["contactEmail"], "contactPhone" => phone || @details["contactPhone"] } details_resp = HTTParty.put("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}/details?access_token=#{@access_token}", :headers => { 'Content-Type' => 'application/json' }, :body =>details.to_json).parsed_response if details_resp["defaultLanguage"] == @language puts "Details entered" else puts "Error in Details" puts details_resp exit end end |
#edit_listings(title, fullDescription, shortDescription, video) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/googlepub/metadata.rb', line 33 def edit_listings (title, fullDescription, shortDescription, video) app_listing = { "language"=> @language, "title"=> title || @listing["title"], "fullDescription"=> fullDescription || @listing["fullDescription"], "shortDescription"=> shortDescription || @listing["shortDescription"], "video"=> video || @listing["video"] } listings = HTTParty.put("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}/listings/#{@language}?access_token=#{@access_token}", :headers => { 'Content-Type' => 'application/json' }, :body =>app_listing.to_json).parsed_response if listings["language"] == @language && listings["title"] == title puts "Done Listing" else puts "Error in Listings" exit end end |
#get_details ⇒ Object
29 30 31 |
# File 'lib/googlepub/metadata.rb', line 29 def get_details @details = HTTParty.get("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}/details?access_token=#{@access_token}", :body =>{}).parsed_response end |
#get_listing ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/googlepub/metadata.rb', line 21 def get_listing @listing = HTTParty.get("https://www.googleapis.com/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}/listings/#{@language}?access_token=#{@access_token}", :body =>{}).parsed_response if @listing["language"] != @language puts "Unable to find Listing" exit end end |
#imagefile(typefile, filename) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/googlepub/metadata.rb', line 69 def imagefile(typefile, filename) @types = ["featureGraphic","icon", "phoneScreenshots", "promoGraphic", "sevenInchScreenshots", "tenInchScreenshots", "tvBanner", "tvScreenshots", "wearScreenshots"] if !@types.include?(typefile) puts "Please provide a type out of: #{@types}" exit (1) end file = File.new(filename) if !file puts "File read error, Maybe file Not found." exit (1) end puts "Uploading #{typefile}" resp = HTTMultiParty.post("https://www.googleapis.com/upload/androidpublisher/v2/applications/#{@package}/edits/#{@edit_id}/listings/#{@language}/#{typefile}?access_token=#{@access_token}", :body =>{:somepngfile => file}, :detect_mime_type => true).parsed_response if !resp["image"] puts "Error Uploading #{typefile}: #{resp}" exit else puts "Done Uploading #{@language}-#{typefile}" end end |