Module: Preposterous
- Defined in:
- lib/preposterous.rb,
lib/preposterous/base.rb,
lib/preposterous/request.rb,
lib/preposterous/httpauth.rb
Defined Under Namespace
Classes: ApiRateLimitReached, Base, CommentsDisabled, HTTPAuth, InvalidDate, InvalidEmailOrPassword, InvalidPostId, InvalidSiteId, Request, UnableToFindObject, UnableToSave, UnableToSaveComment, UserDoesNotHaveAccess
Class Method Summary
collapse
Class Method Details
.make_friendly(response) ⇒ Object
19
20
21
22
|
# File 'lib/preposterous.rb', line 19
def self.make_friendly(response)
raise_errors(response)
Crack::XML.parse(response.body)["rsp"] if not response.nil?
end
|
.raise_errors(response) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/preposterous.rb', line 24
def self.raise_errors(response)
response.body =~ /code="(\d+)" msg="(.*)"/
code = $1.to_i
msg = $2
case code
when 3001
raise InvalidEmailOrPassword, msg
when 3002
raise InvalidSiteId, msg
when 3003
raise UserDoesNotHaveAccess, msg
when 3004
raise UnableToSave, msg
when 3005
raise UnableToFindObject, msg
when 3006
raise InvalidDate, msg
when 3007
raise InvalidPostId, msg
when 3008
raise CommentsDisabled, msg
when 3009
raise UnableToSaveComment, msg
when 3010
raise ApiRateLimitReached, msg
end
end
|