Class: Snowshoe::Client
- Inherits:
-
Object
- Object
- Snowshoe::Client
- Defined in:
- lib/snowshoe/client.rb
Constant Summary collapse
- API_VERSION =
"http://beta.snowshoestamp.com/api/v2"
Instance Method Summary collapse
-
#initialize(key, secret, options = {}) ⇒ Client
constructor
A new instance of Client.
- #log_error(message) ⇒ Object
- #post(body) ⇒ Object
Constructor Details
#initialize(key, secret, options = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/snowshoe/client.rb', line 5 def initialize(key, secret, ={}) # Flexiblity for future endpoint uri changes api_version = [:api_version] || API_VERSION @consumer = OAuth::Consumer.new( key, secret, {:site => api_version, :scheme => :header } ) end |
Instance Method Details
#log_error(message) ⇒ Object
32 33 34 |
# File 'lib/snowshoe/client.rb', line 32 def log_error() puts "ERROR: #{self.class}: #{}" end |
#post(body) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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.) [] end |