74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/auth0/mixins/httpproxy.rb', line 74
def request(method, uri, body = {}, = {})
result = if method == :get
||= {}
= .merge({params: body}).merge()
call(:get, encode_uri(uri), timeout, )
elsif method == :delete
||= {}
= .merge({ params: body })
call(:delete, encode_uri(uri), timeout, )
elsif method == :delete_with_body
call(:delete, encode_uri(uri), timeout, , body.to_json)
elsif method == :post_file
body.merge!(multipart: true)
= .except('Content-Type') if != nil
call(:post, encode_uri(uri), timeout, , body)
elsif method == :post_form
= .except('Content-Type') if != nil
call(:post, encode_uri(uri), timeout, , body.compact)
else
call(method, encode_uri(uri), timeout, , body.to_json)
end
case result.code
when 200...226 then safe_parse_json(result.body)
when 400 then raise Auth0::BadRequest.new(result.body, code: result.code, headers: result.)
when 401 then raise Auth0::Unauthorized.new(result.body, code: result.code, headers: result.)
when 403 then raise Auth0::AccessDenied.new(result.body, code: result.code, headers: result.)
when 404 then raise Auth0::NotFound.new(result.body, code: result.code, headers: result.)
when 429 then raise Auth0::RateLimitEncountered.new(result.body, code: result.code, headers: result.)
when 500 then raise Auth0::ServerError.new(result.body, code: result.code, headers: result.)
else raise Auth0::Unsupported.new(result.body, code: result.code, headers: result.)
end
end
|