class Snowshoe::Client

Constants

API_VERSION

Attributes

consumer[R]

Public Class Methods

new(key, secret, options={}) click to toggle source
# File lib/snowshoe/client.rb, line 5
def initialize(key, secret, options={})
  # Flexiblity for future endpoint uri changes
  api_version = options[:api_version] || API_VERSION

  @consumer = OAuth::Consumer.new(
  key,
  secret,
  {:site => api_version,
    :scheme => :header
  }
  )
end

Public Instance Methods

log_error(message) click to toggle source
# File lib/snowshoe/client.rb, line 32
def log_error(message)
  puts "ERROR: #{self.class}: #{message}"
end
post(body) click to toggle source
# File lib/snowshoe/client.rb, line 18
def post(body)
  response = consumer.request(:post,
  "/stamp",
  nil,
  {},
  body,
  {'Content-Type' => 'application/x-www-form-urlencoded'}
  )
  return JSON.parse(response.body)
rescue => exception
  log_error(exception.message)
  []
end