thinknear 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.1.1
@@ -64,6 +64,47 @@ module ThinkNear
64
64
  get Endpoint.feed(city, app_id)
65
65
  end
66
66
 
67
+ def get_ad_unit_by_geo(latitude, longitude, unit_details = {}, past_prices = [])
68
+ get Endpoint.fetch({:loc_latitude => latitude, :loc_longitude => longitude}, unit_details, past_prices)
69
+ end
70
+
71
+ def get_ad_unit_by_zip_code(zip_code, unit_details = {}, past_prices = [])
72
+ get Endpoint.fetch({:loc_zip_code => zip_code}, unit_details, past_prices)
73
+ end
74
+
75
+ def get_ad_unit_by_city(city, unit_details = {}, past_prices = [])
76
+ get Endpoint.fetch({:loc_city => city}, unit_details, past_prices)
77
+ end
78
+
79
+ def get_ad_unit_by_state(state, unit_details = {}, past_prices = [])
80
+ get Endpoint.fetch({:loc_state => state}, unit_details, past_prices)
81
+ end
82
+
83
+ def get_ad_units_by_geo(latitude, longitude, unit_details = {}, past_prices = [])
84
+ get Endpoint.collect({:loc_latitude => latitude, :loc_longitude => longitude}, unit_details, past_prices)
85
+ end
86
+
87
+ def get_ad_units_by_zip_code(zip_code, unit_details = {}, past_prices = [])
88
+ get Endpoint.collect({:loc_zip_code => zip_code}, unit_details, past_prices)
89
+ end
90
+
91
+ def get_ad_units_by_city(city, unit_details = {}, past_prices = [])
92
+ get Endpoint.collect({:loc_city => city}, unit_details, past_prices)
93
+ end
94
+
95
+ def get_ad_units_by_state(state, unit_details = {}, past_prices = [])
96
+ get Endpoint.collect({:loc_state => state}, unit_details, past_prices)
97
+ end
98
+
99
+ def get_creatives(state)
100
+ get Endpoint.creatives(:loc_state => state)
101
+ end
102
+
103
+ def report(bid_id, clicks = nil, impressions = nil, price = nil, report_id = 1)
104
+ post Endpoint.report({:bid_id => bid_id, :clicks => clicks, :impressions => impressions,
105
+ :price => price, :report_id => report_id})
106
+ end
107
+
67
108
  def get(endpoint)
68
109
  raise NoConnectionEstablished if @@connection.nil?
69
110
  @@connection.get endpoint
@@ -60,10 +60,10 @@ module ThinkNear
60
60
 
61
61
  raise_errors(response)
62
62
 
63
- if response.body.empty?
63
+ if response.body.blank?
64
64
  content = nil
65
65
  else
66
- if response.content_type == 'application/json'
66
+ if response.content_type == 'application/json'
67
67
  begin
68
68
  content = JSON.parse(response.body)
69
69
  rescue JSON::ParserError
@@ -52,10 +52,37 @@ module ThinkNear
52
52
  endpoint_url("offers/#{offer_id}/save", {:email => email}.merge(app_id_hash(app_id)))
53
53
  end
54
54
 
55
- def feed(city)
55
+ def feed(city, app_id)
56
56
  endpoint_url('feeds', {:city => city}.merge(app_id_hash(app_id)), 'rss')
57
57
  end
58
58
 
59
+ def fetch(location, unit_details, past_prices)
60
+ get_ad_units('ad_units/fetch', location, unit_details, past_prices)
61
+ end
62
+
63
+ def collect(location, unit_details, past_prices)
64
+ get_ad_units('ad_units/collect', location, unit_details, past_prices)
65
+ end
66
+
67
+ def get_ad_units(method_endpoint, location, unit_details, past_prices)
68
+ params = location.with_indifferent_access
69
+ unit_details.each do |k, v|
70
+ k = "ud_#{k.to_s}".to_sym
71
+ end
72
+ params.merge!(unit_details)
73
+ p_index = 0
74
+ params.merge!(Hash[past_prices.map {|p| ["p_#{p_index.to_s}", p] }])
75
+ endpoint_url(method_endpoint, params)
76
+ end
77
+
78
+ def creatives(location)
79
+ endpoint_url('ad_units/creatives', location)
80
+ end
81
+
82
+ def report(params)
83
+ endpoint_url('ad_units/report', params)
84
+ end
85
+
59
86
  def endpoint_url(path, params = {}, format = 'json', version = API_VERSION)
60
87
  ["http://#{Client.api_host}", version, [path, format].join('.')].join('/') + "?#{params.to_param}"
61
88
  end
data/thinknear.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{thinknear}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Hinnegan", "Denis Barushev"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: thinknear
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Hinnegan
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- hash: 330524080392240502
154
+ hash: 1254603518259930022
155
155
  segments:
156
156
  - 0
157
157
  version: "0"