Skip to content

Commit f6ce3df

Browse files
Add status_url & status_events. (#431)
* Add status_url & status_events. Add externalDocs, tag metadata, and info in spec. * spelling fix in `ChargeDetails` tsp model * grammar fix in `paramsDescription` in requests.tsp * spec updates --------- Co-authored-by: hey-august <[email protected]>
1 parent ec31241 commit f6ce3df

File tree

7 files changed

+210
-43
lines changed

7 files changed

+210
-43
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "../../_globally_shared/const.tsp";

specs/signalwire-rest/calling-api/calls/main.tsp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace CallingAPI.Calls {
2121
}
2222
| StatusCode401
2323
| StatusCode404
24-
| CallCreate422Error;
24+
| CallCreate422Error
25+
| StatusCode500;
2526

2627
@summary("Update a Call")
2728
@doc("To update an existing call, you send a `PUT` request to the Call resource with a payload including a `command` and additional nested `params`.")
@@ -55,6 +56,7 @@ namespace CallingAPI.Calls {
5556
}
5657
| StatusCode401
5758
| StatusCode404
58-
| CallUpdate422Error;
59+
| CallUpdate422Error
60+
| StatusCode500;
5961
}
6062
}
Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import "../const.tsp";
2+
13
model Call {
24
@doc("The unique identifier of the call on SignalWire. This can be used to update the call programmatically.")
3-
@example("3fa85f64-5717-4562-b3fc-2c963f66afa6")
5+
@example("0e9c80d7-a149-4917-892d-420043709f45")
46
id: string;
57

68
@doc("The origin number or address.")
7-
@example("sip:[email protected]")
9+
@example("+12069708643")
810
from: string;
911

1012
@doc("The destination number or address.")
11-
@example("sip:[email protected]")
13+
@example("+18048390497")
1214
to: string;
1315

1416
@doc("The direction of the call.")
@@ -20,33 +22,51 @@ model Call {
2022
status: "answered" | "queued" | "initiated" | "ringing" | "ending" | "ended";
2123

2224
@doc("The duration of the call in seconds.")
23-
@example(60)
24-
duration: integer;
25+
@example(null)
26+
duration: integer | null;
2527

2628
@doc("The duration of the call in milliseconds.")
27-
@example(60000)
28-
duration_ms: integer;
29+
@example(null)
30+
duration_ms: integer | null;
2931

30-
@doc("The billable duration of the call in seconds.")
31-
@example(60)
32-
billable_duration: integer;
32+
@doc("The billable duration of the call in milliseconds.")
33+
@example(null)
34+
billing_ms: integer | null;
3335

3436
@doc("Source of this call.")
3537
@example("realtime_api")
3638
source: "realtime_api";
3739

3840
@doc("Type of this call.")
39-
@example("relay_sip_call")
41+
@example("relay_pstn_call")
4042
type: "relay_pstn_call" | "relay_sip_call" | "relay_webrtc_call";
4143

44+
@doc("The URL associated with this call.")
45+
@example(null)
46+
url: string | null;
47+
48+
@doc("Total charge for this call.")
49+
@example(0)
50+
charge: float64;
51+
52+
@doc("The date and time when the call was created.")
53+
@example(UTC_TIME_EXAMPLE)
54+
created_at: utcDateTime;
55+
56+
@doc("The parent call ID if this is a child call.")
57+
@example(null)
58+
parent_id: string | null;
59+
4260
@doc("Details on charges associated with this call.")
43-
charge: ChargeDetails[];
61+
charge_details: ChargeDetails[];
4462
}
4563

4664
model ChargeDetails {
4765
@doc("Description for this charge.")
66+
@example("Text to Speech")
4867
description: string;
4968

5069
@doc("Charged amount.")
51-
amount: integer;
70+
@example(0.121176)
71+
amount: float;
5272
}

specs/signalwire-rest/calling-api/calls/models/requests.tsp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const updateCommandDescription = "The `update` command is used to update a exist
1616

1717
const uuidDescription = "The unique identifying ID of a existing call.";
1818

19-
const paramsDescription = "An object of parameters to that will be utilized by the active command.";
19+
const paramsDescription = "An object of parameters that will be utilized by the active command.";
2020

2121
alias CallCreateRequestAlias = CallCreateParamsURL | CallCreateParamsSWML;
2222

@@ -120,6 +120,20 @@ model CallCreateParamsBase {
120120
@doc("The Fallback URL to handle the call. This parameter allows you to specify a backup webhook or different route in your code containing SWML instructions for handling the call.")
121121
@example(CallFallbackURLExample)
122122
fallback_url?: string;
123+
124+
@doc("A URL that will recieve status updates of the current call. Any call events defined in `status_events` will be delivered to the defined URL.")
125+
@example("https://example.com/status_callback")
126+
status_url?: url;
127+
128+
@doc("The call events that will be monitored and sent to the `status_url` when active.")
129+
@example(#["answered", "ended"])
130+
status_events?: (
131+
| "answered"
132+
| "queued"
133+
| "initiated"
134+
| "ringing"
135+
| "ending"
136+
| "ended")[];
123137
}
124138

125139
@summary("Create call (URL)")
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
import "@typespec/http";
2+
import "@typespec/openapi";
23
import "../types";
34
import "./calls";
5+
import "../_globally_shared/const.tsp";
6+
import "./tags.tsp";
47

58
using TypeSpec.Http;
9+
using TypeSpec.OpenAPI;
610
using Types.StatusCodes;
711

12+
@tagMetadata(CALLS_TAG, CALLS_TAG_METADATA)
13+
@externalDocs(
14+
"https://developer.signalwire.com/rest/signalwire-rest/endpoints/calling",
15+
"The Calling API holds a collection of endpoints that will help you create and manage calls."
16+
)
17+
@info(#{
18+
title: "Calling API",
19+
version: "1.0.0",
20+
contact: CONTACT_INFO,
21+
license: LICENSE_INFO,
22+
termsOfService: TERMS_OF_SERVICE,
23+
})
824
@service(#{ title: "Calling API" })
925
@server(
10-
"https://{space_name}.signalwire.com/api/calling",
26+
"https://{space_name}.${SERVER_URL}/calling",
1127
"Endpoint",
1228
{
29+
@doc(SERVER_URL_DESCRIPTION)
30+
@example("example")
1331
space_name: string = "{Your_Space_Name}",
1432
}
1533
)
1634
@useAuth(BasicAuth)
17-
@doc("""
18-
API to create/manage SignalWire's Calls.
19-
To create a new Call, you send a `POST` request to the Call resource with a payload including a `dial` command and additional nested `params`.
20-
""")
35+
@doc("API to create/manage SignalWire's Calls.")
2136
namespace CallingAPI;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "@typespec/openapi3";
2+
3+
const CALLS_TAG = "Calls";
4+
5+
const CALLS_TAG_METADATA = #{
6+
description: "Endpoints related to creating and managing calls",
7+
externalDocs: #{
8+
url: "https://developer.signalwire.com/rest/signalwire-rest/endpoints/calling/calls",
9+
description: "Developer documentation on Calling API Call endpoints",
10+
},
11+
};

0 commit comments

Comments
 (0)