queenbee 1.4.0 → 1.5.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 +9 -2
- data/lib/queenbee/errors/invalid_request_error.rb +1 -1
- data/lib/queenbee/errors/queenbee_error.rb +10 -3
- data/lib/queenbee/event.rb +1 -1
- data/lib/queenbee/metrics.rb +3 -3
- data/lib/queenbee/version.rb +1 -1
- data/lib/queenbee.rb +9 -9
- data/test/queenbee/event_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc6b55b187bac0ea5dfb946d1620fb28beb0b68ecc5fae7e7c9d843be2d8894
|
4
|
+
data.tar.gz: 9c56d7f2dfc851835477894060143589a44d64dc0026e72a23a43560b43fcb04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef33a2fd00f8dd2dee0702262444d47815be114e57ea445c06a8feb3c3ec597054f3cce8e8e372e797950cf7e5c5339722acc428c740d1b1a2dacb2c6d3b297
|
7
|
+
data.tar.gz: 10de4d8eab7020b7c2da0cbe3e1309cb4a6ba50d9d57143f1ccc6416d6bfe285657d5756097a5908a0ca33902becf37bec1927a6f03ca243f29794092dc57a97
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Queenbee
|
2
2
|
|
3
|
-
[![
|
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
|
|
@@ -59,7 +59,7 @@ unsubscribed_at: '2016-05-05 20:13:45'
|
|
59
59
|
```ruby
|
60
60
|
Queenbee::Order.save(
|
61
61
|
uid: '111',
|
62
|
-
unsubscribed_at: Time.
|
62
|
+
unsubscribed_at: Time.current
|
63
63
|
)
|
64
64
|
```
|
65
65
|
|
@@ -69,6 +69,13 @@ Queenbee::Order.save(
|
|
69
69
|
Queenbee::Order.delete('111')
|
70
70
|
```
|
71
71
|
|
72
|
+
## Development
|
73
|
+
|
74
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
75
|
+
|
76
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
77
|
+
|
78
|
+
To experiment with that code, run `bin/console` for an interactive prompt.
|
72
79
|
|
73
80
|
## Tests
|
74
81
|
|
@@ -13,8 +13,15 @@ module Queenbee
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_s
|
16
|
-
|
17
|
-
|
16
|
+
[
|
17
|
+
status_string,
|
18
|
+
json_body,
|
19
|
+
message
|
20
|
+
].compact.join(" - ")
|
21
|
+
end
|
22
|
+
|
23
|
+
def status_string
|
24
|
+
http_status.nil? ? "" : "(Status #{http_status})"
|
18
25
|
end
|
19
26
|
end
|
20
|
-
end
|
27
|
+
end
|
data/lib/queenbee/event.rb
CHANGED
data/lib/queenbee/metrics.rb
CHANGED
@@ -2,12 +2,12 @@ module Queenbee
|
|
2
2
|
class Metrics < APIResource
|
3
3
|
extend Queenbee::APIOperations::Get
|
4
4
|
|
5
|
-
def self.summary(params
|
6
|
-
Queenbee::Metrics.get(params,
|
5
|
+
def self.summary(**params)
|
6
|
+
Queenbee::Metrics.get(params, "/metrics/summary")
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.all
|
10
|
-
Queenbee::Metrics.get(
|
10
|
+
Queenbee::Metrics.get("/metrics/all")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/queenbee/version.rb
CHANGED
data/lib/queenbee.rb
CHANGED
@@ -110,32 +110,32 @@ module Queenbee
|
|
110
110
|
raise general_api_error(rcode, rbody)
|
111
111
|
end
|
112
112
|
|
113
|
-
case rcode
|
113
|
+
case rcode.to_i
|
114
114
|
when 400, 404, 422
|
115
|
-
raise invalid_request_error
|
115
|
+
raise invalid_request_error("Invalid request", rcode, rbody, error_obj).to_s
|
116
116
|
when 401
|
117
|
-
raise authentication_error
|
117
|
+
raise authentication_error("Unauthorized", rcode, rbody, error_obj).to_s
|
118
118
|
when 500
|
119
|
-
raise api_error
|
119
|
+
raise api_error("Server returned an error", rcode, rbody, error_obj).to_s
|
120
120
|
else
|
121
|
-
raise api_error
|
121
|
+
raise api_error("An error has occurred", rcode, rbody, error_obj).to_s
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
125
|
def self.invalid_request_error(message, rcode, rbody, error_obj)
|
126
|
-
InvalidRequestError.new(
|
126
|
+
InvalidRequestError.new(message, nil, rcode, rbody, error_obj)
|
127
127
|
end
|
128
128
|
|
129
129
|
def self.authentication_error(message, rcode, rbody, error_obj)
|
130
|
-
AuthenticationError.new(
|
130
|
+
AuthenticationError.new(message, nil, rcode, rbody, error_obj)
|
131
131
|
end
|
132
132
|
|
133
133
|
def self.api_error(message, rcode, rbody, error_obj)
|
134
|
-
APIError.new(
|
134
|
+
APIError.new(message, nil, rcode, rbody, error_obj)
|
135
135
|
end
|
136
136
|
|
137
137
|
def self.general_api_error(rcode, rbody)
|
138
138
|
APIError.new("Invalid response object from API: #{rbody.inspect} " +
|
139
|
-
"(HTTP response code was #{rcode})", rcode, rbody)
|
139
|
+
"(HTTP response code was #{rcode})", nil, rcode, rbody)
|
140
140
|
end
|
141
141
|
end
|
data/test/queenbee/event_test.rb
CHANGED
@@ -7,7 +7,7 @@ module Queenbee
|
|
7
7
|
date: "2014-07-01 14:50:28",
|
8
8
|
status: "confirmed",
|
9
9
|
message: "From the API",
|
10
|
-
metadata: {
|
10
|
+
metadata: {color: "pink", "sport": "basket-ball", "age": 25, "fruit": "banana"}
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
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: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|