Class: MekariSso::HttpRequest
- Inherits:
-
Object
- Object
- MekariSso::HttpRequest
show all
- Defined in:
- lib/requests/http_request.rb
Direct Known Subclasses
AddUserToCompany, CheckUserExistence, Cities, Companies, CompaniesOfUser, CompanyCurrentOfUser, CompanyMember, CurrentCompany, CurrentUser, GenerateCredentialClient, GenerateCredentialCode, Industries, PostalCodes, Provincies, Refresh, RegisterCompany, RegisterUser, RemoveCompany, RemoveUserFromCompany, Revoke, UpdateAvatar, UpdateCompany, UpdateUser, ValidatePassword, VerifyEmailUser
Instance Method Summary
collapse
Instance Method Details
#after_error(data, error) ⇒ Object
23
24
25
26
|
# File 'lib/requests/http_request.rb', line 23
def after_error(data, error)
result = Struct.new(:response, :error)
result.new(data, error)
end
|
#after_success(data) ⇒ Object
18
19
20
21
|
# File 'lib/requests/http_request.rb', line 18
def after_success(data)
result = Struct.new(:response)
result.new(data)
end
|
#handle_error(response, error) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/requests/http_request.rb', line 49
def handle_error(response, error)
result = JSON.parse(response)
after_error(result, error.to_s)
rescue
after_error(result, error.to_s)
end
|
#handle_response(response) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/requests/http_request.rb', line 33
def handle_response(response)
if @with_original_response
begin
return JSON.parse(response.body)
rescue StandardError
return response.body
end
end
result = JSON.parse(response.body)
after_success(result)
rescue
response
end
|
11
12
13
14
15
16
|
# File 'lib/requests/http_request.rb', line 11
def
{
accept: :json,
content_type: :json
}
end
|
#original_response ⇒ Object
28
29
30
31
|
# File 'lib/requests/http_request.rb', line 28
def original_response
@with_original_response = true
self
end
|
#params ⇒ Object
9
|
# File 'lib/requests/http_request.rb', line 9
def params; end
|
#send ⇒ Object
7
|
# File 'lib/requests/http_request.rb', line 7
def send; end
|