queenbee 1.4.1 → 1.5.0

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: 16b223a7e964ee43ca53e6c0e1b274eb5c041ff1f5b6494da48054784f00230b
4
- data.tar.gz: 123d1ceda4adfa6226bd8e20c64accff1e8d6aef24fe636691f9a227cd371d4a
3
+ metadata.gz: ffc6b55b187bac0ea5dfb946d1620fb28beb0b68ecc5fae7e7c9d843be2d8894
4
+ data.tar.gz: 9c56d7f2dfc851835477894060143589a44d64dc0026e72a23a43560b43fcb04
5
5
  SHA512:
6
- metadata.gz: 5b88696f5abfe45cc27824635cb07cbd9764d3f0c3680c8e17e330fb0bb3d7827cd415d0c51ca126fd42b991d38f39d02928a1be975300aa9d58bc49d9cd9275
7
- data.tar.gz: 29a1c0573bb116849ec55f0868b7d5e38fa4fdb14e3ba6828741ea3171955a78d293f5eda649a6e96988839b4fae5902368d17d14ea61995c2f5df8d6e5ade6d
6
+ metadata.gz: cef33a2fd00f8dd2dee0702262444d47815be114e57ea445c06a8feb3c3ec597054f3cce8e8e372e797950cf7e5c5339722acc428c740d1b1a2dacb2c6d3b297
7
+ data.tar.gz: 10de4d8eab7020b7c2da0cbe3e1309cb4a6ba50d9d57143f1ccc6416d6bfe285657d5756097a5908a0ca33902becf37bec1927a6f03ca243f29794092dc57a97
data/README.md CHANGED
@@ -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.zone.now
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
 
@@ -7,4 +7,4 @@ module Queenbee
7
7
  @param = param
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -13,8 +13,15 @@ module Queenbee
13
13
  end
14
14
 
15
15
  def to_s
16
- status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
17
- "#{status_string}#{@message}"
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
@@ -3,7 +3,7 @@ module Queenbee
3
3
  extend Queenbee::APIOperations::Get
4
4
  include Queenbee::APIOperations::Create
5
5
 
6
- def self.all(opts = {})
6
+ def self.all(**opts)
7
7
  Queenbee::Metrics.get("/events?page=#{opts[:page] || 1}")
8
8
  end
9
9
  end
@@ -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, '/metrics/summary')
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('/metrics/all')
10
+ Queenbee::Metrics.get("/metrics/all")
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Queenbee
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
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 "Invalid request", rcode, rbody, error_obj
115
+ raise invalid_request_error("Invalid request", rcode, rbody, error_obj).to_s
116
116
  when 401
117
- raise authentication_error "Unauthorized", rcode, rbody, error_obj
117
+ raise authentication_error("Unauthorized", rcode, rbody, error_obj).to_s
118
118
  when 500
119
- raise api_error "Server returned an error", rcode, rbody, error_obj
119
+ raise api_error("Server returned an error", rcode, rbody, error_obj).to_s
120
120
  else
121
- raise api_error "An error has occurred", rcode, rbody, error_obj
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(message, rcode, rbody, error_obj)
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(message, rcode, rbody, error_obj)
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(message, rcode, rbody, error_obj)
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
@@ -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: { color: "pink", "sport": "basket-ball", "age": 25, "fruit": "banana" }
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.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-05-02 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler