queenbee 1.3.0 → 1.4.1

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
  SHA256:
3
- metadata.gz: ec35ec081436adddbf6ea80a83a1e20d9eda1e35bf0d1c2f94040976e5f4e9d0
4
- data.tar.gz: ce8bad72ac6c0391d8737ecb63a046828467b70a30451e89d1b90001744a3b3d
3
+ metadata.gz: 16b223a7e964ee43ca53e6c0e1b274eb5c041ff1f5b6494da48054784f00230b
4
+ data.tar.gz: 123d1ceda4adfa6226bd8e20c64accff1e8d6aef24fe636691f9a227cd371d4a
5
5
  SHA512:
6
- metadata.gz: 2396e77d70f3432f2b5a359d77ab6c81a7359b7c72c3fb5271b2f5008a0bbb812c48b460ced66c19467ab1588f27aa0d7e2a1b3790dd8b38ea3a981e3497f0dc
7
- data.tar.gz: 5b2fe4cde93f5ebde93ab477c207fd88b4fc60e3118895129fec816440d5ac9efca9f03cfd87bccc9e3e5db36b395d5d15dd2a22fd0ebe5f72c199c5dff96ada
6
+ metadata.gz: 5b88696f5abfe45cc27824635cb07cbd9764d3f0c3680c8e17e330fb0bb3d7827cd415d0c51ca126fd42b991d38f39d02928a1be975300aa9d58bc49d9cd9275
7
+ data.tar.gz: 29a1c0573bb116849ec55f0868b7d5e38fa4fdb14e3ba6828741ea3171955a78d293f5eda649a6e96988839b4fae5902368d17d14ea61995c2f5df8d6e5ade6d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Queenbee
2
2
 
3
- [![Build Status](https://semaphoreci.com/api/v1/olimart/queenbee-ruby/branches/master/badge.svg)](https://semaphoreci.com/olimart/queenbee-ruby)
3
+ [![Tests](https://github.com/olimart/queenbee-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/olimart/queenbee-ruby/actions/workflows/ci.yml)
4
4
 
5
5
  Simple gem for communicating with external API. Heavily inspired by stripe gem.
6
6
 
@@ -1,3 +1,3 @@
1
1
  module Queenbee
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.1"
3
3
  end
data/lib/queenbee.rb CHANGED
@@ -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,26 +112,26 @@ module Queenbee
113
112
 
114
113
  case rcode
115
114
  when 400, 404, 422
116
- raise invalid_request_error error, rcode, rbody, error_obj
115
+ raise invalid_request_error "Invalid request", rcode, rbody, error_obj
117
116
  when 401
118
- raise authentication_error error, rcode, rbody, error_obj
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(error, rcode, rbody, error_obj)
127
- InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj)
125
+ def self.invalid_request_error(message, rcode, rbody, error_obj)
126
+ InvalidRequestError.new(message, rcode, rbody, error_obj)
128
127
  end
129
128
 
130
- def self.authentication_error(error, rcode, rbody, error_obj)
131
- AuthenticationError.new(error[:message], rcode, rbody, error_obj)
129
+ def self.authentication_error(message, rcode, rbody, error_obj)
130
+ AuthenticationError.new(message, rcode, rbody, error_obj)
132
131
  end
133
132
 
134
- def self.api_error(error, rcode, rbody, error_obj)
135
- APIError.new(error[:message], rcode, rbody, error_obj)
133
+ def self.api_error(message, rcode, rbody, error_obj)
134
+ APIError.new(message, rcode, rbody, error_obj)
136
135
  end
137
136
 
138
137
  def self.general_api_error(rcode, rbody)
@@ -12,20 +12,26 @@ module Queenbee
12
12
  end
13
13
 
14
14
  should "index should return status 200" do
15
- response = Queenbee::Event.all
16
- assert_equal "200", response.code
17
- assert_equal Array, JSON.parse(response.body).class
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
- response = Queenbee::Event.all(page: 10)
22
- assert_equal "200", response.code
23
- assert_equal Array, JSON.parse(response.body).class
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
- response = Queenbee::Event.create(@valid_params)
28
- assert_equal "201", response.code
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
- response = Queenbee::Metrics.summary(start_date: "2014-07-01", end_date: "2014-07-02")
7
- assert_equal "200", response.code
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
- response = Queenbee::Metrics.all
12
- assert_equal "200", response.code
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
@@ -16,8 +16,10 @@ module Queenbee
16
16
  end
17
17
 
18
18
  should "create should return status 201" do
19
- response = Queenbee::Order.create(@valid_params)
20
- assert_equal "201", response.code
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
- response1 = Queenbee::Order.create(@valid_params)
37
- response = Queenbee::Order.save(@updated_params)
38
- assert_equal "200", response.code
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
- response1 = Queenbee::Order.create(@valid_params)
56
- response = Queenbee::Order.delete(@uid)
57
- assert_equal "204", response.code
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.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
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: '0'
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: '0'
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: '0'
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: '0'
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
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '3'
89
+ version: '4.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '3'
96
+ version: '4.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
83
111
  description: E-commerce analytics platform
84
112
  email:
85
113
  - olivier@yafoy.com
@@ -127,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
155
  - !ruby/object:Gem::Version
128
156
  version: '0'
129
157
  requirements: []
130
- rubygems_version: 3.3.7
158
+ rubygems_version: 3.4.10
131
159
  signing_key:
132
160
  specification_version: 4
133
161
  summary: Ruby gem to send orders & events to Queenbee main app.