Class: WorkOS::Radar
- Inherits:
-
Object
- Object
- WorkOS::Radar
- Defined in:
- lib/workos/radar.rb
Instance Method Summary collapse
-
#add_list_entry(type:, action:, entry:, request_options: {}) ⇒ WorkOS::RadarListEntryAlreadyPresentResponse
Add an entry to a Radar list.
-
#create_attempt(ip_address:, user_agent:, email:, auth_method:, action:, device_fingerprint: nil, bot_score: nil, request_options: {}) ⇒ WorkOS::RadarStandaloneResponse
Create an attempt.
-
#initialize(client) ⇒ Radar
constructor
A new instance of Radar.
-
#remove_list_entry(type:, action:, entry:, request_options: {}) ⇒ void
Remove an entry from a Radar list.
-
#update_attempt(id:, challenge_status: nil, attempt_status: nil, request_options: {}) ⇒ void
Update a Radar attempt.
Constructor Details
#initialize(client) ⇒ Radar
Returns a new instance of Radar.
9 10 11 |
# File 'lib/workos/radar.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#add_list_entry(type:, action:, entry:, request_options: {}) ⇒ WorkOS::RadarListEntryAlreadyPresentResponse
Add an entry to a Radar list
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/workos/radar.rb', line 86 def add_list_entry( type:, action:, entry:, request_options: {} ) body = { "entry" => entry }.compact response = @client.request( method: :post, path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}", auth: true, body: body, request_options: ) result = WorkOS::RadarListEntryAlreadyPresentResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_attempt(ip_address:, user_agent:, email:, auth_method:, action:, device_fingerprint: nil, bot_score: nil, request_options: {}) ⇒ WorkOS::RadarStandaloneResponse
Create an attempt
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/workos/radar.rb', line 23 def create_attempt( ip_address:, user_agent:, email:, auth_method:, action:, device_fingerprint: nil, bot_score: nil, request_options: {} ) body = { "ip_address" => ip_address, "user_agent" => user_agent, "email" => email, "auth_method" => auth_method, "action" => action, "device_fingerprint" => device_fingerprint, "bot_score" => bot_score }.compact response = @client.request( method: :post, path: "/radar/attempts", auth: true, body: body, request_options: ) result = WorkOS::RadarStandaloneResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#remove_list_entry(type:, action:, entry:, request_options: {}) ⇒ void
This method returns an undefined value.
Remove an entry from a Radar list
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/workos/radar.rb', line 113 def remove_list_entry( type:, action:, entry:, request_options: {} ) body = { "entry" => entry }.compact @client.request( method: :delete, path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}", auth: true, body: body, request_options: ) nil end |
#update_attempt(id:, challenge_status: nil, attempt_status: nil, request_options: {}) ⇒ void
This method returns an undefined value.
Update a Radar attempt
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/workos/radar.rb', line 60 def update_attempt( id:, challenge_status: nil, attempt_status: nil, request_options: {} ) body = { "challenge_status" => challenge_status, "attempt_status" => attempt_status }.compact @client.request( method: :put, path: "/radar/attempts/#{WorkOS::Util.encode_path(id)}", auth: true, body: body, request_options: ) nil end |