Class: Seam::Clients::ConnectWebviews

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/connect_webviews.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ ConnectWebviews

Returns a new instance of ConnectWebviews.



6
7
8
9
# File 'lib/seam/routes/connect_webviews.rb', line 6

def initialize(client:, defaults:)
  @client = client
  @defaults = defaults
end

Instance Method Details

#create(accepted_capabilities: nil, accepted_providers: nil, automatically_manage_new_devices: nil, custom_metadata: nil, custom_redirect_failure_url: nil, custom_redirect_url: nil, customer_key: nil, excluded_providers: nil, provider_category: nil, wait_for_device_creation: nil) ⇒ Seam::Resources::ConnectWebview

Creates a new Connect Webview.

To enable a user to connect their devices or systems to Seam, they must sign in to their device or system account. To enable a user to sign in, you create a connect_webview. After creating the Connect Webview, you receive a URL that you can use to display the visual component of this Connect Webview for your user. You can open an iframe or new window to display the Connect Webview.

You should make a new connect_webview for each unique login request. Each connect_webview tracks the user that signed in with it. You receive an error if you reuse a Connect Webview for the same user twice or if you use the same Connect Webview for multiple users.

See also: Connect Webview Process.

Parameters:

  • accepted_capabilities (defaults to: nil)

    List of accepted device capabilities that restrict the types of devices that can be connected through the Connect Webview. If not provided, defaults will be determined based on the accepted providers.

  • accepted_providers (defaults to: nil)

    Accepted device provider keys as an alternative to provider_category. Use this parameter to specify accepted providers explicitly. See Customize the Brands to Display in Your Connect Webviews. To list all provider keys, use /devices/list_device_providers with no filters.

  • automatically_manage_new_devices (defaults to: nil)

    Indicates whether newly-added devices should appear as managed devices. See also: Customize the Behavior Settings of Your Connect Webviews.

  • custom_metadata (defaults to: nil)

    Custom metadata that you want to associate with the Connect Webview. Supports up to 50 JSON key:value pairs. Adding custom metadata to a Connect Webview enables you to store custom information, like customer details or internal IDs from your application. The custom metadata is then transferred to any connected accounts that were connected using the Connect Webview, making it easy to find and filter these resources in your workspace. You can also filter Connect Webviews by custom metadata.

  • custom_redirect_failure_url (defaults to: nil)

    Alternative URL that you want to redirect the user to on an error. If you do not set this parameter, the Connect Webview falls back to the custom_redirect_url.

  • custom_redirect_url (defaults to: nil)

    URL that you want to redirect the user to after the provider login is complete.

  • customer_key (defaults to: nil)

    Associate the Connect Webview, the connected account, and all resources under the connected account with a customer. If the connected account already exists, it will be associated with the customer. If the connected account already exists, but is already associated with a customer, the Connect Webview will show an error.

  • excluded_providers (defaults to: nil)

    List of provider keys to exclude from the Connect Webview. These providers will not be shown when the user tries to connect an account.

  • provider_category (defaults to: nil)

    Specifies the category of providers that you want to include. To list all providers within a category, use /devices/list_device_providers with the desired provider_category filter.

  • wait_for_device_creation (defaults to: nil)

    Indicates whether Seam should finish syncing all devices in a newly-connected account before completing the associated Connect Webview. See also: Customize the Behavior Settings of Your Connect Webviews.

Returns:



29
30
31
32
33
# File 'lib/seam/routes/connect_webviews.rb', line 29

def create(accepted_capabilities: nil, accepted_providers: nil, automatically_manage_new_devices: nil, custom_metadata: nil, custom_redirect_failure_url: nil, custom_redirect_url: nil, customer_key: nil, excluded_providers: nil, provider_category: nil, wait_for_device_creation: nil)
  res = @client.post("/connect_webviews/create", {accepted_capabilities: accepted_capabilities, accepted_providers: accepted_providers, automatically_manage_new_devices: automatically_manage_new_devices, custom_metadata: , custom_redirect_failure_url: custom_redirect_failure_url, custom_redirect_url: custom_redirect_url, customer_key: customer_key, excluded_providers: excluded_providers, provider_category: provider_category, wait_for_device_creation: wait_for_device_creation}.compact)

  Seam::Resources::ConnectWebview.load_from_response(res.body["connect_webview"])
end

#delete(connect_webview_id:) ⇒ nil

Deletes a Connect Webview.

You do not need to delete a Connect Webview once a user completes it. Instead, you can simply ignore completed Connect Webviews.

Parameters:

  • connect_webview_id

    ID of the Connect Webview that you want to delete.

Returns:

  • (nil)

    OK



40
41
42
43
44
# File 'lib/seam/routes/connect_webviews.rb', line 40

def delete(connect_webview_id:)
  @client.post("/connect_webviews/delete", {connect_webview_id: connect_webview_id}.compact)

  nil
end

#get(connect_webview_id:) ⇒ Seam::Resources::ConnectWebview

Returns a specified Connect Webview.

Unless you're using a custom_redirect_url, you should poll a newly-created connect_webview to find out if the user has signed in or to get details about what devices they've connected.

Parameters:

  • connect_webview_id

    ID of the Connect Webview that you want to get.

Returns:



51
52
53
54
55
# File 'lib/seam/routes/connect_webviews.rb', line 51

def get(connect_webview_id:)
  res = @client.post("/connect_webviews/get", {connect_webview_id: connect_webview_id}.compact)

  Seam::Resources::ConnectWebview.load_from_response(res.body["connect_webview"])
end

#list(custom_metadata_has: nil, customer_key: nil, limit: nil, page_cursor: nil, search: nil, user_identifier_key: nil) ⇒ Seam::Resources::ConnectWebview

Returns a list of all Connect Webviews.

Parameters:

  • custom_metadata_has (defaults to: nil)

    Custom metadata pairs by which you want to filter Connect Webviews. Returns Connect Webviews with custom_metadata that contains all of the provided key:value pairs.

  • customer_key (defaults to: nil)

    Customer key for which you want to list connect webviews.

  • limit (defaults to: nil)

    Maximum number of records to return per page.

  • page_cursor (defaults to: nil)

    Identifies the specific page of results to return, obtained from the previous page's next_page_cursor.

  • search (defaults to: nil)

    String for which to search. Filters returned Connect Webviews to include all records that satisfy a partial match using connect_webview_id, accepted_providers, custom_metadata, or customer_key.

  • user_identifier_key (defaults to: nil)

    Your user ID for the user by which you want to filter Connect Webviews.

Returns:



65
66
67
68
69
# File 'lib/seam/routes/connect_webviews.rb', line 65

def list(custom_metadata_has: nil, customer_key: nil, limit: nil, page_cursor: nil, search: nil, user_identifier_key: nil)
  res = @client.post("/connect_webviews/list", {custom_metadata_has: , customer_key: customer_key, limit: limit, page_cursor: page_cursor, search: search, user_identifier_key: user_identifier_key}.compact)

  Seam::Resources::ConnectWebview.load_from_response(res.body["connect_webviews"])
end