Skip to content

Commit a4429ff

Browse files
committed
Add device/create-device snippets
1 parent fdda967 commit a4429ff

File tree

6 files changed

+105
-4
lines changed

6 files changed

+105
-4
lines changed

deployed-devices/rest/devices/create-device/create-device.3.x.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
2-
const authToken = 'your_auth_token';
1+
// Get the Node helper library from https://twilio.com/docs/libraries/node
2+
const fs = require('fs');
33
const Twilio = require('twilio').Twilio;
44

5+
// Get your Account SID and Auth Token from https://twilio.com/console
6+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
7+
const authToken = 'your_auth_token';
58
const client = new Twilio(accountSid, authToken);
6-
const fleet = client.preview.deployed_devices.fleets('FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
79

8-
fleet.devices
10+
const fleetSid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
11+
const fleetService = client.preview.deployed_devices.fleets(fleetSid);
12+
13+
fleetService.devices
914
.create({
1015
friendlyName: 'My Device #1'
1116
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get the Node helper library from https://twilio.com/docs/libraries/csharp
2+
using System;
3+
using System.Collections.Generic;
4+
using Twilio;
5+
using Twilio.Rest.Preview.DeployedDevices.Fleet
6+
7+
public class Example
8+
{
9+
public static void Main(string[] args)
10+
{
11+
// Get your Account SID and Auth Token from https://twilio.com/console
12+
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
13+
const string authToken = "your_auth_token";
14+
TwilioClient.Init(accountSid, authToken);
15+
16+
var device = DeviceResource.Create(
17+
pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18+
friendlyName: "My Device #1"
19+
);
20+
21+
Console.WriteLine(device.Sid);
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
// Get the Node helper library from https://twilio.com/docs/libraries/php
3+
require_once '/path/to/vendor/autoload.php'; // Loads the library
4+
5+
use Twilio\Rest\Client;
6+
7+
// Get your Account SID and Auth Token from https://twilio.com/console
8+
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
9+
$authToken = 'your_auth_token';
10+
$client = new Client($sid, $token);
11+
12+
$fleetSid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
13+
$fleetService = $client->preview->deployedDevices->fleets($fleetSid);
14+
15+
$device = $fleetService->device->create([
16+
'friendlyName' => 'My Device #1'
17+
]);
18+
19+
echo $device->sid;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Get the Node helper library from https://twilio.com/docs/libraries/ruby
2+
require 'twilio-ruby'
3+
4+
# Get your Account SID and Auth Token from https://twilio.com/console
5+
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
6+
auth_token = 'your_auth_token'
7+
client = Twilio::REST::Client.new(account_sid, auth_token)
8+
9+
fleet_sid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
10+
fleet_service = client.preview.deployed_devices.fleets(fleet_sid)
11+
12+
device = fleet_service.device.create(
13+
friendly_name: 'My Device #1'
14+
)
15+
16+
puts device.sid
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Get the Node helper library from https://twilio.com/docs/libraries/python
2+
from pathlib import Path
3+
from Twilio.rest import Client
4+
5+
# Get your Account SID and Auth Token from https://twilio.com/console
6+
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
7+
auth_token = 'your_auth_token'
8+
client = Client(account_sid, auth_token)
9+
10+
fleet_sid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
11+
fleet_service = client.preview.deployed_devices.fleets(fleet_sid)
12+
13+
device = fleet_service.device.create(friendly_name='My Device #1')
14+
15+
print(device.sid)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get the Node helper library from https://twilio.com/docs/libraries/java
2+
import com.twilio.Twilio;
3+
import com.twilio.base.ResourceSet;
4+
import com.twilio.rest.preview.deployedDevices.fleet;
5+
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Paths;
8+
9+
public class Example {
10+
// Get your Account SID and Auth Token from https://twilio.com/console
11+
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
12+
public static final String AUTH_TOKEN = "your_auth_token";
13+
14+
public static void main(String[] args) {
15+
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
16+
17+
Device device = DeviceCreator("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
18+
.setFriendlyName("My Device #1")
19+
.create();
20+
21+
System.out.println(device.getSid());
22+
}
23+
}

0 commit comments

Comments
 (0)