lucid_intercom 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucid_intercom/post_request.rb +1 -1
- data/lib/lucid_intercom/response.rb +30 -6
- data/lib/lucid_intercom/version.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: 0fdfafd4312a7ee7bce683223c3b5ce972199834e5668c505a0fca07f5813faa
|
4
|
+
data.tar.gz: 93d58ab3f55ea61f6c020dcc6f83a11b9e90ba3ba9521d45cd214bf8990fecfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3bb863f4d31b9312b14d9774711f74e02e636bb9e58f092706ea3f2a316899a05b9ca21fbbf691c763e8666a13bbd5f2e2cbda6fa1b1c76a5298457ce94219
|
7
|
+
data.tar.gz: 7523ced9f7b08cf4198130b741f13f762e171f653a91138625fa5192143fa7c9a2e5652f6b9fc579f67b3b97b118626a6eff1c9ba3aed8ce8dcbd6d90c58526a
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
4
|
+
|
3
5
|
require 'lucid_intercom'
|
4
6
|
|
5
7
|
module LucidIntercom
|
@@ -10,14 +12,14 @@ module LucidIntercom
|
|
10
12
|
class Error < LucidIntercom::Error
|
11
13
|
extend Dry::Initializer
|
12
14
|
|
13
|
-
# @return [
|
14
|
-
param :
|
15
|
+
# @return [Response]
|
16
|
+
param :response
|
15
17
|
|
16
18
|
#
|
17
19
|
# @return [String]
|
18
20
|
#
|
19
21
|
def message
|
20
|
-
"bad response (#{status_code})"
|
22
|
+
"bad response (#{response.status_code})"
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -28,22 +30,44 @@ module LucidIntercom
|
|
28
30
|
|
29
31
|
# @return [Integer]
|
30
32
|
param :status_code
|
33
|
+
# @return [Hash]
|
34
|
+
param :headers
|
35
|
+
# @return [String]
|
36
|
+
param :data
|
37
|
+
# @return [Hash] the parsed response body
|
38
|
+
param :data_hash, default: -> { parse_data }
|
39
|
+
|
40
|
+
#
|
41
|
+
# @return [Hash]
|
42
|
+
#
|
43
|
+
private def parse_data
|
44
|
+
return {} unless json?
|
45
|
+
|
46
|
+
JSON.parse(data)
|
47
|
+
end
|
31
48
|
|
32
49
|
#
|
33
50
|
# @return [Boolean]
|
34
51
|
#
|
52
|
+
private def json?
|
53
|
+
headers['Content-Type'] =~ /application\/json/
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# @return [self]
|
58
|
+
#
|
35
59
|
# @raise [ClientError] for status 4xx
|
36
60
|
# @raise [ServerError] for status 5xx
|
37
61
|
#
|
38
62
|
def assert!
|
39
63
|
case status_code
|
40
64
|
when 400..499
|
41
|
-
raise ClientError.new(
|
65
|
+
raise ClientError.new(self)
|
42
66
|
when 500..599
|
43
|
-
raise ServerError.new(
|
67
|
+
raise ServerError.new(self)
|
44
68
|
end
|
45
69
|
|
46
|
-
|
70
|
+
self
|
47
71
|
end
|
48
72
|
end
|
49
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|