-
Notifications
You must be signed in to change notification settings - Fork 0
/
Export.as
107 lines (93 loc) · 4.37 KB
/
Export.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* // Example usage
* void Main()
* {
* // Add the audiences you need
* NadeoServices::AddAudience("NadeoLiveServices");
*
* // Wait until the services are authenticated
* while (!NadeoServices::IsAuthenticated("NadeoLiveServices")) {
* yield();
* }
*
* // Build the API URL
* string url = NadeoServices::BaseURLLive() + "/api/token/campaign/month?offset=0&length=27";
*
* // Create a request to the live services
* auto req = NadeoServices::Get("NadeoLiveServices", url);
*
* // Start the request and wait for it to complete
* req.Start();
* while (!req.Finished()) {
* yield();
* }
* print("API response: " + req.String());
* }
*/
namespace NadeoServices
{
// Add the audiences you need, eg. "NadeoServices" or "NadeoLiveServices".
import void AddAudience(const string &in audience) from "NadeoServices";
// Checks if the given audience is authenticated.
import bool IsAuthenticated(const string &in audience) from "NadeoServices";
// Gets the currently authenticated account ID.
import string GetAccountID() from "NadeoServices";
// Returns the base URL for the core API. (Requires the "NadeoServices" audience)
import string BaseURLCore() from "NadeoServices";
// Returns the base URL for the live API. (Requires the "NadeoLiveServices" audience)
import string BaseURLLive() from "NadeoServices";
// Returns the base URL for the meet API. (Requires the "NadeoLiveServices" audience)
import string BaseURLMeet() from "NadeoServices";
// Create an HTTP request object with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Request(const string &in audience) from "NadeoServices";
// Creates a GET HTTP request with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Get(
const string &in audience,
const string &in url = ""
) from "NadeoServices";
// Creates a POST HTTP request with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Post(
const string &in audience,
const string &in url = "",
const string &in body = "",
const string &in contentType = "application/json"
) from "NadeoServices";
// Creates a PUT HTTP request with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Put(
const string &in audience,
const string &in url = "",
const string &in body = "",
const string &in contentType = "application/json"
) from "NadeoServices";
// Creates a DELETE HTTP request with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Delete(
const string &in audience,
const string &in url = ""
) from "NadeoServices";
// Creates a PATCH HTTP request with the correct authentication header for the audience already
// filled in. Throws an exception if the audience is not authenticated yet.
import Net::HttpRequest@ Patch(
const string &in audience,
const string &in url = "",
const string &in body = "",
const string &in contentType = "application/json"
) from "NadeoServices";
// Gets a display name from an account ID. Must be called from a yieldable function. If you want
// to fetch multiple display names, use `GetDisplayNamesAsync` instead, as it will be much more
// efficient.
import string GetDisplayNameAsync(const string &in accountId) from "NadeoServices";
// Gets multiple display names (as `string`) from their account IDs. Must be called from a
// yieldable function. If you want to fetch only a single display name you can also use
// `GetDisplayNameAsync`.
import dictionary GetDisplayNamesAsync(const array<string> &in accountIds) from "NadeoServices";
// Converts a login to an account ID. For example:
// `c5jutptORLinoaIUmVWscA` => `7398eeb6-9b4e-44b8-a7a1-a2149955ac70`
import string LoginToAccountId(const string &in login) from "NadeoServices";
// Converts an account ID to a login. For example:
// `7398eeb6-9b4e-44b8-a7a1-a2149955ac70` => `c5jutptORLinoaIUmVWscA`
import string AccountIdToLogin(const string &in accountId) from "NadeoServices";
}