Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch committed Apr 26, 2024
1 parent effaccc commit 82f8f9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
34 changes: 21 additions & 13 deletions packages/elastic-sip-trunking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ const credentials: UnifiedCredentials = {
keySecret: 'KEY_SECRET',
};

// Access the 'fax' service registered on the Sinch Client
// Access the 'elasticSipTrunking' service registered on the Sinch Client
const sinch = new SinchClient(credentials);
const elasticSipTrunkingService: ElasticSipTrunkingService = sinch.elasticSipTrunking;

// Build the request data
const requestData: ElasticSipTrunking.InterfaceTBD = {
const requestData: ElasticSipTrunking.CreateSipTrunkRequestData = {
createSipTrunkRequestBody: {
name: 'Acme Trunk',
hostName: 'acme-domain-1',
}
};

// Access the 'elasticSipTrunking' service registered on the Sinch Client
const result = await sinch.elasticSipTrunking.tag.method(requestData);
// Use the 'elasticSipTrunking' service registered on the Sinch Client
const result = await sinch.elasticSipTrunking.sipTrunks.create(requestData);
```

### Standalone
Expand All @@ -82,11 +86,15 @@ const credentials: UnifiedCredentials = {
const elasticSipTrunkingService = new ElasticSipTrunkingService(options);

// Build the request data
const requestData: ElasticSipTrunking.InterfaceTBD = {
const requestData: ElasticSipTrunking.CreateSipTrunkRequestData = {
createSipTrunkRequestBody: {
name: 'Acme Trunk',
hostName: 'acme-domain-1',
}
};

// Use the standalone declaration of the 'elasticSipTrunking' service
const result = await elasticSipTrunkingService.tag.method(requestData);
const result = await elasticSipTrunkingService.sipTrunks.create(requestData);
```

## Promises
Expand All @@ -95,18 +103,18 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa

```typescript
// Method 1: Wait for the Promise to complete
let result: ElasticSipTrunking.ResultInterfaceTBD;
let result: ElasticSipTrunking.SipTrunk;
try {
result = await elasticSipTrunkingService.tag.method(requestData);
console.log(``);
result = await elasticSipTrunkingService.sipTrunks.create(requestData);
console.log(`SIP trunk successfully created at '${response.createTime.toISOString()}' with the id '${response.id}'`);
} catch (error: any) {
console.error(`ERROR ${error.statusCode}: `);
console.error(`ERROR ${error.statusCode}: Impossible to create a SIP Trunk with the hostname '${requestData.hostName}'`);
}

// Method 2: Resolve the promise
elasticSipTrunkingService.tag.method(requestData)
.then(response => console.log(``))
.catch(error => console.error(`ERROR ${error.statusCode}: `));
elasticSipTrunkingService.sipTrunks.create(requestData)
.then(response => console.log(`SIP trunk successfully created at '${response.createTime.toISOString()}' with the id '${response.id}'`))
.catch(error => console.error(`ERROR ${error.statusCode}: Impossible to create a SIP Trunk with the hostname '${requestData.hostName}'`));
```

## Contact
Expand Down
3 changes: 1 addition & 2 deletions packages/elastic-sip-trunking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "Sinch Elastic SIP Trunking API",
"homepage": "",
"repository": {
"type": "git",
"url": ""
"type": "git"
},
"license": "Apache-2.0",
"author": "Sinch",
Expand Down

0 comments on commit 82f8f9f

Please sign in to comment.