Class: EspressoPath::GeoPath

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/espresso_path/geo_path.rb

Instance Method Summary collapse

Instance Method Details

#audienceObject



32
33
34
# File 'lib/espresso_path/geo_path.rb', line 32

def audience
  self.class.get("/audience", @options)
end

#countiesObject



40
41
42
# File 'lib/espresso_path/geo_path.rb', line 40

def counties
  self.class.get("/counties", @options)
end

#custom_demosObject



44
45
46
# File 'lib/espresso_path/geo_path.rb', line 44

def custom_demos
  self.class.get("/custom-demos", @options)
end

#day_partsObject



36
37
38
# File 'lib/espresso_path/geo_path.rb', line 36

def day_parts
  self.class.get("/day-parts", @options)
end

#demo_categoriesObject



72
73
74
# File 'lib/espresso_path/geo_path.rb', line 72

def demo_categories
  self.class.get("/demos/categories", @options)
end

#loginObject

base_uri ‘insights-api.geopath.org’



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/espresso_path/geo_path.rb', line 10

def 
  self.class.base_uri EspressoPath.configuration.base_url
  uri = URI.parse(EspressoPath.configuration.base_url + "/login")

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data({ :username => EspressoPath.configuration.user_name, :password => EspressoPath.configuration.password })

  response = http.request(request)
  body = JSON.parse(response.body)

  @access_token = body["access_token"]

  @options = {
      headers: {
          "Authorization"=> "Bearer #{@access_token}"
      }
  }
end

#market(market) ⇒ Object



64
65
66
# File 'lib/espresso_path/geo_path.rb', line 64

def market(market)
  self.class.get("/markets/#{market}", @options)
end

#marketsObject



60
61
62
# File 'lib/espresso_path/geo_path.rb', line 60

def markets
  self.class.get("/markets", @options)
end

#media_typesObject



48
49
50
# File 'lib/espresso_path/geo_path.rb', line 48

def media_types
  self.class.get("/media-types", @options)
end

#operatorsObject



52
53
54
# File 'lib/espresso_path/geo_path.rb', line 52

def operators
  self.class.get("/operators", @options)
end

#panelsObject



68
69
70
# File 'lib/espresso_path/geo_path.rb', line 68

def panels
  self.class.get("/panels", @options)
end

#plantsObject



56
57
58
# File 'lib/espresso_path/geo_path.rb', line 56

def plants
  self.class.get("/plants", @options)
end

#statesObject



76
77
78
# File 'lib/espresso_path/geo_path.rb', line 76

def states
  self.class.get("/states", @options)
end