Class: Signnow::Authentications::Oauth
- Includes:
- Operations::Create
- Defined in:
- lib/signnow/authentications/oauth.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#created ⇒ Object
Returns the value of attribute created.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#last_login ⇒ Object
Returns the value of attribute last_login.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#token_type ⇒ Object
Returns the value of attribute token_type.
Class Method Summary collapse
-
.authorize_url(options = {}) ⇒ Object
Returns the redirect url to authorize.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Oauth
constructor
Initializes the object using the given attributes.
-
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
-
#set_attributes(attributes) ⇒ Object
Sets the attributes.
Methods included from Operations::Create
Methods inherited from Base
Constructor Details
#initialize(attributes = {}) ⇒ Oauth
Initializes the object using the given attributes
46 47 48 49 |
# File 'lib/signnow/authentications/oauth.rb', line 46 def initialize(attributes = {}) set_attributes(attributes) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def access_token @access_token end |
#created ⇒ Object
Returns the value of attribute created.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def created @created end |
#expires_in ⇒ Object
Returns the value of attribute expires_in.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def expires_in @expires_in end |
#last_login ⇒ Object
Returns the value of attribute last_login.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def last_login @last_login end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def refresh_token @refresh_token end |
#scope ⇒ Object
Returns the value of attribute scope.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def scope @scope end |
#token_type ⇒ Object
Returns the value of attribute token_type.
6 7 8 |
# File 'lib/signnow/authentications/oauth.rb', line 6 def token_type @token_type end |
Class Method Details
.authorize_url(options = {}) ⇒ Object
Returns the redirect url to authorize
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/signnow/authentications/oauth.rb', line 14 def ( = {}) protocol = "https" base_url = "#{protocol}://#{domain}.#{API_BASE}" path = "/proxy/index.php/authorize" params = { client_id: Signnow.configuration[:app_id], redirect_uri: [:redirect_uri], response_type: 'code' } "#{base_url}#{path}?#{URI.encode_www_form(params)}" end |
Instance Method Details
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
61 62 63 64 65 |
# File 'lib/signnow/authentications/oauth.rb', line 61 def @created = Time.at(created.to_i) if created @expires_in = Time.at(expires_in.to_i) if expires_in @last_login = Time.at(last_login.to_i) if last_login end |
#set_attributes(attributes) ⇒ Object
Sets the attributes
54 55 56 57 58 |
# File 'lib/signnow/authentications/oauth.rb', line 54 def set_attributes(attributes) attributes.each_pair do |key, value| instance_variable_set("@#{key}", value) end end |