class Signetify::Client

Attributes

client[RW]
error_message[R]
response[R]

Public Class Methods

authorize(token) click to toggle source
# File lib/signetify.rb, line 14
def self.authorize(token)
  client.refresh_token = token
  client.grant_type = "refresh_token"
  client.fetch_access_token!

  new(response: client)
rescue Signet::AuthorizationError => e
  new(error_message: e.message)
end
client() click to toggle source
# File lib/signetify.rb, line 24
def self.client
  @client ||= fresh_client
end
client_options() click to toggle source
# File lib/signetify.rb, line 28
def self.client_options
  template = ERB.new File.new("#{Rails.root}/config/signetify.yml").read
  YAML.load template.result(binding)
end
fresh_client() click to toggle source
# File lib/signetify.rb, line 33
def self.fresh_client
  Signet::OAuth2::Client.new(client_options)
end
new(options={}) click to toggle source
# File lib/signetify.rb, line 9
def initialize(options={})
  @response = options[:response]
  @error_message = options[:error_message]
end

Public Instance Methods

successful?() click to toggle source
# File lib/signetify.rb, line 37
def successful?
  response.present?
end