evvnt 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/evvnt/api.rb +15 -2
- data/lib/evvnt/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: a47d1cbd78431a560d6af1770f0c39b7acd13a5502d7b3d7dc0a3956dd1d6b9b
|
4
|
+
data.tar.gz: 11748b29a0c32f0d7cbd7e631ff87b113374c5def75a1658ccfc32af3294a93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '034909308fc3530b691ddfe906a7b7051ae4b8d9e5c7a82feef05f921621607bde97a9e548fbaf2ea005918c89b4d954508091cf54ff5b37de0cf59b9fab6210'
|
7
|
+
data.tar.gz: b936fbb2f161fc8cec56cdeea5817780b6ccce3501c002b447a21d673c69ca98cef22341aabc7dfb8d875c3bb75cb6924a71ff934bd0593078c8dbed3e650b96
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
Provides a Ruby wrapper around the evvnt APIs
|
4
4
|
|
5
|
-
[](https://
|
5
|
+
[](https://rubygems.org/gems/evvnt)
|
6
6
|
[](https://circleci.com/gh/KatanaCode/evvnt)
|
7
7
|
[](https://img.shields.io/github/downloads/katanacode/evvnt/total.svg)
|
8
8
|
[](https://codeclimate.com/github/KatanaCode/evvnt/maintainability)
|
9
|
+
[](https://codeclimate.com/github/KatanaCode/evvnt/test_coverage)
|
10
|
+
|
9
11
|
|
10
12
|
|
11
13
|
---
|
data/lib/evvnt/api.rb
CHANGED
@@ -41,7 +41,12 @@ module Evvnt
|
|
41
41
|
log_request(verb, path, params)
|
42
42
|
response = public_send(verb, path, query: params, headers: headers)
|
43
43
|
log_response(response)
|
44
|
-
|
44
|
+
case response.code
|
45
|
+
when 200, 201
|
46
|
+
parse_response(response, options)
|
47
|
+
else
|
48
|
+
raise ApiError, parse_error_response(response.body)
|
49
|
+
end
|
45
50
|
end
|
46
51
|
|
47
52
|
# Log the request being sent to the API
|
@@ -70,6 +75,10 @@ module Evvnt
|
|
70
75
|
TEXT
|
71
76
|
end
|
72
77
|
|
78
|
+
def parse_body(body)
|
79
|
+
Oj.load(body)
|
80
|
+
end
|
81
|
+
|
73
82
|
##
|
74
83
|
# Parse a response from the API and create objects from local classes.
|
75
84
|
#
|
@@ -79,11 +88,15 @@ module Evvnt
|
|
79
88
|
# Returns Array
|
80
89
|
# Returns Evvnt::Base subclass
|
81
90
|
def parse_response(response, **options)
|
82
|
-
json =
|
91
|
+
json = parse_body(response.body)
|
83
92
|
json = json[options[:object]] if options.key?(:object)
|
84
93
|
json.is_a?(Array) ? json.map { |a| new(a) } : new(json)
|
85
94
|
end
|
86
95
|
|
96
|
+
def parse_error_response(body)
|
97
|
+
parse_body(body)["errors"].join(", ")
|
98
|
+
end
|
99
|
+
|
87
100
|
# Ensure the path is the correct format with a leading slash and ".json" extension
|
88
101
|
#
|
89
102
|
# path - A String with the API request path.
|
data/lib/evvnt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evvnt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bodacious
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|