Module: AndroidAppIndex

Defined in:
lib/android_app_index.rb,
lib/android_app_index/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.get(package) ⇒ Object



77
78
79
80
81
82
# File 'lib/android_app_index.rb', line 77

def self.get(package)
  @index.get_object(package)
rescue Algolia::AlgoliaProtocolError
  # Handle the error that occurs if the app is not yet indexed.
  index package
end

.index(package, name = nil, icon_url = nil) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/android_app_index.rb', line 84

def self.index(package, name = nil, icon_url = nil)
  @index_and_parse_play_store.call(package, name, icon_url)
rescue OpenURI::HTTPError
  {
    error: 'no_app_found',
    error_message: "Unable to find an app with package=#{package}"
  }
end

.search(query) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/android_app_index.rb', line 93

def self.search(query)
  search_results = @index.search(
    query,
    attributesToRetrieve: 'package,icon_url,name',
    hitsPerPage: 100
  )

  search_results['hits'].map(&@hit_to_result)
end