Skip to content

Commit d519c30

Browse files
author
Andrei Birjukov
committed
Sync TTL related changes to snippets
1 parent 7ab284e commit d519c30

File tree

88 files changed

+521
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+521
-44
lines changed

sync/rest/documents/create-document/create-document.3.x.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ service.documents
99
.create({
1010
uniqueName: 'MyFirstDocument',
1111
data: { firstName: 'Alice' },
12+
ttl: 1814400 // expires in 21 days
1213
})
1314
.then(response => {
1415
console.log(response);

sync/rest/documents/create-document/create-document.5.x.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static void Main(string[] args)
2525

2626
var doc = DocumentResource.Create(serviceSid,
2727
"MyFirstDocument",
28-
data);
28+
data,
29+
1814400); // expires in 21 days
2930

3031
Console.WriteLine(doc.Sid);
3132
}

sync/rest/documents/create-document/create-document.5.x.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
->documents->create(
2727
array(
2828
'uniqueName' => "MyFirstDocument",
29-
'data' => $data
29+
'data' => $data,
30+
'ttl' => 1814400 // expires in 21 days
3031
)
3132
);
3233

sync/rest/documents/create-document/create-document.5.x.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
# Create the Document, data can be any JSON
2121
response = service.documents.create(
2222
unique_name: 'MyFirstDocument',
23-
data: "{#{data.join(',')}}"
23+
data: "{#{data.join(',')}}",
24+
ttl: 1814400 # expires in 21 days
2425
)
2526

2627
puts response

sync/rest/documents/create-document/create-document.6.x.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
document = client.sync \
1919
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
2020
.documents \
21-
.create(unique_name="MyFirstDocument", data=data)
21+
.create(unique_name="MyFirstDocument",
22+
data=data,
23+
ttl=1814400) # expires in 21 days
2224

2325
print(document.sid)

sync/rest/documents/create-document/create-document.7.x.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void main(String[] args) {
2828
.creator("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
2929
.setUniqueName("MyFirstDocument")
3030
.setData(data)
31+
.setTtl(1814400) // expires in 21 days
3132
.create();
3233

3334
System.out.println(document.getSid());
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Documents \
22
-d 'UniqueName=MyFirstDocument' \
3-
-d 'Data={"firstName":"Alice"}' \
3+
-d 'Data={"firstName":"Alice"}' \
4+
-d 'Ttl=1814400'
45
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

sync/rest/documents/create-document/output/create-document.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_created": "2016-07-07T20:53:38Z",
77
"date_updated": "2016-07-07T20:53:38Z",
8+
"date_expires": "2016-07-28T20:53:38Z",
89
"sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1011
"data": {

sync/rest/documents/list-documents/output/list-documents.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"created_by": "system",
77
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
88
"date_created": "2016-07-07T20:53:38Z",
9-
"date_updated": null,
9+
"date_updated": "2016-07-07T20:53:38Z",
10+
"date_expires": null,
1011
"sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1112
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1213
"data": {

sync/rest/documents/retrieve-document/output/retrieve-document.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_created": "2016-07-07T20:53:38Z",
77
"date_updated": "2016-07-07T20:53:38Z",
8+
"date_expires": null,
89
"sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1011
"data": {

sync/rest/documents/update-document/output/update-document.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_created": "2016-07-07T20:53:38Z",
77
"date_updated": "2016-07-07T20:53:38Z",
8+
"date_expires": null,
89
"sid": "ETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1011
"data": {

sync/rest/documents/update-document/update-document.7.x.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public static void main(String[] args) {
2424
data.put("starring", starring);
2525
data.put("genre", "Romance");
2626

27-
Document document = Document.updater(SERVICE_SID, "MyFirstDocument", data).update();
27+
Document document = Document.updater(SERVICE_SID, "MyFirstDocument")
28+
.setData(data)
29+
.update();
2830

2931
System.out.println(document.getData());
3032
}

sync/rest/lists/create-list-item/create-list-item.3.x.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ service
99
.syncLists('MyFirstList')
1010
.syncListItems.create({
1111
data: { text: 'welcome!' },
12+
ttl: 864000 // expires in 10 days
1213
})
1314
.then(response => {
1415
console.log(response);

sync/rest/lists/create-list-item/create-list-item.5.x.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public static void Main(string[] args)
2323

2424
var item = SyncListItemResource.Create(serviceSid,
2525
"MyCollection",
26-
data);
26+
data,
27+
864000); // expires in 10 days
2728

2829
Console.WriteLine(item.Index);
2930
}

sync/rest/lists/create-list-item/create-list-item.5.x.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
2424
->syncLists("MyCollection")
2525
->syncListItems->create(
26-
array(
27-
'data' => $data
28-
)
26+
$data,
27+
array('ttl' => 864000) // expires in 10 days
2928
);
3029

3130
print_r($item->data);

sync/rest/lists/create-list-item/create-list-item.5.x.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# Create a Sync List Item
1212
response = service.sync_lists('MyCollection').sync_list_items.create(
13-
data: "{ 'number': '001', 'name': 'Bulbasaur', 'attack':'49'}"
13+
data: "{ 'number': '001', 'name': 'Bulbasaur', 'attack':'49'}",
14+
ttl: 864000 # expires in 10 days
1415
)
1516

1617
puts response

sync/rest/lists/create-list-item/create-list-item.6.x.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
1313
.sync_lists("MyCollection") \
1414
.sync_list_items \
15-
.create(data=data)
15+
.create(data=data,
16+
ttl=864000) # expires in 10 days
1617

1718
print(list_item.data)

sync/rest/lists/create-list-item/create-list-item.7.x.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public static void main(String[] args) {
2121
data.put("name", "'Bulbasaur");
2222
data.put("attack", 49);
2323

24-
SyncListItem item = SyncListItem.creator(SERVICE_SID, LIST_SID, data).create();
24+
SyncListItem item = SyncListItem.creator(SERVICE_SID, LIST_SID, data)
25+
.setTtl(864000) // expires in 10 days
26+
.create();
2527

2628
System.out.println(item);
2729
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Lists/ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items \
2-
-d 'Data={text:"welcome!"}' \
3-
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
2+
-d 'Data={text:"welcome!"}' \
3+
-d 'Ttl=864000'
4+
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

sync/rest/lists/create-list-item/output/create-list-item.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_updated": "2016-07-11T19:24:43Z",
77
"date_created": "2016-07-11T19:24:43Z",
8+
"date_expires": "2016-07-21T19:24:43Z",
89
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"data": {
1011
"text": "welcome!"

sync/rest/lists/create-list/create-list.3.x.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const service = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
88
service.syncLists
99
.create({
1010
uniqueName: 'MyFirstList',
11+
ttl: 1814400
1112
})
1213
.then(response => {
1314
console.log(response);

sync/rest/lists/create-list/create-list.5.x.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public static void Main(string[] args)
1414

1515
TwilioClient.Init(accountSid, authToken);
1616

17-
var list = SyncListResource.Create(serviceSid, "MyCollection");
17+
var list = SyncListResource.Create(serviceSid,
18+
"MyCollection",
19+
1814400);
1820

1921
Console.WriteLine(list.Sid);
2022
}

sync/rest/lists/create-list/create-list.5.x.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
1818
->syncLists->create(
1919
array(
20-
'uniqueName' => "MyCollection"
20+
'uniqueName' => "MyCollection",
21+
'ttl' => 1814400
2122
)
2223
);
2324

24-
echo $list->sid, PHP_EOL;
25+
echo $list->sid, PHP_EOL;

sync/rest/lists/create-list/create-list.5.x.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
service = client.sync.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
1010

1111
# Create a List
12-
response = service.sync_lists.create(unique_name: 'MyCollection')
12+
response = service.sync_lists.create(unique_name: 'MyCollection',
13+
ttl: 1814400)
1314

1415
puts response

sync/rest/lists/create-list/create-list.6.x.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
list_instance = client.sync \
1010
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
1111
.sync_lists \
12-
.create(unique_name="MyCollection")
12+
.create(unique_name="MyCollection", ttl=1814400)
1313

1414
print(list_instance.unique_name)

sync/rest/lists/create-list/create-list.7.x.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ public class Example {
1212
public static void main(String[] args) {
1313
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
1414

15-
SyncList list = SyncList.creator(SERVICE_SID).setUniqueName("MyFirstList").create();
15+
SyncList list = SyncList.creator(SERVICE_SID)
16+
.setUniqueName("MyFirstList")
17+
.setTtl(1814400)
18+
.create();
1619

1720
System.out.println(list.getSid());
1821
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
curl -X POST https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Lists \
22
-d 'UniqueName=MyFirstList' \
3-
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
3+
-d 'Ttl=1814400' \
4+
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

sync/rest/lists/create-list/output/create-list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1010
"date_created": "2016-07-11T19:11:15Z",
1111
"date_updated": "2016-07-11T19:11:15Z",
12+
"date_expires": "2016-08-01T19:11:15Z",
1213
"sid": "ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1314
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1415
"revision": "0"

sync/rest/lists/list-lists/output/list-lists.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
2121
"date_created": "2016-07-11T19:11:15Z",
2222
"date_updated": "2016-07-11T19:11:15Z",
23+
"date_expires": null,
2324
"sid": "ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
2425
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
2526
"revision": "0"

sync/rest/lists/query-list/output/retrieve-list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
88
"date_updated": "2016-07-25T20:06:36Z",
99
"date_created": "2016-07-25T20:06:36Z",
10+
"date_expires": null,
1011
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1112
"data": {
1213
"text": "welcome!"

sync/rest/lists/retrieve-list-item/output/retrieve-list-item.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_updated": "2016-07-11T19:24:43Z",
77
"date_created": "2016-07-11T19:24:43Z",
8+
"date_expires": null,
89
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"data": {
1011
"number": "001",

sync/rest/lists/retrieve-list/output/retrieve-list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1010
"date_created": "2016-07-25T19:57:03Z",
1111
"date_updated": "2016-07-25T19:57:03Z",
12+
"date_expires": null,
1213
"sid": "ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1314
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
1415
"revision": "0"

sync/rest/lists/update-list-item/output/update-list-item.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
66
"date_updated": "2016-07-25T20:16:55Z",
77
"date_created": "2016-07-25T20:06:36Z",
8+
"date_expires": null,
89
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
910
"data": {
1011
"number": "001",

sync/rest/lists/update-list-item/update-list-item.7.x.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public static void main(String[] args) {
2222
data.put("name", "'Bulbasaur");
2323
data.put("attack", 49);
2424

25-
SyncListItem item = SyncListItem.updater(SERVICE_SID, LIST_SID, 0, data).update();
25+
SyncListItem item = SyncListItem.updater(SERVICE_SID, LIST_SID, 0)
26+
.setData(data)
27+
.update();
2628

2729
System.out.println(item.getData());
2830
}

sync/rest/lists/update-list/meta.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Update a Sync List",
3+
"type": "server"
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"unique_name": "MyFirstList",
3+
"links": {
4+
"items": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Lists/ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Items",
5+
"permissions": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Lists/ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Permissions"
6+
},
7+
"url": "https://sync.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Lists/ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
8+
"created_by": "system",
9+
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
10+
"date_created": "2016-07-11T19:11:15Z",
11+
"date_updated": "2016-07-11T19:11:15Z",
12+
"date_expires": "2016-07-21T19:11:15Z",
13+
"sid": "ESXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
14+
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
15+
"revision": "0"
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
2+
const authToken = 'your_auth_token';
3+
const Twilio = require('twilio').Twilio;
4+
5+
const client = new Twilio(accountSid, authToken);
6+
const service = client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
7+
8+
service.syncLists('MyFirstList')
9+
.update({
10+
ttl: 864000 // expires in 10 days
11+
})
12+
.then(list => {
13+
console.log(list.dateExpires);
14+
})
15+
.catch(error => {
16+
console.log(error);
17+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
2+
using System;
3+
using Twilio;
4+
using Twilio.Rest.Sync.V1.Service;
5+
6+
public class Example
7+
{
8+
public static void Main(string[] args)
9+
{
10+
// Find your Account SID and Auth Token at twilio.com/console
11+
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
12+
const string authToken = "your_auth_token";
13+
const string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
14+
15+
TwilioClient.Init(accountSid, authToken);
16+
17+
var list = SyncListResource.Update(serviceSid,
18+
"MyFirstList",
19+
864000); // expires in 10 days
20+
21+
Console.WriteLine(list.DateExpires);
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
// NOTE: This example uses the next generation Twilio helper library - for more
3+
// information on how to download and install this version, visit
4+
// https://www.twilio.com/docs/libraries/php
5+
require_once 'vendor/autoload.php';
6+
7+
use Twilio\Rest\Client;
8+
9+
// Your Account SID from www.twilio.com/console
10+
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
11+
// Your Auth Token from www.twilio.com/console
12+
$token = "your_auth_token";
13+
14+
$client = new Client($sid, $token);
15+
16+
$list = $client->sync
17+
->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
18+
->syncLists("MyFirstList")->update(
19+
array(
20+
'ttl' => 864000 // expires in 10 days
21+
)
22+
);
23+
24+
echo $list->dateExpires, PHP_EOL;

0 commit comments

Comments
 (0)