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



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

def get(endpoint)
  raise NoConnectionEstablished  if @@connection.nil?
  @@connection.get endpoint
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_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



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

def post(endpoint)
  raise NoConnectionEstablished  if @@connection.nil?
  @@connection.post endpoint
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