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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f84be6bd77fdba862713a2f2acf4745523056a105d4e6b6a5e22071ddd7ce070
4
- data.tar.gz: 653a551829a466e48e17b4c8f33af5f03fa3f0575b3ef89c6d140b0f9f622fc8
3
+ metadata.gz: a47d1cbd78431a560d6af1770f0c39b7acd13a5502d7b3d7dc0a3956dd1d6b9b
4
+ data.tar.gz: 11748b29a0c32f0d7cbd7e631ff87b113374c5def75a1658ccfc32af3294a93b
5
5
  SHA512:
6
- metadata.gz: fef09abc0b0a9be762253756e0eb8928e5404613ebbe0c6666e44f825d23c9f404264f4e31c201598be4b5fdde7de2333d535c1351819f3f24b5d339983a4d53
7
- data.tar.gz: 833dac9233c10b563e57c2e8f024249cc5a5e96c0dbb6da19a1ba6d3f386cd20384169073c0ec064816189b8c0a9ba2060c552dac15595d4eca8842fee191142
6
+ metadata.gz: '034909308fc3530b691ddfe906a7b7051ae4b8d9e5c7a82feef05f921621607bde97a9e548fbaf2ea005918c89b4d954508091cf54ff5b37de0cf59b9fab6210'
7
+ data.tar.gz: b936fbb2f161fc8cec56cdeea5817780b6ccce3501c002b447a21d673c69ca98cef22341aabc7dfb8d875c3bb75cb6924a71ff934bd0593078c8dbed3e650b96
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- evvnt (0.2.3)
4
+ evvnt (0.2.4)
5
5
  activesupport (>= 3.0)
6
6
  httparty (>= 0.16.0)
7
7
  oj
data/README.md CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  Provides a Ruby wrapper around the evvnt APIs
4
4
 
5
- [![Latest Version](https://img.shields.io/gem/v/evvnt.svg)](https://img.shields.io/gem/v/evvnt.svg)
5
+ [![Latest Version](https://img.shields.io/gem/v/evvnt.svg)](https://rubygems.org/gems/evvnt)
6
6
  [![CircleCI](https://circleci.com/gh/KatanaCode/evvnt.svg?style=svg)](https://circleci.com/gh/KatanaCode/evvnt)
7
7
  [![Downloads](https://img.shields.io/github/downloads/katanacode/evvnt/total.svg)](https://img.shields.io/github/downloads/katanacode/evvnt/total.svg)
8
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/fdd8cffc25d6002a68df/maintainability)](https://codeclimate.com/github/KatanaCode/evvnt/maintainability)
9
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/fdd8cffc25d6002a68df/test_coverage)](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
- parse_response(response, options)
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 = Oj.load(response.body)
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
@@ -1,3 +1,3 @@
1
1
  module Evvnt
2
- VERSION = "0.2.3".freeze
2
+ VERSION = "0.2.4".freeze
3
3
  end
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.3
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-10 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport