workable 1.0.0.rc1 → 1.0.0.rc2
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/lib/workable/client.rb +19 -4
- data/lib/workable/errors.rb +1 -0
- data/lib/workable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ada51e56baba92f9000eef95141cf2398a1e928f
|
4
|
+
data.tar.gz: c3d58edf13520d31ea1f318c28757301b986db89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a4cff53fe413453ab557278c2f90c7762fd0a425842db4f0eb94081f9c348da28adf2c8fd88eb95a9929caabec0a0e64968360be4f94f666bcf9b1394719d0
|
7
|
+
data.tar.gz: c816f6b7c325a148da17b2765ca63cdd9fc06117c7f6c2222f817bc6b9cea00081b934480966bc482556ce5bddb6b9a642f62049e6875dcc80db4f179477e082
|
data/lib/workable/client.rb
CHANGED
@@ -120,14 +120,16 @@ module Workable
|
|
120
120
|
# parse the api response
|
121
121
|
def parse!(response)
|
122
122
|
case response.code.to_i
|
123
|
-
when 204, 205
|
123
|
+
when 204, 205 # handled no response
|
124
124
|
nil
|
125
|
-
when 200...300
|
125
|
+
when 200...300 # handled with response
|
126
126
|
JSON.parse(response.body)
|
127
127
|
when 401
|
128
|
-
raise Errors::NotAuthorized, response.body
|
128
|
+
raise Errors::NotAuthorized, JSON.parse(response.body)["error"]
|
129
129
|
when 404
|
130
|
-
raise Errors::NotFound, response.body
|
130
|
+
raise Errors::NotFound, JSON.parse(response.body)["error"]
|
131
|
+
when 422
|
132
|
+
handle_response_422(response)
|
131
133
|
when 503
|
132
134
|
raise Errors::RequestToLong, response.body
|
133
135
|
else
|
@@ -135,6 +137,19 @@ module Workable
|
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
140
|
+
def handle_response_422(response)
|
141
|
+
data = JSON.parse(response.body)
|
142
|
+
if
|
143
|
+
data["validation_errors"] &&
|
144
|
+
data["validation_errors"]["email"] &&
|
145
|
+
data["validation_errors"]["email"].include?("candidate already exists")
|
146
|
+
then
|
147
|
+
raise Errors::AlreadyExists, data["error"]
|
148
|
+
else
|
149
|
+
raise Errors::NotFound, data["error"]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
138
153
|
# default headers for authentication and JSON support
|
139
154
|
def headers
|
140
155
|
{
|
data/lib/workable/errors.rb
CHANGED
data/lib/workable/version.rb
CHANGED