Class: Syncano::Resources::ApiKey

Inherits:
Base
  • Object
show all
Defined in:
lib/syncano/resources/api_key.rb

Overview

Api key resource

Instance Attribute Summary

Attributes inherited from Base

#attributes, #destroyed, #id

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, all, #batch, batch_create, #batch_destroy, #batch_save, #batch_update, count, create, #destroy, #destroyed?, find, #new_record?, #reload!, #save, #saved?, #update

Constructor Details

#initialize(client, attributes = {}) ⇒ ApiKey

Overwritten constructor with initializing associated role object

Parameters:



8
9
10
11
12
13
14
15
16
17
# File 'lib/syncano/resources/api_key.rb', line 8

def initialize(client, attributes = {})
  super(client, attributes)
  if @attributes[:role].is_a?(Hash)
    @attributes[:role] = ::Syncano::Resources::Role.new(client, @attributes[:role])
  end

  if @saved_attributes[:role].is_a?(Hash)
    @saved_attributes[:role] = ::Syncano::Resources::Role.new(client, @saved_attributes[:role])
  end
end

Instance Method Details

#authorize(permission) ⇒ Syncano::Resources::Base

Wrapper for api “authorize” method

Parameters:

  • permission (String)

Returns:



22
23
24
25
# File 'lib/syncano/resources/api_key.rb', line 22

def authorize(permission)
  perform_authorize(nil, permission: permission)
  self
end

#batch_authorize(batch_client, permission) ⇒ Syncano::Resources::Base

Wrapper for api “authorize” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • permission (String)

Returns:



31
32
33
34
# File 'lib/syncano/resources/api_key.rb', line 31

def batch_authorize(batch_client, permission)
  perform_authorize(batch_client, permission: permission)
  self
end

#batch_deauthorize(batch_client, permission) ⇒ Syncano::Resources::Base

Wrapper for api “deauthorize” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • permission (String)

Returns:



48
49
50
51
# File 'lib/syncano/resources/api_key.rb', line 48

def batch_deauthorize(batch_client, permission)
  perform_deauthorize(batch_client, permission: permission)
  self
end

#deauthorize(permission) ⇒ Syncano::Resources::Base

Wrapper for api “deauthorize” method

Parameters:

  • permission (String)

Returns:



39
40
41
42
# File 'lib/syncano/resources/api_key.rb', line 39

def deauthorize(permission)
  perform_deauthorize(nil, permission: permission)
  self
end