-
Notifications
You must be signed in to change notification settings - Fork 0
/
postprocess.ts
131 lines (122 loc) · 3.43 KB
/
postprocess.ts
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// 2023-07-18 update
// 2.5 to 4 yo class
// https://yarraleisure.perfectgym.com.au/clientportal2/Groups/GroupDetailsModal/Details?groupId=6462
// {
// "Id": 6462,
// "Name": "Tuesday 10.00am Preschoolers",
// "ClubId": 3,
// "PhotoUrl": null,
// "Vacancies": 1,
// "BookingIndicator": {
// "Indicator": 1,
// "Limit": 8,
// "Available": 1
// },
// "Durations": [
// "PT30M"
// ],
// "Level": "Preschoolers",
// "Trainer": "Robyn Gosbell",
// "TrainerDetails": null,
// "Status": "Bookable",
// "AboutGroup": null,
// "ClassDates": [
// {
// "Dates": [
// "2023-07-18T10:00:00"
// ],
// "Day": "Tue"
// }
// ],
// "Users": [
// {
// "GroupInfo": {
// "GroupIsFull": true,
// "NotMatchingAge": false,
// "NotMatchingLevel": false,
// "LevelCanBeAssessed": false,
// "EnrollmentNotActive": false,
// "UserAlreadyInGroup": false,
// "GroupEnded": false,
// "GroupNotAvailableForApplication": false,
// "GroupIsLocked": false,
// "InvalidDates": false,
// "CanEnrollToGroup": false,
// "CanEnrollToGroupWithForce": true
// },
// "IsTransferAvailable": false,
// "ActivityCategoryId": 88,
// "Status": "Unavailable",
// "Reason": null,
// "User": {
// ...
// },
// "BookedSeatNumber": null,
// "StandByQueueNumber": null
// },
// {
// "GroupInfo": {
// "GroupIsFull": true,
// "NotMatchingAge": true,
// "NotMatchingLevel": false,
// "LevelCanBeAssessed": false,
// "EnrollmentNotActive": false,
// "UserAlreadyInGroup": false,
// "GroupEnded": false,
// "GroupNotAvailableForApplication": false,
// "GroupIsLocked": false,
// "InvalidDates": false,
// "CanEnrollToGroup": false,
// "CanEnrollToGroupWithForce": true
// },
// "IsTransferAvailable": false,
// "ActivityCategoryId": 88,
// "Status": "Unavailable",
// "Reason": null,
// "User": {
// ...
// },
// "BookedSeatNumber": null,
// "StandByQueueNumber": null
// }
// ]
// }
import {
readJSON,
writeJSON,
// writeCSV,
} from "https://deno.land/x/flat@0.0.15/mod.ts";
import { Octokit } from "https://esm.sh/@octokit/rest";
import * as log from "https://deno.land/std@0.194.0/log/mod.ts";
const octokit = new Octokit({
auth: Deno.env.get("GITHUB_TOKEN"),
});
log.info("Reading JSON file: ", Deno.args[0])
const json = await readJSON(Deno.args[0]);
log.info("JSON read successful")
log.info("Checking if booking available...")
if ( json.BookingIndicator.Available > 0 ) {
log.info("Found available booking?")
try {
log.info("Attempting to make request to Github")
await octokit.request("POST /repos/dalanmiller/baby-swim-flat/issues", {
owner: "dalanmiller",
repo: "baby-swim-flat",
title: `Class available! ${json.name}`,
assignees: ["dalanmiller"],
body: `
# ${json.name}
status: ${json.status}
available: ${json.BookingIndicator.Available}
limit: ${json.BookingIndicator.Limit}
UserDetail: ${targetUser.GroupInfo}
https://yarraleisure.perfectgym.com.au/clientportal2/?saquwjj4kvg5rhji23pg24fh4e=mxa3seq5jbe75bguags2gsr3ye#/Groups/3?ageLimitId=3&vacancies=1
@dalanmiller
`,
});
} catch (e) {
log.error(e);
Deno.exit(1)
}
}
log.info("Done.")