citygrid_api 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.sass-cache/c6f2c767b164f077e5b9fb1f18a7886d7c755211/test.scssc +0 -0
- data/README.rdoc +42 -13
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/citygrid_api.gemspec +23 -12
- data/citygrid_api.yml.sample +10 -2
- data/citygrid_api.yml.sandbox +46 -0
- data/dashboard.rb +1 -1
- data/fixtures/vcr_cassettes/AdGroupCriterion_mutate.yml +3 -3
- data/fixtures/vcr_cassettes/AdGroupCriterion_search.yml +3 -3
- data/fixtures/vcr_cassettes/Adding_a_place.yml +4 -4
- data/fixtures/vcr_cassettes/Geo.yml +30 -13
- data/fixtures/vcr_cassettes/Getting_an_offer.yml +413 -0
- data/fixtures/vcr_cassettes/Getting_an_offer_by_listing_ID.yml +12 -12
- data/fixtures/vcr_cassettes/Import_a_cg_account.yml +28 -16
- data/fixtures/vcr_cassettes/Initiating_a_Details.yml +14 -30
- data/fixtures/vcr_cassettes/Initiating_new_MultiDetails.yml +13 -13
- data/fixtures/vcr_cassettes/Mutating_AdGroup_Ads.yml +4 -4
- data/fixtures/vcr_cassettes/Report_summary_daily.yml +34 -34
- data/fixtures/vcr_cassettes/Report_summary_user_actions.yml +14 -10
- data/fixtures/vcr_cassettes/Search_Ad_Group_by_Campaign_Id.yml +3 -3
- data/fixtures/vcr_cassettes/Search_Billing_by_Campaign_Id.yml +31 -12
- data/fixtures/vcr_cassettes/Search_account_manager_by_Campaign_Id.yml +25 -12
- data/fixtures/vcr_cassettes/Searching_AdGroup_Geo.yml +6 -6
- data/fixtures/vcr_cassettes/Searching_budgets.yml +31 -12
- data/fixtures/vcr_cassettes/Searching_categories_by_listing_id.yml +3 -3
- data/fixtures/vcr_cassettes/Searching_categories_by_query.yml +3 -3
- data/fixtures/vcr_cassettes/Upload_an_image_Add_a_preview.yml +31 -12
- data/fixtures/vcr_cassettes/{Method_of_Payment_mutate.yml → create_a_mop.yml} +24 -12
- data/fixtures/vcr_cassettes/create_an_offer.yml +51 -0
- data/fixtures/vcr_cassettes/create_campaign.yml +5 -5
- data/fixtures/vcr_cassettes/create_campaign_then_create_ad_group_belonging_to_campaign.yml +61 -0
- data/fixtures/vcr_cassettes/create_campaign_then_create_ad_group_belonging_to_campaign_then_search_.yml +91 -0
- data/fixtures/vcr_cassettes/getting_reviews_by_listing_id.yml +91 -0
- data/fixtures/vcr_cassettes/log_in_a_session.yml +3 -3
- data/fixtures/vcr_cassettes/log_in_a_session_mutate_places.yml +7 -7
- data/fixtures/vcr_cassettes/query_account_type_by_id.yml +24 -12
- data/fixtures/vcr_cassettes/search_for_an_account_by_id.yml +24 -13
- data/fixtures/vcr_cassettes/search_for_an_account_by_name.yml +27 -17
- data/fixtures/vcr_cassettes/search_for_call_detail_by_campaign.yml +49 -0
- data/fixtures/vcr_cassettes/search_for_mop_by_account_id.yml +65 -0
- data/fixtures/vcr_cassettes/searching_for_a_CityGrid_listing.yml +57 -53
- data/fixtures/vcr_cassettes/searching_for_a_special_CityGrid_listing.yml +10 -10
- data/fixtures/vcr_cassettes/user_log_in_with_raw_API.yml +24 -0
- data/fixtures/vcr_cassettes/user_log_in_with_session.yml +24 -0
- data/lib/citygrid/api/accounts/account.rb +2 -2
- data/lib/citygrid/api/accounts/method_of_payment.rb +2 -2
- data/lib/citygrid/api/accounts/user.rb +8 -4
- data/lib/citygrid/api/advertising/account_manager.rb +1 -1
- data/lib/citygrid/api/advertising/ad_group.rb +2 -2
- data/lib/citygrid/api/advertising/ad_group_ad.rb +2 -2
- data/lib/citygrid/api/advertising/ad_group_criterion.rb +2 -2
- data/lib/citygrid/api/advertising/ad_group_geo.rb +2 -2
- data/lib/citygrid/api/advertising/billing.rb +2 -1
- data/lib/citygrid/api/advertising/budget.rb +2 -2
- data/lib/citygrid/api/advertising/call_detail.rb +2 -2
- data/lib/citygrid/api/advertising/campaign.rb +2 -2
- data/lib/citygrid/api/advertising/category.rb +2 -2
- data/lib/citygrid/api/advertising/geolocation.rb +2 -2
- data/lib/citygrid/api/advertising/image.rb +3 -3
- data/lib/citygrid/api/advertising/offers.rb +10 -0
- data/lib/citygrid/api/advertising/places.rb +2 -2
- data/lib/citygrid/api/content/offers.rb +11 -2
- data/lib/citygrid/api/content/places.rb +1 -1
- data/lib/citygrid/api/content/response.rb +14 -0
- data/lib/citygrid/api/content/reviews.rb +5 -2
- data/lib/citygrid/api/mutable.rb +13 -0
- data/lib/citygrid/api/searchable.rb +4 -6
- data/lib/citygrid/api.rb +70 -52
- data/lib/citygrid/session.rb +5 -9
- data/lib/citygrid.rb +28 -1
- data/test/api/accounts/test_account.rb +53 -32
- data/test/api/accounts/test_method_of_payment.rb +40 -43
- data/test/api/accounts/test_user.rb +16 -0
- data/test/api/advertising/test_call_detail.rb +17 -2
- data/test/api/advertising/test_offers.rb +33 -0
- data/test/api/advertising/test_places.rb +18 -0
- data/test/api/content/test_offers.rb +14 -14
- data/test/api/content/test_response.rb +51 -0
- data/test/api/content/test_reviews.rb +11 -0
- data/test/helper.rb +18 -11
- metadata +41 -29
- data/README +0 -21
- data/citygrid_api.yml.backup +0 -35
- data/fixtures/vcr_cassettes/Call_Detail_by_campaign.yml +0 -79
- data/fixtures/vcr_cassettes/Method_of_Payment_search.yml +0 -59
- data/lib/citygrid/api/mutatable.rb +0 -15
@@ -13,9 +13,9 @@ class CityGrid
|
|
13
13
|
:body => {"mutateOperationListResource" => [
|
14
14
|
{
|
15
15
|
"operand" => {
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
16
|
+
"imageType" => type,
|
17
|
+
"imageName" => name,
|
18
|
+
"imageFormat" => format,
|
19
19
|
"image" => image_data
|
20
20
|
},
|
21
21
|
"operator" => "ADD",
|
@@ -2,8 +2,17 @@ class CityGrid
|
|
2
2
|
class API
|
3
3
|
class Content
|
4
4
|
class Offers < Content
|
5
|
-
define_action :where, :get, "search/where",
|
6
|
-
|
5
|
+
define_action :where, :get, "search/where",
|
6
|
+
:auth_token => false,
|
7
|
+
:publisher => true,
|
8
|
+
:client_ip => true,
|
9
|
+
:format => true
|
10
|
+
|
11
|
+
define_action :places, :get, "search/places",
|
12
|
+
:auth_token => false,
|
13
|
+
:publisher => true,
|
14
|
+
:client_ip => true,
|
15
|
+
:format => true
|
7
16
|
end
|
8
17
|
end
|
9
18
|
end
|
@@ -2,7 +2,7 @@ class CityGrid
|
|
2
2
|
class API
|
3
3
|
class Content
|
4
4
|
class Places < Content
|
5
|
-
|
5
|
+
include CityGrid::API::Mutable
|
6
6
|
|
7
7
|
define_action :detail, :get, "detail", :auth_token => false, :publisher => true, :client_ip => true
|
8
8
|
define_action :search, :get, "search/where", :auth_token => false, :publisher => true, :client_ip => true
|
@@ -2,8 +2,11 @@ class CityGrid
|
|
2
2
|
class API
|
3
3
|
class Content
|
4
4
|
class Reviews < Content
|
5
|
-
|
6
|
-
|
5
|
+
define_action :where, :get, "search/where",
|
6
|
+
:auth_token => false,
|
7
|
+
:publisher => true,
|
8
|
+
:client_ip => true,
|
9
|
+
:format => true
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
@@ -3,12 +3,10 @@
|
|
3
3
|
class CityGrid
|
4
4
|
class API
|
5
5
|
module Searchable
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:query => options,
|
11
|
-
:headers => merge_headers("authToken" => token)
|
6
|
+
def self.included base
|
7
|
+
base.define_action :search, :get, "get",
|
8
|
+
:auth_token => true,
|
9
|
+
:format => true
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
data/lib/citygrid/api.rb
CHANGED
@@ -4,14 +4,13 @@ require "json"
|
|
4
4
|
class CityGrid
|
5
5
|
class API
|
6
6
|
include HTTParty
|
7
|
-
format :json
|
8
7
|
#debug_output $stderr
|
9
8
|
|
10
9
|
DEFAULT_HEADERS = {
|
11
10
|
"Accept" => "application/json",
|
12
11
|
"Content-Type" => "Application/JSON"}
|
13
12
|
|
14
|
-
|
13
|
+
DEFAULT_ACTION_OPTIONS = {
|
15
14
|
:auth_token => false,
|
16
15
|
:format => true,
|
17
16
|
:publisher => false,
|
@@ -26,8 +25,8 @@ class CityGrid
|
|
26
25
|
# ip: pass IP, needed for content
|
27
26
|
# format: pass JSON flag
|
28
27
|
|
29
|
-
define_options =
|
30
|
-
|
28
|
+
define_options = DEFAULT_ACTION_OPTIONS.merge define_options
|
29
|
+
|
31
30
|
define_singleton_method name.intern do |*args|
|
32
31
|
options = args.first.clone || {}
|
33
32
|
params = {}
|
@@ -36,7 +35,7 @@ class CityGrid
|
|
36
35
|
|
37
36
|
headers = API::DEFAULT_HEADERS.clone
|
38
37
|
|
39
|
-
headers.merge! "authToken" => token if define_options[:auth_token]
|
38
|
+
headers.merge! "authToken" => token if define_options[:auth_token] && token
|
40
39
|
|
41
40
|
options.merge! "format" => "json" if define_options[:format]
|
42
41
|
options.merge! "publisher" => CityGrid.publisher if define_options[:publisher]
|
@@ -91,66 +90,77 @@ class CityGrid
|
|
91
90
|
http_method = HTTP_METHODS[http_method.to_s]
|
92
91
|
raise "Unknown http method: #{http_method}" unless http_method
|
93
92
|
end
|
94
|
-
|
93
|
+
|
95
94
|
req_options = default_options.dup
|
96
95
|
req_options = req_options.merge(options)
|
97
|
-
|
96
|
+
|
97
|
+
raise ConfigurationError.new "No endpoint defined" if !path || path.empty?
|
98
|
+
raise ConfigurationError.new "No hostname defined" if !req_options[:base_uri] || req_options[:base_uri].empty?
|
99
|
+
|
98
100
|
req = HTTParty::Request.new http_method, path, req_options
|
99
|
-
error = nil
|
100
101
|
|
101
|
-
|
102
|
+
|
103
|
+
begin
|
102
104
|
response = req.perform
|
103
105
|
rescue => ex
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
error = ex
|
109
|
-
end
|
110
|
-
|
111
|
-
if defined?(Rails.logger)
|
112
|
-
Rails.logger.info req.to_curl
|
113
|
-
else
|
114
|
-
puts req.to_curl
|
115
|
-
end
|
116
|
-
|
117
|
-
unless error
|
118
|
-
if !response.parsed_response.is_a?(Hash)
|
119
|
-
error = InvalidResponseFormat.new response
|
120
|
-
elsif response["errors"]
|
121
|
-
error = Error.new response["errors"], response
|
106
|
+
raise RequestError.new req, ex
|
107
|
+
ensure
|
108
|
+
if defined?(Rails.logger)
|
109
|
+
Rails.logger.info req.to_curl
|
122
110
|
else
|
123
|
-
|
111
|
+
puts req.to_curl
|
124
112
|
end
|
125
113
|
end
|
126
114
|
|
127
|
-
if
|
128
|
-
|
129
|
-
|
130
|
-
|
115
|
+
if !response.parsed_response.is_a?(Hash)
|
116
|
+
raise ResponseParseError.new req, response
|
117
|
+
elsif response["errors"]
|
118
|
+
raise ResponseError.new req, response["errors"], response
|
119
|
+
elsif response["message"] && response["message"] == "Invalid Token or Expired"
|
120
|
+
raise InvalidAuthToken.new
|
121
|
+
else
|
122
|
+
return CityGrid::API::Response.new response
|
131
123
|
end
|
124
|
+
|
125
|
+
rescue => ex
|
126
|
+
raise ex if CityGrid.raise_errors?
|
132
127
|
end
|
133
128
|
end
|
134
129
|
|
135
130
|
# ERRORS
|
136
|
-
class
|
137
|
-
|
138
|
-
|
139
|
-
def initialize msg,
|
140
|
-
|
141
|
-
@httparty = response
|
131
|
+
class APIError < StandardError
|
132
|
+
attr_accessor :request
|
133
|
+
|
134
|
+
def initialize msg, request
|
135
|
+
super msg
|
142
136
|
end
|
143
137
|
end
|
144
|
-
|
145
|
-
class
|
146
|
-
|
147
|
-
|
138
|
+
|
139
|
+
class ResponseError < APIError
|
140
|
+
attr_accessor :errors, :response
|
141
|
+
|
142
|
+
def initialize request, errors, response
|
143
|
+
self.errors = errors
|
144
|
+
self.response = response
|
145
|
+
|
146
|
+
super "API returned error message", request
|
148
147
|
end
|
149
148
|
end
|
150
|
-
|
151
|
-
class
|
152
|
-
attr_accessor :
|
153
|
-
|
149
|
+
|
150
|
+
class RequestError < APIError
|
151
|
+
attr_accessor :inner_exception
|
152
|
+
|
153
|
+
def initialize request, inner_exception, msg = nil
|
154
|
+
self.inner_exception = inner_exception
|
155
|
+
self.request = request
|
156
|
+
super msg || "Error while performing request: #{inner_exception.message}", request
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class ResponseParseError < APIError
|
161
|
+
attr_accessor :server_msg, :description, :raw_response
|
162
|
+
def initialize request, response
|
163
|
+
self.raw_response = response
|
154
164
|
# parse Tomcat error report
|
155
165
|
if response.match /<title>Apache Tomcat.* - Error report<\/title>/
|
156
166
|
response.scan(/<p><b>(message|description)<\/b> *<u>(.*?)<\/u><\/p>/).each do |match|
|
@@ -168,24 +178,32 @@ class CityGrid
|
|
168
178
|
Unexpected response format. Expected response to be a hash, but was instead:\n#{error_body}\n
|
169
179
|
EOS
|
170
180
|
|
171
|
-
super msg,
|
181
|
+
super msg, request
|
172
182
|
else
|
173
183
|
msg = <<-EOS
|
174
184
|
Unexpected response format. Expected response to be a hash, but was instead:\n#{response.parsed_response}\n
|
175
185
|
EOS
|
176
186
|
|
177
|
-
super msg,
|
187
|
+
super msg, request
|
178
188
|
end
|
179
189
|
end
|
180
190
|
end
|
181
191
|
|
182
|
-
class
|
183
|
-
def initialize
|
192
|
+
class InvalidAuthToken < StandardError
|
193
|
+
def initialize message = "Invalid Token or Expired"
|
184
194
|
super message
|
185
195
|
end
|
196
|
+
end
|
186
197
|
|
187
|
-
|
188
|
-
|
198
|
+
class MissingAuthToken < StandardError
|
199
|
+
def initialize
|
200
|
+
super "Missing authToken - token is required"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
class ConfigurationError < StandardError
|
205
|
+
def initialize message = "Invalid Configuration"
|
206
|
+
super message
|
189
207
|
end
|
190
208
|
end
|
191
209
|
end
|
data/lib/citygrid/session.rb
CHANGED
@@ -26,19 +26,15 @@ class CityGrid
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def login username, password
|
29
|
-
res = CityGrid::API::Accounts::
|
29
|
+
res = CityGrid::API::Accounts::User.login :username => username, :password => password
|
30
30
|
self.username = username
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
|
33
|
+
self.auth_token = res.authToken
|
34
|
+
if !auth_token.nil? && auth_token != ""
|
35
35
|
self.logged_in = true
|
36
|
-
# puts "logged in ok"
|
37
|
-
when 400
|
38
|
-
# puts "error"
|
39
|
-
else
|
40
|
-
# puts "unexpected response code"
|
41
36
|
end
|
37
|
+
|
42
38
|
end
|
43
39
|
|
44
40
|
def call_api klass, action, options = {}
|
data/lib/citygrid.rb
CHANGED
@@ -16,7 +16,25 @@ class CityGrid
|
|
16
16
|
raise PublisherNotConfigured if !defined?(@publisher) || @publisher.nil?
|
17
17
|
@publisher
|
18
18
|
end
|
19
|
+
|
20
|
+
# whether api calls will throw errors or fail silently
|
21
|
+
# by default, we will raise errors
|
22
|
+
def raise_errors= v
|
23
|
+
@raise_errors = v
|
24
|
+
end
|
25
|
+
|
26
|
+
def raise_errors?
|
27
|
+
!defined?(@raise_errors) || @raise_errors
|
28
|
+
end
|
19
29
|
|
30
|
+
def use_vcr= v
|
31
|
+
@use_vcr = v
|
32
|
+
end
|
33
|
+
|
34
|
+
def use_vcr?
|
35
|
+
defined?(VCR) && defined?(@use_vcr) && @use_vcr
|
36
|
+
end
|
37
|
+
|
20
38
|
def search opts = {}
|
21
39
|
Search.new opts
|
22
40
|
end
|
@@ -70,11 +88,13 @@ class CityGrid
|
|
70
88
|
# if hostname is set, use it
|
71
89
|
# otherwise if ssl is set then use ssl_hostname. fallback to default_hostname
|
72
90
|
hostname = v["hostname"] || (v["ssl"] ? ssl_hostname : default_hostname)
|
91
|
+
throw ParseConfigurationError.new file_path, "No endpoint defined for #{k}" unless v["endpoint"]
|
73
92
|
endpoint = v["endpoint"].start_with?("/") ? v["endpoint"] : "/#{v["endpoint"]}"
|
74
93
|
klass.endpoint endpoint
|
75
94
|
klass.base_uri hostname
|
76
95
|
else
|
77
96
|
# should not get here. value should be String or Hash
|
97
|
+
throw ParseConfigurationError.new file_path, "Invalid value type for #{k}"
|
78
98
|
end
|
79
99
|
|
80
100
|
# puts "#{klass.name} => #{klass.base_uri} : #{klass.endpoint}"
|
@@ -96,13 +116,20 @@ class CityGrid
|
|
96
116
|
super "Endpoint is not properly configured. Run 'CityGrid.load_config'"
|
97
117
|
end
|
98
118
|
end
|
119
|
+
|
120
|
+
class ParseConfigurationError < StandardError
|
121
|
+
def initialize path, msg = nil
|
122
|
+
super msg ? "#{msg} at '#{path}'" : "Error parsing configuration file at '#{path}'"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
99
126
|
end
|
100
127
|
|
101
128
|
require "citygrid/abstraction"
|
102
129
|
require "citygrid/api"
|
103
130
|
require "yaml"
|
104
131
|
|
105
|
-
require "citygrid/api/
|
132
|
+
require "citygrid/api/mutable"
|
106
133
|
require "citygrid/api/searchable"
|
107
134
|
|
108
135
|
require "citygrid/search"
|
@@ -19,7 +19,7 @@ context "search for an account" do
|
|
19
19
|
run_with_rescue do
|
20
20
|
SessionHelper.sales_coord.call_api CityGrid::API::Accounts::Account,
|
21
21
|
:search,
|
22
|
-
:id
|
22
|
+
:id => 1250702
|
23
23
|
end
|
24
24
|
end
|
25
25
|
should("not be empty"){ !topic.empty? }
|
@@ -57,9 +57,9 @@ context "import a cg account" do
|
|
57
57
|
"phone" => "9001111112",
|
58
58
|
"businessName" =>"businessProveApi",
|
59
59
|
"address1" =>"dir-api",
|
60
|
-
"city"
|
61
|
-
"state"
|
62
|
-
"zipCode"
|
60
|
+
"city" =>"montevideo",
|
61
|
+
"state" =>"Montevideo",
|
62
|
+
"zipCode" =>"90069"
|
63
63
|
}
|
64
64
|
}]
|
65
65
|
end
|
@@ -72,38 +72,59 @@ end
|
|
72
72
|
context "create an account" do
|
73
73
|
set :vcr, false
|
74
74
|
|
75
|
-
username = "randuser_#{rand(10000000)}"
|
75
|
+
username = "randuser_9178989" # "randuser_#{rand(10000000)}"
|
76
|
+
email = "#{username}@a.com"
|
76
77
|
password = "randuserpass"
|
77
78
|
|
78
|
-
setup do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
should("not be empty"){ !topic.empty? }
|
99
|
-
should("return message OK"){ topic.accountList.first.response.message }.equals("OK")
|
100
|
-
should("return response code OK"){ topic.accountList.first.response.code.to_i }.equals(200)
|
101
|
-
|
102
|
-
context "then logging in" do
|
79
|
+
# setup do
|
80
|
+
# SessionHelper.sales_coord.call_api CityGrid::API::Accounts::Account,
|
81
|
+
# :mutate,
|
82
|
+
# "mutateOperationListResource" => [{
|
83
|
+
# "operator" => "ADD",
|
84
|
+
# "operand" => {
|
85
|
+
# "firstName" => "nico-api",
|
86
|
+
# "lastName" => "gomez-api",
|
87
|
+
# "phone" => "9001111112",
|
88
|
+
# "email" => email,
|
89
|
+
# "userName" => username,
|
90
|
+
# "password" => password,
|
91
|
+
# "businessName" => "businessProveApi",
|
92
|
+
# "address1" => "dir-api",
|
93
|
+
# "city" => "montevideo",
|
94
|
+
# "state" => "Montevideo",
|
95
|
+
# "zipCode" => "90069"
|
96
|
+
# }
|
97
|
+
# }]
|
98
|
+
# end
|
99
|
+
# should("not be empty"){ !topic.empty? }
|
100
|
+
# should("return message OK"){ topic.accountList.first.response.message }.equals("OK")
|
101
|
+
# should("return response code OK"){ topic.accountList.first.response.code.to_i }.equals(200)
|
102
|
+
#
|
103
|
+
# context "then logging in" do
|
104
|
+
# setup do
|
105
|
+
# CityGrid.login :username => username, :password => password
|
106
|
+
# end
|
107
|
+
# should("return an authToken"){ topic.authToken }
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# context "then validate with session" do
|
111
|
+
# setup do
|
112
|
+
# session = CityGrid.session username, password
|
113
|
+
# session.call_api CityGrid::API::Accounts::User, :validate, :oauth_token => session.auth_token
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# should("match on display_name") { topic.display_name }.equals(username)
|
117
|
+
# should("match on email") { topic.email }.equals(email)
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
context "then validate with raw API" do
|
103
121
|
setup do
|
104
|
-
CityGrid.
|
122
|
+
session = CityGrid.session username, password
|
123
|
+
CityGrid::API::Accounts::User.validate :oauth_token => session.auth_token
|
105
124
|
end
|
106
|
-
|
125
|
+
|
126
|
+
should("match on display_name") { topic.display_name }.equals(username)
|
127
|
+
should("match on email") { topic.email }.equals(email)
|
107
128
|
end
|
108
129
|
|
109
130
|
end
|
@@ -1,50 +1,47 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
|
2
2
|
|
3
|
-
context "
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:accountId => 111
|
10
|
-
end
|
3
|
+
context "search for mop by account_id" do
|
4
|
+
setup do
|
5
|
+
run_with_rescue do
|
6
|
+
SessionHelper.kunimom.call_api CityGrid::API::Accounts::MethodOfPayment,
|
7
|
+
:search,
|
8
|
+
:accountId => 111
|
11
9
|
end
|
12
|
-
should("not be empty"){ !topic.empty?}
|
13
|
-
should("have MOP resources"){ !topic.mopResources.empty? }
|
14
10
|
end
|
11
|
+
should("not be empty"){ !topic.empty?}
|
12
|
+
should("have MOP resources"){ !topic.mopResources.empty? }
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
"
|
23
|
-
|
24
|
-
"
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}]
|
44
|
-
end
|
15
|
+
context "create a mop" do
|
16
|
+
setup do
|
17
|
+
run_with_rescue do
|
18
|
+
SessionHelper.kunimom.call_api CityGrid::API::Accounts::MethodOfPayment,
|
19
|
+
:mutate,
|
20
|
+
"mutateOperationListResource" => [{
|
21
|
+
"operator" => "ADD",
|
22
|
+
"operand" => {
|
23
|
+
"cardNumber" => "4112344112344113",
|
24
|
+
"expirationMonth" => 12,
|
25
|
+
"expirationYear" => 2012,
|
26
|
+
"nameOnAccount" => "Ara Tatous",
|
27
|
+
"cardType" => "Visa",
|
28
|
+
"state" => "NY" ,
|
29
|
+
"description" => "test addMOP",
|
30
|
+
"firstName" => "Ara",
|
31
|
+
"lastName" => "Tatous",
|
32
|
+
"phoneNumber" => "4252838811",
|
33
|
+
"address1" => "3131 Montrose Ave",
|
34
|
+
"address2" => "Apt. 9",
|
35
|
+
"city" => "LaCrescenta",
|
36
|
+
"postalCode" => "10016",
|
37
|
+
"accountId" => 2458392,
|
38
|
+
"securityCode" => "719",
|
39
|
+
"paymentType" => "Credit Card"
|
40
|
+
}
|
41
|
+
}]
|
45
42
|
end
|
46
|
-
should("not be empty"){ !topic.empty? }
|
47
|
-
should("return code OK"){ topic.resources.first.response.code }.equals(200)
|
48
|
-
should("return message OK") { topic.resources.first.response.message }.equals("OK")
|
49
43
|
end
|
50
|
-
|
44
|
+
should("not be empty"){ !topic.empty? }
|
45
|
+
should("return code OK"){ topic.resources.first.response.code }.equals(200)
|
46
|
+
should("return message OK") { topic.resources.first.response.message }.equals("OK")
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'helper'))
|
2
|
+
|
3
|
+
context "user log in with raw API" do
|
4
|
+
setup do
|
5
|
+
CityGrid.login :username => "GARYTEST", :password => 'pppppp'
|
6
|
+
end
|
7
|
+
should("return an authToken"){ topic.authToken }
|
8
|
+
end
|
9
|
+
|
10
|
+
context "user log in with session" do
|
11
|
+
setup do
|
12
|
+
CityGrid.session "GARYTEST", "pppppp"
|
13
|
+
end
|
14
|
+
should("have an auth_token"){ topic.auth_token }
|
15
|
+
should("be logged in"){ topic.logged_in? }
|
16
|
+
end
|