queenbee 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/queenbee/version.rb +1 -1
- data/lib/queenbee.rb +8 -9
- data/test/queenbee/event_test.rb +14 -8
- data/test/queenbee/metrics_test.rb +8 -4
- data/test/queenbee/order_test.rb +12 -8
- data/test/test_helper.rb +12 -0
- metadata +41 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cab732f16b643efe93cceaf0044247931c3576cbb99eae5d9ccfeb3d4d27025c
|
4
|
+
data.tar.gz: 8b5bc0f6775dc2313102155c3b08630f24c57c851fa29bb84bd68d759752f361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d26e9371cab7b33d862e96c749868a7d6bfaadc9a03c480d65efe79b57c3c00dd85ecf1fc00f7a91d0f0a2cc3d1124b6730bc50bba632a3cde77456b27f88844
|
7
|
+
data.tar.gz: 7f5f61f23c1a6a9e6851fefd2c291b583963eefdaf98f416611d4a1f7579759b3e0bb67b57dc8cc9b184ebb9ad4f16b061cc68fc2581c490f06f90ad2796e83d
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Queenbee
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/olimart/queenbee-ruby/branches/master/badge.svg)](https://semaphoreci.com/olimart/queenbee-ruby)
|
4
4
|
|
5
5
|
Simple gem for communicating with external API. Heavily inspired by stripe gem.
|
6
6
|
|
@@ -45,7 +45,7 @@ Queenbee::Order.create(
|
|
45
45
|
)
|
46
46
|
```
|
47
47
|
|
48
|
-
Optional attributes are
|
48
|
+
Optional attributes are available for subscription-type application such as:
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
subscribed_at: '2015-05-05 20:13:45',
|
data/lib/queenbee/version.rb
CHANGED
data/lib/queenbee.rb
CHANGED
@@ -30,7 +30,7 @@ require "queenbee/errors/invalid_request_error"
|
|
30
30
|
require "queenbee/errors/authentication_error"
|
31
31
|
|
32
32
|
module Queenbee
|
33
|
-
@api_base = "https://queenbee
|
33
|
+
@api_base = "https://queenbee.yafoy.com/api"
|
34
34
|
|
35
35
|
class << self
|
36
36
|
attr_accessor :token, :api_base, :verify_ssl_certs, :api_version
|
@@ -69,7 +69,6 @@ module Queenbee
|
|
69
69
|
response = http.start { |h| h.request(request) }
|
70
70
|
|
71
71
|
handle_api_error(response.code, response.body) unless (200..299).include?(response.code.to_i)
|
72
|
-
|
73
72
|
rescue SocketError => e
|
74
73
|
handle_connection_error(e)
|
75
74
|
rescue NoMethodError => e
|
@@ -113,25 +112,25 @@ module Queenbee
|
|
113
112
|
|
114
113
|
case rcode
|
115
114
|
when 400, 404, 422
|
116
|
-
raise invalid_request_error
|
115
|
+
raise invalid_request_error "Invalid request", rcode, rbody, error_obj
|
117
116
|
when 401
|
118
|
-
raise authentication_error
|
117
|
+
raise authentication_error "Unauthorized", rcode, rbody, error_obj
|
119
118
|
when 500
|
120
|
-
raise api_error error, rcode, rbody, error_obj
|
119
|
+
raise api_error "Server returned an error", rcode, rbody, error_obj
|
121
120
|
else
|
122
|
-
raise api_error error, rcode, rbody, error_obj
|
121
|
+
raise api_error "An error has occurred", rcode, rbody, error_obj
|
123
122
|
end
|
124
123
|
end
|
125
124
|
|
126
|
-
def self.invalid_request_error(
|
125
|
+
def self.invalid_request_error(message, rcode, rbody, error_obj)
|
127
126
|
InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj)
|
128
127
|
end
|
129
128
|
|
130
|
-
def self.authentication_error(
|
129
|
+
def self.authentication_error(message, rcode, rbody, error_obj)
|
131
130
|
AuthenticationError.new(error[:message], rcode, rbody, error_obj)
|
132
131
|
end
|
133
132
|
|
134
|
-
def self.api_error(
|
133
|
+
def self.api_error(message, rcode, rbody, error_obj)
|
135
134
|
APIError.new(error[:message], rcode, rbody, error_obj)
|
136
135
|
end
|
137
136
|
|
data/test/queenbee/event_test.rb
CHANGED
@@ -12,20 +12,26 @@ module Queenbee
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "index should return status 200" do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
VCR.use_cassette("events.all") do
|
16
|
+
response = Queenbee::Event.all
|
17
|
+
assert_equal "200", response.code
|
18
|
+
assert_equal Array, JSON.parse(response.body).class
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
should "index should paginate" do
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
VCR.use_cassette("events.page") do
|
24
|
+
response = Queenbee::Event.all(page: 10)
|
25
|
+
assert_equal "200", response.code
|
26
|
+
assert_equal Array, JSON.parse(response.body).class
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
should "create should return status 201" do
|
27
|
-
|
28
|
-
|
31
|
+
VCR.use_cassette("event.created") do
|
32
|
+
response = Queenbee::Event.create(@valid_params)
|
33
|
+
assert_equal "201", response.code
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
should "raise Queenbee::AuthenticationError if no token provided" do
|
@@ -3,13 +3,17 @@ require File.expand_path("../../test_helper", __FILE__)
|
|
3
3
|
module Queenbee
|
4
4
|
class MetricsTest < Test::Unit::TestCase
|
5
5
|
should "summary should return status 200" do
|
6
|
-
|
7
|
-
|
6
|
+
VCR.use_cassette("metrics.summary") do
|
7
|
+
response = Queenbee::Metrics.summary(start_date: "2014-07-01", end_date: "2014-07-02")
|
8
|
+
assert_equal "200", response.code
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
should "all should return status 200" do
|
11
|
-
|
12
|
-
|
13
|
+
VCR.use_cassette("metrics.all") do
|
14
|
+
response = Queenbee::Metrics.all
|
15
|
+
assert_equal "200", response.code
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/test/queenbee/order_test.rb
CHANGED
@@ -16,8 +16,10 @@ module Queenbee
|
|
16
16
|
end
|
17
17
|
|
18
18
|
should "create should return status 201" do
|
19
|
-
|
20
|
-
|
19
|
+
VCR.use_cassette("order.created") do
|
20
|
+
response = Queenbee::Order.create(@valid_params)
|
21
|
+
assert_equal "201", response.code
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
should "raise Queenbee::AuthenticationError if no token provided" do
|
@@ -33,9 +35,10 @@ module Queenbee
|
|
33
35
|
end
|
34
36
|
|
35
37
|
should "Update should return 200" do
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
VCR.use_cassette("order.updated") do
|
39
|
+
response = Queenbee::Order.save(@updated_params.merge!(uid: "334a9f80"))
|
40
|
+
assert_equal "200", response.code
|
41
|
+
end
|
39
42
|
end
|
40
43
|
|
41
44
|
# Queenbee API raises error if record not found `find_by!`
|
@@ -52,9 +55,10 @@ module Queenbee
|
|
52
55
|
# end
|
53
56
|
|
54
57
|
should "Delete should return 204" do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
VCR.use_cassette("order.deleted") do
|
59
|
+
response = Queenbee::Order.delete("334a9f80")
|
60
|
+
assert_equal "204", response.code
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
# should "Delete should return 404 if UID incorrect" do
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'queenbee'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |config|
|
7
|
+
config.cassette_library_dir = 'test/fixtures'
|
8
|
+
config.hook_into :webmock
|
9
|
+
config.filter_sensitive_data('<TOKEN>') { |interaction|
|
10
|
+
auths = interaction.request.headers['Authorization'].first
|
11
|
+
if (match = auths.match /Token token=/ )
|
12
|
+
match.captures.first
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
4
16
|
|
5
17
|
class Test::Unit::TestCase
|
6
18
|
setup do
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queenbee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
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: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13'
|
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
|
-
version: '
|
40
|
+
version: '13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,18 +68,46 @@ dependencies:
|
|
68
68
|
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3'
|
103
|
+
version: '3.4'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3'
|
110
|
+
version: '3.4'
|
83
111
|
description: E-commerce analytics platform
|
84
112
|
email:
|
85
113
|
- olivier@yafoy.com
|
@@ -127,12 +155,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
155
|
- !ruby/object:Gem::Version
|
128
156
|
version: '0'
|
129
157
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
158
|
+
rubygems_version: 3.4.10
|
131
159
|
signing_key:
|
132
160
|
specification_version: 4
|
133
|
-
summary:
|
161
|
+
summary: Ruby gem to send orders & events to Queenbee main app.
|
134
162
|
test_files:
|
163
|
+
- test/queenbee/event_test.rb
|
135
164
|
- test/queenbee/metrics_test.rb
|
136
165
|
- test/queenbee/order_test.rb
|
137
|
-
- test/queenbee/event_test.rb
|
138
166
|
- test/test_helper.rb
|