Permalink
Browse files

Added token creation for upload tokens.

  • Loading branch information...
1 parent 6d547b8 commit ab8d089627c1584bedc8bd24545a49012d1404ed @jeremyboles committed Jan 29, 2013
Showing with 21 additions and 2 deletions.
  1. +1 −0 lib/snapshot.rb
  2. +0 −1 lib/snapshot/image.rb
  3. +19 −0 lib/snapshot/token.rb
  4. +1 −1 lib/snapshot/url.rb
View
1 lib/snapshot.rb
@@ -1,5 +1,6 @@
require 'snapshot/connection'
require 'snapshot/image'
+require 'snapshot/token'
require 'snapshot/url'
require 'snapshot/version'
View
1 lib/snapshot/image.rb
@@ -1,5 +1,4 @@
require 'json'
-require 'rest_client'
module Snapshot
class Image
View
19 lib/snapshot/token.rb
@@ -0,0 +1,19 @@
+module Snapshot
+ class Token
+ attr_accessor :expires_in, :token
+
+ def self.create
+ result = Snapshot.connection.post('/token')
+ info = JSON.parse(result)
+
+ self.new.tap do |t|
+ t.expires_in = info['expires_in']
+ t.token = info['token']
+ end
+ end
+
+ def to_s
+ token
+ end
+ end
+end
View
2 lib/snapshot/url.rb
@@ -10,7 +10,7 @@ def initialize(id, extension, &block)
end
def method_missing(processor, *options)
- @options << [processor.to_s, options]
+ @options << [":#{processor}", options]
end
def to_s

0 comments on commit ab8d089

Please sign in to comment.