Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruby code samples to only use keyword arguments and hash dot access #431

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api-clients/access_codes/delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% tabs %}
{% tab title="Ruby" %}
```ruby
seam.access_codes.delete("123e4567-e89b-12d3-a456-426614174000")
seam.access_codes.delete(access_code_id: "123e4567-e89b-12d3-a456-426614174000")

# <Seam::ActionAttempt:0x0000000107026c98
# status="success"
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/access_codes/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ description: Get Access Code of a Device by its Access Code ID
{% tabs %}
{% tab title="Ruby" %}
```ruby
seam.access_codes.get("123e4567-e89b-12d3-a456-426614174000")
seam.access_codes.get(access_code_id: "123e4567-e89b-12d3-a456-426614174000")

# <Seam::AccessCode:0x007cd58
# code="669781"
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/access_codes/unmanaged/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Not all providers support unmanaged access codes. The following providers do not
{% tab title="Ruby" %}

```ruby
seam.access_codes.unmanaged.get("123e4567-e89b-12d3-a456-426614174000")
seam.access_codes.unmanaged.get(access_code_id: "123e4567-e89b-12d3-a456-426614174000")

# <Seam::AccessCode:0x007cd58
# code="669781"
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/action_attempts/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ await seam.actionAttempts.get(

{% tab title="Ruby" %}
```ruby
seam.action_attempts.get("f7d02670-128a-49f1-b615-b44a2808e5c4")
seam.action_attempts.get(action_attempt_id: "f7d02670-128a-49f1-b615-b44a2808e5c4")
```
{% endtab %}
{% endtabs %}
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/connect_webviews/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ await seam.connectWebviews.get(

{% tab title="Ruby" %}
```ruby
seam.connect_webviews.get("123e4567-e89b-12d3-a456-426614174000")
seam.connect_webviews.get(connect_webview_id: "123e4567-e89b-12d3-a456-426614174000")

# <Seam::ConnectWebview:0x00bd4e8
# url="https://connect.getseam.com/connect_webviews/view?connect_webview_id=48880840-278b-4f55-bdc4-42ba8611952b&auth_token=asjDHKADH8392hf923FH"
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/devices/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ console.log(await seam.devices.get({device_id: "30fd243b-3054-4384-a713-5487076a

{% tab title="Ruby" %}
```ruby
puts client.devices.get("30fd243b-3054-4384-a713-5487076a3826").inspect
puts client.devices.get(device_id: "30fd243b-3054-4384-a713-5487076a3826").inspect
```
{% endtab %}

Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/devices/unmanaged/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ console.log(await seam.devices.unmanaged.get({device_id: "882dd63f-db9b-4210-bac

{% tab title="Ruby" %}
```ruby
puts client.unmanaged_devices.get("882dd63f-db9b-4210-bac2-68372aa0aff7").inspect
puts client.unmanaged_devices.get(device_id: "882dd63f-db9b-4210-bac2-68372aa0aff7").inspect
```
{% endtab %}

Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/locks/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ require "seam"
seam = Seam.new(api_key: "MY_API_KEY")
device_id = "123e4567-e89b-12d3-a456-426614174000"

device = seam.locks.get(device_id)
device = seam.locks.get(device_id: device_id)

puts device
# <Seam::Device:0x00764f8
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/locks/lock_door.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ description: Issue a lock command on the Device by its Device ID
{% tabs %}
{% tab title="Ruby" %}
```ruby
seam.locks.lock_door("123e4567-e89b-12d3-a456-426614174000")
seam.locks.lock_door(device_id: "123e4567-e89b-12d3-a456-426614174000")

#<Seam::ActionAttempt:0x00438
# status="pending"
Expand Down
2 changes: 1 addition & 1 deletion docs/api-clients/locks/unlock_door.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ID of device to be unlocked
{% tabs %}
{% tab title="Ruby" %}
```ruby
seam.locks.unlock_door("123e4567-e89b-12d3-a456-426614174000")
seam.locks.unlock_door(device_id: "123e4567-e89b-12d3-a456-426614174000")

# <Seam::ActionAttempt:0x008f6b0
# status="pending"
Expand Down
6 changes: 3 additions & 3 deletions docs/core-concepts/devices/displaying-device-health.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Online: true
**Request:**

```ruby
device = client.devices.get("36cf1a96-196d-41b0-9804-88154387f1f9")
puts "Online: " + device.properties['online'].to_s
device = client.devices.get(device_id: "36cf1a96-196d-41b0-9804-88154387f1f9")
puts "Online: " + device.properties.online.to_s
```

**Response:**
Expand All @@ -91,7 +91,7 @@ Online: true
**Request:**

```php
$device = $seam->devices->get("36cf1a96-196d-41b0-9804-88154387f1f9");
$device = $seam->devices->get(device_id: "36cf1a96-196d-41b0-9804-88154387f1f9");
if ($device->properties->online === true) {
echo "Online: true\n";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ Battery Status: full
**Request:**

```ruby
device = client.devices.get("36cf1a96-196d-41b0-9804-88154387f1f9")
if(device.properties['has_direct_power'] == true)
device = client.devices.get(device_id: "36cf1a96-196d-41b0-9804-88154387f1f9")
if(device.properties.has_direct_power == true)
puts "Power Source: Wired"
else
puts "Power Source: Battery-powered"
puts "Battery Level: " + device.properties['battery']['level'].to_s
puts "Battery Status: " + device.properties['battery']['status']
puts "Battery Level: " + device.properties.battery.level.to_s
puts "Battery Status: " + device.properties.battery.status
end
```

Expand Down
4 changes: 2 additions & 2 deletions docs/core-concepts/devices/managed-and-unmanaged-devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ seam = Seam.new()
device_id = "aa3958c3-4236-4f71-bd77-3b60f85b3456"

seam.devices.update(device_id: device_id, is_managed: false)
unmanaged_device = seam.unmanaged_devices.get(device_id)
unmanaged_device = seam.unmanaged_devices.get(device_id: device_id)
puts unmanaged_device.inspect

# <Seam::UnmanagedDevice:0x00438
Expand Down Expand Up @@ -294,7 +294,7 @@ seam = Seam.new()
device_id = "aa3958c3-4236-4f71-bd77-3b60f85b3456"
seam.unmanaged_devices.update(device_id: device_id, is_managed: true)

device = seam.devices.get(device_id)
device = seam.devices.get(device_id: device_id)

puts device.inspect
# <Seam::Device:0x00438
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Coming soon!

```ruby
# Get the device.
device = client.devices.get("11111111-1111-1111-1111-444444444444")
device = client.devices.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that Seam supports simulated disconnection for the device.
if (device.can_simulate_disconnection)
Expand Down Expand Up @@ -366,7 +366,7 @@ Coming soon!

```ruby
# Get the device.
device = client.devices.get("11111111-1111-1111-1111-444444444444")
device = client.devices.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that Seam supports simulated connection for the device.
if (device.can_simulate_connection)
Expand Down Expand Up @@ -603,7 +603,7 @@ Coming soon!

```ruby
# Get the device.
device = client.devices.get("11111111-1111-1111-1111-444444444444")
device = client.devices.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that Seam supports simulated removal for the device.
if (device.can_simulate_removal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ all_four_suites_locks = seam.devices.list(manufacturer: "four_suites")
front_door = all_four_suites_locks[0]

# Inspect specific properties.
puts front_door.properties['online'] # true
puts front_door.properties['locked'] # true
puts front_door.properties.online # true
puts front_door.properties.locked # true

# View the entire returned device object.
puts front_door.inspect
Expand Down Expand Up @@ -1082,7 +1082,7 @@ if (frontDoor.can_remotely_unlock) {
if (front_door.can_remotely_unlock)
# Perform the unlock operation
# and return an action attempt.
action_attempt = seam.locks.unlock_door(front_door.device_id)
action_attempt = seam.locks.unlock_door(device_id: front_door.device_id)
end
```

Expand Down Expand Up @@ -1296,7 +1296,7 @@ updated_front_door = seam.devices.get(device_id: front_door.device_id)

# Inspect the locked property to confirm
# that the unlock operation was successful.
puts updated_front_door.properties['locked'] # false
puts updated_front_door.properties.locked # false
```

**Output:**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ all_akiles_locks = seam.devices.list(manufacturer: "akiles")
front_door = all_akiles_locks[0]

# Inspect specific properties.
puts front_door.properties['online'] # true
puts front_door.properties['locked'] # true
puts front_door.properties.online # true
puts front_door.properties.locked # true

# View the entire returned device object.
puts front_door.inspect
Expand Down Expand Up @@ -1083,7 +1083,7 @@ if (frontDoor.can_remotely_unlock) {
if (front_door.can_remotely_unlock)
# Perform the unlock operation
# and return an action attempt.
action_attempt = seam.locks.unlock_door(front_door.device_id)
action_attempt = seam.locks.unlock_door(device_id: front_door.device_id)
end
```

Expand Down Expand Up @@ -1296,7 +1296,7 @@ updated_front_door = seam.devices.get(device_id: front_door.device_id)

# Inspect the locked property to confirm
# that the unlock operation was successful.
puts updated_front_door.properties['locked'] # false
puts updated_front_door.properties.locked # false
```

**Output:**
Expand Down Expand Up @@ -1594,7 +1594,7 @@ if (updatedFrontDoor.can_program_online_access_codes) {
```ruby
# Confirm that the device supports online access codes.
# Here's another capability flag!
if (updated_front_door['can_program_online_access_codes'])
if (updated_front_door.can_program_online_access_codes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrii-balitskyi Did I have this reference to a property wrong before, or what changed to make it possible to refer to a property using dot notation now?

# Create an ongoing online access code.
seam.access_codes.create(
device_id: updated_front_door.device_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ if (device.can_program_offline_access_codes) {

```ruby
# Get the device.
device = client.locks.get("11111111-1111-1111-1111-444444444444")
device = client.locks.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that the device supports offline access codes.
if (device.can_program_offline_access_codes)
Expand Down Expand Up @@ -636,7 +636,7 @@ if (device.can_program_offline_access_codes) {

```ruby
# Get the device.
device = client.locks.get("11111111-1111-1111-1111-444444444444")
device = client.locks.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that the device supports offline access codes.
if (device.can_program_offline_access_codes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ if (device.can_program_offline_access_codes) {

```ruby
# Get the device.
device = client.locks.get("11111111-1111-1111-1111-444444444444")
device = client.locks.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that the device supports offline access codes.
if (device.can_program_offline_access_codes)
Expand Down Expand Up @@ -575,7 +575,7 @@ if (device.can_program_offline_access_codes) {

```ruby
# Get the device.
device = client.locks.get("11111111-1111-1111-1111-444444444444")
device = client.locks.get(device_id: "11111111-1111-1111-1111-444444444444")

# Confirm that the device supports offline access codes.
if (device.can_program_offline_access_codes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Confirm the Connect Webview was successful by querying its status:
{% tabs %}
{% tab title="Python" %}
```python
updated_webview = seam.connect_webviews.get(webview.connect_webview_id)
updated_webview = seam.connect_webviews.get(connect_webview_id: webview.connect_webview_id)

assert updated_webview.login_successful # true
```
Expand All @@ -191,7 +191,7 @@ console.log(updatedWebview.login_successful) // true

{% tab title="Ruby" %}
```ruby
updated_webview = seam.connect_webviews.get(webview.connect_webview_id)
updated_webview = seam.connect_webviews.get(connect_webview_id: webview.connect_webview_id)

puts updated_webview.login_successful # true
```
Expand Down Expand Up @@ -287,8 +287,8 @@ console.log(someLock)
```ruby
some_lock = seam.locks.list.first

puts some_lock.properties['online'] # true
puts some_lock.properties['locked'] # true
puts some_lock.properties.online # true
puts some_lock.properties.locked # true

puts some_lock

Expand Down Expand Up @@ -346,13 +346,13 @@ Next, you can perform the basic action of locking and unlocking a door.
{% tab title="Python" %}
```python
# lock the door
seam.locks.lock_door(some_lock)
updated_lock = seam.locks.get(some_lock.device_id)
seam.locks.lock_door(device_id: some_lock.device_id)
updated_lock = seam.locks.get(device_id: some_lock.device_id)
assert updated_lock.properties["locked"] is True

# Now unlock the door
seam.locks.unlock_door(some_lock)
updated_lock = seam.locks.get(some_lock.device_id)
seam.locks.unlock_door(device_id: some_lock.device_id)
updated_lock = seam.locks.get(device_id: some_lock.device_id)
assert updated_lock.properties["locked"] is False
```
{% endtab %}
Expand All @@ -374,14 +374,14 @@ console.log(updatedLock.properties.locked) // false
{% tab title="Ruby" %}
```ruby
# lock the door
seam.locks.lock_door(some_lock)
updated_lock = seam.locks.get(some_lock.device_id)
puts updated_lock.properties['locked'] # true
seam.locks.lock_door(device_id: some_lock.device_id)
updated_lock = seam.locks.get(device_id: some_lock.device_id)
puts updated_lock.properties.locked # true

# unlock the door
seam.locks.unlock_door(some_lock)
updated_lock = seam.locks.get(some_lock.device_id)
puts updated_lock.properties['locked'] # false
seam.locks.unlock_door(device_id: some_lock.device_id)
updated_lock = seam.locks.get(device_id: some_lock.device_id)
puts updated_lock.properties.locked # false
```
{% endtab %}

Expand Down Expand Up @@ -474,8 +474,7 @@ seam.access_codes.create(
ends_at: '2028-08-13T19:23:42+0000'
)

# you can use a device or a device_id as the "device" parameter
seam.access_codes.list(some_lock)
seam.access_codes.list(device_id: some_lock.device_id)
```
{% endtab %}

Expand Down
Loading
Loading