dropwallet 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dropwallet.rb +3 -0
- data/lib/dropwallet/core/cart.rb +39 -0
- data/lib/dropwallet/core/model.rb +5 -7
- data/lib/dropwallet/core/user.rb +6 -0
- data/lib/dropwallet/version.rb +1 -1
- data/test/testCarts.rb +18 -0
- data/test/testOrders.rb +1 -0
- data/test/testProduct.rb +12 -18
- data/test/testUser.rb +15 -1
- metadata +4 -3
- data/lib/dropwallet/core/cartItem.rb +0 -3
data/lib/dropwallet.rb
CHANGED
@@ -5,6 +5,9 @@ require "dropwallet/core/model"
|
|
5
5
|
require "dropwallet/core/user"
|
6
6
|
require "dropwallet/core/product"
|
7
7
|
require "dropwallet/core/order"
|
8
|
+
require "dropwallet/core/cart"
|
9
|
+
require "dropwallet/core/address"
|
10
|
+
require "dropwallet/core/paymentMethod"
|
8
11
|
|
9
12
|
#CDN Web Services
|
10
13
|
require "dropwallet/cdn/file"
|
data/lib/dropwallet/core/cart.rb
CHANGED
@@ -1,3 +1,42 @@
|
|
1
1
|
class Dropwallet::Core::Cart < Dropwallet::Core::Model
|
2
|
+
field :cartId
|
3
|
+
field :cartRefNum
|
4
|
+
field :subtotal
|
5
|
+
field :grandtotal
|
6
|
+
field :taxtotal
|
7
|
+
field :shippingtotal
|
8
|
+
field :items
|
9
|
+
field :shippingAddressId
|
10
|
+
field :paymentMethodId
|
2
11
|
|
12
|
+
#Adds an item to the current cart.
|
13
|
+
def addItem(item)
|
14
|
+
options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/carts/#{cartId}/items"}
|
15
|
+
doc = JSON.parse(RestClient.post(options[:path], item, {:accept => :json }))
|
16
|
+
return doc
|
17
|
+
end
|
18
|
+
|
19
|
+
#Merges a cookie cart with a user cart, returns the ID of the newly merged user cart.
|
20
|
+
def merge(userId)
|
21
|
+
options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/carts/#{cartId}/mergecart/#{userId}"}
|
22
|
+
doc = JSON.parse(RestClient.post(options[:path], item, {:accept => :json }))
|
23
|
+
return doc['cartId']
|
24
|
+
end
|
25
|
+
|
26
|
+
#Override the default behavior for Shipping Address ID
|
27
|
+
def shippingAddressId
|
28
|
+
if self.attributes.include? 'shippingAddressId'
|
29
|
+
return self.attributes['shippingAddressId']
|
30
|
+
else
|
31
|
+
return 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
#Override the default behavior for Payment Method ID
|
35
|
+
def paymentMethodId
|
36
|
+
if self.attributes.include? 'paymentMethodId'
|
37
|
+
return self.attributes['paymentMethodId']
|
38
|
+
else
|
39
|
+
return 0
|
40
|
+
end
|
41
|
+
end
|
3
42
|
end
|
@@ -102,7 +102,6 @@ class Dropwallet::Core::Model
|
|
102
102
|
defaults = {:path => "#{serviceUrl}"}
|
103
103
|
options.merge(defaults)
|
104
104
|
options[:path] = (options[:path] << "?page=1&limit=1")
|
105
|
-
puts options[:path]
|
106
105
|
doc = JSON.parse(RestClient.get(options[:path], {:accept => :json}))
|
107
106
|
if doc.include? 'errorMessage'
|
108
107
|
raise doc['errorMessage']
|
@@ -114,7 +113,6 @@ class Dropwallet::Core::Model
|
|
114
113
|
defaults = {:path => "#{serviceUrl}"}
|
115
114
|
options.merge(defaults)
|
116
115
|
options[:path] = (options[:path] << "?page=1&limit=20")
|
117
|
-
puts options[:path]
|
118
116
|
doc = JSON.parse(RestClient.get(options[:path], {:accept => :json}))
|
119
117
|
if doc.include? 'errorMessage'
|
120
118
|
raise doc['errorMessage']
|
@@ -126,9 +124,9 @@ class Dropwallet::Core::Model
|
|
126
124
|
unless isNew?
|
127
125
|
return update
|
128
126
|
end
|
129
|
-
defaults = {:path => "#{serviceUrl}"}
|
127
|
+
defaults = {:path => "#{self.class.serviceUrl}"}
|
130
128
|
defaults.merge(options)
|
131
|
-
item = JSON.parse(RestClient.post(defaults[:path].strip, to_json, {:accept => :json}))
|
129
|
+
item = JSON.parse(RestClient.post(defaults[:path].strip, to_json, {:accept => :json, :'content-type'=> 'application/json'}))
|
132
130
|
if item.include? 'errorMessage'
|
133
131
|
raise item['errorMessage']
|
134
132
|
end
|
@@ -140,13 +138,13 @@ class Dropwallet::Core::Model
|
|
140
138
|
if isNew?
|
141
139
|
return save
|
142
140
|
end
|
143
|
-
defaults = {:path => "#{serviceUrl}/#{id}"}
|
141
|
+
defaults = {:path => "#{self.class.serviceUrl}/#{id}"}
|
144
142
|
defaults.merge(options)
|
145
|
-
return JSON.parse(RestClient.put(defaults[:path].strip,
|
143
|
+
return JSON.parse(RestClient.put(defaults[:path].strip, @attributes, {:accept => :json}))#, :'content-type'=> 'application/json'}))
|
146
144
|
end
|
147
145
|
|
148
146
|
def delete(options={})
|
149
|
-
defaults = {:path => "#{serviceUrl}/#{id}"}
|
147
|
+
defaults = {:path => "#{self.class.serviceUrl}/#{id}"}
|
150
148
|
defaults.merge(options)
|
151
149
|
item = JSON.parse(RestClient.delete(defaults[:path].strip, {:accept => :json}))
|
152
150
|
if item.include? 'errorMessage'
|
data/lib/dropwallet/core/user.rb
CHANGED
@@ -5,6 +5,12 @@ class Dropwallet::Core::User < Dropwallet::Core::Model
|
|
5
5
|
field :password
|
6
6
|
field :firstName
|
7
7
|
field :lastName
|
8
|
+
field :phoneNumber
|
9
|
+
|
10
|
+
#only used for password updating
|
11
|
+
field :currentPassword
|
12
|
+
field :newPassword
|
13
|
+
field :confirmPassword
|
8
14
|
|
9
15
|
def orders(page = 1)
|
10
16
|
options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders.json"}
|
data/lib/dropwallet/version.rb
CHANGED
data/test/testCarts.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'dropwallet'
|
3
|
+
|
4
|
+
class TestCarts < Test::Unit::TestCase
|
5
|
+
def testCarts
|
6
|
+
RestClient.log = "stdout" #{}"/dev/null"
|
7
|
+
Dropwallet::username = 'dropwallet'
|
8
|
+
Dropwallet::password = 'icuetv789'
|
9
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
10
|
+
cart = Dropwallet::Core::Cart.new()
|
11
|
+
cart.save
|
12
|
+
item = {:productId=>'250845', :quantity=> 1}
|
13
|
+
cart.addItem(item)
|
14
|
+
cart = Dropwallet::Core::Cart.find(cart.cartId)
|
15
|
+
puts 'CART--'
|
16
|
+
puts cart.to_s
|
17
|
+
end
|
18
|
+
end
|
data/test/testOrders.rb
CHANGED
@@ -6,6 +6,7 @@ class TestOrders < Test::Unit::TestCase
|
|
6
6
|
RestClient.log = "/dev/null"
|
7
7
|
Dropwallet::username = 'dropwallet'
|
8
8
|
Dropwallet::password = 'icuetv789'
|
9
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
9
10
|
user1 = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
10
11
|
items = user1.orders
|
11
12
|
puts 'ORDERS'
|
data/test/testProduct.rb
CHANGED
@@ -1,20 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'dropwallet'
|
3
3
|
|
4
|
-
|
4
|
+
class TestProduct < Test::Unit::TestCase
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# Dropwallet::username = 'dropwallet'
|
16
|
-
# Dropwallet::password = 'icuetv789'
|
17
|
-
# products = Dropwallet::Core::Product.all
|
18
|
-
# assert_not_nil products
|
19
|
-
# end
|
20
|
-
# end
|
6
|
+
def testFind
|
7
|
+
RestClient.log = "stdout"
|
8
|
+
Dropwallet::username = 'dropwallet'
|
9
|
+
Dropwallet::password = 'icuetv789'
|
10
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
11
|
+
product = Dropwallet::Core::Product.find(250845)
|
12
|
+
assert_not_nil product
|
13
|
+
end
|
14
|
+
end
|
data/test/testUser.rb
CHANGED
@@ -11,9 +11,22 @@ class TestUser < Test::Unit::TestCase
|
|
11
11
|
assert_equal Dropwallet::Core::User.create().valid?, false
|
12
12
|
end
|
13
13
|
|
14
|
+
def testUpdate
|
15
|
+
Dropwallet::username = 'dropwallet'
|
16
|
+
Dropwallet::password = 'icuetv789'
|
17
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
18
|
+
user = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
19
|
+
user.firstName = 'Random'
|
20
|
+
puts 'USER UPDATE!!'
|
21
|
+
user.update
|
22
|
+
user = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
23
|
+
assert_equal user.firstName, 'Random'
|
24
|
+
end
|
25
|
+
|
14
26
|
def testLogin
|
15
27
|
Dropwallet::username = 'dropwallet'
|
16
28
|
Dropwallet::password = 'icuetv789'
|
29
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
17
30
|
userId = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
18
31
|
assert_not_nil userId
|
19
32
|
end
|
@@ -22,6 +35,7 @@ class TestUser < Test::Unit::TestCase
|
|
22
35
|
#RestClient.log = "stdout"
|
23
36
|
Dropwallet::username = 'dropwallet'
|
24
37
|
Dropwallet::password = 'icuetv789'
|
38
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
25
39
|
user1 = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
26
40
|
user2 = Dropwallet::Core::User.find(user1.id)
|
27
41
|
assert_not_nil user2
|
@@ -31,12 +45,12 @@ class TestUser < Test::Unit::TestCase
|
|
31
45
|
RestClient.log = "/dev/null"
|
32
46
|
Dropwallet::username = 'dropwallet'
|
33
47
|
Dropwallet::password = 'icuetv789'
|
48
|
+
Dropwallet::apiUrl = 'http://10.0.1.41:8080/core/restful'
|
34
49
|
user1 = Dropwallet::Core::User.login('customer0000@icuetv.com','password')
|
35
50
|
items = user1.orders
|
36
51
|
puts 'ORDERS'
|
37
52
|
items.each do |item|
|
38
53
|
order = user1.order(item.orderId)
|
39
|
-
puts order.to_s
|
40
54
|
end
|
41
55
|
puts "Pages: #{user1.ordersPages}"
|
42
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropwallet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -94,13 +94,13 @@ files:
|
|
94
94
|
- lib/dropwallet/cdn/file.rb
|
95
95
|
- lib/dropwallet/core/address.rb
|
96
96
|
- lib/dropwallet/core/cart.rb
|
97
|
-
- lib/dropwallet/core/cartItem.rb
|
98
97
|
- lib/dropwallet/core/model.rb
|
99
98
|
- lib/dropwallet/core/order.rb
|
100
99
|
- lib/dropwallet/core/paymentMethod.rb
|
101
100
|
- lib/dropwallet/core/product.rb
|
102
101
|
- lib/dropwallet/core/user.rb
|
103
102
|
- lib/dropwallet/version.rb
|
103
|
+
- test/testCarts.rb
|
104
104
|
- test/testCdnFile.rb
|
105
105
|
- test/testOrders.rb
|
106
106
|
- test/testProduct.rb
|
@@ -131,6 +131,7 @@ signing_key:
|
|
131
131
|
specification_version: 3
|
132
132
|
summary: Dropwallet API Bindings for Ruby
|
133
133
|
test_files:
|
134
|
+
- test/testCarts.rb
|
134
135
|
- test/testCdnFile.rb
|
135
136
|
- test/testOrders.rb
|
136
137
|
- test/testProduct.rb
|