Module: Auth0::Api::V2::Connections
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/connections.rb
Overview
Methods to use the connections endpoints
Instance Method Summary collapse
-
#connection(connection_id, fields: nil, include_fields: true) ⇒ json
Retrieves a connection by its id.
-
#connections(strategy: nil, fields: nil, include_fields: true) ⇒ json
(also: #get_connections)
Retrieves every connection matching the specified strategy.
-
#create_connection(body) ⇒ json
Creates a new connection according to the JSON object received in body.
-
#delete_connection(connection_id) ⇒ Object
Deletes a connection and all its users.
-
#delete_connection_user(connection_id, user_email) ⇒ Object
Deletes a specified connection user by its email (currently only database connections are supported and you cannot delete all users from specific connection).
-
#update_connection(connection_id, body) ⇒ json
Updates a connection.
Instance Method Details
#connection(connection_id, fields: nil, include_fields: true) ⇒ json
Retrieves a connection by its id.
45 46 47 48 49 50 51 52 53 |
# File 'lib/auth0/api/v2/connections.rb', line 45 def connection(connection_id, fields: nil, include_fields: true) raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? path = "#{connections_path}/#{connection_id}" request_params = { fields: fields, include_fields: include_fields } get(path, request_params) end |
#connections(strategy: nil, fields: nil, include_fields: true) ⇒ json Also known as: get_connections
Retrieves every connection matching the specified strategy. All connections are retrieved if no strategy is being specified. Accepts a list of fields to include or exclude in the resulting list of connection objects. ‘facebook’, ‘twitter’).
17 18 19 20 21 22 23 24 |
# File 'lib/auth0/api/v2/connections.rb', line 17 def connections(strategy: nil, fields: nil, include_fields: true) request_params = { strategy: strategy, fields: fields, include_fields: include_fields } get(connections_path, request_params) end |
#create_connection(body) ⇒ json
Creates a new connection according to the JSON object received in body.
32 33 34 35 36 |
# File 'lib/auth0/api/v2/connections.rb', line 32 def create_connection(body) raise Auth0::InvalidParameter, 'Must specify a body to create a connection' if body.to_s.empty? request_params = body post(connections_path, request_params) end |
#delete_connection(connection_id) ⇒ Object
Deletes a connection and all its users.
58 59 60 61 62 |
# File 'lib/auth0/api/v2/connections.rb', line 58 def delete_connection(connection_id) raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? path = "#{connections_path}/#{connection_id}" delete(path) end |
#delete_connection_user(connection_id, user_email) ⇒ Object
Deletes a specified connection user by its email (currently only database connections are supported and you cannot delete all users from specific connection).
69 70 71 72 73 74 |
# File 'lib/auth0/api/v2/connections.rb', line 69 def delete_connection_user(connection_id, user_email) raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid user email' if user_email.to_s.empty? path = "#{connections_path}/#{connection_id}/users?email=#{user_email}" delete(path) end |
#update_connection(connection_id, body) ⇒ json
Updates a connection. Updates the fields specified in the body parameter.
82 83 84 85 86 |
# File 'lib/auth0/api/v2/connections.rb', line 82 def update_connection(connection_id, body) raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? path = "#{connections_path}/#{connection_id}" patch(path, body) end |