Class: Spaceship::Tunes::AppRatings

Inherits:
TunesBase show all
Defined in:
lib/spaceship/tunes/app_ratings.rb

Overview

Represents app ratings from iTunesConnect

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TunesBase

client

Methods inherited from Base

attr_accessor, attr_mapping, #attributes, attributes, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Instance Attribute Details

#applicationSpaceship::Tunes::Application

Returns A reference to the application this version is for.

Returns:



7
8
9
# File 'lib/spaceship/tunes/app_ratings.rb', line 7

def application
  @application
end

#rating_summarySpaceship::Tunes::AppRatingSummary

Returns A summary of the overall ratings for the application.

Returns:



10
11
12
# File 'lib/spaceship/tunes/app_ratings.rb', line 10

def rating_summary
  @rating_summary
end

#store_frontsHash (readonly)

Returns mapping country codes to a (Spaceship::Tunes::AppRatingSummary) summary of ratings for that country.

Returns:

  • (Hash)

    mapping country codes to a (Spaceship::Tunes::AppRatingSummary) summary of ratings for that country



13
14
15
# File 'lib/spaceship/tunes/app_ratings.rb', line 13

def store_fronts
  @store_fronts
end

#versionsHash (readonly)

Returns of iTunesConnect version id’s to readable version numbers.

Returns:

  • (Hash)

    of iTunesConnect version id’s to readable version numbers



16
17
18
# File 'lib/spaceship/tunes/app_ratings.rb', line 16

def versions
  @versions
end

Class Method Details

.factory(attrs) ⇒ Object

Create a new object based on a hash. This is used to create a new object based on the server response.



25
26
27
28
29
30
31
32
# File 'lib/spaceship/tunes/app_ratings.rb', line 25

def factory(attrs)
  obj = self.new(attrs)

  obj.unfold_rating_summary(attrs['ratings'])
  obj.unfold_store_fronts(attrs['storeFronts'])

  return obj
end

Instance Method Details

#reviews(store_front, versionId = '') ⇒ Array

Returns of raw hashes representing user reviews for the given store front (and optional versionId).

Returns:

  • (Array)

    of raw hashes representing user reviews for the given store front (and optional versionId)



51
52
53
# File 'lib/spaceship/tunes/app_ratings.rb', line 51

def reviews(store_front, versionId = '')
  client.get_reviews(application.apple_id, application.platform, store_front, versionId)
end

#unfold_rating_summary(attrs) ⇒ Object



35
36
37
38
# File 'lib/spaceship/tunes/app_ratings.rb', line 35

def unfold_rating_summary(attrs)
  unfolded_rating_summary = AppRatingSummary.new(attrs)
  instance_variable_set(:@rating_summary, unfolded_rating_summary)
end

#unfold_store_fronts(attrs) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/spaceship/tunes/app_ratings.rb', line 40

def unfold_store_fronts(attrs)
  unfolded_store_fronts = {}

  attrs.each do |info|
    unfolded_store_fronts[info['countryCode']] = AppRatingSummary.new(info['ratings'])
  end

  instance_variable_set(:@store_fronts, unfolded_store_fronts)
end