Class: EloquaApiService::Credential
- Inherits:
-
Object
- Object
- EloquaApiService::Credential
- Defined in:
- lib/eloqua_api_service/credential.rb
Constant Summary collapse
- DEFAULT_SERVICE =
'infunnel_cli_default'- LABEL =
'infunnel_cli'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #all ⇒ Object
- #create(make_default: nil, options: {}) ⇒ Object
- #default ⇒ Object
- #find(account: nil) ⇒ Object
-
#initialize ⇒ Credential
constructor
A new instance of Credential.
- #set_default(account:) ⇒ Object
Constructor Details
#initialize ⇒ Credential
Returns a new instance of Credential.
9 10 11 12 13 14 |
# File 'lib/eloqua_api_service/credential.rb', line 9 def initialize @key = nil = { label: LABEL } end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/eloqua_api_service/credential.rb', line 4 def key @key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/eloqua_api_service/credential.rb', line 4 def end |
Instance Method Details
#all ⇒ Object
22 23 24 |
# File 'lib/eloqua_api_service/credential.rb', line 22 def all Keychain.generic_passwords.where(label: LABEL).all end |
#create(make_default: nil, options: {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/eloqua_api_service/credential.rb', line 26 def create(make_default: nil, options: {}) find(account: [:account]).delete if find(account: [:account]) Keychain.generic_passwords.create(.merge()) if make_default || !default set_default(account: [:account]) end end |
#default ⇒ Object
36 37 38 39 40 41 |
# File 'lib/eloqua_api_service/credential.rb', line 36 def default default_pointer = Keychain.generic_passwords.where(service: DEFAULT_SERVICE).first if default_pointer @default ||= Keychain.generic_passwords.where(account: default_pointer.account).first end end |
#find(account: nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/eloqua_api_service/credential.rb', line 16 def find(account: nil) return default unless account Keychain.generic_passwords.where(account: account).first end |
#set_default(account:) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eloqua_api_service/credential.rb', line 43 def set_default(account:) default_pointer = Keychain.generic_passwords.where(service: DEFAULT_SERVICE).first default_pointer.delete if default_pointer Keychain.generic_passwords.create({ password: '-', service: DEFAULT_SERVICE, account: account }) end |