Class: ThinkNear::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/think_near/client.rb

Constant Summary collapse

@@connection =
nil
@@debug =
false

Class Method Summary collapse

Class Method Details

.api_hostObject



23
24
25
# File 'lib/think_near/client.rb', line 23

def api_host
  @@api_host
end

.claim_offer(offer_id, latitude, longitude, app_id = nil) ⇒ Object



55
56
57
# File 'lib/think_near/client.rb', line 55

def claim_offer(offer_id, latitude, longitude, app_id = nil)
  post Endpoint.claim_offer(offer_id, latitude, longitude, app_id)
end

.debugObject



19
20
21
# File 'lib/think_near/client.rb', line 19

def debug
  @@debug
end

.debug=(debug_flag) ⇒ Object



14
15
16
17
# File 'lib/think_near/client.rb', line 14

def debug=(debug_flag)
  @@debug = debug_flag
  @@connection.debug = @@debug  if @@connection
end

.get(endpoint) ⇒ Object



108
109
110
111
# File 'lib/think_near/client.rb', line 108

def get(endpoint)
  raise NoConnectionEstablished  if @@connection.nil?
  @@connection.get endpoint
end

.get_ad_unit_by_city(city, unit_details = {}, past_prices = []) ⇒ Object



75
76
77
# File 'lib/think_near/client.rb', line 75

def get_ad_unit_by_city(city, unit_details = {}, past_prices = [])
  get Endpoint.fetch({:loc_city => city}, unit_details, past_prices)
end

.get_ad_unit_by_geo(latitude, longitude, unit_details = {}, past_prices = []) ⇒ Object



67
68
69
# File 'lib/think_near/client.rb', line 67

def get_ad_unit_by_geo(latitude, longitude, unit_details = {}, past_prices = [])
  get Endpoint.fetch({:loc_latitude => latitude, :loc_longitude => longitude}, unit_details, past_prices)
end

.get_ad_unit_by_state(state, unit_details = {}, past_prices = []) ⇒ Object



79
80
81
# File 'lib/think_near/client.rb', line 79

def get_ad_unit_by_state(state, unit_details = {}, past_prices = [])
  get Endpoint.fetch({:loc_state => state}, unit_details, past_prices)
end

.get_ad_unit_by_zip_code(zip_code, unit_details = {}, past_prices = []) ⇒ Object



71
72
73
# File 'lib/think_near/client.rb', line 71

def get_ad_unit_by_zip_code(zip_code, unit_details = {}, past_prices = [])
  get Endpoint.fetch({:loc_zip_code => zip_code}, unit_details, past_prices)
end

.get_ad_units_by_city(city, unit_details = {}, past_prices = []) ⇒ Object



91
92
93
# File 'lib/think_near/client.rb', line 91

def get_ad_units_by_city(city, unit_details = {}, past_prices = []) 
  get Endpoint.collect({:loc_city => city}, unit_details, past_prices)
end

.get_ad_units_by_geo(latitude, longitude, unit_details = {}, past_prices = []) ⇒ Object



83
84
85
# File 'lib/think_near/client.rb', line 83

def get_ad_units_by_geo(latitude, longitude, unit_details = {}, past_prices = []) 
  get Endpoint.collect({:loc_latitude => latitude, :loc_longitude => longitude}, unit_details, past_prices)
end

.get_ad_units_by_state(state, unit_details = {}, past_prices = []) ⇒ Object



95
96
97
# File 'lib/think_near/client.rb', line 95

def get_ad_units_by_state(state, unit_details = {}, past_prices = []) 
  get Endpoint.collect({:loc_state => state}, unit_details, past_prices)
end

.get_ad_units_by_zip_code(zip_code, unit_details = {}, past_prices = []) ⇒ Object



87
88
89
# File 'lib/think_near/client.rb', line 87

def get_ad_units_by_zip_code(zip_code, unit_details = {}, past_prices = []) 
  get Endpoint.collect({:loc_zip_code => zip_code}, unit_details, past_prices)
end

.get_authenticatedObject



35
36
37
# File 'lib/think_near/client.rb', line 35

def get_authenticated
  get Endpoint.authenticated
end

.get_categoriesObject



39
40
41
# File 'lib/think_near/client.rb', line 39

def get_categories
  get Endpoint.categories
end

.get_creatives(state) ⇒ Object



99
100
101
# File 'lib/think_near/client.rb', line 99

def get_creatives(state) 
  get Endpoint.creatives(:loc_state => state)
end

.get_draws(category) ⇒ Object



43
44
45
# File 'lib/think_near/client.rb', line 43

def get_draws(category)
  get Endpoint.draws(category)
end

.get_feed(city, app_id = nil) ⇒ Object



63
64
65
# File 'lib/think_near/client.rb', line 63

def get_feed(city, app_id = nil)
  get Endpoint.feed(city, app_id)
end

.get_healthObject



31
32
33
# File 'lib/think_near/client.rb', line 31

def get_health
  get Endpoint.health
end

.get_offer(id, app_id = nil) ⇒ Object



51
52
53
# File 'lib/think_near/client.rb', line 51

def get_offer(id, app_id = nil)
  get Endpoint.offer(id, app_id)
end

.get_offers(params, app_id = nil) ⇒ Object



47
48
49
# File 'lib/think_near/client.rb', line 47

def get_offers(params, app_id = nil)
  get Endpoint.offers(params, app_id)
end

.get_pingObject



27
28
29
# File 'lib/think_near/client.rb', line 27

def get_ping
  get Endpoint.ping
end

.post(endpoint) ⇒ Object



113
114
115
116
# File 'lib/think_near/client.rb', line 113

def post(endpoint)
  raise NoConnectionEstablished  if @@connection.nil?
  @@connection.post endpoint
end

.report(bid_id, clicks = nil, impressions = nil, price = nil, report_id = 1) ⇒ Object



103
104
105
106
# File 'lib/think_near/client.rb', line 103

def report(bid_id, clicks = nil, impressions = nil, price = nil, report_id = 1)
  post Endpoint.report({:bid_id => bid_id, :clicks => clicks, :impressions => impressions, 
                       :price => price, :report_id => report_id})
end

.save_offer(offer_id, email, app_id = nil) ⇒ Object



59
60
61
# File 'lib/think_near/client.rb', line 59

def save_offer(offer_id, email, app_id = nil)
  post Endpoint.save_offer(offer_id, email, app_id)
end

.set_credentials(token, secret, api_host = API_HOST, app_id = nil) ⇒ Object



7
8
9
10
11
12
# File 'lib/think_near/client.rb', line 7

def set_credentials(token, secret, api_host = API_HOST, app_id = nil)
  @@api_host = api_host || API_HOST
  @@connection = Connection.new(token, secret)
  @@connection.debug = @@debug
  Endpoint.app_id = app_id if app_id
end