citygrid_api 0.0.5 → 0.0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.sass-cache/7a5a675d951455410512a59af5ab2d160bd1735c/test.scssc +0 -0
  2. data/Gemfile +10 -8
  3. data/Gemfile.lock +24 -9
  4. data/README +21 -0
  5. data/citygrid_api.gemspec +77 -17
  6. data/citygrid_api.yml.sample +33 -0
  7. data/config.ru +2 -0
  8. data/dashboard.rb +110 -0
  9. data/lib/citygrid/abstraction/collection.rb +1 -1
  10. data/lib/citygrid/abstraction/super_hash.rb +2 -0
  11. data/lib/citygrid/api/ad_center/account.rb +26 -0
  12. data/lib/citygrid/api/ad_center/account_manager.rb +8 -0
  13. data/lib/citygrid/api/ad_center/ad_group.rb +8 -0
  14. data/lib/citygrid/api/ad_center/ad_group_ad.rb +8 -0
  15. data/lib/citygrid/api/ad_center/ad_group_criterion.rb +8 -0
  16. data/lib/citygrid/api/ad_center/ad_group_geo.rb +8 -0
  17. data/lib/citygrid/api/ad_center/authentication.rb +20 -0
  18. data/lib/citygrid/api/ad_center/billing.rb +8 -0
  19. data/lib/citygrid/api/ad_center/budget.rb +9 -0
  20. data/lib/citygrid/api/ad_center/call_detail.rb +25 -0
  21. data/lib/citygrid/api/ad_center/campaign.rb +8 -0
  22. data/lib/citygrid/api/ad_center/category.rb +9 -0
  23. data/lib/citygrid/api/ad_center/geolocation.rb +9 -0
  24. data/lib/citygrid/api/ad_center/image.rb +30 -0
  25. data/lib/citygrid/api/ad_center/method_of_payment.rb +10 -0
  26. data/lib/citygrid/api/ad_center/performance.rb +17 -0
  27. data/lib/citygrid/api/ad_center/places.rb +8 -0
  28. data/lib/citygrid/api/ad_center/user.rb +8 -0
  29. data/lib/citygrid/api/ad_center.rb +20 -0
  30. data/lib/citygrid/api/content/offers.rb +14 -9
  31. data/lib/citygrid/api/content/places/detail.rb +5 -11
  32. data/lib/citygrid/api/content/places/search.rb +5 -11
  33. data/lib/citygrid/api/content/places.rb +30 -14
  34. data/lib/citygrid/api/content/reviews.rb +5 -10
  35. data/lib/citygrid/api/content.rb +12 -3
  36. data/lib/citygrid/api/response.rb +2 -2
  37. data/lib/citygrid/api.rb +190 -3
  38. data/lib/citygrid/details.rb +1 -1
  39. data/lib/citygrid/listing.rb +7 -2
  40. data/lib/citygrid/offers.rb +4 -0
  41. data/lib/citygrid/reviews.rb +4 -0
  42. data/lib/citygrid/search.rb +6 -0
  43. data/lib/citygrid.rb +117 -12
  44. data/lib/dashboard/sinatra_partial.rb +17 -0
  45. data/lib/dashboard/stored_reporter.rb +101 -0
  46. data/lib/dashboard/test_result.rb +8 -0
  47. data/lib/request_ext.rb +32 -0
  48. data/public/javascript/dashboard.js +5 -0
  49. data/test/api/ad_center/test_account.rb +120 -0
  50. data/test/api/ad_center/test_ad_group.rb +50 -0
  51. data/test/api/ad_center/test_ad_group_ad.rb +27 -0
  52. data/test/api/ad_center/test_ad_group_criterion.rb +37 -0
  53. data/test/api/ad_center/test_ad_group_geo.rb +19 -0
  54. data/test/api/ad_center/test_authentication.rb +22 -0
  55. data/test/api/ad_center/test_billing.rb +14 -0
  56. data/test/api/ad_center/test_budget.rb +13 -0
  57. data/test/api/ad_center/test_call_detail.rb +36 -0
  58. data/test/api/ad_center/test_campaign.rb +27 -0
  59. data/test/api/ad_center/test_category.rb +37 -0
  60. data/test/api/ad_center/test_geolocation.rb +19 -0
  61. data/test/api/ad_center/test_image.rb +17 -0
  62. data/test/api/ad_center/test_method_of_payment.rb +51 -0
  63. data/test/api/ad_center/test_places.rb +79 -0
  64. data/test/api/ad_center/test_reports.rb +37 -0
  65. data/test/api/content/test_offers.rb +28 -0
  66. data/test/api/content/test_places.rb +66 -0
  67. data/test/helper.rb +67 -14
  68. data/test/test_config.rb +11 -0
  69. data/test/test_details.rb +14 -5
  70. data/test/test_img.jpg +0 -0
  71. data/test/test_img_big.png +0 -0
  72. data/test/test_listing.rb +64 -64
  73. data/test/test_search.rb +21 -1
  74. data/test/test_super_array.rb +1 -1
  75. data/test/test_super_hash.rb +1 -1
  76. data/views/_context_result.haml +25 -0
  77. data/views/_request.haml +3 -0
  78. data/views/_test_result.haml +4 -0
  79. data/views/stylesheets/test.scss +53 -0
  80. data/views/test.haml +8 -0
  81. metadata +145 -114
  82. data/lib/citygrid/api/base.rb +0 -60
  83. data/test/test_citygrid.rb +0 -7
data/Gemfile CHANGED
@@ -1,15 +1,17 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem "httparty", "~> 0.7.8"
6
2
 
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
3
+ gem "httparty", "~> 0.8.1"
4
+ gem "json", "1.5.3"
5
+ gem "riot", "~> 0.12.4"
6
+ gem "awesome_print", "~> 0.4.0", :require => "ap"
7
+ gem "haml"
8
+
9
9
  group :development do
10
- gem "awesome_print", "~> 0.4.0", :require => "ap"
11
- gem "riot", "~> 0.12.4"
12
10
  gem "bundler", "~> 1.0.0"
13
11
  gem "jeweler", "~> 1.6.2"
14
12
  gem "rcov", ">= 0"
15
13
  end
14
+
15
+ group :dashboard do
16
+ gem "sinatra"
17
+ end
data/Gemfile.lock CHANGED
@@ -2,19 +2,31 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  awesome_print (0.4.0)
5
- crack (0.1.8)
6
5
  git (1.2.5)
7
- httparty (0.7.8)
8
- crack (= 0.1.8)
9
- jeweler (1.6.2)
6
+ haml (3.1.4)
7
+ httparty (0.8.1)
8
+ multi_json
9
+ multi_xml
10
+ jeweler (1.6.4)
10
11
  bundler (~> 1.0)
11
12
  git (>= 1.2.5)
12
13
  rake
13
- rake (0.9.2)
14
- rcov (0.9.9)
15
- riot (0.12.4)
14
+ json (1.5.3)
15
+ multi_json (1.0.4)
16
+ multi_xml (0.4.1)
17
+ rack (1.3.5)
18
+ rack-protection (1.1.4)
19
+ rack
20
+ rake (0.9.2.2)
21
+ rcov (0.9.11)
22
+ riot (0.12.5)
16
23
  rr
17
- rr (1.0.2)
24
+ rr (1.0.4)
25
+ sinatra (1.3.1)
26
+ rack (~> 1.3, >= 1.3.4)
27
+ rack-protection (~> 1.1, >= 1.1.2)
28
+ tilt (~> 1.3, >= 1.3.3)
29
+ tilt (1.3.3)
18
30
 
19
31
  PLATFORMS
20
32
  ruby
@@ -22,7 +34,10 @@ PLATFORMS
22
34
  DEPENDENCIES
23
35
  awesome_print (~> 0.4.0)
24
36
  bundler (~> 1.0.0)
25
- httparty (~> 0.7.8)
37
+ haml
38
+ httparty (~> 0.8.1)
26
39
  jeweler (~> 1.6.2)
40
+ json (= 1.5.3)
27
41
  rcov
28
42
  riot (~> 0.12.4)
43
+ sinatra
data/README ADDED
@@ -0,0 +1,21 @@
1
+ = citygrid
2
+
3
+ Don't use this. NOT PRODUCTION READY
4
+
5
+ Description goes here.
6
+
7
+ == Contributing to citygrid
8
+
9
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
10
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
11
+ * Fork the project
12
+ * Start a feature/bugfix branch
13
+ * Commit and push until you are happy with your contribution
14
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
15
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2011 Elpizo Choi. See LICENSE.txt for
20
+ further details.
21
+
data/citygrid_api.gemspec CHANGED
@@ -4,27 +4,33 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{citygrid_api}
8
- s.version = "0.0.5"
7
+ s.name = "citygrid_api"
8
+ s.version = "0.0.5.1"
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 = %q{2011-07-18}
13
- s.description = %q{Ruby wrapper for CityGrid APIs}
14
- s.email = %q{fu7iin@gmail.com}
12
+ s.date = "2011-12-17"
13
+ s.description = "Ruby wrapper for CityGrid APIs"
14
+ s.email = "fu7iin@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
+ "README",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
20
21
  ".document",
22
+ ".sass-cache/7a5a675d951455410512a59af5ab2d160bd1735c/test.scssc",
21
23
  "Gemfile",
22
24
  "Gemfile.lock",
23
25
  "LICENSE.txt",
26
+ "README",
24
27
  "README.rdoc",
25
28
  "Rakefile",
26
29
  "VERSION",
27
30
  "citygrid_api.gemspec",
31
+ "citygrid_api.yml.sample",
32
+ "config.ru",
33
+ "dashboard.rb",
28
34
  "lib/citygrid.rb",
29
35
  "lib/citygrid/abstraction.rb",
30
36
  "lib/citygrid/abstraction/collection.rb",
@@ -33,7 +39,25 @@ Gem::Specification.new do |s|
33
39
  "lib/citygrid/abstraction/super_array.rb",
34
40
  "lib/citygrid/abstraction/super_hash.rb",
35
41
  "lib/citygrid/api.rb",
36
- "lib/citygrid/api/base.rb",
42
+ "lib/citygrid/api/ad_center.rb",
43
+ "lib/citygrid/api/ad_center/account.rb",
44
+ "lib/citygrid/api/ad_center/account_manager.rb",
45
+ "lib/citygrid/api/ad_center/ad_group.rb",
46
+ "lib/citygrid/api/ad_center/ad_group_ad.rb",
47
+ "lib/citygrid/api/ad_center/ad_group_criterion.rb",
48
+ "lib/citygrid/api/ad_center/ad_group_geo.rb",
49
+ "lib/citygrid/api/ad_center/authentication.rb",
50
+ "lib/citygrid/api/ad_center/billing.rb",
51
+ "lib/citygrid/api/ad_center/budget.rb",
52
+ "lib/citygrid/api/ad_center/call_detail.rb",
53
+ "lib/citygrid/api/ad_center/campaign.rb",
54
+ "lib/citygrid/api/ad_center/category.rb",
55
+ "lib/citygrid/api/ad_center/geolocation.rb",
56
+ "lib/citygrid/api/ad_center/image.rb",
57
+ "lib/citygrid/api/ad_center/method_of_payment.rb",
58
+ "lib/citygrid/api/ad_center/performance.rb",
59
+ "lib/citygrid/api/ad_center/places.rb",
60
+ "lib/citygrid/api/ad_center/user.rb",
37
61
  "lib/citygrid/api/content.rb",
38
62
  "lib/citygrid/api/content/offers.rb",
39
63
  "lib/citygrid/api/content/places.rb",
@@ -47,42 +71,78 @@ Gem::Specification.new do |s|
47
71
  "lib/citygrid/reviews.rb",
48
72
  "lib/citygrid/search.rb",
49
73
  "lib/citygrid_api.rb",
74
+ "lib/dashboard/sinatra_partial.rb",
75
+ "lib/dashboard/stored_reporter.rb",
76
+ "lib/dashboard/test_result.rb",
77
+ "lib/request_ext.rb",
78
+ "public/javascript/dashboard.js",
79
+ "test/api/ad_center/test_account.rb",
80
+ "test/api/ad_center/test_ad_group.rb",
81
+ "test/api/ad_center/test_ad_group_ad.rb",
82
+ "test/api/ad_center/test_ad_group_criterion.rb",
83
+ "test/api/ad_center/test_ad_group_geo.rb",
84
+ "test/api/ad_center/test_authentication.rb",
85
+ "test/api/ad_center/test_billing.rb",
86
+ "test/api/ad_center/test_budget.rb",
87
+ "test/api/ad_center/test_call_detail.rb",
88
+ "test/api/ad_center/test_campaign.rb",
89
+ "test/api/ad_center/test_category.rb",
90
+ "test/api/ad_center/test_geolocation.rb",
91
+ "test/api/ad_center/test_image.rb",
92
+ "test/api/ad_center/test_method_of_payment.rb",
93
+ "test/api/ad_center/test_places.rb",
94
+ "test/api/ad_center/test_reports.rb",
95
+ "test/api/content/test_offers.rb",
96
+ "test/api/content/test_places.rb",
50
97
  "test/helper.rb",
51
98
  "test/publisher_helper.rb.sample",
52
- "test/test_citygrid.rb",
99
+ "test/test_config.rb",
53
100
  "test/test_details.rb",
101
+ "test/test_img.jpg",
102
+ "test/test_img_big.png",
54
103
  "test/test_listing.rb",
55
104
  "test/test_search.rb",
56
105
  "test/test_super_array.rb",
57
- "test/test_super_hash.rb"
106
+ "test/test_super_hash.rb",
107
+ "views/_context_result.haml",
108
+ "views/_request.haml",
109
+ "views/_test_result.haml",
110
+ "views/stylesheets/test.scss",
111
+ "views/test.haml"
58
112
  ]
59
113
  s.licenses = ["MIT"]
60
114
  s.require_paths = ["lib"]
61
- s.rubygems_version = %q{1.7.2}
62
- s.summary = %q{Ruby wrapper for CityGrid APIs}
115
+ s.rubygems_version = "1.8.12"
116
+ s.summary = "Ruby wrapper for CityGrid APIs"
63
117
 
64
118
  if s.respond_to? :specification_version then
65
119
  s.specification_version = 3
66
120
 
67
121
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
- s.add_runtime_dependency(%q<httparty>, ["~> 0.7.8"])
69
- s.add_development_dependency(%q<awesome_print>, ["~> 0.4.0"])
70
- s.add_development_dependency(%q<riot>, ["~> 0.12.4"])
122
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.8.1"])
123
+ s.add_runtime_dependency(%q<json>, ["= 1.5.3"])
124
+ s.add_runtime_dependency(%q<riot>, ["~> 0.12.4"])
125
+ s.add_runtime_dependency(%q<awesome_print>, ["~> 0.4.0"])
126
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
71
127
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
72
128
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
73
129
  s.add_development_dependency(%q<rcov>, [">= 0"])
74
130
  else
75
- s.add_dependency(%q<httparty>, ["~> 0.7.8"])
76
- s.add_dependency(%q<awesome_print>, ["~> 0.4.0"])
131
+ s.add_dependency(%q<httparty>, ["~> 0.8.1"])
132
+ s.add_dependency(%q<json>, ["= 1.5.3"])
77
133
  s.add_dependency(%q<riot>, ["~> 0.12.4"])
134
+ s.add_dependency(%q<awesome_print>, ["~> 0.4.0"])
135
+ s.add_dependency(%q<haml>, [">= 0"])
78
136
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
79
137
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
80
138
  s.add_dependency(%q<rcov>, [">= 0"])
81
139
  end
82
140
  else
83
- s.add_dependency(%q<httparty>, ["~> 0.7.8"])
84
- s.add_dependency(%q<awesome_print>, ["~> 0.4.0"])
141
+ s.add_dependency(%q<httparty>, ["~> 0.8.1"])
142
+ s.add_dependency(%q<json>, ["= 1.5.3"])
85
143
  s.add_dependency(%q<riot>, ["~> 0.12.4"])
144
+ s.add_dependency(%q<awesome_print>, ["~> 0.4.0"])
145
+ s.add_dependency(%q<haml>, [">= 0"])
86
146
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
87
147
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
88
148
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -0,0 +1,33 @@
1
+ defaults:
2
+ hostname: api.qa.citygrid.com
3
+ ssl_hostname: api-qassl.citygrid.com
4
+
5
+ # endpoint_name: endpoint
6
+ # OR
7
+ # endpoint_name:
8
+ # ssl: true/false
9
+ # endpoint: endpoint
10
+
11
+ endpoints:
12
+ account:
13
+ ssl: true
14
+ endpoint: accounts/account/v2
15
+ ad_group: advertising/adgroup/v2
16
+ ad_group_ad: advertising/adgroupad/v2
17
+ ad_group_criterion: advertising/adgroupcriterion/v2
18
+ ad_group_geo: advertising/adgroupgeo/v2
19
+ authentication:
20
+ ssl: true
21
+ endpoint: accounts/user/v2
22
+ budget: advertising/budget/v2/recommend
23
+ campaign: advertising/campaign/v2
24
+ category: content/category/v2
25
+ geo_location: content/places/v2/geocode
26
+ image: advertising/image/v2
27
+ method_of_payment:
28
+ ssl: true
29
+ endpoint: accounts/mop/v2
30
+ places: content/places/v2
31
+ performance: advertising/performance/v2/campaign
32
+ user: accounts/user/v2
33
+ call_detail: advertising/calldetail/v2
data/config.ru ADDED
@@ -0,0 +1,2 @@
1
+ require './dashboard'
2
+ run Sinatra::Application
data/dashboard.rb ADDED
@@ -0,0 +1,110 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require "awesome_print"
4
+ require "riot"
5
+ require "haml"
6
+ require 'stringio'
7
+
8
+ IN_DASHBOARD = true
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib', "dashboard"))
11
+ require "stored_reporter"
12
+ require "sinatra_partial"
13
+ require "test_result"
14
+
15
+ helpers Sinatra::Partials
16
+
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
18
+ require "citygrid_api"
19
+ CityGrid.publisher = "test"
20
+ CityGrid.load_config File.join(File.dirname(__FILE__), 'citygrid_api.yml.sample'), "qa"
21
+
22
+ def run_with_rescue
23
+ # don't do anything here, we'll catch
24
+ yield
25
+ end
26
+
27
+ module Riot
28
+ class Context
29
+ def run(reporter)
30
+ reporter.describe_context(self)
31
+ local_run(reporter, situation_class.new)
32
+ run_sub_contexts(reporter)
33
+ reporter
34
+ end
35
+ end
36
+ end
37
+
38
+ # hack to trap all HTTParty::Requests so we can inspect them
39
+ class RequestTrap
40
+ def self.trap
41
+ @@trap ||= []
42
+ end
43
+ end
44
+
45
+ module HTTParty
46
+ class Request
47
+ alias_method :old_perform, :perform
48
+
49
+ def perform
50
+ RequestTrap.trap << self
51
+ old_perform
52
+ end
53
+ end
54
+ end
55
+
56
+ # render stylesheets
57
+ get '/stylesheets/:name.css' do
58
+ content_type 'text/css', :charset => 'utf-8'
59
+ scss :"stylesheets/#{params[:name]}"
60
+ end
61
+
62
+ get '/' do
63
+ # we want to run tests ourselves
64
+ Riot.alone!
65
+
66
+ # test_paths = Dir.glob "test/**/test_*.rb"
67
+ test_paths = Dir.glob("test/api/ad_center/test_*.rb").sort
68
+ # test_paths = ["test/api/ad_center/test_account.rb"]
69
+
70
+ @results = []
71
+ test_paths.each do |path|
72
+ eval(IO.read(path), binding, path)
73
+ # root_contexts << [path, Riot.root_contexts.clone]
74
+
75
+ result = TestResult.new path.gsub(/^test\//, "").gsub(/\.rb$/, "").split("/").map{|x| x.gsub("_", " ")}.join(" > ")
76
+ Riot.root_contexts.each do |context|
77
+ out = StringIO.new
78
+ reporter = StoredReporter.new out
79
+ begin
80
+ # $stdout = out
81
+ context.run reporter
82
+ rescue CityGrid::API::InvalidResponseFormat => ex
83
+ puts "CAUGHT AN ERROR!"
84
+ x = {"description" => ex.description, "server_msg" => ex.server_msg}
85
+ reporter.fail ex.description, ex.server_msg, "", ""
86
+ rescue => ex
87
+ puts "CAUGHT AN ERROR!"
88
+ reporter.fail ex.to_s, "", "", ""
89
+ ensure
90
+ # $stdout = STDOUT
91
+ end
92
+
93
+ reporter.context_finished
94
+ result.results += reporter.context_results
95
+ end
96
+
97
+ @results << result
98
+
99
+ Riot.root_contexts.clear
100
+ end
101
+
102
+ haml :test
103
+ end
104
+
105
+ get '/evented' do
106
+ stream(:keep_open) do |out|
107
+ EventMachine::PeriodicTimer.new(1) { out << "#{Time.now}\n" }
108
+ end
109
+ end
110
+
@@ -8,7 +8,7 @@ class CityGrid
8
8
  end
9
9
 
10
10
  def update array
11
- replace array
11
+ replace array if array
12
12
  end
13
13
  end
14
14
  end
@@ -15,6 +15,8 @@ class CityGrid
15
15
  # create new SuperHash if value is hash
16
16
  if val.is_a? Hash
17
17
  SuperHash.new val
18
+ elsif val.is_a? Array
19
+ SuperArray.new val
18
20
  elsif keys.include?(sym) || keys.include?(sym.to_s)
19
21
  val
20
22
  else
@@ -0,0 +1,26 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Account < AdCenter
5
+ # Adds new customer account to existing user
6
+ # http://docs.prod.cs/display/citygridv2/Internal+-+Account#Internal-Account-AddNewCustomerAccounttoExistingUser
7
+ def self.import_to_cg options = {}
8
+ token = extract_auth_token options
9
+ request_and_handle :post,
10
+ "#{base_uri}/accounts/account/v2/customer/mutate",
11
+ :body => options.to_json,
12
+ :headers => merge_headers("authToken" => token)
13
+ end
14
+
15
+ #http://docs-dev.prod.cs/display/citygridv2/Internal+-+Account+Type
16
+ def self.account_type options = {}
17
+ token = extract_auth_token options
18
+ request_and_handle :get,
19
+ "#{endpoint}/get/type",
20
+ :query => options,
21
+ :headers => merge_headers("authToken" => token)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class AccountManager < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class AdGroup < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class AdGroupAd < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class AdGroupCriterion < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class AdGroupGeo < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Authentication < AdCenter
5
+ def self.login options = {}
6
+ request_and_handle :post,
7
+ "#{endpoint}/login",
8
+ :query => options
9
+ end
10
+
11
+ def self.validate options = {}
12
+ request_and_handle :get,
13
+ "#{endpoint}/validate",
14
+ :query => options,
15
+ :headers => merge_headers
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Billing < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Budget < AdCenter
5
+ endpoint "/adcenter/budget/v2/recommendation"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class CallDetail < AdCenter
5
+ class << self
6
+ def get by, options = {}
7
+ token = extract_auth_token options
8
+ request_and_handle :post,
9
+ "#{endpoint}/#{by}",
10
+ :body => options.to_json,
11
+ :headers => merge_headers("authToken" => token)
12
+ end
13
+
14
+ def note options = {}
15
+ token = extract_auth_token options
16
+ request_and_handle :post,
17
+ "#{endpoint}/note",
18
+ :body => options.to_json,
19
+ :headers => merge_headers("authToken" => token)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Campaign < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Category < AdCenter
5
+ endpoint "/adcenter/categories/v2"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class GeoLocation < AdCenter
5
+ endpoint "/adcenter/categories/v2"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ require 'base64'
2
+
3
+ class CityGrid
4
+ class API
5
+ class AdCenter
6
+ class Image < AdCenter
7
+ def self.upload user_id, name, type, image_path, options = {}
8
+ token = extract_auth_token options
9
+ image_data = Base64.encode64(File.open(image_path).read.to_s).gsub(/\n/, "")
10
+ format = options[:format] || image_path.split(".").last
11
+ request_and_handle :post,
12
+ "#{base_uri}/#{endpoint}/upload",
13
+ :body => {"mutateOperationListResource" => [
14
+ {
15
+ "operand" => {
16
+ "image_type" => type,
17
+ "image_name" => name,
18
+ "image_format" => format,
19
+ "image" => image_data
20
+ },
21
+ "operator" => "ADD",
22
+ "userId" => user_id
23
+ }
24
+ ]}.to_json,
25
+ :headers => merge_headers("authToken" => token)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class MethodOfPayment < AdCenter
5
+ server :ssl
6
+ endpoint "/adcenter/account/v2/mop"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Performance < AdCenter
5
+ class << self
6
+ def summary type, options = {}
7
+ token = extract_auth_token options
8
+ request_and_handle :post,
9
+ "#{endpoint}/#{type}",
10
+ :body => options.to_json,
11
+ :headers => merge_headers("authToken" => token)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ class CityGrid
2
+ class API
3
+ class AdCenter
4
+ class Places < AdCenter
5
+ end
6
+ end
7
+ end
8
+ end