Class: SFRest::Site_guard

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrest/site_guard.rb

Overview

We need to keep this naming due to the way connection.rb autoloads things. rubocop: disable Naming/ClassAndModuleCamelCase Manage the site guard feature.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Site_guard

Returns a new instance of Site_guard.

Parameters:



11
12
13
# File 'lib/sfrest/site_guard.rb', line 11

def initialize(conn)
  @conn = conn
end

Instance Method Details

#current_settingsArray

Get current site guard settings.

Returns:

  • (Array)

    an array containing current settings.



18
19
20
# File 'lib/sfrest/site_guard.rb', line 18

def current_settings
  @conn.get('/api/v1/site-guard')
end

#disable_site_guardArray

Removes and disableds the site guard settings.

Returns:

  • (Array)

    an array containing the message given by the server.



41
42
43
# File 'lib/sfrest/site_guard.rb', line 41

def disable_site_guard
  @conn.delete('/api/v1/site-guard')
end

#enable_site_guard(message, username, password) ⇒ Array

Set and enables the site guard settings.

Parameters:

  • The (String)

    message which will be displayed by the site guard.

  • The (String)

    username which will be required by the site guard.

  • The (String)

    password which will be required by the site guard.

Returns:

  • (Array)

    an array containing the message given by the server.



28
29
30
31
32
33
34
35
36
# File 'lib/sfrest/site_guard.rb', line 28

def enable_site_guard(message, username, password)
  payload = {
    'message' => message,
    'username' => username,
    'password' => password
  }

  @conn.put('/api/v1/site-guard', payload.to_json)
end