queenbee 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/queenbee.rb +1 -0
- data/lib/queenbee/api_operations/delete.rb +17 -0
- data/lib/queenbee/order.rb +1 -0
- data/lib/queenbee/version.rb +1 -1
- data/test/queenbee/order_test.rb +34 -29
- data/test/test_helper.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c818cd545702cbf87b04e8094599829ec4ce906
|
4
|
+
data.tar.gz: ed89bc29b903786697be10f5008c260676cacef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea7f6f3ac1c527445d05c508e6e9bfa4fe5f703079e94ae5100de503b28ee06670c1114e0031e6a43a15d14868ebb957df8c9b79f6c7fca485dc2561462bbc59
|
7
|
+
data.tar.gz: 69b1ab1686a0fcf2dc7cec8dd5b6af9b276ec9b2b57c52ff7a2b3a90cf2b7c0bf2811d9fd6cf6eea38bca33099cbe8c16521c91e81e9170dd54721471ad8e6ee
|
data/README.md
CHANGED
@@ -47,6 +47,21 @@ Queenbee::Order.create(
|
|
47
47
|
|
48
48
|
**For Sinatra app** you may need to add `require 'bundler/setup'`
|
49
49
|
|
50
|
+
3. Update order
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Queenbee::Order.save(
|
54
|
+
uid: '111',
|
55
|
+
unsubscribed_at: Time.zone.now
|
56
|
+
)
|
57
|
+
```
|
58
|
+
|
59
|
+
4. Delete order
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Queenbee::Order.delete('111')
|
63
|
+
```
|
64
|
+
|
50
65
|
|
51
66
|
## Tests
|
52
67
|
|
data/lib/queenbee.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Queenbee
|
2
|
+
module APIOperations
|
3
|
+
module Delete
|
4
|
+
module ClassMethods
|
5
|
+
def delete(params = {}, token = nil)
|
6
|
+
url = self.url + '/' + params[:uid]
|
7
|
+
response, token = Queenbee.request(:delete, url, token, params)
|
8
|
+
response
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(base)
|
13
|
+
base.extend(ClassMethods)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/queenbee/order.rb
CHANGED
data/lib/queenbee/version.rb
CHANGED
data/test/queenbee/order_test.rb
CHANGED
@@ -2,18 +2,26 @@ require File.expand_path("../../test_helper", __FILE__)
|
|
2
2
|
|
3
3
|
module Queenbee
|
4
4
|
class OrderTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
@uid = SecureRandom.hex(4)
|
7
|
+
@valid_params = {
|
8
|
+
date: "2014-07-01 14:50:28",
|
9
|
+
currency: "CAD", city: "Paris",
|
10
|
+
country: "Canada", client_email: "d@email.com",
|
11
|
+
amount: "10", shipping: "2", total_price: "12",
|
12
|
+
uid: @uid
|
13
|
+
}
|
14
|
+
@updated_params = @valid_params.merge!(client_email: "kk@email.com")
|
15
|
+
end
|
16
|
+
|
5
17
|
should "create should return status 201" do
|
6
|
-
response = Queenbee::Order.create(
|
7
|
-
date: "2014-07-01 14:50:28",
|
8
|
-
currency: "CAD", city: "Paris",
|
9
|
-
country: "Canada", client_email: "d@email.com",
|
10
|
-
uid: SecureRandom.hex(4))
|
18
|
+
response = Queenbee::Order.create(@valid_params)
|
11
19
|
assert_equal "201", response.code
|
12
20
|
end
|
13
21
|
|
14
|
-
should "raise Queenbee::AuthenticationError if
|
22
|
+
should "raise Queenbee::AuthenticationError if no token provided" do
|
15
23
|
Queenbee.token = nil
|
16
|
-
assert_raises(Queenbee::AuthenticationError) {Queenbee::Order.create}
|
24
|
+
assert_raises(Queenbee::AuthenticationError) { Queenbee::Order.create }
|
17
25
|
end
|
18
26
|
|
19
27
|
should "raise Queenbee::InvalidRequestError if not enough parameters" do
|
@@ -24,31 +32,28 @@ module Queenbee
|
|
24
32
|
end
|
25
33
|
|
26
34
|
should "Update should return 200" do
|
27
|
-
|
28
|
-
|
29
|
-
date: "2014-07-01 14:50:28",
|
30
|
-
currency: "CAD", city: "Paris",
|
31
|
-
country: "Canada", client_email: "d@email.com",
|
32
|
-
uid: uid)
|
33
|
-
response = Queenbee::Order.save(
|
34
|
-
date: "2014-07-01 14:50:28",
|
35
|
-
currency: "CAD", city: "Paris",
|
36
|
-
country: "Canada", client_email: "kk@email.com",
|
37
|
-
uid: uid)
|
35
|
+
response1 = Queenbee::Order.create(@valid_params)
|
36
|
+
response = Queenbee::Order.save(@updated_params)
|
38
37
|
assert_equal "200", response.code
|
39
38
|
end
|
40
39
|
|
41
|
-
should "Update should return 404 if UID
|
42
|
-
response1 = Queenbee::Order.create(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
should "Update should return 404 if UID incorrect" do
|
41
|
+
response1 = Queenbee::Order.create(@valid_params)
|
42
|
+
invalid_params = @valid_params.merge!(uid: "fakeuid")
|
43
|
+
response = Queenbee::Order.save(invalid_params)
|
44
|
+
puts "---------#{response.inspect}"
|
45
|
+
puts "---------#{response.code}"
|
46
|
+
assert_equal "404", response.code
|
47
|
+
end
|
48
|
+
|
49
|
+
should "Delete should return 204" do
|
50
|
+
response1 = Queenbee::Order.create(@valid_params)
|
51
|
+
response = Queenbee::Order.delete(@uid)
|
52
|
+
assert_equal "204", response.code
|
53
|
+
end
|
54
|
+
|
55
|
+
should "Delete should return 404 if UID incorrect" do
|
56
|
+
response = Queenbee::Order.delete("fakeuid")
|
52
57
|
assert_equal "404", response.code
|
53
58
|
end
|
54
59
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queenbee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- README.md
|
91
91
|
- lib/queenbee.rb
|
92
92
|
- lib/queenbee/api_operations/create.rb
|
93
|
+
- lib/queenbee/api_operations/delete.rb
|
93
94
|
- lib/queenbee/api_operations/update.rb
|
94
95
|
- lib/queenbee/api_resource.rb
|
95
96
|
- lib/queenbee/errors/api_connection_error.rb
|