-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetCommunityStreamWindowData.pqm
74 lines (74 loc) · 3.28 KB
/
GetCommunityStreamWindowData.pqm
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
let
GetCommunityStreamWindowData = (
token as text, communityStreamUrl as text, communityId as text, startIndex as datetime, endIndex as datetime
) as table =>
let
// construct community stream data query
resource = List.First(Text.Split(communityStreamUrl, "/api/")),
dataQuery = "/api/"
& List.Last(Text.Split(communityStreamUrl, "/api/"))
& "/Data?startIndex="
& DateTime.ToText(startIndex, "o")
& "&endIndex="
& DateTime.ToText(endIndex, "o"),
getJsonQuery = Json.Document(
Web.Contents(
resource,
[
RelativePath = dataQuery,
Headers = [
Authorization = token,
#"Community-Id" = communityId
]
]
)
),
tableOfData = Table.FromList(getJsonQuery, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
tableOfData,
GetCommunityStreamWindowDataType = type function (
token as (
type text meta [
Documentation.FieldCaption = "Token",
Documentation.FieldDescription = "OAuth bearer token. Generate using GetToken.",
Documentation.SampleValues = {"Generate using GetToken()"}
]
),
resource as (
type text meta [
Documentation.FieldCaption = "Community Stream Url",
Documentation.FieldDescription = "Community Stream Url.",
Documentation.SampleValues = {"Enter Community Stream Url"}
]
),
communityId as (
type text meta [
Documentation.FieldCaption = "Community Id",
Documentation.FieldDescription = "CommunityIdentifier.",
Documentation.SampleValues = {"Enter Community Id"}
]
),
startIndex as (
type datetime meta [
Documentation.FieldCaption = "Start Index",
Documentation.FieldDescription = "Index identifying the beginning of the series of events to return."
]
),
endIndex as (
type datetime meta [
Documentation.FieldCaption = "End Index",
Documentation.FieldDescription = "Index identifying the end of the series of events to return."
]
)
) as binary meta [
Documentation.Name = "Get Community Stream Window Data",
Documentation.LongDescription = "Returns a collection of stored values based on request parameters.
<br>
<br>     <b>Token</b>: OAuth bearer token. Generate using GetToken().
<br>     <b>Community Stream Url</b>: Community Stream Url.
<br>     <b>Community Id</b>: Community Identifier.
<br>     <b>Start Index</b>: Index identifying the beginning of the series of events to return.
<br>     <b>End Index</b>: Index identifying the end of the series of events to return."
]
in
Value.ReplaceType(GetCommunityStreamWindowData, GetCommunityStreamWindowDataType)