lib/soaspec/exchange_handlers/rest_accessors.rb in soaspec-0.1.12 vs lib/soaspec/exchange_handlers/rest_accessors.rb in soaspec-0.1.13
- old
+ new
@@ -1,5 +1,7 @@
+require_relative 'rest_accessors_defaults'
+
module Soaspec
# Accessors specific to REST handler
module RestAccessors
# Defines method 'base_url_value' containing base URL used in REST requests
@@ -9,28 +11,23 @@
url
end
end
# Will create access_token method based on passed parameters
- # @param [Hash] params Params client_id: nil, client_secret: nil, token_url: nil, username: nil, password: nil, security_token: nil
+ # @param [Hash] params OAuth 2 parameters
+ # @param_value [token_url] URL to retrieve OAuth token from. @Note this can be set globally instead of here
+ # @param_value [client_id] Client ID
+ # @param_value [client_secret] Client Secret
+ # @param_value [username] Username used in password grant
+ # @param_value [password] Password used in password grant
+ # @param_value [security_token] Security Token used in password grant
def oauth2(params)
- # Object to handle oauth2
- define_method('oauth_obj') do
- OAuth2.new(params, api_username)
- end
-
- # Method to send request to get oauth token based on parameters
- define_method('oauth_response') do
- oauth_obj.response
- end
-
- define_method('access_token') do
- oauth_obj.access_token
- end
-
- define_method('instance_url') do
- oauth_response['instance_url']
- end
+ # @!method oauth_obj Object to handle oauth2
+ define_method('oauth_obj') { OAuth2.new(params, api_username) }
+ # @!method access_token Retrieve OAuth2 access token
+ define_method('access_token') { oauth_obj.access_token }
+ # @!method instance_url Retrieve instance url from OAuth request
+ define_method('instance_url') { oauth_obj.response['instance_url'] }
end
# Pass path to YAML file containing OAuth2 parameters
# @param [String] path_to_filename Will have Soaspec.credentials_folder appended to it if set
def oauth2_file(path_to_filename)
\ No newline at end of file