Class: Seam::Clients::Spaces

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ Spaces

Returns a new instance of Spaces.



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

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

Instance Method Details

#add_acs_entrances(acs_entrance_ids:, space_id:) ⇒ nil

Adds entrances to a specific space.

Parameters:

  • acs_entrance_ids (Array<String>)

    IDs of the entrances that you want to add to the space.

  • space_id (String)

    ID of the space to which you want to add entrances.

Returns:

  • (nil)

    OK



15
16
17
18
19
# File 'lib/seam/routes/spaces.rb', line 15

def add_acs_entrances(acs_entrance_ids:, space_id:)
  @client.put("/spaces/add_acs_entrances", {acs_entrance_ids: acs_entrance_ids, space_id: space_id}.compact)

  nil
end

#add_connected_account(connected_account_id:, space_id:) ⇒ nil

Adds a connected account to a specific space.

Parameters:

  • connected_account_id (String)

    ID of the connected account that you want to add to the space.

  • space_id (String)

    ID of the space to which you want to add the connected account.

Returns:

  • (nil)

    OK



25
26
27
28
29
# File 'lib/seam/routes/spaces.rb', line 25

def (connected_account_id:, space_id:)
  @client.put("/spaces/add_connected_account", {connected_account_id: , space_id: space_id}.compact)

  nil
end

#add_devices(device_ids:, space_id:) ⇒ nil

Adds devices to a specific space.

Parameters:

  • device_ids (Array<String>)

    IDs of the devices that you want to add to the space.

  • space_id (String)

    ID of the space to which you want to add devices.

Returns:

  • (nil)

    OK



35
36
37
38
39
# File 'lib/seam/routes/spaces.rb', line 35

def add_devices(device_ids:, space_id:)
  @client.put("/spaces/add_devices", {device_ids: device_ids, space_id: space_id}.compact)

  nil
end

#create(name:, acs_entrance_ids: nil, connected_account_ids: nil, customer_data: nil, customer_key: nil, device_ids: nil, space_key: nil) ⇒ Seam::Resources::Space

Creates a new space.

Parameters:

  • name (String)

    Name of the space that you want to create.

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

    IDs of the entrances that you want to add to the new space.

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

    IDs of connected accounts to associate with the new space. Persisted on seam.location_third_party_account so the UI can show which provider account(s) a space came from.

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

    Reservation/stay-related defaults for the space.

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

    Customer key for which you want to create the space.

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

    IDs of the devices that you want to add to the new space.

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

    Unique key for the space within the workspace.

Returns:



50
51
52
53
54
# File 'lib/seam/routes/spaces.rb', line 50

def create(name:, acs_entrance_ids: nil, connected_account_ids: nil, customer_data: nil, customer_key: nil, device_ids: nil, space_key: nil)
  res = @client.post("/spaces/create", {name: name, acs_entrance_ids: acs_entrance_ids, connected_account_ids: , customer_data: customer_data, customer_key: customer_key, device_ids: device_ids, space_key: space_key}.compact)

  Seam::Resources::Space.load_from_response(res.body["space"])
end

#delete(space_id:) ⇒ nil

Deletes a space.

Parameters:

  • space_id (String)

    ID of the space that you want to delete.

Returns:

  • (nil)

    OK



59
60
61
62
63
# File 'lib/seam/routes/spaces.rb', line 59

def delete(space_id:)
  @client.delete("/spaces/delete", {space_id: space_id}.compact)

  nil
end

#get(space_id: nil, space_key: nil) ⇒ Seam::Resources::Space

Gets a space.

Parameters:

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

    ID of the space that you want to get.

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

    Unique key of the space that you want to get.

Returns:



69
70
71
72
73
74
75
76
77
# File 'lib/seam/routes/spaces.rb', line 69

def get(space_id: nil, space_key: nil)
  if space_id.nil? && space_key.nil?
    raise TypeError, "At least one parameter is required for /spaces/get"
  end

  res = @client.get("/spaces/get", {space_id: space_id, space_key: space_key}.compact)

  Seam::Resources::Space.load_from_response(res.body["space"])
end

Gets all related resources for one or more Spaces.

Parameters:

  • exclude (Array<String>, nil) (defaults to: nil)
  • include (Array<String>, nil) (defaults to: nil)
  • space_ids (Array<String>, nil) (defaults to: nil)

    IDs of the spaces that you want to get along with their related resources.

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

    Keys of the spaces that you want to get along with their related resources.

Returns:



85
86
87
88
89
90
91
92
93
# File 'lib/seam/routes/spaces.rb', line 85

def get_related(exclude: nil, include: nil, space_ids: nil, space_keys: nil)
  if exclude.nil? && include.nil? && space_ids.nil? && space_keys.nil?
    raise TypeError, "At least one parameter is required for /spaces/get_related"
  end

  res = @client.post("/spaces/get_related", {exclude: exclude, include: include, space_ids: space_ids, space_keys: space_keys}.compact)

  Seam::Resources::Batch.load_from_response(res.body["batch"])
end

#list(customer_key: nil, limit: nil, page_cursor: nil, search: nil, space_key: nil) ⇒ Seam::Resources::Space

Returns a list of all spaces.

Parameters:

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

    Customer key for which you want to list spaces.

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

    Maximum number of records to return per page.

  • page_cursor (String, 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 spaces to include all records that satisfy a partial match using name, space_key, or customer_key.

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

    Filter spaces by space_key.

Returns:



102
103
104
105
106
# File 'lib/seam/routes/spaces.rb', line 102

def list(customer_key: nil, limit: nil, page_cursor: nil, search: nil, space_key: nil)
  res = @client.get("/spaces/list", {customer_key: customer_key, limit: limit, page_cursor: page_cursor, search: search, space_key: space_key}.compact)

  Seam::Resources::Space.load_from_response(res.body["spaces"])
end

#remove_acs_entrances(acs_entrance_ids:, space_id:) ⇒ nil

Removes entrances from a specific space.

Parameters:

  • acs_entrance_ids (Array<String>)

    IDs of the entrances that you want to remove from the space.

  • space_id (String)

    ID of the space from which you want to remove entrances.

Returns:

  • (nil)

    OK



112
113
114
115
116
# File 'lib/seam/routes/spaces.rb', line 112

def remove_acs_entrances(acs_entrance_ids:, space_id:)
  @client.post("/spaces/remove_acs_entrances", {acs_entrance_ids: acs_entrance_ids, space_id: space_id}.compact)

  nil
end

#remove_connected_account(connected_account_id:, space_id:) ⇒ nil

Removes a connected account from a specific space.

Parameters:

  • connected_account_id (String)

    ID of the connected account that you want to remove from the space.

  • space_id (String)

    ID of the space from which you want to remove the connected account.

Returns:

  • (nil)

    OK



122
123
124
125
126
# File 'lib/seam/routes/spaces.rb', line 122

def (connected_account_id:, space_id:)
  @client.delete("/spaces/remove_connected_account", {connected_account_id: , space_id: space_id}.compact)

  nil
end

#remove_devices(device_ids:, space_id:) ⇒ nil

Removes devices from a specific space.

Parameters:

  • device_ids (Array<String>)

    IDs of the devices that you want to remove from the space.

  • space_id (String)

    ID of the space from which you want to remove devices.

Returns:

  • (nil)

    OK



132
133
134
135
136
# File 'lib/seam/routes/spaces.rb', line 132

def remove_devices(device_ids:, space_id:)
  @client.post("/spaces/remove_devices", {device_ids: device_ids, space_id: space_id}.compact)

  nil
end

#update(acs_entrance_ids: nil, customer_data: nil, device_ids: nil, name: nil, space_id: nil, space_key: nil) ⇒ Seam::Resources::Space

Updates an existing space.

Parameters:

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

    IDs of the entrances that you want to set for the space. If specified, this will replace all existing entrances.

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

    Reservation/stay-related defaults for the space. Only the keys you provide are updated; omit a key to leave it unchanged. Pass null on a key to clear it.

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

    IDs of the devices that you want to set for the space. If specified, this will replace all existing devices.

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

    Name of the space.

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

    ID of the space that you want to update.

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

    Unique key of the space that you want to update.

Returns:



146
147
148
149
150
# File 'lib/seam/routes/spaces.rb', line 146

def update(acs_entrance_ids: nil, customer_data: nil, device_ids: nil, name: nil, space_id: nil, space_key: nil)
  res = @client.patch("/spaces/update", {acs_entrance_ids: acs_entrance_ids, customer_data: customer_data, device_ids: device_ids, name: name, space_id: space_id, space_key: space_key}.compact)

  Seam::Resources::Space.load_from_response(res.body["space"])
end