Class: DMS::API
Instance Attribute Summary collapse
-
#api_access_key ⇒ Object
Returns the value of attribute api_access_key.
-
#api_token ⇒ Object
Returns the value of attribute api_token.
Instance Method Summary collapse
- #format_extension ⇒ Object
- #generate_timestamp ⇒ Object
- #get(slug) ⇒ Object
-
#initialize(api_token = nil, api_access_key = nil) ⇒ API
constructor
A new instance of API.
- #slug_to_path(slug) ⇒ Object
Constructor Details
#initialize(api_token = nil, api_access_key = nil) ⇒ API
Returns a new instance of API.
11 12 13 14 |
# File 'lib/dms/api.rb', line 11 def initialize(api_token = nil, api_access_key = nil) @api_token = api_token.to_s @api_access_key = api_access_key.to_s end |
Instance Attribute Details
#api_access_key ⇒ Object
Returns the value of attribute api_access_key.
9 10 11 |
# File 'lib/dms/api.rb', line 9 def api_access_key @api_access_key end |
#api_token ⇒ Object
Returns the value of attribute api_token.
8 9 10 |
# File 'lib/dms/api.rb', line 8 def api_token @api_token end |
Instance Method Details
#format_extension ⇒ Object
16 17 18 |
# File 'lib/dms/api.rb', line 16 def format_extension ".#{self.class.format.to_s}" end |
#generate_timestamp ⇒ Object
20 21 22 |
# File 'lib/dms/api.rb', line 20 def Time.now.to_i.to_s end |
#get(slug) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dms/api.rb', line 28 def get(slug) response = perform_request(slug) if response.code == 200 DMS::Node.new(response) elsif response.code == 401 raise AuthenticationError.new(response.body) elsif response.code == 404 raise ResourceNotFound.new(response.body) else raise UnknownError.new(response.body) end end |
#slug_to_path(slug) ⇒ Object
24 25 26 |
# File 'lib/dms/api.rb', line 24 def slug_to_path(slug) File.join("/", slug.to_s) + format_extension end |