-
Notifications
You must be signed in to change notification settings - Fork 0
/
courseInstance.go
131 lines (104 loc) · 5.83 KB
/
courseInstance.go
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
package axcelerate
import (
"fmt"
"time"
jsontime "github.com/liamylian/jsontime/v2/v2"
)
// Instance of a course
type Instance struct {
RowID int `json:"ROWID"`
Type string `json:"TYPE"`
CourseName string `json:"COURSENAME"`
Cost int `json:"COST"`
CustomFieldWeekends interface{} `json:"CUSTOMFIELD_WEEKENDS"`
Code string `json:"CODE"`
DateDescriptor string `json:"DATEDESCRIPTOR"`
EnrolmentOpen bool `json:"ENROLMENTOPEN"`
Public bool `json:"PUBLIC"`
CourseID int `json:"ID"`
InstanceID int `json:"INSTANCEID"`
IsActive bool `json:"ISACTIVE"`
Location string `json:"LOCATION"`
Domain string `json:"DOMAINNAME"`
MaxParticipants int `json:"MAXPARTICIPANTS"`
MinParticipants int `json:"MINPARTICIPANTS"`
Name string `json:"NAME"`
Notices interface{} `json:"NOTICES"`
OwnerContactID int `json:"OWNERCONTACTID"`
Participants int `json:"PARTICIPANTS"`
ParticipantVacancy int `json:"PARTICIPANTVACANCY"`
StartDate time.Time `json:"STARTDATE" time_format:"axc_datetime"`
FinishDate time.Time `json:"FINISHDATE" time_format:"axc_datetime"`
TrainerContactID int `json:"TRAINERCONTACTID"`
VirtualClassroomID interface{} `json:"VIRTUALCLASSROOMID"`
Count int `json:"COUNT"`
LinkedClassID int `json:"LINKEDCLASSID"`
VenueContactID int `json:"VENUECONTACTID"`
LastUpdatedUTC time.Time `json:"LASTUPDATEDUTC" time_format:"axc_date_hours"`
LinkedElearning []LinkedElearning `json:"LINKEDELEARNING"`
ComplexDates []ComplexDate `json:"COMPLEXDATES"`
SyncDateDescriptor bool `json:"SYNCDATEDESCRIPTOR"`
Items []interface{} `json:"ITEMS"`
Duration string `json:"DURATION"`
DomainID int `json:"DOMAINID"`
State string `json:"STATE"`
GroupedCourseID int `json:"GROUPEDCOURSEID"`
GroupedCourseName string `json:"GROUPEDCOURSENAME"`
GroupedCourseSimultaneous bool `json:"GROUPEDCOURSEISSIMULTANEOUS"`
GroupedMaxParticipants int `json:"GROUPEDMAXPARTICIPANTS"`
GroupedParticipants int `json:"GROUPEDPARTICIPANTS"`
TrainingCategory interface{} `json:"TRAININGCATEGORY"`
}
// LinkedElearning represents the structure for linked e-learning data
type LinkedElearning struct {
EndDate interface{} `json:"ENDDATE"`
InstanceID int `json:"INSTANCEID"`
StartDate interface{} `json:"STARTDATE"`
Code string `json:"CODE"`
Name string `json:"NAME"`
}
// ComplexDate represents the structure for complex date information
type ComplexDate struct {
ComplexID int `json:"COMPLEXID"`
Date string `json:"DATE"` // Keep as string for parsing flexibility
StartTime string `json:"STARTTIME"` // Keep as string for parsing flexibility
EndTime string `json:"ENDTIME"` // Keep as string for parsing flexibility
TrainerContactID int `json:"TRAINERCONTACTID"`
Location string `json:"LOCATION"`
RoomID int `json:"ROOMID"`
VenueContactID interface{} `json:"VENUECONTACTID"` // Flexible to handle null, string, or int
State *string `json:"STATE,omitempty"` // Pointer to handle null or missing values
}
/*
GetCoursesInstances returns a list of instances
activityType
The type of the activity. w = workshop, p = accredited program, el = e-learning.
# Request Parameters
public
Whether to include public courses only. If false, returns ALL course instances for type w and el. For type p, passing false will return ONLY non-public classes.
current
Whether to include only current courses. A current course instance is a course that is currently running, or coming up. If false, returns all course instances.
isActive
Whether to include active/inactive courses instances only. By default both will be included
lastUpdated_min date time
In YYYY-MM-DD hh:mm format. The course instance last updated date must be greater than or equal to this date time. Instances last updated prior to Nov 2018 may not appear. Time is optional and in clients current timezone. Only applicable to w or p types.
lastUpdated_max date time
In YYYY-MM-DD hh:mm format. The course instance last updated date must be less than or equal to this date time. Instances last updated prior to Nov 2018 may not appear. Time is optional and in clients current timezone. Only applicable to w or p types.
*/
func (s *CoursesService) GetCoursesInstances(coursesID int, activityType string, parms map[string]string) ([]Instance, *Response, error) {
var obj []Instance
if len(parms) == 0 {
parms = map[string]string{}
}
parms["ID"] = fmt.Sprintf("%d", coursesID)
parms["type"] = activityType
resp, err := do(s.client, "GET", Params{parms: parms, u: "/course/instances"}, obj)
if err != nil {
return obj, resp, err
}
var json = jsontime.ConfigWithCustomTimeFormat
jsontime.AddTimeFormatAlias("axc_datetime", "2006-01-02 15:04:05")
jsontime.AddTimeFormatAlias("axc_date_hours", "2006-01-02 15:04")
err = json.Unmarshal([]byte(resp.Body), &obj)
return obj, resp, err
}