Class: AndroidFetcher
- Inherits:
-
ReviewFetcher
- Object
- ReviewFetcher
- AndroidFetcher
- Defined in:
- lib/AndroidFetcher.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes inherited from ReviewFetcher
#config, #logger, #platform, #processors
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(config) ⇒ AndroidFetcher
constructor
A new instance of AndroidFetcher.
Methods inherited from ReviewFetcher
#getPlatformLatestCheckTimestamp, #processReviews, #registerProcessor, #sendWelcomMessage, #setPlatformLatestCheckTimestamp
Constructor Details
#initialize(config) ⇒ AndroidFetcher
Returns a new instance of AndroidFetcher.
13 14 15 16 17 18 19 20 |
# File 'lib/AndroidFetcher.rb', line 13 def initialize(config) @processors = [] @config = config @platform = 'Android' @client = Google::Apis::AndroidpublisherV3::AndroidPublisherService.new @client. = Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: config.keyContent, scope: 'https://www.googleapis.com/auth/androidpublisher') end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
11 12 13 |
# File 'lib/AndroidFetcher.rb', line 11 def client @client end |
#token ⇒ Object
Returns the value of attribute token.
11 12 13 |
# File 'lib/AndroidFetcher.rb', line 11 def token @token end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/AndroidFetcher.rb', line 22 def execute() latestCheckTimestamp = getPlatformLatestCheckTimestamp() reviews = [] # Google API Bug, couldn't specify limit/offse/pagination, google only return a few recent reviews. customerReviews = client.list_reviews(config.packageName).reviews customerReviews.each do |customerReview| customerReviewID = customerReview.review_id customerReviewTitle = nil customerReviewBody = customerReview.comments[0].user_comment.text.strip customerReviewRating = customerReview.comments[0].user_comment..to_i customerReviewReviewerNickname = customerReview. customerReviewCreatedDateTimestamp = customerReview.comments[0].user_comment.last_modified.seconds.to_i customerReviewTerritory = customerReview.comments[0].user_comment.reviewer_language customerReviewVersionString = "unknown" if !customerReview.comments[0].user_comment.app_version_name.nil? customerReviewVersionString = "#{customerReview.comments[0].user_comment.app_version_name}" if !customerReview.comments[0].user_comment.app_version_code.nil? customerReviewVersionString = "#{customerReviewVersionString}(#{customerReview.comments[0].user_comment.app_version_code})" end end customerReviewPlatform = "Android #{customerReview.comments[0].user_comment.android_os_version}" url = "https://play.google.com/store/apps/details?id=#{config.packageName}&reviewId=#{customerReviewID}" if !config.accountID.nil? && !config.appID.nil? url = "https://play.google.com/console/developers/#{config.accountID}/app/#{config.appID}/user-feedback/review-details?reviewId=#{customerReviewID}" end reviews.append(Review.new(customerReviewPlatform, customerReviewID, customerReviewReviewerNickname, customerReviewRating, customerReviewTitle, customerReviewBody, customerReviewCreatedDateTimestamp, url, customerReviewVersionString, customerReviewTerritory)) end reviews = reviews.reject{ |review| latestCheckTimestamp >= review.createdDateTimestamp }.sort! { |a, b| a.createdDateTimestamp <=> b.createdDateTimestamp } if reviews.length > 0 setPlatformLatestCheckTimestamp(reviews.last.createdDateTimestamp) # init first time, send welcome message if latestCheckTimestamp == 0 sendWelcomMessage() return end processReviews(reviews, platform) end end |