diff --git a/3.0/connectwise/company.go b/3.0/connectwise/company.go index 0b28f54..f067e72 100644 --- a/3.0/connectwise/company.go +++ b/3.0/connectwise/company.go @@ -145,6 +145,22 @@ type Company struct { } `json:"customFields"` } +type CompanyStatus struct { + ID int `json:"id"` + Name string `json:"name"` + DefaultFlag bool `json:"defaultFlag"` + InactiveFlag bool `json:"inactiveFlag"` + NotifyFlag bool `json:"notifyFlag"` + DisallowSavingFlag bool `json:"disallowSavingFlag"` + NotificationMessage string `json:"notificationMessage,omitempty"` + CustomNoteFlag bool `json:"customNoteFlag"` + CancelOpenTracksFlag bool `json:"cancelOpenTracksFlag"` + Info struct { + LastUpdated time.Time `json:"lastUpdated"` + UpdatedBy string `json:"updatedBy"` + } `json:"_info"` +} + //CompanyCount returns the number of companies in ConnectWise func (cw *Site) CompanyCount() (int, error) { req := cw.NewRequest("/company/companies/count", "GET", nil) @@ -203,3 +219,19 @@ func (cw *Site) GetCompanyByID(companyID int) (*Company, error) { return co, nil } + +func (cw *Site) GetCompanyStatuses() (*[]CompanyStatus, error) { + req := cw.NewRequest("/company/companies/statuses", "GET", nil) + err := req.Do() + if err != nil { + return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err) + } + + costat := &[]CompanyStatus{} + err = json.Unmarshal(req.Body, costat) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) + } + + return costat, nil +} diff --git a/3.0/connectwise/service.go b/3.0/connectwise/service.go index b2445c1..a7df479 100644 --- a/3.0/connectwise/service.go +++ b/3.0/connectwise/service.go @@ -67,6 +67,48 @@ type BoardTeam struct { } `json:"_info"` } +type BoardStatus struct { + ID int `json:"id"` + Name string `json:"name"` + Board struct { + ID int `json:"id"` + Name string `json:"name"` + Info struct { + BoardHref string `json:"board_href"` + } `json:"_info"` + } `json:"board"` + ExternalIntegrationXref struct { + ID int `json:"id"` + Identifier string `json:"identifier"` + Name string `json:"name"` + Info struct { + StatusExternalIntegrationHref string `json:"statusExternalIntegration_href"` + } `json:"_info"` + } `json:"externalIntegrationXref,omitempty"` + SortOrder int `json:"sortOrder"` + DisplayOnBoard bool `json:"displayOnBoard"` + Inactive bool `json:"inactive"` + ClosedStatus bool `json:"closedStatus"` + TimeEntryNotAllowed bool `json:"timeEntryNotAllowed"` + DefaultFlag bool `json:"defaultFlag"` + EscalationStatus string `json:"escalationStatus"` + CustomerPortalDescription string `json:"customerPortalDescription,omitempty"` + CustomerPortalFlag bool `json:"customerPortalFlag"` + EmailTemplate struct { + ID int `json:"id"` + Identifier string `json:"identifier"` + Info struct { + EmailTemplateHref string `json:"emailTemplate_href"` + } `json:"_info"` + } `json:"emailTemplate,omitempty"` + Info struct { + LastUpdated time.Time `json:"lastUpdated"` + UpdatedBy string `json:"updatedBy"` + DateEntered time.Time `json:"dateEntered"` + EnteredBy string `json:"enteredBy"` + } `json:"_info"` +} + //Ticket is a struct to hold the unmarshaled JSON data when making a call to the Service API type Ticket struct { ID int `json:"id"` @@ -471,6 +513,23 @@ func (cw *Site) GetBoardTeams(boardID int) (*[]BoardTeam, error) { return boardTeam, nil } +func (cw *Site) GetBoardStatuses(boardID int) (*[]BoardStatus, error) { + req := cw.NewRequest(fmt.Sprintf("/service/boards/%d/statuses", boardID), "GET", nil) + err := req.Do() + if err != nil { + return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err) + } + + boardStatus := &[]BoardStatus{} + err = json.Unmarshal(req.Body, boardStatus) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) + } + + return boardStatus, nil + +} + //GetBoardTeamByName returns a pointer to a board team in Connectwise func (cw *Site) GetBoardTeamByName(boardID int, teamName string) (*BoardTeam, error) { req := cw.NewRequest(fmt.Sprintf("/service/boards/%d/teams", boardID), "GET", nil)