Class: OktaRedis::Grants

Inherits:
Model show all
Defined in:
app/models/okta_redis/grants.rb

Constant Summary collapse

CLASS_NAME =
'GrantsService'

Constants inherited from Model

Model::REDIS_CONFIG_KEY

Constants inherited from Common::RedisStore

Common::RedisStore::REQ_CLASS_INSTANCE_VARS

Instance Attribute Summary

Attributes inherited from Model

#id, #user

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Methods included from Common::CacheAside

#cache, #cached?, #do_cached_with

Methods inherited from Common::RedisStore

create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!

Constructor Details

This class inherits a constructor from Common::RedisStore

Instance Method Details

#allObject



7
8
9
# File 'app/models/okta_redis/grants.rb', line 7

def all
  @all_grants ||= service.grants(@user.okta_profile.id).body
end

#delete_grant(grant_id) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'app/models/okta_redis/grants.rb', line 15

def delete_grant(grant_id)
  delete_response = service.delete_grant(@user.okta_profile.id, grant_id)
  unless delete_response.success?
    log_message_to_sentry("Error deleting grant #{grant_id}", :error,
                          body: delete_response.body)
    raise 'Unable to delete grant'
  end
  delete_response
end

#delete_grants(grant_ids) ⇒ Object



11
12
13
# File 'app/models/okta_redis/grants.rb', line 11

def delete_grants(grant_ids)
  grant_ids.map { |grant| delete_grant(grant) }
end