queenbee 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/queenbee/api_operations/create.rb +2 -2
- data/lib/queenbee/api_operations/get.rb +10 -0
- data/lib/queenbee/metrics.rb +14 -0
- data/lib/queenbee/version.rb +1 -1
- data/lib/queenbee.rb +19 -19
- data/test/queenbee/metrics_test.rb +15 -0
- data/test/queenbee/order_test.rb +40 -40
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa104c36396a2ceb76794c4f2a0a4f7920ce9e23
|
4
|
+
data.tar.gz: 0f1e895d2ff5f824dec9ce2d52cf2dc41621d521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb9f6a416025fb21da26d85bd9c38bb72f31e98b3d2d412ff8e12cc3692e674f4cefda90ed86884acbe4795fb1d70f5b11cf0ba7d7540bf81a53d9c40f6c609
|
7
|
+
data.tar.gz: bcb9e9e51a3bc4b986b364454d57a34bbc1d7c14e9ed1bcc83e6f83cd97a230426633d16e4d30e9f82c0676f059bf7156d5faad0966fc164e38a52850cb3950a
|
data/README.md
CHANGED
@@ -45,6 +45,13 @@ Queenbee::Order.create(
|
|
45
45
|
)
|
46
46
|
```
|
47
47
|
|
48
|
+
Optional attributes are avaiable for subscription-type such as:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
subscribed_at: '2015-05-05 20:13:45',
|
52
|
+
unsubscribed_at: '2016-05-05 20:13:45'
|
53
|
+
```
|
54
|
+
|
48
55
|
**For Sinatra app** you may need to add `require 'bundler/setup'`
|
49
56
|
|
50
57
|
3. Update order
|
@@ -2,7 +2,7 @@ module Queenbee
|
|
2
2
|
module APIOperations
|
3
3
|
module Create
|
4
4
|
module ClassMethods
|
5
|
-
def create(params={}, token=nil)
|
5
|
+
def create(params = {}, token = nil)
|
6
6
|
response, token = Queenbee.request(:post, self.url, token, params)
|
7
7
|
response
|
8
8
|
end
|
@@ -13,4 +13,4 @@ module Queenbee
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Queenbee
|
2
|
+
class Metrics < APIResource
|
3
|
+
extend Queenbee::APIOperations::Get
|
4
|
+
|
5
|
+
def self.summary(params = {})
|
6
|
+
Queenbee::Metrics.get(params, '/metrics/summary')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.all
|
10
|
+
Queenbee::Metrics.get('/metrics/all')
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/queenbee/version.rb
CHANGED
data/lib/queenbee.rb
CHANGED
@@ -11,6 +11,7 @@ require "queenbee/version"
|
|
11
11
|
|
12
12
|
# API operations
|
13
13
|
require "queenbee/api_operations/create"
|
14
|
+
require "queenbee/api_operations/get"
|
14
15
|
require "queenbee/api_operations/update"
|
15
16
|
require "queenbee/api_operations/delete"
|
16
17
|
|
@@ -18,6 +19,7 @@ require "queenbee/api_operations/delete"
|
|
18
19
|
require "queenbee/queenbee_object"
|
19
20
|
require "queenbee/api_resource"
|
20
21
|
require "queenbee/order"
|
22
|
+
require "queenbee/metrics"
|
21
23
|
|
22
24
|
# Errors
|
23
25
|
require "queenbee/errors/queenbee_error"
|
@@ -46,8 +48,10 @@ module Queenbee
|
|
46
48
|
|
47
49
|
begin
|
48
50
|
uri = URI(url)
|
51
|
+
request = Net::HTTP::Get.new(uri) if method == :get
|
49
52
|
request = Net::HTTP::Post.new(uri) if method == :post
|
50
53
|
request = Net::HTTP::Put.new(uri) if method == :put
|
54
|
+
request = Net::HTTP::Delete.new(uri) if method == :delete
|
51
55
|
request["User-Agent"] = "Queenbee gem"
|
52
56
|
request["Authorization"] = "Token token=\"#{token}\""
|
53
57
|
request["Content-Type"] = "application/json"
|
@@ -91,14 +95,12 @@ module Queenbee
|
|
91
95
|
|
92
96
|
def self.handle_connection_error(e)
|
93
97
|
case e
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
else
|
101
|
-
message = "Unexpected error communicating with Queenbee."
|
98
|
+
when SocketError
|
99
|
+
message = "Unexpected error when trying to connect to Queenbee."
|
100
|
+
when NoMethodError
|
101
|
+
message = "Unexpected HTTP response code"
|
102
|
+
else
|
103
|
+
message = "Unexpected error communicating with Queenbee."
|
102
104
|
end
|
103
105
|
|
104
106
|
raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
|
@@ -112,21 +114,19 @@ module Queenbee
|
|
112
114
|
end
|
113
115
|
|
114
116
|
case rcode
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
when 400, 404, 422
|
118
|
+
raise invalid_request_error error, rcode, rbody, error_obj
|
119
|
+
when 401
|
120
|
+
raise authentication_error error, rcode, rbody, error_obj
|
121
|
+
when 500
|
122
|
+
raise api_error error, rcode, rbody, error_obj
|
123
|
+
else
|
124
|
+
# raise api_error error, rcode, rbody, error_obj
|
123
125
|
end
|
124
|
-
|
125
126
|
end
|
126
127
|
|
127
128
|
def self.invalid_request_error(error, rcode, rbody, error_obj)
|
128
|
-
InvalidRequestError.new(error[:message], error[:param], rcode,
|
129
|
-
rbody, error_obj)
|
129
|
+
InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj)
|
130
130
|
end
|
131
131
|
|
132
132
|
def self.authentication_error(error, rcode, rbody, error_obj)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
module Queenbee
|
4
|
+
class MetricsTest < Test::Unit::TestCase
|
5
|
+
should "summary should return status 200" do
|
6
|
+
response = Queenbee::Metrics.summary(start_date: "2014-07-01", end_date: "2014-07-02")
|
7
|
+
assert_equal "200", response.code
|
8
|
+
end
|
9
|
+
|
10
|
+
should "all should return status 200" do
|
11
|
+
response = Queenbee::Metrics.all
|
12
|
+
assert_equal "200", response.code
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/test/queenbee/order_test.rb
CHANGED
@@ -14,46 +14,46 @@ module Queenbee
|
|
14
14
|
@updated_params = @valid_params.merge!(client_email: "kk@email.com")
|
15
15
|
end
|
16
16
|
|
17
|
-
should "create should return status 201" do
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
should "raise Queenbee::AuthenticationError if no token provided" do
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
should "raise Queenbee::InvalidRequestError if not enough parameters" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
should "Update should return 200" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
should "Update should return 404 if UID incorrect" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
should "Delete should return 204" do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
should "Delete should return 404 if UID incorrect" do
|
54
|
-
|
55
|
-
|
56
|
-
end
|
17
|
+
# should "create should return status 201" do
|
18
|
+
# response = Queenbee::Order.create(@valid_params)
|
19
|
+
# assert_equal "201", response.code
|
20
|
+
# end
|
21
|
+
|
22
|
+
# should "raise Queenbee::AuthenticationError if no token provided" do
|
23
|
+
# Queenbee.token = nil
|
24
|
+
# assert_raises(Queenbee::AuthenticationError) { Queenbee::Order.create }
|
25
|
+
# end
|
26
|
+
|
27
|
+
# should "raise Queenbee::InvalidRequestError if not enough parameters" do
|
28
|
+
# begin
|
29
|
+
# rescue JSON::ParserError
|
30
|
+
# assert_raises(Queenbee::InvalidRequestError) { Queenbee::Order.create }
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
# should "Update should return 200" do
|
35
|
+
# response1 = Queenbee::Order.create(@valid_params)
|
36
|
+
# response = Queenbee::Order.save(@updated_params)
|
37
|
+
# assert_equal "200", response.code
|
38
|
+
# end
|
39
|
+
|
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
|
+
# assert_equal "404", response.code
|
45
|
+
# end
|
46
|
+
|
47
|
+
# should "Delete should return 204" do
|
48
|
+
# response1 = Queenbee::Order.create(@valid_params)
|
49
|
+
# response = Queenbee::Order.delete(@uid)
|
50
|
+
# assert_equal "204", response.code
|
51
|
+
# end
|
52
|
+
|
53
|
+
# should "Delete should return 404 if UID incorrect" do
|
54
|
+
# response = Queenbee::Order.delete("fakeuid")
|
55
|
+
# assert_equal "404", response.code
|
56
|
+
# end
|
57
57
|
|
58
58
|
end
|
59
59
|
end
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -44,40 +44,40 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.8
|
47
|
+
version: '1.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.8
|
54
|
+
version: '1.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: shoulda
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.4
|
61
|
+
version: '3.4'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.4
|
68
|
+
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: test-unit
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: E-commerce analytics platform
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/queenbee.rb
|
92
92
|
- lib/queenbee/api_operations/create.rb
|
93
93
|
- lib/queenbee/api_operations/delete.rb
|
94
|
+
- lib/queenbee/api_operations/get.rb
|
94
95
|
- lib/queenbee/api_operations/update.rb
|
95
96
|
- lib/queenbee/api_resource.rb
|
96
97
|
- lib/queenbee/errors/api_connection_error.rb
|
@@ -98,9 +99,11 @@ files:
|
|
98
99
|
- lib/queenbee/errors/authentication_error.rb
|
99
100
|
- lib/queenbee/errors/invalid_request_error.rb
|
100
101
|
- lib/queenbee/errors/queenbee_error.rb
|
102
|
+
- lib/queenbee/metrics.rb
|
101
103
|
- lib/queenbee/order.rb
|
102
104
|
- lib/queenbee/queenbee_object.rb
|
103
105
|
- lib/queenbee/version.rb
|
106
|
+
- test/queenbee/metrics_test.rb
|
104
107
|
- test/queenbee/order_test.rb
|
105
108
|
- test/test_helper.rb
|
106
109
|
homepage: https://github.com/olimart/queenbee-ruby
|
@@ -123,10 +126,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
126
|
version: '0'
|
124
127
|
requirements: []
|
125
128
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.4.
|
129
|
+
rubygems_version: 2.4.3
|
127
130
|
signing_key:
|
128
131
|
specification_version: 4
|
129
132
|
summary: Gem to send e-commerce orders to the Queenbee central app.
|
130
133
|
test_files:
|
134
|
+
- test/queenbee/metrics_test.rb
|
131
135
|
- test/queenbee/order_test.rb
|
132
136
|
- test/test_helper.rb
|