Module: Broadstreet::NetworkMethods

Included in:
Client
Defined in:
lib/broadstreet/network_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_network(params) ⇒ Hash

Create a new network and make the current user a network_admin

Parameters:

  • params: (Hash)

    a hash of the data for the network

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :name (String)

    The name of the network

Returns:

  • (Hash)

    the detail of the created network



34
35
36
# File 'lib/broadstreet/network_methods.rb', line 34

def create_network(params)
  request(:post, 'api/1/networks', params).network
end

#create_network_admin(network_id, user_id) ⇒ Object

Create a network admin

Parameters:

  • network_id: (Fixnum)

    The id of the network for the admin

  • user_id: (Fixnum)

    The id of the user to make an admin



42
43
44
45
# File 'lib/broadstreet/network_methods.rb', line 42

def create_network_admin(network_id, user_id)
  params = { user_id: user_id }
  request(:post, "api/1/networks/#{network_id}/network_admins", params)
end

#get_network(network_id) ⇒ Hash

Get a particular network

Parameters:

  • network_id: (Fixnum)

    The ID of the network to retrieve

Returns:

  • (Hash)

    the network detail



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

def get_network(network_id)
  request(:get, "api/1/networks/#{network_id}").network
end

#list_networksArray<Hash>

List accessible networks

Returns:

  • (Array<Hash>)

    the data for the networks



8
9
10
# File 'lib/broadstreet/network_methods.rb', line 8

def list_networks
  request(:get, 'api/1/networks').networks
end

#remove_network_admin(network_id, user_id) ⇒ Object

Remove a network admin

Parameters:

  • network_id: (Fixnum)

    The id of the network for the admin

  • user_id: (Fixnum)

    The id of the user to make an admin



51
52
53
54
# File 'lib/broadstreet/network_methods.rb', line 51

def remove_network_admin(network_id, user_id)
  params = { user_id: user_id }
  request(:delete, "api/1/networks/#{network_id}/network_admins", params)
end

#update_network(network_id, params) ⇒ Hash

Update the data for a particular network

Parameters:

  • network_id: (Fixnum)

    The ID of the network to update

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :name (String)

    The name of the network

Returns:

  • (Hash)

    the updated network detail



25
26
27
# File 'lib/broadstreet/network_methods.rb', line 25

def update_network(network_id, params)
  request(:put, "api/1/networks/#{network_id}", params).network
end