Class: AppfiguresClient::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/appfigures_client/api.rb

Constant Summary collapse

URL =
'https://api.appfigures.com/v2/'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Api

Returns a new instance of Api.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/appfigures_client/api.rb', line 8

def initialize(options)
  @request ||= Net::Request.new(options)

  data = @request.make

  if data[:status].to_i == 200
    self
  else
    raise data[:message]
  end

  @routes = YAML::load(File.open("#{AppfiguresClient.root}/config/routes.yml")).with_indifferent_access

end

Instance Method Details

#adsObject



35
36
37
# File 'lib/appfigures_client/api.rb', line 35

def ads
  @ads ||= AppfiguresClient::Endpoints::Ads.new(self, @routes[:report][:ads])
end

#dataObject



23
24
25
# File 'lib/appfigures_client/api.rb', line 23

def data
  @data ||= AppfiguresClient::Endpoints::Data.new(self, @routes[:data])
end

#productsObject



27
28
29
# File 'lib/appfigures_client/api.rb', line 27

def products
  @products ||= AppfiguresClient::Endpoints::Products.new(self, @routes[:products])
end

#ranksObject



39
40
41
# File 'lib/appfigures_client/api.rb', line 39

def ranks
  @ranks ||= AppfiguresClient::Endpoints::Ranks.new(self, @routes[:ranks])
end

#requestObject



47
48
49
# File 'lib/appfigures_client/api.rb', line 47

def request
  @request
end

#reviewsObject



43
44
45
# File 'lib/appfigures_client/api.rb', line 43

def reviews
  @ranks ||= AppfiguresClient::Endpoints::Reviews.new(self, @routes[:reviews])
end

#salesObject



31
32
33
# File 'lib/appfigures_client/api.rb', line 31

def sales
  @sales ||= AppfiguresClient::Endpoints::Sales.new(self, @routes[:report][:sales])
end