Add correct types to schedule entry struct
This commit is contained in:
parent
a403fa2e58
commit
03728eda85
@ -3,6 +3,7 @@ package connectwise
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Calendar struct {
|
type Calendar struct {
|
||||||
@ -43,8 +44,8 @@ type ScheduleEntry struct {
|
|||||||
MemberHref string `json:"member_href"`
|
MemberHref string `json:"member_href"`
|
||||||
} `json:"_info"`
|
} `json:"_info"`
|
||||||
} `json:"member,omitempty"`
|
} `json:"member,omitempty"`
|
||||||
DateStart string `json:"dateStart,omitempty"`
|
DateStart time.Time `json:"dateStart,omitempty"`
|
||||||
DateEnd string `json:"dateEnd,omitempty"`
|
DateEnd time.Time `json:"dateEnd,omitempty"`
|
||||||
Reminder struct {
|
Reminder struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -92,9 +93,13 @@ func (cw *Site) GetCalendars() (*[]Calendar, error) {
|
|||||||
return calendar, nil
|
return calendar, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//ScheduleEntryCount returns the number of companies in ConnectWise
|
//ScheduleEntryOnDayCount returns the number of companies in ConnectWise
|
||||||
func (cw *Site) ScheduleEntryOnDayCount() (int, error) {
|
func (cw *Site) ScheduleEntryOnDayCount(day time.Time) (int, error) {
|
||||||
req := cw.NewRequest("/schedule/entries/count", "GET", nil)
|
req := cw.NewRequest("/schedule/entries/count", "GET", nil)
|
||||||
|
req.PageSize = 3000
|
||||||
|
tom := day.Add(time.Hour * 24)
|
||||||
|
fmt.Printf("%d-%d-%dT00:00:00Z", day.Year(), day.Month(), day.Day())
|
||||||
|
fmt.Println(tom)
|
||||||
req.URLValues.Add("conditions", "datestart > [2018-07-26T00:00:00Z] and dateend < [2018-07-27T00:00:00Z]")
|
req.URLValues.Add("conditions", "datestart > [2018-07-26T00:00:00Z] and dateend < [2018-07-27T00:00:00Z]")
|
||||||
err := req.Do()
|
err := req.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -111,10 +116,11 @@ func (cw *Site) ScheduleEntryOnDayCount() (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GetScheduleEntriesOnDay expects a date in the format of "YYYY-MM-DD" and returns a pointer to a slice of ScheduleEntries on that day
|
//GetScheduleEntriesOnDay expects a date in the format of "YYYY-MM-DD" and returns a pointer to a slice of ScheduleEntries on that day
|
||||||
func (cw *Site) GetScheduleEntriesOnDay(day string) (*[]ScheduleEntry, error) {
|
func (cw *Site) GetScheduleEntriesOnDay(day time.Time) (*[]ScheduleEntry, error) {
|
||||||
req := cw.NewRequest("/schedule/entries", "GET", nil)
|
req := cw.NewRequest("/schedule/entries", "GET", nil)
|
||||||
req.URLValues.Add("orderBy", "dateStart asc")
|
req.URLValues.Add("orderBy", "dateStart asc")
|
||||||
req.URLValues.Add("conditions", "datestart > [2018-07-26T00:00:00Z] and dateend < [2018-07-27T00:00:00Z]")
|
tom := day.Add(time.Hour * 24)
|
||||||
|
req.URLValues.Add("conditions", fmt.Sprintf("datestart > [%d-%d-%dT00:00:00Z] and dateend < [%d-%d-%dT00:00:00Z]", day.Year(), day.Month(), day.Day(), tom.Year(), tom.Month(), tom.Day()))
|
||||||
|
|
||||||
err := req.Do()
|
err := req.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user