Parent

Simplify::AccessToken

An OAuth access token.

Public Class Methods

create(auth_code, redirect_uri, *auth) click to toggle source

Creates an OAuth access token object.

auth_code: The OAuth authentication code. redirect_uri: The OAuth redirection URI.

auth

Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used.

# File lib/simplify/accesstoken.rb, line 49
def self.create(auth_code, redirect_uri, *auth)

    props = {
            'grant_type' => 'authorization_code',
            'code' => auth_code,
            'redirect_uri' => redirect_uri
    }

    h = Simplify::PaymentsApi.send_auth_request(props, 'token', Simplify::PaymentsApi.create_auth_object(auth))

    obj = AccessToken.new()
    obj = obj.merge!(h)

    obj

end
new(options = {}) click to toggle source

Construct a AccessToken from a hash.

# File lib/simplify/accesstoken.rb, line 38
def initialize(options = {})
    self.merge!(options)
end

Public Instance Methods

refresh(*auth) click to toggle source

Refreshes the OAuth access token

auth

Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used.

# File lib/simplify/accesstoken.rb, line 71
def refresh(*auth)

    rt = self['refresh_token']
    if rt == nil || rt.empty?
        raise ArgumentError.new("Cannot refresh access token; refresh token is invalid.")
    end

    props = {
            'grant_type' => 'refresh_token',
            'refresh_token' => rt
    }

    h = Simplify::PaymentsApi.send_auth_request(props, 'token', Simplify::PaymentsApi.create_auth_object(auth))

    self.merge!(h)
    self
end
revoke(*auth) click to toggle source

Revokes the access token.

auth

Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used.

# File lib/simplify/accesstoken.rb, line 94
def revoke(*auth)

    token = self['access_token']
    if token == nil || token.empty?
        raise ArgumentError.new("Cannot revoke access token; access token is invalid.")
    end

    props = {
            'token' => token
    }

    h = Simplify::PaymentsApi.send_auth_request(props, 'revoke', Simplify::PaymentsApi.create_auth_object(auth))
    self.clear
    self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.