sweettooth 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/sweettooth.rb +2 -2
- data/lib/sweettooth/spending.rb +15 -0
- data/lib/sweettooth/{redemption_option.rb → spending_option.rb} +1 -1
- data/lib/sweettooth/util.rb +2 -2
- data/lib/sweettooth/version.rb +1 -1
- data/test/sweettooth/spending_option_test.rb +14 -0
- data/test/sweettooth/spending_test.rb +13 -0
- data/test/test_helper.rb +13 -14
- metadata +8 -9
- data/lib/sweettooth/account.rb +0 -4
- data/lib/sweettooth/redemption.rb +0 -5
- data/test/sweettooth/redemption_option_test.rb +0 -14
- data/test/sweettooth/redemption_test.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e81152b64a5d4b1fe3d53b305e10678cd950cb67
|
4
|
+
data.tar.gz: e24c57e01f87da3b45b9b56c9150770845d5f57c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161641d081452aee9091542352a86d66182137b22399636860ec92f3675435afbcaea839a67f265aed53af6dd141b51d023bd095fb90dee58291c135561427ba
|
7
|
+
data.tar.gz: a2b458d3e585c2ea8556f6900e68421723dc7cff86606f9cbf12c098e0ad46c6f6112beeb795eba7aeb98c753c301f5227926b8cada7e23894382e0ec22aaf95
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/lib/sweettooth.rb
CHANGED
@@ -25,8 +25,8 @@ require 'sweettooth/singleton_api_resource'
|
|
25
25
|
require 'sweettooth/collection_object'
|
26
26
|
require 'sweettooth/activity'
|
27
27
|
require 'sweettooth/customer'
|
28
|
-
require 'sweettooth/
|
29
|
-
require 'sweettooth/
|
28
|
+
require 'sweettooth/spending'
|
29
|
+
require 'sweettooth/spending_option'
|
30
30
|
|
31
31
|
# Errors
|
32
32
|
require 'sweettooth/errors/sweettooth_error'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SweetTooth
|
2
|
+
class Spending < APIResource
|
3
|
+
include SweetTooth::APIOperations::Create
|
4
|
+
|
5
|
+
def cancel()
|
6
|
+
response, api_key = SweetTooth.request(:post, cancel_url, @api_key)
|
7
|
+
refresh_from(response, api_key)
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
def cancel_url
|
12
|
+
url + '/cancel'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/sweettooth/util.rb
CHANGED
@@ -19,8 +19,8 @@ module SweetTooth
|
|
19
19
|
@object_classes ||= {
|
20
20
|
'activity' => Activity,
|
21
21
|
'customer' => Customer,
|
22
|
-
'
|
23
|
-
'
|
22
|
+
'spending' => Spending,
|
23
|
+
'spending_option' => SpendingOption,
|
24
24
|
'collection' => CollectionObject,
|
25
25
|
}
|
26
26
|
end
|
data/lib/sweettooth/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module SweetTooth
|
4
|
+
class SpendingOptionTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should "spending options should be listable" do
|
7
|
+
@mock.expects(:get).once.returns(test_response(test_spending_option_array))
|
8
|
+
c = SweetTooth::SpendingOption.all.items
|
9
|
+
assert c.kind_of? Array
|
10
|
+
assert c[0].kind_of? SweetTooth::SpendingOption
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module SweetTooth
|
4
|
+
class SpendingTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
should "create should return a new spending" do
|
7
|
+
@mock.expects(:post).once.returns(test_response(test_spending))
|
8
|
+
r = SweetTooth::Spending.create
|
9
|
+
assert_equal "spe_test_spending", r.id
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -72,13 +72,12 @@ def test_activity(params={})
|
|
72
72
|
}.merge(params)
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def test_spending(params={})
|
76
76
|
{
|
77
|
-
:_object => "
|
78
|
-
:id => "
|
77
|
+
:_object => "spending",
|
78
|
+
:id => "spe_test_spending",
|
79
79
|
:customer_id => "cus_test_customer",
|
80
|
-
:
|
81
|
-
:redemption_option_id => "rop_test_redemption_option",
|
80
|
+
:spending_option_id => "spo_test_spending_option",
|
82
81
|
:status => "completed",
|
83
82
|
:comment => nil,
|
84
83
|
:created => "2014-01-14T19:25:32.000Z",
|
@@ -86,23 +85,23 @@ def test_redemption(params={})
|
|
86
85
|
}.merge(params)
|
87
86
|
end
|
88
87
|
|
89
|
-
def
|
88
|
+
def test_spending_option(params={})
|
90
89
|
{
|
91
|
-
:_object => "
|
92
|
-
:id => "
|
93
|
-
:
|
94
|
-
:name => "
|
95
|
-
:description => "Spend 100 points to receive
|
90
|
+
:_object => "spending_option",
|
91
|
+
:id => "spo_test_spending_option",
|
92
|
+
:readable_id => "gift_item",
|
93
|
+
:name => "Gift Item",
|
94
|
+
:description => "Spend 100 points to receive an exclusive gift package",
|
96
95
|
:created => "2014-01-14T17:25:32.000Z",
|
97
96
|
:updated => "2014-01-14T17:25:32.000Z"
|
98
97
|
}.merge(params)
|
99
98
|
end
|
100
99
|
|
101
|
-
def
|
100
|
+
def test_spending_option_array
|
102
101
|
{
|
103
|
-
:items => [
|
102
|
+
:items => [test_spending_option, test_spending_option, test_spending_option],
|
104
103
|
:_object => 'collection',
|
105
|
-
:url => '/v1/
|
104
|
+
:url => '/v1/spending_options'
|
106
105
|
}
|
107
106
|
end
|
108
107
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweettooth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Curtis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -133,7 +133,6 @@ files:
|
|
133
133
|
- gemfiles/json.gemfile
|
134
134
|
- gemfiles/yajl.gemfile
|
135
135
|
- lib/sweettooth.rb
|
136
|
-
- lib/sweettooth/account.rb
|
137
136
|
- lib/sweettooth/activity.rb
|
138
137
|
- lib/sweettooth/api_operations/create.rb
|
139
138
|
- lib/sweettooth/api_operations/delete.rb
|
@@ -148,17 +147,17 @@ files:
|
|
148
147
|
- lib/sweettooth/errors/invalid_request_error.rb
|
149
148
|
- lib/sweettooth/errors/sweettooth_error.rb
|
150
149
|
- lib/sweettooth/json.rb
|
151
|
-
- lib/sweettooth/redemption.rb
|
152
|
-
- lib/sweettooth/redemption_option.rb
|
153
150
|
- lib/sweettooth/singleton_api_resource.rb
|
151
|
+
- lib/sweettooth/spending.rb
|
152
|
+
- lib/sweettooth/spending_option.rb
|
154
153
|
- lib/sweettooth/sweettooth_object.rb
|
155
154
|
- lib/sweettooth/util.rb
|
156
155
|
- lib/sweettooth/version.rb
|
157
156
|
- sweettooth.gemspec
|
158
157
|
- test/sweettooth/activity_test.rb
|
159
158
|
- test/sweettooth/customer_test.rb
|
160
|
-
- test/sweettooth/
|
161
|
-
- test/sweettooth/
|
159
|
+
- test/sweettooth/spending_option_test.rb
|
160
|
+
- test/sweettooth/spending_test.rb
|
162
161
|
- test/test_helper.rb
|
163
162
|
homepage: https://www.sweettoothrewards.com/api
|
164
163
|
licenses: []
|
@@ -186,7 +185,7 @@ summary: Ruby bindings for the Sweet Tooth API
|
|
186
185
|
test_files:
|
187
186
|
- test/sweettooth/activity_test.rb
|
188
187
|
- test/sweettooth/customer_test.rb
|
189
|
-
- test/sweettooth/
|
190
|
-
- test/sweettooth/
|
188
|
+
- test/sweettooth/spending_option_test.rb
|
189
|
+
- test/sweettooth/spending_test.rb
|
191
190
|
- test/test_helper.rb
|
192
191
|
has_rdoc:
|
data/lib/sweettooth/account.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module SweetTooth
|
4
|
-
class RedemptionOptionTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
should "redemption options should be listable" do
|
7
|
-
@mock.expects(:get).once.returns(test_response(test_redemption_option_array))
|
8
|
-
c = SweetTooth::RedemptionOption.all.items
|
9
|
-
assert c.kind_of? Array
|
10
|
-
assert c[0].kind_of? SweetTooth::RedemptionOption
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module SweetTooth
|
4
|
-
class RedemptionTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
should "create should return a new redemption" do
|
7
|
-
@mock.expects(:post).once.returns(test_response(test_redemption))
|
8
|
-
r = SweetTooth::Redemption.create
|
9
|
-
assert_equal "red_test_redemption", r.id
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|