citygrid_api 0.0.5 → 0.0.5.1

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.
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
@@ -0,0 +1,101 @@
1
+ class StoredReporter < Riot::SilentReporter
2
+ class ContextResult
3
+ attr_accessor :desc, :children, :passes, :fails, :requests
4
+
5
+ def initialize context
6
+ @fails = []
7
+ @passes = []
8
+ @requests = []
9
+ @children = []
10
+
11
+ @desc = context.description
12
+ end
13
+
14
+ def fail fail
15
+ @fails << fail
16
+ end
17
+
18
+ def pass pass
19
+ @passes << pass
20
+ end
21
+
22
+ def passed?
23
+ return false unless fails.empty?
24
+
25
+ children.each do |c|
26
+ return false unless c.passed?
27
+ end
28
+
29
+ return true
30
+ end
31
+
32
+ end
33
+
34
+ class Fail
35
+ attr_accessor :desc, :result, :a, :b
36
+
37
+ def initialize desc, result, a = nil, b = nil
38
+ self.desc = desc
39
+ self.result = result
40
+ end
41
+ end
42
+
43
+ class Pass
44
+ attr_accessor :desc, :result
45
+
46
+ def initialize desc, result
47
+ self.desc = desc
48
+ self.result = result
49
+ end
50
+ end
51
+
52
+ attr_accessor :context_results
53
+
54
+ def initialize string_io
55
+ @string_io = string_io
56
+
57
+ # lookup hash for contexts to handle nesting
58
+ @contexts = {}
59
+ @context_results = []
60
+ super()
61
+ end
62
+
63
+ def context_finished
64
+ return unless @current_result
65
+
66
+ @current_result.requests = RequestTrap.trap.clone
67
+ RequestTrap.trap.clear
68
+ #
69
+ # str = @string_io.string
70
+ # # puts "flushing with #{str} inside #{@current_result.desc}"
71
+ # # @current_result.curls = str.split(/\n/).select{|x| x.index("curl") == 0} if @current_result
72
+ # @string_io.truncate 0
73
+ end
74
+
75
+ def describe_context context
76
+ context_finished
77
+ @current_result = ContextResult.new context
78
+ @contexts[context] = @current_result
79
+
80
+ if context.parent && @contexts[context.parent]
81
+ @contexts[context.parent].children << @current_result
82
+ else
83
+ # it's a top level result
84
+ @context_results << @current_result
85
+ end
86
+
87
+ super context
88
+ end
89
+
90
+ def pass *args
91
+ @current_result.pass Pass.new *args
92
+ end
93
+
94
+ def error *args
95
+ @current_result.fail Fail.new *args
96
+ end
97
+
98
+ def fail *args
99
+ @current_result.fail Fail.new *args
100
+ end
101
+ end
@@ -0,0 +1,8 @@
1
+ class TestResult
2
+ attr_accessor :desc, :results
3
+
4
+ def initialize desc
5
+ self.desc = desc
6
+ @results = []
7
+ end
8
+ end
@@ -0,0 +1,32 @@
1
+ module HTTParty
2
+ class Request
3
+
4
+ def get_uri
5
+ if (self.respond_to?('last_uri') && last_uri)
6
+ return last_uri
7
+ else
8
+ return uri
9
+ end
10
+ end
11
+
12
+ def to_json
13
+ {
14
+ "requestUrl" => get_uri,
15
+ "requestMethod" => http_method.to_s.split("::").last.upcase,
16
+ "requestBody" => send(:body) || "",
17
+ "headers" => options[:headers].to_a.flatten || []
18
+ }.to_json
19
+ end
20
+
21
+ def to_curl
22
+ args = ["curl -X #{http_method.to_s.split("::").last.upcase}"]
23
+ args << "-d #{send(:body).to_json}" if self.send(:body)
24
+
25
+ args << "#{(options[:headers] || []).map{|k, v| "--header \"#{k}:#{v}\""}.join(" ")}" if options[:headers]
26
+
27
+ args << "\"#{get_uri}\""
28
+
29
+ return args.join(" ")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ $(function() {
2
+ $(".curl").click(function() {
3
+ this.select();
4
+ })
5
+ });
@@ -0,0 +1,120 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+ context "Search for a user" do
5
+ context "by name" do
6
+ setup do
7
+ run_with_rescue do
8
+ CityGrid::API::AdCenter::Account.search(
9
+ :token => AuthToken.sales_coord,
10
+ :userName => '25-1'
11
+ )
12
+ end
13
+ end
14
+ should("not be empty"){ !topic.empty? }
15
+ should("return message OK"){ topic.accountResources.first.response.message }.equals("OK")
16
+ should("return response code OK"){ topic.accountResources.first.response.code.to_i }.equals(200)
17
+ end
18
+
19
+ context "Search by id" do
20
+ setup do
21
+ run_with_rescue do
22
+ CityGrid::API::AdCenter::Account.search(
23
+ :token => AuthToken.sales_coord,
24
+ :id => 1250702
25
+ )
26
+ end
27
+ end
28
+ should("not be empty"){ !topic.empty? }
29
+ should("return message OK"){ topic.accountResources.first.response.message }.equals("OK")
30
+ should("return response code OK"){ topic.accountResources.first.response.code.to_i }.equals(200)
31
+ end
32
+ end
33
+
34
+
35
+ context "Search for account type" do
36
+ context "Search by id" do
37
+ setup do
38
+ run_with_rescue do
39
+ CityGrid::API::AdCenter::Account.account_type(
40
+ :token => token,
41
+ :id => 1250702
42
+ )
43
+ end
44
+ end
45
+ should("not be empty"){ !topic.empty? }
46
+ should("return message OK"){ topic.response.message }.equals("OK")
47
+ should("return response code OK"){ topic.response.code.to_i }.equals(200)
48
+ should("return type s CYB code OK"){ topic.accountType }.equals("CYB")
49
+ end
50
+ end
51
+
52
+ context "Import a cg account" do
53
+ setup do
54
+ run_with_rescue do
55
+ auth_token = CityGrid.login(
56
+ :username => 'GARYTEST',
57
+ :password => 'pppppp'
58
+ ).authToken
59
+
60
+ CityGrid::API::AdCenter::Account.import_to_cg(
61
+ :token => auth_token,
62
+ "mutateOperationListResource" => [{
63
+ "operator" => "ADD",
64
+ "operand" => {
65
+ "firstName" => "nico-api",
66
+ "lastName" => "gomez-api",
67
+ "phone" => "9001111112",
68
+ "businessName" =>"businessProveApi",
69
+ "address1" =>"dir-api",
70
+ "city" =>"montevideo",
71
+ "state" =>"Montevideo",
72
+ "zipCode" =>"90069"
73
+ }
74
+ }]
75
+ )
76
+ end
77
+ end
78
+ should("not be empty"){ !topic.empty? }
79
+ should("return message OK"){ topic.accountResources.first.response.message }.equals("OK")
80
+ should("return response code OK"){ topic.accountResources.first.response.code.to_i }.equals(200)
81
+ end
82
+
83
+
84
+ context "Creating an account" do
85
+ setup do
86
+ run_with_rescue do
87
+ CityGrid::API::AdCenter::Account.mutate(
88
+ :token => token,
89
+ "mutateOperationListResource" => [{
90
+ "operator" => "ADD",
91
+ "operand" => {
92
+ "firstName" => "nico-api",
93
+ "lastName" => "gomez-api",
94
+ "phone" => "9001111112",
95
+ "email" => "goodtry#{rand(1000000)}@a.com",
96
+ "userName" => "goodtry#{rand(1000000)}",
97
+ "password" => "pppppp",
98
+ "businessName" => "businessProveApi",
99
+ "address1" => "dir-api",
100
+ "city" => "montevideo",
101
+ "state" => "Montevideo",
102
+ "zipCode" => "90069"
103
+ }
104
+ }]
105
+ )
106
+ end
107
+ end
108
+ should("not be empty"){ !topic.empty? }
109
+ should("return message OK"){ topic.accountResources.first.response.message }.equals("OK")
110
+ should("return response code OK"){ topic.accountResources.first.response.code.to_i }.equals(200)
111
+ end
112
+
113
+ context "Logging in" do
114
+ setup do
115
+ run_with_rescue do
116
+ CityGrid.login(:username => "goodtry#{AuthToken.rand_number}", :password => 'pppppp')
117
+ end
118
+ end
119
+ should("return an authToken"){ topic.authToken }
120
+ end
@@ -0,0 +1,50 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Mutating Ad Group" do
6
+ setup do
7
+ run_with_rescue do
8
+ CityGrid::API::AdCenter::AdGroup.search(:token => token, :adGroupIds => 30966312)
9
+ end
10
+ end
11
+ should("not be empty"){ !topic.empty? }
12
+ should("have campaignId"){ !topic.adGroups.first.campaignId.nil? }
13
+ end
14
+
15
+ context "Search Ad Group by Campaign Id" do
16
+ setup do
17
+ run_with_rescue do
18
+ CityGrid::API::AdCenter::AdGroup.search(:token => AuthToken.sales_coord, :campaignId => 2434702)
19
+ end
20
+ end
21
+ should("not be empty"){ !topic.empty? }
22
+ should("have campaignId"){ !topic.adGroups.first.campaignId.nil? }
23
+ end
24
+
25
+
26
+ context "Mutating Ad Group" do
27
+ setup do
28
+ run_with_rescue do
29
+ CityGrid::API::AdCenter::AdGroup.mutate(
30
+ :token => token,
31
+ "mutateOperationListResource" => [{
32
+ "operator" => "ADD",
33
+ "operand" => {
34
+ "placeId" => "10728522",
35
+ "campaignId" => "2435332",
36
+ "contractTermMonths" =>"12",
37
+ "monthlyServiceFee" => "19.95",
38
+ "bids" => [{
39
+ "actionTargetName" => "map & directions",
40
+ "ppe" => "1.80"
41
+ }]
42
+ }
43
+ }]
44
+ )
45
+ end
46
+ end
47
+ should("not be empty"){ !topic.empty? }
48
+ should("have campaignId"){ !topic.adGroups.first.campaignId.nil? }
49
+ end
50
+
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Mutating AdGroup Ads" do
6
+ setup do
7
+ run_with_rescue do
8
+ CityGrid::API::AdCenter::AdGroupAd.mutate(
9
+ :token => token,
10
+ "mutateOperationListResource" => [{
11
+ "operator" => "ADD",
12
+ "operand" => {
13
+ "groupId" => "31919852",
14
+ "ad"=>{
15
+ "type" =>"PERFORMANCE_AD",
16
+ "tagline" => "ad_tagline",
17
+ "imageUrl" => "ad_photo.com"
18
+ }
19
+ }
20
+ }]
21
+ )
22
+ end
23
+ end
24
+ should("not be empty"){ !topic.empty? }
25
+ should("return code OK"){ topic.adResources.first.response.code }.equals(200)
26
+ should("return message OK") { topic.adResources.first.response.message }.equals("OK")
27
+ end
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+ token = AuthToken.generate
3
+ context "AdGroupCriterion" do
4
+ context "search" do
5
+ setup do
6
+ run_with_rescue do
7
+ CityGrid::API::AdCenter::AdGroupCriterion.search(:token => AuthToken.sales_coord, :adGroupId => 6)
8
+ end
9
+ end
10
+ should("not be empty?"){ !topic.empty? }
11
+ should("return code OK"){ topic.adGroupCriterionResources.first.response.code }.equals(200)
12
+ should("return message OK") { topic.adGroupCriterionResources.first.response.message }.equals("OK")
13
+ end
14
+
15
+ context "mutate" do
16
+ setup do
17
+ run_with_rescue do
18
+ CityGrid::API::AdCenter::AdGroupCriterion.mutate(
19
+ :token => token,
20
+ "mutateOperationListResource" => [{
21
+ "operator" => "ADD",
22
+ "operand" => {
23
+ "adGroupId" => "31919852",
24
+ "adGroupAdId" => "87768542",
25
+ "adGroupCriterionId" =>
26
+ "1722",
27
+ "type" => "2"
28
+ }
29
+ }]
30
+ )
31
+ end
32
+ end
33
+ should("not be empty"){ !topic.empty? }
34
+ should("return code OK"){ topic.adGroupCriterionResources.first.response.code }.equals(200)
35
+ should("return message OK") { topic.adGroupCriterionResources.first.response.message }.equals("OK")
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ context "Searching AdGroup Geo" do
4
+ setup do
5
+ run_with_rescue do
6
+ CityGrid::API::AdCenter::AdGroupGeo.search(
7
+ :token => AuthToken.sales_coord,
8
+ "adGroupId" => 78,
9
+ "streetAddress" => "200 Robertson Blvd",
10
+ "city" => "Beverly Hills",
11
+ "state" => "CA",
12
+ "zipCode" => "90211"
13
+ )
14
+ end
15
+ end
16
+ should("not be empty"){ !topic.empty? }
17
+ should("have entries"){ topic.totalNumEntries > 0}
18
+ should("have adGroupGeos"){ !topic.adGroupGeos.empty? }
19
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ context "Logging in" do
4
+ setup do
5
+ run_with_rescue do
6
+ CityGrid.login(:username => 'GARYTEST', :password => 'pppppp')
7
+ end
8
+ end
9
+ should("return an authToken"){ topic.authToken }
10
+ end
11
+
12
+ context "Valiate user" do
13
+ setup do
14
+ run_with_rescue do
15
+ token = AuthToken.kunimom
16
+ CityGrid::API::AdCenter::Authentication.validate :oauth_token => token
17
+ end
18
+ end
19
+ should("have id"){ topic.id }
20
+ should("have status"){ topic.status }
21
+ should("have display_name"){ topic.display_name }
22
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+
4
+ context "Search Billing by Campaign Id" do
5
+ setup do
6
+ run_with_rescue do
7
+ CityGrid::API::AdCenter::Billing.search(:token => AuthToken.sales_coord, :campaignId => 16631)
8
+ end
9
+ end
10
+ should("not be empty"){ !topic.empty? }
11
+ should("have campaignId"){ !topic.campaignId.nil? }
12
+ end
13
+
14
+
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Searching budgets" do
6
+ setup do
7
+ run_with_rescue do
8
+ CityGrid::API::AdCenter::Budget.search(:listingId => 833372, :token => token)
9
+ end
10
+ end
11
+ should("not be empty"){ !topic.empty? }
12
+ should("have budget suggestions"){ topic.budgetSuggestionResources.length > 0 }
13
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.sales_coord
4
+
5
+ context "Call Detail" do
6
+ context "by campaign" do
7
+ setup do
8
+ run_with_rescue do
9
+ CityGrid::API::AdCenter::CallDetail.get(
10
+ :campaign,
11
+ :campaignId => 786,
12
+ :period => 'last30Days',
13
+ :token => token
14
+ )
15
+ end
16
+ end
17
+ should("not be empty"){ !topic.empty? }
18
+ should("have call detail resources"){
19
+ topic.callDetailsResources.length > 0
20
+ }
21
+ end
22
+
23
+ # context "note" do
24
+ # setup do
25
+ # run_with_rescue do
26
+ # CityGrid::API::AdCenter::CallDetail.note(
27
+ # :campaignId => 786,
28
+ # :period => 'last30Days',
29
+ # :token => token
30
+ # )
31
+ # end
32
+ # end
33
+ # should("not be empty"){ !topic.empty? }
34
+ # should("have user actions"){ topic.userActions.length > 0 }
35
+ # end
36
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Adding a campaign" do
6
+ setup do
7
+ run_with_rescue do
8
+ CityGrid::API::AdCenter::Campaign.mutate(
9
+ :token => token,
10
+ :mutateOperationListResource => [{
11
+ :operator => "ADD",
12
+ :operand => {
13
+ :name => "PleaseWork6",
14
+ :startDate => (Date.today+1).to_s.gsub("-", ""),
15
+ :endDate => (Date.today + 10).to_s.gsub("-", ""),
16
+ :product => "PERFORMANCE",
17
+ :budget => {:amount => 30000},
18
+ :mopId => 387552
19
+ }
20
+ }]
21
+ )
22
+ end
23
+ end
24
+ should("not be empty"){ !topic.empty? }
25
+ should("return code OK"){ topic.campaignResources.first.response.code }.equals(200)
26
+ should("return message OK") { topic.campaignResources.first.response.message }.equals("OK")
27
+ end
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Searching categories" do
6
+ context "by listing id" do
7
+ setup do
8
+ run_with_rescue do
9
+ CityGrid::API::AdCenter::Category.search(
10
+ :token => token,
11
+ :listingId => 3680332,
12
+ :startIndex => 0,
13
+ :numberResults => 10
14
+ )
15
+ end
16
+ end
17
+ should("not be empty"){ !topic.empty? }
18
+ should("respond with OK"){ topic.response.code == 200 }
19
+ should("have resources"){ !topic.resources.empty? }
20
+ end
21
+
22
+ context "by query" do
23
+ setup do
24
+ run_with_rescue do
25
+ CityGrid::API::AdCenter::Category.search(
26
+ :keywords => "pizza",
27
+ :startIndex => 0,
28
+ :numberResults => 10,
29
+ :token => token
30
+ )
31
+ end
32
+ end
33
+ should("not be empty"){ !topic.empty? }
34
+ should("respond with OK"){ topic.response.code == 200 }
35
+ should("have resources"){ !topic.resources.empty? }
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ context "Geo" do
4
+ setup do
5
+ run_with_rescue do
6
+ CityGrid::API::AdCenter::GeoLocation.search(
7
+ "streetAddress" => "720 3rd ave",
8
+ "city" => "seattle",
9
+ "state" => "wa",
10
+ "zipCode" => "98007",
11
+ :token => ""
12
+ )
13
+ end
14
+ end
15
+
16
+ should("not be empty") { !topic.empty? }
17
+ should("return message OK") { topic.message }.equals("OK")
18
+ should("return code 200") { !topic.geocodeResponse.first.geoAccuracy.nil? }
19
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ context "Upload an image" do
4
+ context "Add a preview" do
5
+ setup do
6
+ run_with_rescue do
7
+ image_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_img.jpg'))
8
+ resp = CityGrid::API::AdCenter::Image.upload(68, "a pic", "PROFILE_IMAGE", image_path, :token => AuthToken.sales_coord)
9
+ ap resp
10
+ resp
11
+ end
12
+ end
13
+ should("not be empty"){ !topic.empty? }
14
+ should("return message OK"){ topic.resources.first.response.message }.equals("OK")
15
+ should("return response code OK"){ topic.resources.first.response.code.to_i }.equals(200)
16
+ end
17
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
2
+
3
+ token = AuthToken.generate
4
+
5
+ context "Method of Payment" do
6
+ context "search" do
7
+ setup do
8
+ run_with_rescue do
9
+ CityGrid::API::AdCenter::MethodOfPayment.search(:accountId => 111, :token => token)
10
+ end
11
+ end
12
+ should("not be empty"){ !topic.empty?}
13
+ should("have MOP resources"){ !topic.mopResources.empty? }
14
+ end
15
+
16
+ # API not working here
17
+ context "mutate" do
18
+ setup do
19
+ run_with_rescue do
20
+ CityGrid::API::AdCenter::MethodOfPayment.mutate(
21
+ :token => token,
22
+ "mutateOperationListResource" => [{
23
+ "operator" => "ADD",
24
+ "operand" => {
25
+ "cardNumber" => "4112344112344113",
26
+ "expirationMonth" => 12,
27
+ "expirationYear" => 2012,
28
+ "nameOnAccount" => "Ara Tatous",
29
+ "cardType" => "Visa",
30
+ "state" => "NY" ,
31
+ "description" => "test addMOP",
32
+ "firstName" => "Ara",
33
+ "lastName" => "Tatous",
34
+ "phoneNumber" => "4252838811",
35
+ "address1" => "3131 Montrose Ave",
36
+ "address2" => "Apt. 9",
37
+ "city" => "LaCrescenta",
38
+ "postalCode" => "10016",
39
+ "accountId" => 2458392,
40
+ "securityCode" => "719",
41
+ "paymentType" => "Credit Card"
42
+ }
43
+ }]
44
+ )
45
+ end
46
+ end
47
+ should("not be empty"){ !topic.empty? }
48
+ should("return code OK"){ topic.resources.first.response.code }.equals(200)
49
+ should("return message OK") { topic.resources.first.response.message }.equals("OK")
50
+ end
51
+ end