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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e2ecbf88bab97a30dc9d76d899d83235e11bffe
4
- data.tar.gz: 1f4d8257dcbe653e9a02dd74f280a817a6ca5df2
3
+ metadata.gz: 1c818cd545702cbf87b04e8094599829ec4ce906
4
+ data.tar.gz: ed89bc29b903786697be10f5008c260676cacef2
5
5
  SHA512:
6
- metadata.gz: 8fcc250632939434fc3decdb721606b0d9fbcbcd05481d74888ff40f160f8abf226fe54033b10cea373df6b803d8d9670a00fb2ac35cccb0de27a652443e4757
7
- data.tar.gz: 89eab4a4c89771376015ebd335a382e0f256365dd183955a957fe8c6f31aa2376175e8139ffac678dc641ba7c64eb8af10e46cbe72c774b7c26eaa3317f8cef7
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
 
@@ -12,6 +12,7 @@ require "queenbee/version"
12
12
  # API operations
13
13
  require "queenbee/api_operations/create"
14
14
  require "queenbee/api_operations/update"
15
+ require "queenbee/api_operations/delete"
15
16
 
16
17
  # Resources
17
18
  require "queenbee/queenbee_object"
@@ -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
@@ -2,5 +2,6 @@ module Queenbee
2
2
  class Order < APIResource
3
3
  include Queenbee::APIOperations::Create
4
4
  include Queenbee::APIOperations::Update
5
+ include Queenbee::APIOperations::Delete
5
6
  end
6
7
  end
@@ -1,3 +1,3 @@
1
1
  module Queenbee
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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 not token provided" do
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
- uid = SecureRandom.hex(4)
28
- response1 = Queenbee::Order.create(
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 missing" do
42
- response1 = Queenbee::Order.create(
43
- date: "2014-07-01 14:50:28",
44
- currency: "CAD", city: "Paris",
45
- country: "Canada", client_email: "d@email.com",
46
- uid: SecureRandom.hex(4))
47
- response = Queenbee::Order.save(
48
- date: "2014-07-01 14:50:28",
49
- currency: "CAD", city: "Paris",
50
- country: "Canada", client_email: "kk@email.com",
51
- uid: "")
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
 
@@ -4,7 +4,7 @@ require 'shoulda'
4
4
 
5
5
  class Test::Unit::TestCase
6
6
  setup do
7
- Queenbee.api_base = 'http://localhost:3024/api'
7
+ Queenbee.api_base = 'http://localhost:3019/api'
8
8
  Queenbee.token = '111'
9
9
  end
10
10
 
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.2
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-10-08 00:00:00.000000000 Z
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