Class: Signatory::Credentials
- Inherits:
-
Object
- Object
- Signatory::Credentials
- Defined in:
- lib/signatory/credentials.rb
Instance Attribute Summary collapse
-
#access_secret ⇒ Object
Returns the value of attribute access_secret.
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, secret, access_token, access_secret, api_version = '1.2') ⇒ Credentials
constructor
A new instance of Credentials.
- #token ⇒ Object
Constructor Details
#initialize(key, secret, access_token, access_secret, api_version = '1.2') ⇒ Credentials
Returns a new instance of Credentials.
5 6 7 8 |
# File 'lib/signatory/credentials.rb', line 5 def initialize(key, secret, access_token, access_secret, api_version='1.2') $stderr.puts "Deprecation Warning: Signatory is now compatible with RightSignature API version 1.2, you have chosen #{api_version}. Please upgrade." if api_version != '1.2' @key, @secret, @access_token, @access_secret, @api_version = key, secret, access_token, access_secret, api_version end |
Instance Attribute Details
#access_secret ⇒ Object
Returns the value of attribute access_secret.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def access_secret @access_secret end |
#access_token ⇒ Object
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def access_token @access_token end |
#api_version ⇒ Object
Returns the value of attribute api_version.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def api_version @api_version end |
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
3 4 5 |
# File 'lib/signatory/credentials.rb', line 3 def secret @secret end |
Class Method Details
.load(source) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/signatory/credentials.rb', line 10 def self.load(source) h = if source.respond_to?(:read) YAML.load(source) elsif source.is_a?(Hash) source.inject({}){ |acc, (k, v)| acc[k.to_s] = v; acc} end new(h['key'], h['secret'], h['access_token'], h['access_secret'], h['api_version']||'1.2') end |
Instance Method Details
#token ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/signatory/credentials.rb', line 20 def token @consumer ||= OAuth::Consumer.new(key, secret, { :site => 'https://rightsignature.com', :scheme => :header, :http_method => :post, :request_token_path => "/oauth/request_token", :access_token_path => "/oauth/access_token", :authorize_path => "/oauth/authorize" }) @token ||= OAuth::AccessToken.new( @consumer, access_token, access_secret ) end |