Class: CFC::UserAPIToken

Inherits:
APIObject show all
Defined in:
lib/cfc/objects/user_api_token.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#initialize, #inspect, #method_missing, opts, relationship, #respond_to_missing?

Constructor Details

This class inherits a constructor from CFC::APIObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CFC::APIObject

Class Method Details

.delete(identifier) ⇒ Object



19
20
21
# File 'lib/cfc/objects/user_api_token.rb', line 19

def self.delete(identifier)
  @api.delete_to_json("user/tokens/#{identifier}")
end

.details(identifier) ⇒ Object



15
16
17
# File 'lib/cfc/objects/user_api_token.rb', line 15

def self.details(identifier)
  new(@api.get_json("user/tokens/#{identifier}")['result'])
end

.list(page: nil, per_page: nil, direction: nil) ⇒ Object



10
11
12
13
# File 'lib/cfc/objects/user_api_token.rb', line 10

def self.list(page: nil, per_page: nil, direction: nil)
  params = opts(binding).compact
  @api.get_json('user/tokens', params: params)['result'].map { |o| new(o) }
end

.roll(identifier) ⇒ Object



23
24
25
# File 'lib/cfc/objects/user_api_token.rb', line 23

def self.roll(identifier)
  @api.put_to_json("user/tokens/#{identifier}/value", {})
end

Instance Method Details

#deleteObject



31
32
33
# File 'lib/cfc/objects/user_api_token.rb', line 31

def delete
  CFC::UserAPIToken.delete(id)
end

#detailsObject



27
28
29
# File 'lib/cfc/objects/user_api_token.rb', line 27

def details
  CFC::UserAPIToken.details(id)
end

#rollObject



35
36
37
# File 'lib/cfc/objects/user_api_token.rb', line 35

def roll
  CFC::UserAPIToken.roll(id)
end