traitify 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/traitify/connection.rb +1 -1
- data/lib/traitify/error.rb +5 -5
- data/lib/traitify/request.rb +9 -4
- data/lib/traitify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 261a556aad6aecf312c66a850910b0657aeb6c6b
|
4
|
+
data.tar.gz: a8fa60ebf999db0fa01260751602b2eca4620fc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 445f43a6bb9f9f19276798fe23094bb63d3617c441961b96e82784ee31dd903de84b65c7b29445b4d5561f4d31d4aa53bb43f9a700aa77c5a37e4185518d160b
|
7
|
+
data.tar.gz: bba888360a4fd1f8973323a6bdbfd3ce606fe105887426a1b852b3f9fc3c0defeef1bb785e1c3d5daad4497b1e2ab486ae4bb056f884e3eb7dcd8447c5ea4351
|
data/Gemfile.lock
CHANGED
data/lib/traitify/connection.rb
CHANGED
data/lib/traitify/error.rb
CHANGED
@@ -2,8 +2,8 @@ module Traitify
|
|
2
2
|
class Error < StandardError
|
3
3
|
attr_accessor :response
|
4
4
|
|
5
|
-
def self.from(
|
6
|
-
if klass = case status
|
5
|
+
def self.from(response)
|
6
|
+
if klass = case response.status
|
7
7
|
when 400 then Traitify::BadRequest
|
8
8
|
when 401 then Traitify::Unauthorized
|
9
9
|
when 404 then Traitify::NotFound
|
@@ -24,10 +24,10 @@ module Traitify
|
|
24
24
|
|
25
25
|
private
|
26
26
|
def error_message
|
27
|
-
message = "#{response.
|
28
|
-
message << "#{response.
|
27
|
+
message = "#{response.method.upcase} | "
|
28
|
+
message << "#{response.url.to_s} | "
|
29
29
|
message << "#{response.status} | "
|
30
|
-
message << "#{response.body}"
|
30
|
+
message << "#{response.body.first["message"]}"
|
31
31
|
message
|
32
32
|
end
|
33
33
|
end
|
data/lib/traitify/request.rb
CHANGED
@@ -9,10 +9,15 @@ module Traitify
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def request(method, path, options = {})
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
begin
|
13
|
+
conn(url: api_host).send(method) do |request|
|
14
|
+
request.url [api_version, path].join
|
15
|
+
request.body = options.to_json if options
|
16
|
+
end.body
|
17
|
+
rescue => e
|
18
|
+
puts e.message
|
19
|
+
{ error: e.message }
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
data/lib/traitify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traitify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Prats
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|