Class: Seam::Clients::Devices

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ Devices

Returns a new instance of Devices.



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

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

Instance Method Details

#get(device_id: nil, name: nil) ⇒ Seam::Resources::Device

Returns a specified device.

You must specify either device_id or name.

Parameters:

  • device_id (String, nil) (defaults to: nil)

    ID of the device that you want to get.

  • name (String, nil) (defaults to: nil)

    Name of the device that you want to get.

Returns:



25
26
27
28
29
30
31
32
33
# File 'lib/seam/routes/devices.rb', line 25

def get(device_id: nil, name: nil)
  if device_id.nil? && name.nil?
    raise TypeError, "At least one parameter is required for /devices/get"
  end

  res = @client.get("/devices/get", {device_id: device_id, name: name}.compact)

  Seam::Resources::Device.load_from_response(res.body["device"])
end

#list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, customer_key: nil, device_ids: nil, device_type: nil, device_types: nil, limit: nil, manufacturer: nil, page_cursor: nil, search: nil, space_id: nil, unstable_location_id: nil, user_identifier_key: nil) ⇒ Seam::Resources::Device

Deprecated.

unstable_location_id: Use space_id.

Returns a list of all devices.

Parameters:

  • connect_webview_id (String, nil) (defaults to: nil)

    ID of the Connect Webview for which you want to list devices.

  • connected_account_id (String, nil) (defaults to: nil)

    ID of the connected account for which you want to list devices.

  • connected_account_ids (Array<String>, nil) (defaults to: nil)

    Array of IDs of the connected accounts for which you want to list devices.

  • created_before (Time, nil) (defaults to: nil)

    Timestamp by which to limit returned devices. Returns devices created before this timestamp.

  • custom_metadata_has (Hash, nil) (defaults to: nil)

    Set of key:value custom metadata pairs for which you want to list devices.

  • customer_key (String, nil) (defaults to: nil)

    Customer key for which you want to list devices.

  • device_ids (Array<String>, nil) (defaults to: nil)

    Array of device IDs for which you want to list devices.

  • device_type (String, nil) (defaults to: nil)

    Device type for which you want to list devices.

  • device_types (Array<String>, nil) (defaults to: nil)

    Array of device types for which you want to list devices.

  • limit (Float, nil) (defaults to: nil)

    Numerical limit on the number of devices to return.

  • manufacturer (String, nil) (defaults to: nil)

    Manufacturer for which you want to list devices.

  • page_cursor (String, Seam::Null, nil) (defaults to: nil)

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

  • search (String, nil) (defaults to: nil)

    String for which to search. Filters returned devices to include all records that satisfy a partial match using device_id (full or partial UUID prefix, minimum 4 characters), connected_account_id, display_name, custom_metadata or location.location_name.

  • space_id (String, nil) (defaults to: nil)

    ID of the space for which you want to list devices.

  • unstable_location_id (String, Seam::Null, nil) (defaults to: nil)
  • user_identifier_key (String, nil) (defaults to: nil)

    Your own internal user ID for the user for which you want to list devices.

Returns:



54
55
56
57
58
# File 'lib/seam/routes/devices.rb', line 54

def list(connect_webview_id: nil, connected_account_id: nil, connected_account_ids: nil, created_before: nil, custom_metadata_has: nil, customer_key: nil, device_ids: nil, device_type: nil, device_types: nil, limit: nil, manufacturer: nil, page_cursor: nil, search: nil, space_id: nil, unstable_location_id: nil, user_identifier_key: nil)
  res = @client.post("/devices/list", {connect_webview_id: connect_webview_id, connected_account_id: , connected_account_ids: , created_before: created_before, custom_metadata_has: , customer_key: customer_key, device_ids: device_ids, device_type: device_type, device_types: device_types, limit: limit, manufacturer: manufacturer, page_cursor: page_cursor, search: search, space_id: space_id, unstable_location_id: unstable_location_id, user_identifier_key: user_identifier_key}.compact)

  Seam::Resources::Device.load_from_response(res.body["devices"])
end

#list_device_providers(provider_category: nil) ⇒ Seam::Resources::DeviceProvider

Returns a list of all device providers.

The information that this endpoint returns for each provider includes a set of capability flags, such as device_provider.can_remotely_unlock. If at least one supported device from a provider has a specific capability, the corresponding capability flag is true.

When you create a Connect Webview, you can customize the providers—that is, the brands—that it displays. In the /connect_webviews/create request, include the desired set of device provider keys in the accepted_providers parameter. See also Customize the Brands to Display in Your Connect Webviews.

Parameters:

  • provider_category (String, nil) (defaults to: nil)

    Category for which you want to list providers.

Returns:



67
68
69
70
71
# File 'lib/seam/routes/devices.rb', line 67

def list_device_providers(provider_category: nil)
  res = @client.get("/devices/list_device_providers", {provider_category: provider_category}.compact)

  Seam::Resources::DeviceProvider.load_from_response(res.body["device_providers"])
end

#report_provider_metadata(devices:) ⇒ nil

Updates provider-specific metadata for devices.

Parameters:

  • devices (Array<Hash>)

    Array of devices with provider metadata to update

Returns:

  • (nil)

    OK



76
77
78
79
80
# File 'lib/seam/routes/devices.rb', line 76

def (devices:)
  @client.post("/devices/report_provider_metadata", {devices: devices}.compact)

  nil
end

#simulateObject



11
12
13
# File 'lib/seam/routes/devices.rb', line 11

def simulate
  @simulate ||= Seam::Clients::DevicesSimulate.new(client: @client, defaults: @defaults)
end

#unmanagedObject



15
16
17
# File 'lib/seam/routes/devices.rb', line 15

def unmanaged
  @unmanaged ||= Seam::Clients::DevicesUnmanaged.new(client: @client, defaults: @defaults)
end

#update(device_id:, backup_access_code_pool_enabled: nil, custom_metadata: nil, is_managed: nil, name: nil, properties: nil) ⇒ nil

Updates a specified device.

You can add or change custom metadata for a device, change the device's name, or convert a managed device to unmanaged.

Parameters:

  • device_id (String)

    ID of the device that you want to update.

  • backup_access_code_pool_enabled (Boolean, nil) (defaults to: nil)

    Indicates whether the device's backup access code pool is enabled. Set to false to disable the pool: Seam stops refilling it and removes any backup codes that have not yet been pulled into active use.

  • custom_metadata (Hash, nil) (defaults to: nil)

    Custom metadata that you want to associate with the device. Supports up to 50 JSON key:value pairs. Adding custom metadata to a device enables you to store custom information, like customer details or internal IDs from your application. Then, you can filter devices by the desired metadata.

  • is_managed (Boolean, nil) (defaults to: nil)

    Indicates whether the device is managed. To unmanage a device, set is_managed to false.

  • name (String, Seam::Null, nil) (defaults to: nil)

    Name for the device.

  • properties (Hash, nil) (defaults to: nil)

Returns:

  • (nil)

    OK



92
93
94
95
96
# File 'lib/seam/routes/devices.rb', line 92

def update(device_id:, backup_access_code_pool_enabled: nil, custom_metadata: nil, is_managed: nil, name: nil, properties: nil)
  @client.patch("/devices/update", {device_id: device_id, backup_access_code_pool_enabled: backup_access_code_pool_enabled, custom_metadata: , is_managed: is_managed, name: name, properties: properties}.compact)

  nil
end