magicbell 1.0.3 → 1.0.4

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: 68c41d47dfcb956fd6ce283573619aafe27c5dc8ecae3db01807ae442afce912
4
- data.tar.gz: 6dc6769e62c3b105a675854ccb0ea683f01b425a5d3fc1836fd962f1e370b9fc
3
+ metadata.gz: 29113907c736b89c737a0522778b8479f863b436732c0d374946a4f04fb96c1a
4
+ data.tar.gz: '038fac96186f5de27eec5f0deca1ded68e06555ec6b3662e9f48800e807b3046'
5
5
  SHA512:
6
- metadata.gz: 24b81b3179c672118ac6550a80c8e28bfdb73c293b9f96a1c8ca88e7836c36157eed6ab8fa5d7850199674cdc81770ab237dc5218c28d637f281c787e04b093f
7
- data.tar.gz: edb2e6dcdc5e5827b55d4a75067c386a6278dddf52d70ea614657a47a7abcbcccef47e3255ef0918a8af4bbd053f888861a420989db248b5e37ee3d94083f784
6
+ metadata.gz: c62643f20bd3ccc2ff67d8260af27431b810b57f4f2c7a702fcb4ff7fc248c07ceb55acef118b792cc2d6cd2748fa86c02fdf3de54dd1cec3a89537ac5d967ec
7
+ data.tar.gz: 3c8b6720557cf512ab763e4787e283ec8fcb5f4621d2bc0ba8e31248dde536b62146668a27f8a4112c0d570cad01477193c8dc95435bd42ffea4373e81f39d67
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+ require 'colorize'
1
3
  module MagicBell
2
4
  module ApiOperations
3
5
  def get(url, options = {})
@@ -34,11 +36,20 @@ module MagicBell
34
36
 
35
37
  def raise_http_error_unless_2xx_response(response)
36
38
  return if response.success?
37
-
39
+
38
40
  e = MagicBell::Client::HTTPError.new
39
41
  e.response_status = response.code
40
42
  e.response_headers = response.headers.to_h
41
43
  e.response_body = response.body
44
+ e.errors = []
45
+ unless e.response_body.nil? || e.response_body.empty?
46
+ body = JSON.parse(response.body)
47
+ e.errors = body["errors"]
48
+ e.errors.each do |error, index|
49
+ puts "#{error["suggestion"].red}"
50
+ puts "#{error["help_link"].blue.on_white}"
51
+ end
52
+ end
42
53
  raise e
43
54
  end
44
55
  end
@@ -3,7 +3,8 @@ module MagicBell
3
3
  class HTTPError < StandardError
4
4
  attr_accessor :response_status,
5
5
  :response_headers,
6
- :response_body
6
+ :response_body,
7
+ :errors
7
8
  end
8
9
 
9
10
  include ApiOperations
@@ -1,3 +1,3 @@
1
1
  module MagicBell
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magicbell
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hana Mohan
8
8
  - Nisanth Chunduru
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-30 00:00:00.000000000 Z
12
+ date: 2021-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: colorize
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: actionmailer
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +157,7 @@ homepage: https://magicbell.io
143
157
  licenses:
144
158
  - MIT
145
159
  metadata: {}
146
- post_install_message:
160
+ post_install_message:
147
161
  rdoc_options: []
148
162
  require_paths:
149
163
  - lib
@@ -159,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
173
  version: '0'
160
174
  requirements: []
161
175
  rubygems_version: 3.1.4
162
- signing_key:
176
+ signing_key:
163
177
  specification_version: 4
164
178
  summary: Ruby wrapper for MagicBell.io
165
179
  test_files: []