Class: Craftar::Token

Inherits:
Base
  • Object
show all
Defined in:
lib/craftar/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

basic_options, create, find, list, parse_response

Constructor Details

#initialize(opts) ⇒ Token

Returns a new instance of Token.



8
9
10
11
12
# File 'lib/craftar/token.rb', line 8

def initialize(opts)
  @collection = opts[:collection]
  @token = opts[:token]
  @resource_uri = opts[:resource_uri]
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



3
4
5
# File 'lib/craftar/token.rb', line 3

def collection
  @collection
end

#resource_uriObject (readonly)

Returns the value of attribute resource_uri.



3
4
5
# File 'lib/craftar/token.rb', line 3

def resource_uri
  @resource_uri
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/craftar/token.rb', line 3

def token
  @token
end

Class Method Details

.craftar_nameObject



4
5
6
# File 'lib/craftar/token.rb', line 4

def self.craftar_name
  'token'
end

Instance Method Details

#destroyObject



25
26
27
# File 'lib/craftar/token.rb', line 25

def destroy
  self.class.delete("/token/#{@token}/", self.class.basic_options)
end

#find(token) ⇒ Object



21
22
23
# File 'lib/craftar/token.rb', line 21

def find(token)
  raise 'You cannot find a token'
end

#saveObject



14
15
16
17
18
19
# File 'lib/craftar/token.rb', line 14

def save
  response = json_call(:post, collection: @collection)
  @token = response['token']
  @resource_uri = response['resource_uri']
  self
end