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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cab732f16b643efe93cceaf0044247931c3576cbb99eae5d9ccfeb3d4d27025c
4
- data.tar.gz: 8b5bc0f6775dc2313102155c3b08630f24c57c851fa29bb84bd68d759752f361
3
+ metadata.gz: ffc6b55b187bac0ea5dfb946d1620fb28beb0b68ecc5fae7e7c9d843be2d8894
4
+ data.tar.gz: 9c56d7f2dfc851835477894060143589a44d64dc0026e72a23a43560b43fcb04
5
5
  SHA512:
6
- metadata.gz: d26e9371cab7b33d862e96c749868a7d6bfaadc9a03c480d65efe79b57c3c00dd85ecf1fc00f7a91d0f0a2cc3d1124b6730bc50bba632a3cde77456b27f88844
7
- data.tar.gz: 7f5f61f23c1a6a9e6851fefd2c291b583963eefdaf98f416611d4a1f7579759b3e0bb67b57dc8cc9b184ebb9ad4f16b061cc68fc2581c490f06f90ad2796e83d
6
+ metadata.gz: cef33a2fd00f8dd2dee0702262444d47815be114e57ea445c06a8feb3c3ec597054f3cce8e8e372e797950cf7e5c5339722acc428c740d1b1a2dacb2c6d3b297
7
+ data.tar.gz: 10de4d8eab7020b7c2da0cbe3e1309cb4a6ba50d9d57143f1ccc6416d6bfe285657d5756097a5908a0ca33902becf37bec1927a6f03ca243f29794092dc57a97
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
 
@@ -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.0"
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(error[:message], error[:param], 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(error[: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(error[: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.0
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