Module: Authsignal

Defined in:
lib/authsignal.rb,
lib/authsignal/client.rb,
lib/authsignal/version.rb,
lib/authsignal/api_error.rb,
lib/authsignal/configuration.rb,
lib/authsignal/middleware/json_request.rb,
lib/authsignal/middleware/json_response.rb

Defined Under Namespace

Modules: Middleware Classes: ApiError, Client, Configuration

Constant Summary collapse

NON_API_METHODS =
[:setup, :configuration, :default_configuration]
VERSION =
"4.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



20
21
22
# File 'lib/authsignal.rb', line 20

def configuration
    @configuration ||= Authsignal::Configuration.new
end

Class Method Details

.default_configurationObject



24
25
26
# File 'lib/authsignal.rb', line 24

def default_configuration
    configuration.defaults
end

.delete_authenticator(user_id:, user_authenticator_id:) ⇒ Object



65
66
67
68
69
# File 'lib/authsignal.rb', line 65

def delete_authenticator(user_id:, user_authenticator_id: )
    response = Client.new.delete_authenticator(user_id: user_id, user_authenticator_id: user_authenticator_id)

    handle_response(response)
end

.delete_user(user_id:) ⇒ Object



40
41
42
43
44
# File 'lib/authsignal.rb', line 40

def delete_user(user_id:)
    response = Client.new.delete_user(user_id: user_id)

    handle_response(response)
end

.enroll_verified_authenticator(user_id:, authenticator:) ⇒ Object



59
60
61
62
63
# File 'lib/authsignal.rb', line 59

def enroll_verified_authenticator(user_id:, authenticator:)
    response = Client.new.enroll_verified_authenticator(user_id, authenticator)

    handle_response(response)
end

.get_action(user_id:, action:, idempotency_key:) ⇒ Object



46
47
48
49
50
# File 'lib/authsignal.rb', line 46

def get_action(user_id:, action:, idempotency_key:)
    response = Client.new.get_action(user_id, action, idempotency_key)

    handle_response(response)
end

.get_user(user_id:, redirect_url: nil) ⇒ Object



28
29
30
31
32
# File 'lib/authsignal.rb', line 28

def get_user(user_id:, redirect_url: nil)
    response = Client.new.get_user(user_id: user_id, redirect_url: redirect_url)

    handle_response(response)
end

.setup {|configuration| ... } ⇒ Object

Yields:



16
17
18
# File 'lib/authsignal.rb', line 16

def setup
    yield(configuration)
end

.track(event, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


71
72
73
74
75
76
77
# File 'lib/authsignal.rb', line 71

def track(event, options={})
    raise ArgumentError, "Action Code is required" unless event[:action].to_s.length > 0
    raise ArgumentError, "User ID value" unless event[:user_id].to_s.length > 0

    response = Client.new.track(event)
    handle_response(response)
end

.update_action_state(user_id:, action:, idempotency_key:, state:) ⇒ Object



52
53
54
55
56
57
# File 'lib/authsignal.rb', line 52

def update_action_state(user_id:, action:, idempotency_key:, state:)
    # NOTE: Rely on API to respond when given invalid state
    response = Client.new.update_action_state(user_id: user_id, action: action, idempotency_key: idempotency_key, state: state)

    handle_response(response)
end

.update_user(user_id:, user:) ⇒ Object



34
35
36
37
38
# File 'lib/authsignal.rb', line 34

def update_user(user_id:, user:)
    response = Client.new.update_user(user_id: user_id, user: user)

    handle_response(response)
end

.validate_challenge(token:, user_id: nil, action: nil) ⇒ Object



79
80
81
82
83
# File 'lib/authsignal.rb', line 79

def validate_challenge(token:, user_id: nil, action: nil)
    response = Client.new.validate_challenge(user_id: user_id, token: token, action: action)
    
    handle_response(response)
end