Module: DwollaSwagger::Swagger
- Defined in:
- lib/dwolla_swagger/swagger.rb,
lib/dwolla_swagger/swagger/request.rb,
lib/dwolla_swagger/swagger/version.rb,
lib/dwolla_swagger/swagger/response.rb,
lib/dwolla_swagger/swagger/configuration.rb
Defined Under Namespace
Classes: Configuration, Request, Response
Constant Summary collapse
- VERSION =
"1.0.12"
Class Attribute Summary collapse
-
.configuration ⇒ Object
A Swagger configuration object.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.resources ⇒ Object
Returns the value of attribute resources.
Class Method Summary collapse
- .authenticate ⇒ Object
- .authenticated? ⇒ Boolean
-
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
- .de_authenticate ⇒ Object
Class Attribute Details
.configuration ⇒ Object
A Swagger configuration object. Must act like a hash and return sensible values for all Swagger configuration options. See Swagger::Configuration.
11 12 13 |
# File 'lib/dwolla_swagger/swagger.rb', line 11 def configuration @configuration end |
.logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/dwolla_swagger/swagger.rb', line 7 def logger @logger end |
.resources ⇒ Object
Returns the value of attribute resources.
13 14 15 |
# File 'lib/dwolla_swagger/swagger.rb', line 13 def resources @resources end |
Class Method Details
.authenticate ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dwolla_swagger/swagger.rb', line 51 def authenticate return if Swagger.authenticated? if Swagger.configuration.username.blank? || Swagger.configuration.password.blank? raise ClientError, "Username and password are required to authenticate." end request = Swagger::Request.new( :get, "account/authenticate/{username}", :params => { :username => Swagger.configuration.username, :password => Swagger.configuration.password } ) response_body = request.response.body Swagger.configuration.access_token = response_body['token'] end |
.authenticated? ⇒ Boolean
43 44 45 |
# File 'lib/dwolla_swagger/swagger.rb', line 43 def authenticated? Swagger.configuration.access_token.present? end |
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dwolla_swagger/swagger.rb', line 25 def configure yield(configuration) if block_given? # Configure logger. Default to use Rails self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT)) # remove :// from scheme configuration.scheme.sub!(/:\/\//, '') # remove http(s):// and anything after a slash configuration.host.sub!(/https?:\/\//, '') configuration.host = configuration.host.split('/').first # Add leading and trailing slashes to base_path configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/') configuration.base_path = "" if configuration.base_path == "/" end |
.de_authenticate ⇒ Object
47 48 49 |
# File 'lib/dwolla_swagger/swagger.rb', line 47 def de_authenticate Swagger.configuration.access_token = nil end |