Class: Recurly::API
- Inherits:
-
Object
show all
- Extended by:
- Net::HTTPAdapter
- Defined in:
- lib/recurly/api.rb,
lib/recurly/api/errors.rb,
lib/recurly/api/net_http_adapter.rb
Overview
The API class handles all requests to the Recurly API. While most of its
functionality is leveraged by the Resource class, it can be used directly,
as well.
Requests are made with methods named after the four main HTTP verbs
recognized by the Recurly API.
Defined Under Namespace
Modules: Net
Classes: BadRequest, ClientError, Forbidden, GatewayError, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, NotModified, PaymentRequired, PreconditionFailed, Redirection, ResponseError, ServerError, ServiceUnavailable, Unauthorized, UnprocessableEntity, UnsupportedMediaType
Constant Summary
- ERRORS =
Error mapping by status code.
Hash.new { |hash, code|
unless hash.key? code
case code
when 400...500 then ClientError
when 500...600 then ServerError
else ResponseError
end
end
}.update(
304 => NotModified,
400 => BadRequest,
401 => Unauthorized,
402 => PaymentRequired,
403 => Forbidden,
404 => NotFound,
406 => NotAcceptable,
412 => PreconditionFailed,
415 => UnsupportedMediaType,
422 => UnprocessableEntity,
500 => InternalServerError,
502 => GatewayError,
503 => ServiceUnavailable
).freeze
- @@base_uri =
"https://api.recurly.com/v2/"
Net::HTTPAdapter::METHODS
Class Attribute Summary (collapse)
#net_http
Class Method Summary
(collapse)
-
+ (URI::Generic) base_uri
-
+ (Net::HTTPNoContent, Net::HTTPResponse) delete(uri, options = {})
-
+ (Net::HTTPOK, Net::HTTPResponse) get(uri, params = {}, options = {})
-
+ (Net::HTTPOK, Net::HTTPResponse) head(uri, params = {}, options = {})
-
+ (Net::HTTPCreated, Net::HTTPResponse) post(uri, body = nil, options = {})
-
+ (Net::HTTPOK, Net::HTTPResponse) put(uri, body = nil, options = {})
-
+ (String) user_agent
Class Attribute Details
+ (String) accept_language
21
22
23
|
# File 'lib/recurly/api.rb', line 21
def accept_language
@accept_language
end
|
Class Method Details
+ (URI::Generic) base_uri
54
55
56
|
# File 'lib/recurly/api.rb', line 54
def base_uri
URI.parse @@base_uri
end
|
+ (Net::HTTPNoContent, Net::HTTPResponse) delete(uri, options = {})
49
50
51
|
# File 'lib/recurly/api.rb', line 49
def delete uri, options = {}
request :delete, uri, options
end
|
+ (Net::HTTPOK, Net::HTTPResponse) get(uri, params = {}, options = {})
31
32
33
|
# File 'lib/recurly/api.rb', line 31
def get uri, params = {}, options = {}
request :get, uri, { :params => params }.merge(options)
end
|
+ (Net::HTTPOK, Net::HTTPResponse) head(uri, params = {}, options = {})
25
26
27
|
# File 'lib/recurly/api.rb', line 25
def head uri, params = {}, options = {}
request :head, uri, { :params => params }.merge(options)
end
|
+ (Net::HTTPCreated, Net::HTTPResponse) post(uri, body = nil, options = {})
37
38
39
|
# File 'lib/recurly/api.rb', line 37
def post uri, body = nil, options = {}
request :post, uri, { :body => body.to_s }.merge(options)
end
|
+ (Net::HTTPOK, Net::HTTPResponse) put(uri, body = nil, options = {})
43
44
45
|
# File 'lib/recurly/api.rb', line 43
def put uri, body = nil, options = {}
request :put, uri, { :body => body.to_s }.merge(options)
end
|
+ (String) user_agent
59
60
61
|
# File 'lib/recurly/api.rb', line 59
def user_agent
"Recurly/#{Version}; #{RUBY_DESCRIPTION}"
end
|