Class: SFRest::Site_ownership

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Site_ownership

Returns a new instance of Site_ownership.

Parameters:



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

def initialize(conn)
  @conn = conn
end

Instance Method Details

#default_ownershipArray

Get current site ownership settings.

Returns:

  • (Array)

    an array containing current settings.



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

def default_ownership
  @conn.get('/api/v1/site-ownership')
end

#make_default_owner(username) ⇒ Array

Set the site ownership settings.

Parameters:

  • The (String)

    default owner username. The user has to have the “Platform admin” role.

Returns:

  • (Array)

    an array containing the message given by the server.



26
27
28
29
30
31
32
# File 'lib/sfrest/site_ownership.rb', line 26

def make_default_owner(username)
  payload = {
    'username' => username
  }

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

#remove_default_ownerArray

Removes the default site owner.

Returns:

  • (Array)

    an array containing the message given by the server.



37
38
39
# File 'lib/sfrest/site_ownership.rb', line 37

def remove_default_owner
  @conn.delete('/api/v1/site-ownership')
end

#transfer_site_ownership_using_email(site_id, email, force_transfer) ⇒ Array

Transfers site ownership using recipients email.

Parameters:

  • site (Integer)

    id.

  • email. (String)
  • force_transfer. (Boolean)

Returns:

  • (Array)

    an array containing the message given by the server.



62
63
64
65
66
67
68
69
# File 'lib/sfrest/site_ownership.rb', line 62

def transfer_site_ownership_using_email(site_id, email, force_transfer)
  payload = {
    'email' => email,
    'force_transfer' => force_transfer
  }

  @conn.post("/api/v1/site-ownership/#{site_id}", payload.to_json)
end

#transfer_site_ownership_using_username(site_id, username, force_transfer) ⇒ Array

Transfers site ownership using recipients username.

Parameters:

  • site (Integer)

    id.

  • username. (String)
  • force_transfer. (Boolean)

Returns:

  • (Array)

    an array containing the message given by the server.



47
48
49
50
51
52
53
54
# File 'lib/sfrest/site_ownership.rb', line 47

def transfer_site_ownership_using_username(site_id, username, force_transfer)
  payload = {
    'username' => username,
    'force_transfer' => force_transfer
  }

  @conn.post("/api/v1/site-ownership/#{site_id}", payload.to_json)
end