citygrid_api 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -2
- data/Gemfile.lock +12 -2
- data/README.rdoc +6 -0
- data/VERSION +1 -1
- data/citygrid_api.gemspec +14 -8
- data/citygrid_api.yml.sample +6 -3
- data/lib/citygrid.rb +9 -5
- data/lib/citygrid/api.rb +1 -0
- data/lib/citygrid/api/advertising/campaign_promotions.rb +9 -0
- data/lib/citygrid/api/mutable.rb +3 -0
- data/spec/api_status_checks/content/listing_api_spec.rb +36 -0
- data/spec/spec_helper.rb +76 -0
- metadata +18 -4
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "httparty", "
|
4
|
-
gem "json", "1.5.3"
|
3
|
+
gem "httparty", ">= 0.8.1"
|
4
|
+
gem "json", ">= 1.5.3"
|
5
5
|
gem "riot", "~> 0.12.4"
|
6
6
|
|
7
7
|
group :development do
|
@@ -10,6 +10,7 @@ group :development do
|
|
10
10
|
gem "vcr"
|
11
11
|
gem "webmock"
|
12
12
|
gem 'rdoc'
|
13
|
+
gem 'rspec'
|
13
14
|
end
|
14
15
|
|
15
16
|
group :dashboard do
|
data/Gemfile.lock
CHANGED
@@ -3,6 +3,7 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
addressable (2.2.6)
|
5
5
|
crack (0.3.1)
|
6
|
+
diff-lcs (1.1.3)
|
6
7
|
git (1.2.5)
|
7
8
|
haml (3.1.4)
|
8
9
|
httparty (0.8.1)
|
@@ -25,6 +26,14 @@ GEM
|
|
25
26
|
riot (0.12.5)
|
26
27
|
rr
|
27
28
|
rr (1.0.4)
|
29
|
+
rspec (2.11.0)
|
30
|
+
rspec-core (~> 2.11.0)
|
31
|
+
rspec-expectations (~> 2.11.0)
|
32
|
+
rspec-mocks (~> 2.11.0)
|
33
|
+
rspec-core (2.11.1)
|
34
|
+
rspec-expectations (2.11.3)
|
35
|
+
diff-lcs (~> 1.1.3)
|
36
|
+
rspec-mocks (2.11.3)
|
28
37
|
sinatra (1.3.1)
|
29
38
|
rack (~> 1.3, >= 1.3.4)
|
30
39
|
rack-protection (~> 1.1, >= 1.1.2)
|
@@ -40,12 +49,13 @@ PLATFORMS
|
|
40
49
|
|
41
50
|
DEPENDENCIES
|
42
51
|
haml
|
43
|
-
httparty (
|
52
|
+
httparty (>= 0.8.1)
|
44
53
|
jeweler (~> 1.6.2)
|
45
|
-
json (
|
54
|
+
json (>= 1.5.3)
|
46
55
|
rcov
|
47
56
|
rdoc
|
48
57
|
riot (~> 0.12.4)
|
58
|
+
rspec
|
49
59
|
sinatra
|
50
60
|
vcr
|
51
61
|
webmock
|
data/README.rdoc
CHANGED
@@ -21,6 +21,12 @@ Add a file called citygrid_api.rb under config/initializers.
|
|
21
21
|
Configure the gem to use your publisher code with:
|
22
22
|
|
23
23
|
CityGrid.publisher = 'your_publisher_code'
|
24
|
+
|
25
|
+
Additional options are available such as:
|
26
|
+
|
27
|
+
CityGrid.print_curls = true/false
|
28
|
+
CityGrid.custom_timeout = 20 #time in seconds
|
29
|
+
CityGrid.raise_errors = true/false
|
24
30
|
|
25
31
|
If you don't have a publisher code, you can obtain one at http://developer.citygridmedia.com
|
26
32
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.22
|
data/citygrid_api.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "citygrid_api"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.22"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Elpizo Choi"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-12-06"
|
13
13
|
s.description = "Ruby wrapper for CityGrid APIs"
|
14
14
|
s.email = "fu7iin@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -94,6 +94,7 @@ Gem::Specification.new do |s|
|
|
94
94
|
"lib/citygrid/api/advertising/budget.rb",
|
95
95
|
"lib/citygrid/api/advertising/call_detail.rb",
|
96
96
|
"lib/citygrid/api/advertising/campaign.rb",
|
97
|
+
"lib/citygrid/api/advertising/campaign_promotions.rb",
|
97
98
|
"lib/citygrid/api/advertising/category.rb",
|
98
99
|
"lib/citygrid/api/advertising/geolocation.rb",
|
99
100
|
"lib/citygrid/api/advertising/image.rb",
|
@@ -123,6 +124,8 @@ Gem::Specification.new do |s|
|
|
123
124
|
"lib/request_ext.rb",
|
124
125
|
"lib/string_ext.rb",
|
125
126
|
"public/javascript/dashboard.js",
|
127
|
+
"spec/api_status_checks/content/listing_api_spec.rb",
|
128
|
+
"spec/spec_helper.rb",
|
126
129
|
"test/api/accounts/test_account.rb",
|
127
130
|
"test/api/accounts/test_method_of_payment.rb",
|
128
131
|
"test/api/accounts/test_temp_impersonation.rb",
|
@@ -174,33 +177,36 @@ Gem::Specification.new do |s|
|
|
174
177
|
s.specification_version = 3
|
175
178
|
|
176
179
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
177
|
-
s.add_runtime_dependency(%q<httparty>, ["
|
178
|
-
s.add_runtime_dependency(%q<json>, ["
|
180
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.8.1"])
|
181
|
+
s.add_runtime_dependency(%q<json>, [">= 1.5.3"])
|
179
182
|
s.add_runtime_dependency(%q<riot>, ["~> 0.12.4"])
|
180
183
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
181
184
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
182
185
|
s.add_development_dependency(%q<vcr>, [">= 0"])
|
183
186
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
184
187
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
188
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
185
189
|
else
|
186
|
-
s.add_dependency(%q<httparty>, ["
|
187
|
-
s.add_dependency(%q<json>, ["
|
190
|
+
s.add_dependency(%q<httparty>, [">= 0.8.1"])
|
191
|
+
s.add_dependency(%q<json>, [">= 1.5.3"])
|
188
192
|
s.add_dependency(%q<riot>, ["~> 0.12.4"])
|
189
193
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
190
194
|
s.add_dependency(%q<rcov>, [">= 0"])
|
191
195
|
s.add_dependency(%q<vcr>, [">= 0"])
|
192
196
|
s.add_dependency(%q<webmock>, [">= 0"])
|
193
197
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
198
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
194
199
|
end
|
195
200
|
else
|
196
|
-
s.add_dependency(%q<httparty>, ["
|
197
|
-
s.add_dependency(%q<json>, ["
|
201
|
+
s.add_dependency(%q<httparty>, [">= 0.8.1"])
|
202
|
+
s.add_dependency(%q<json>, [">= 1.5.3"])
|
198
203
|
s.add_dependency(%q<riot>, ["~> 0.12.4"])
|
199
204
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
200
205
|
s.add_dependency(%q<rcov>, [">= 0"])
|
201
206
|
s.add_dependency(%q<vcr>, [">= 0"])
|
202
207
|
s.add_dependency(%q<webmock>, [">= 0"])
|
203
208
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
209
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
204
210
|
end
|
205
211
|
end
|
206
212
|
|
data/citygrid_api.yml.sample
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
defaults:
|
2
|
+
# QA
|
2
3
|
hostname: api.qa.citygrid.com
|
3
4
|
ssl_hostname: api-qassl.citygrid.com
|
4
5
|
|
@@ -38,22 +39,24 @@ api:
|
|
38
39
|
endpoint: report/calldetail/v2
|
39
40
|
hostname: lax1qatxpi4.test.cs:8080
|
40
41
|
campaign: advertising/campaign/v2
|
42
|
+
campaign_promotions: advertising/campaign/v2/promo
|
41
43
|
category: content/category/v2
|
42
44
|
geo_location: content/places/v2/geocode
|
43
45
|
image: advertising/image/v2
|
44
46
|
offers: advertising/offer/v2
|
45
47
|
places: content/places/v2
|
46
48
|
performance: advertising/performance/v2
|
49
|
+
|
47
50
|
content:
|
48
51
|
offers:
|
49
52
|
endpoint: content/offers/v2
|
50
|
-
hostname: api.citygridmedia.com
|
53
|
+
hostname: api.qa.citygridmedia.com
|
51
54
|
places:
|
52
55
|
endpoint: content/places/v2
|
53
|
-
hostname: api.citygridmedia.com
|
56
|
+
hostname: api.qa.citygridmedia.com
|
54
57
|
reviews:
|
55
58
|
endpoint: content/reviews/v2
|
56
|
-
hostname: api.citygridmedia.com
|
59
|
+
hostname: api.qa.citygridmedia.com
|
57
60
|
response:
|
58
61
|
endpoint: content/reviews/v2/response
|
59
62
|
profile_internal: #internal use only
|
data/lib/citygrid.rb
CHANGED
@@ -37,12 +37,16 @@ class CityGrid
|
|
37
37
|
defined?(@print_curls) ? @print_curls : false
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
@
|
40
|
+
def custom_timeout= timeout #in seconds
|
41
|
+
@custom_timeout = timeout
|
42
42
|
end
|
43
|
-
|
44
|
-
def
|
45
|
-
|
43
|
+
|
44
|
+
def custom_timeout
|
45
|
+
@custom_timeout
|
46
|
+
end
|
47
|
+
|
48
|
+
def custom_timeout_set?
|
49
|
+
defined?(@custom_timeout)
|
46
50
|
end
|
47
51
|
|
48
52
|
def search opts = {}
|
data/lib/citygrid/api.rb
CHANGED
@@ -174,6 +174,7 @@ class CityGrid
|
|
174
174
|
|
175
175
|
# prepare request
|
176
176
|
req = HTTParty::Request.new http_method, path, req_options
|
177
|
+
req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?
|
177
178
|
|
178
179
|
# Sanitized request for logs
|
179
180
|
safe_req_options = strip_unsafe_params(http_method, req_options)
|
data/lib/citygrid/api/mutable.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "listing apis" do
|
4
|
+
|
5
|
+
context "search" do
|
6
|
+
|
7
|
+
it "should not raise an error" do
|
8
|
+
lambda do
|
9
|
+
CityGrid.search :what => "sushi", :where => "Seattle"
|
10
|
+
end.should_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get a response" do
|
14
|
+
data = CityGrid.search :what => "sushi", :where => "Seattle"
|
15
|
+
data.should_not be_empty
|
16
|
+
data.first.should_not be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
context "details" do
|
22
|
+
# CityGrid::Details.new :public_id =>
|
23
|
+
|
24
|
+
it "should not raise an error" do
|
25
|
+
lambda do
|
26
|
+
CityGrid::Details.new :public_id => "philip-marie-restaurant-new-york"
|
27
|
+
end.should_not raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should get a response" do
|
31
|
+
data = CityGrid::Details.new :public_id => "philip-marie-restaurant-new-york"
|
32
|
+
data.should_not be_empty
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test', "auth_token")
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'test', "session_helper")
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
# don't do gem setup if we're in the dashboad environment
|
6
|
+
unless defined? IN_DASHBOARD
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler'
|
9
|
+
begin
|
10
|
+
Bundler.setup(:default, :development)
|
11
|
+
rescue Bundler::BundlerError => e
|
12
|
+
$stderr.puts e.message
|
13
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
14
|
+
exit e.status_code
|
15
|
+
end
|
16
|
+
require "riot"
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
+
require "citygrid_api"
|
21
|
+
require "publisher_helper"
|
22
|
+
|
23
|
+
# load default config
|
24
|
+
CityGrid.load_config File.expand_path(File.join(File.dirname(__FILE__), '..', 'citygrid_api.yml.sample'))
|
25
|
+
|
26
|
+
# CityGrid.load_config File.expand_path(File.join(File.dirname(__FILE__), '..', 'citygrid_api.yml.sandbox'))
|
27
|
+
|
28
|
+
# Run code with rescue so that exceptions
|
29
|
+
# will be printed, but won't stop test suite
|
30
|
+
def run_with_rescue
|
31
|
+
begin
|
32
|
+
yield
|
33
|
+
# TODO: fix?
|
34
|
+
#rescue CityGrid::API::InvalidResponseFormat => ex
|
35
|
+
rescue StandardError => ex
|
36
|
+
x = {"description" => ex.message, "server_msg" => "blank"}
|
37
|
+
#x = {"description" => ex.description, "server_msg" => ex.server_msg}
|
38
|
+
puts "======= ERROR ======="
|
39
|
+
pp x
|
40
|
+
pp ex.backtrace
|
41
|
+
false
|
42
|
+
rescue => ex
|
43
|
+
pp ex
|
44
|
+
puts ex.backtrace.join("\n")
|
45
|
+
false # return false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# patch in VCR
|
50
|
+
require 'vcr'
|
51
|
+
|
52
|
+
VCR.config do |c|
|
53
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
54
|
+
c.stub_with :webmock
|
55
|
+
c.allow_http_connections_when_no_cassette = true
|
56
|
+
end
|
57
|
+
|
58
|
+
# contexts now use VCR, with a cassette named by the description
|
59
|
+
module Riot
|
60
|
+
class Context
|
61
|
+
alias_method :old_run, :run
|
62
|
+
def run reporter
|
63
|
+
# TODO: does it make any sense for API gem to use vcr?
|
64
|
+
#if option(:vcr) != nil && option(:vcr) == false
|
65
|
+
old_run reporter
|
66
|
+
# else
|
67
|
+
# VCR.use_cassette self.detailed_description[0..70] do
|
68
|
+
# old_run reporter
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: citygrid_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.22
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Elpizo Choi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.8.1
|
24
24
|
type: :runtime
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.5.3
|
35
35
|
type: :runtime
|
@@ -100,6 +100,17 @@ dependencies:
|
|
100
100
|
version: "0"
|
101
101
|
type: :development
|
102
102
|
version_requirements: *id008
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec
|
105
|
+
prerelease: false
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
type: :development
|
113
|
+
version_requirements: *id009
|
103
114
|
description: Ruby wrapper for CityGrid APIs
|
104
115
|
email: fu7iin@gmail.com
|
105
116
|
executables: []
|
@@ -187,6 +198,7 @@ files:
|
|
187
198
|
- lib/citygrid/api/advertising/budget.rb
|
188
199
|
- lib/citygrid/api/advertising/call_detail.rb
|
189
200
|
- lib/citygrid/api/advertising/campaign.rb
|
201
|
+
- lib/citygrid/api/advertising/campaign_promotions.rb
|
190
202
|
- lib/citygrid/api/advertising/category.rb
|
191
203
|
- lib/citygrid/api/advertising/geolocation.rb
|
192
204
|
- lib/citygrid/api/advertising/image.rb
|
@@ -216,6 +228,8 @@ files:
|
|
216
228
|
- lib/request_ext.rb
|
217
229
|
- lib/string_ext.rb
|
218
230
|
- public/javascript/dashboard.js
|
231
|
+
- spec/api_status_checks/content/listing_api_spec.rb
|
232
|
+
- spec/spec_helper.rb
|
219
233
|
- test/api/accounts/test_account.rb
|
220
234
|
- test/api/accounts/test_method_of_payment.rb
|
221
235
|
- test/api/accounts/test_temp_impersonation.rb
|