Class: Round::Application

Inherits:
Base
  • Object
show all
Defined in:
lib/round/application.rb

Instance Attribute Summary

Attributes inherited from Base

#resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

association, #hash_identifier, #initialize, #method_missing, #refresh

Constructor Details

This class inherits a constructor from Round::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Round::Base

Class Method Details

.hash_identifierObject



30
31
32
# File 'lib/round/application.rb', line 30

def self.hash_identifier
  'name'
end

Instance Method Details

#account_from_key(user_key, account_key) ⇒ Object



26
27
28
# File 'lib/round/application.rb', line 26

def (user_key, )
  user_from_key(user_key).accounts.detect { |a| a.key ==  }
end

#authorize_instance(name) ⇒ Object



10
11
12
# File 'lib/round/application.rb', line 10

def authorize_instance(name)
  @resource.authorize_instance(name: name)
end

#get_mfaObject



38
39
40
# File 'lib/round/application.rb', line 38

def get_mfa
  @totp.now
end

#reset(*resets) ⇒ Object



47
48
49
50
# File 'lib/round/application.rb', line 47

def reset(*resets)
  @resource.reset(resets)
  self
end

#totp=(totp_secret) ⇒ Object



34
35
36
# File 'lib/round/application.rb', line 34

def totp=(totp_secret)
  @totp = ROTP::TOTP.new(totp_secret)
end

#user_from_key(key) ⇒ Object



22
23
24
# File 'lib/round/application.rb', line 22

def user_from_key(key)
  users.detect { |u| u.key == key }
end

#walletsObject



14
15
16
17
18
19
20
# File 'lib/round/application.rb', line 14

def wallets
  Round::WalletCollection.new(
    resource: @resource.wallets,
    client: @client,
    application: self
  )
end

#with_mfa!(token) ⇒ Object



42
43
44
45
# File 'lib/round/application.rb', line 42

def with_mfa!(token)
  context.mfa_token = token
  self
end