From 901202c019947a091b2a07d8c1df46634ae942cc Mon Sep 17 00:00:00 2001 From: Tristan Goers Date: Tue, 26 Sep 2023 15:54:17 -0800 Subject: [PATCH] v0.1.2 --- account.go | 29 +++++++ api.go | 5 +- comments.go | 83 +++++++++++++++++++ contacts.go | 51 ++++++++++++ customFields.go | 43 ++++++++++ folders.go | 48 +++++------ groups.go | 70 ++++++++++++++++ invitations.go | 42 ++++++++++ parameters/account.go | 10 +++ parameters/comments.go | 19 +++++ parameters/contacts.go | 23 ++++++ parameters/customFields.go | 41 ++++++++++ parameters/folders.go | 88 ++++++++++---------- parameters/groups.go | 39 +++++++++ parameters/invitations.go | 17 ++++ parameters/sharedParamaters.go | 9 ++- parameters/tasks.go | 142 ++++++++++++++++----------------- parameters/users.go | 9 +++ parameters/workflows.go | 19 +++++ response/account.go | 57 +++++++++++++ response/comments.go | 31 +++++++ response/contacts.go | 63 +++++++++++++++ response/customFields.go | 27 +++++++ response/groups.go | 27 +++++++ response/invitations.go | 26 ++++++ response/users.go | 43 ++++++++++ response/workflows.go | 29 +++++++ tasks.go | 40 +++++----- users.go | 26 ++++++ workflows.go | 36 +++++++++ 30 files changed, 1029 insertions(+), 163 deletions(-) create mode 100644 account.go create mode 100644 comments.go create mode 100644 contacts.go create mode 100644 customFields.go create mode 100644 groups.go create mode 100644 invitations.go create mode 100644 parameters/account.go create mode 100644 parameters/comments.go create mode 100644 parameters/contacts.go create mode 100644 parameters/customFields.go create mode 100644 parameters/groups.go create mode 100644 parameters/invitations.go create mode 100644 parameters/users.go create mode 100644 parameters/workflows.go create mode 100644 response/account.go create mode 100644 response/comments.go create mode 100644 response/contacts.go create mode 100644 response/customFields.go create mode 100644 response/groups.go create mode 100644 response/invitations.go create mode 100644 response/users.go create mode 100644 response/workflows.go create mode 100644 users.go create mode 100644 workflows.go diff --git a/account.go b/account.go new file mode 100644 index 0000000..87f2e2a --- /dev/null +++ b/account.go @@ -0,0 +1,29 @@ +package wrikego + +import ( + "log" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryAccount(config Config, params params.QueryAccount) (resp.Account, error) { + path := "/account" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.AccountFromJSON(response) +} + +func ModifyAccount(config Config, params params.QueryAccount) (resp.Account, error) { + path := "/account" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.AccountFromJSON(response) +} \ No newline at end of file diff --git a/api.go b/api.go index f37a5c8..b002a0b 100644 --- a/api.go +++ b/api.go @@ -19,8 +19,8 @@ func Put(config Config, path string, params url.Values) ([]byte, error) { return api("PUT", config, path, params) } -func Delete(config Config, path string) ([]byte, error) { - return api("DELETE", config, path, nil) +func Delete(config Config, path string, params url.Values) ([]byte, error) { + return api("DELETE", config, path, params) } func api(method string, config Config, path string, params url.Values) ([]byte, error) { @@ -42,5 +42,6 @@ func api(method string, config Config, path string, params url.Values) ([]byte, if err != nil { fmt.Println("io.ReadAll Error:", err) } + fmt.Println(string(response)) return response, err } diff --git a/comments.go b/comments.go new file mode 100644 index 0000000..000338f --- /dev/null +++ b/comments.go @@ -0,0 +1,83 @@ +package wrikego + +import ( + "fmt" + "log" + "strings" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryComments(config Config, params params.QueryComments) (resp.Comments, error) { + path := "/comments" + response, _ := Get(config, path, nil) + return resp.CommentsFromJSON(response) +} + +func QueryCommentsByFolder(config Config, params params.QueryComments, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/folders/%s/comments", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.CommentsFromJSON(response) +} + +func QueryCommentsByTask(config Config, params params.QueryComments, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/tasks/%s/comments", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.CommentsFromJSON(response) +} + +func QueryCommentsByIds(config Config, params params.QueryComments, pathId []string) (resp.Comments, error) { + path := fmt.Sprintf("/comments/%s", strings.Join(pathId, ",")) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.CommentsFromJSON(response) +} + +func CreateCommentByFolder(config Config, params params.CreateComments, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/folders/%s/comments", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Post(config, path, body) + return resp.CommentsFromJSON(response) +} + +func CreateCommentByTask(config Config, params params.CreateComments, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/folders/%s/comments", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Post(config, path, body) + return resp.CommentsFromJSON(response) +} + +func ModifyCommentById(config Config, params params.ModifyComments, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/comments/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.CommentsFromJSON(response) +} + +func DeleteCommentById(config Config, pathId string) (resp.Comments, error) { + path := fmt.Sprintf("/comments/%s", pathId) + response, _ := Delete(config, path, nil) + return resp.CommentsFromJSON(response) +} \ No newline at end of file diff --git a/contacts.go b/contacts.go new file mode 100644 index 0000000..b8ef9cf --- /dev/null +++ b/contacts.go @@ -0,0 +1,51 @@ +package wrikego + +import ( + "fmt" + "log" + "strings" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryContacts(config Config, params params.QueryContacts) (resp.Contacts, error) { + path := "/contacts" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.ContactsFromJSON(response) +} + +func QueryContactsByIds(config Config, params params.QueryContacts, pathId []string) (resp.Contacts, error) { + path := fmt.Sprintf("/contacts/%s", strings.Join(pathId, ",")) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.ContactsFromJSON(response) +} + +func QueryContactsFieldsHistoryByIds(config Config, params params.QueryContacts, pathId []string) (resp.Contacts, error) { + path := fmt.Sprintf("/contacts/%s/contacts_history", strings.Join(pathId, ",")) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.ContactsFromJSON(response) +} + +func ModifyContactsById(config Config, params params.ModifyFolders, pathId string) (resp.Contacts, error) { + path := fmt.Sprintf("/contacts/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.ContactsFromJSON(response) +} \ No newline at end of file diff --git a/customFields.go b/customFields.go new file mode 100644 index 0000000..78abba4 --- /dev/null +++ b/customFields.go @@ -0,0 +1,43 @@ +package wrikego + +import ( + "fmt" + "log" + "strings" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryCustomFields(config Config) (resp.CustomFields, error) { + path := "/customfields" + response, _ := Get(config, path, nil) + return resp.CustomFieldsFromJSON(response) +} + +func QueryCustomFieldsByIds(config Config, pathId []string) (resp.CustomFields, error) { + path := fmt.Sprintf("/customfields/%s", strings.Join(pathId, ",")) + response, _ := Get(config, path, nil) + return resp.CustomFieldsFromJSON(response) +} + +func CreateCustomFields(config Config, params params.CreateCustomFields) (resp.CustomFields, error) { + path := "/customfields" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Post(config, path, body) + return resp.CustomFieldsFromJSON(response) +} + +func ModifyCustomFieldsById(config Config, params params.ModifyCustomFields, pathId string) (resp.CustomFields, error) { + path := fmt.Sprintf("/customfields/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.CustomFieldsFromJSON(response) +} \ No newline at end of file diff --git a/folders.go b/folders.go index f0788fe..0b6775b 100644 --- a/folders.go +++ b/folders.go @@ -6,112 +6,112 @@ import ( "strings" params "github.com/TGoers-FNSB/WrikeGo/parameters" - types "github.com/TGoers-FNSB/WrikeGo/response" + resp "github.com/TGoers-FNSB/WrikeGo/response" query "github.com/google/go-querystring/query" ) -func QueryFolders(config Config, params params.QueryFolders) (types.Folders, error) { +func QueryFolders(config Config, params params.QueryFolders) (resp.Folders, error) { path := "/folders" body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func QueryFoldersInFolder(config Config, params params.QueryFolders, pathId string) (types.Folders, error) { +func QueryFoldersInFolder(config Config, params params.QueryFolders, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s/folders", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func QueryFoldersInSpace(config Config, params params.QueryFolders, pathId string) (types.Folders, error) { +func QueryFoldersInSpace(config Config, params params.QueryFolders, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/spaces/%s/folders", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func QueryFoldersFieldsHistoryByIds(config Config, params params.QueryFolders, pathId []string) (types.Folders, error) { +func QueryFoldersFieldsHistoryByIds(config Config, params params.QueryFolders, pathId []string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s/folders_history", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func QueryFoldersByIds(config Config, params params.QueryFolders, pathId []string) (types.Folders, error) { +func QueryFoldersByIds(config Config, params params.QueryFolders, pathId []string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func CreateFolderInFolder(config Config, params params.CreateFolders, pathId string) (types.Folders, error) { +func CreateFolderInFolder(config Config, params params.CreateFolders, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s/folders", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Post(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func CreateFolderCopyById(config Config, params params.CreateFoldersCopy, pathId string) (types.Folders, error) { +func CreateFolderCopyById(config Config, params params.CreateFoldersCopy, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/copy_folders/%s", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Post(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func CreateFolderCopyAsyncById(config Config, params params.CreateFoldersCopy, pathId string) (types.Folders, error) { +func CreateFolderCopyAsyncById(config Config, params params.CreateFoldersCopy, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/copy_folders_async/%s", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Post(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func ModifyFolderById(config Config, params params.ModifyFolders, pathId string) (types.Folders, error) { +func ModifyFolderById(config Config, params params.ModifyFolders, pathId string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Put(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func ModifyFoldersByIds(config Config, params params.ModifyFolders, pathId []string) (types.Folders, error) { +func ModifyFoldersByIds(config Config, params params.ModifyFolders, pathId []string) (resp.Folders, error) { path := fmt.Sprintf("/folders/%s", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Put(config, path, body) - return types.FoldersFromJSON(response) + return resp.FoldersFromJSON(response) } -func DeleteFolderById(config Config, pathId string) (types.Tasks, error) { +func DeleteFolderById(config Config, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/folders/%s", pathId) - response, _ := Delete(config, path) - return types.TasksFromJSON(response) + response, _ := Delete(config, path, nil) + return resp.TasksFromJSON(response) } \ No newline at end of file diff --git a/groups.go b/groups.go new file mode 100644 index 0000000..8607c26 --- /dev/null +++ b/groups.go @@ -0,0 +1,70 @@ +package wrikego + +import ( + "fmt" + "log" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryGroupById(config Config, params params.QueryGroups, pathId string) (resp.Groups, error) { + path := fmt.Sprintf("/groups/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.GroupsFromJSON(response) +} + +func QueryGroups(config Config, params params.QueryGroups) (resp.Groups, error) { + path := "/groups" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.GroupsFromJSON(response) +} + +func CreateGroup(config Config, params params.CreateGroups) (resp.Groups, error) { + path := "/groups" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Post(config, path, body) + return resp.GroupsFromJSON(response) +} + +func ModifyGroupsBulk(config Config, params params.ModifyGroupsBulk) (resp.Groups, error) { + path := "groups_bulk" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.GroupsFromJSON(response) +} + +func ModifyGroupById(config Config, params params.ModifyGroups, pathId string) (resp.Groups, error) { + path := fmt.Sprintf("/groups/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.GroupsFromJSON(response) +} + +func DeleteGroupById(config Config, params params.DeleteGroups, pathId string) (resp.Groups, error) { + path := fmt.Sprintf("/groups/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Delete(config, path, body) + return resp.GroupsFromJSON(response) +} \ No newline at end of file diff --git a/invitations.go b/invitations.go new file mode 100644 index 0000000..0c3e560 --- /dev/null +++ b/invitations.go @@ -0,0 +1,42 @@ +package wrikego + +import ( + "fmt" + "log" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryInvitations(config Config) (resp.Invitations, error) { + path := "/invitations" + response, _ := Get(config, path, nil) + return resp.InvitationsFromJSON(response) +} + +func CreateInvitation(config Config, params params.CreateInvitations) (resp.Invitations, error) { + path := "/invitations" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Get(config, path, body) + return resp.InvitationsFromJSON(response) +} + +func ModifyInvitationById(config Config, params params.ModifyInvitaions, pathId string) (resp.Invitations, error) { + path := fmt.Sprintf("/inivations/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.InvitationsFromJSON(response) +} + +func DeleteInvitationById(config Config, pathId string) (resp.Invitations, error) { + path := fmt.Sprintf("/invitations/%s", pathId) + response, _ := Delete(config, path, nil) + return resp.InvitationsFromJSON(response) +} \ No newline at end of file diff --git a/parameters/account.go b/parameters/account.go new file mode 100644 index 0000000..e0525b8 --- /dev/null +++ b/parameters/account.go @@ -0,0 +1,10 @@ +package wrikeparams + +type QueryAccount struct { + Metadata *[]Metadata `url:"metadata,omitempty"` + Fields *[]string `url:"fields,omitempty"` +} + +type ModifyAccount struct { + Metadata *Metadata `url:"metadata,omitempty"` +} diff --git a/parameters/comments.go b/parameters/comments.go new file mode 100644 index 0000000..a7c3223 --- /dev/null +++ b/parameters/comments.go @@ -0,0 +1,19 @@ +package wrikeparams + +type QueryComments struct { + PlainText *bool `url:"plainText,omitempty"` + Types *[]string `url:"types,omitempty"` + UpdatedDate *DateOrRange `url:"updatedDate,omitempty"` + Limit *int `url:"limit,omitempty"` + Fields *[]string `url:"fields,omitempty"` +} + +type CreateComments struct { + Text string `url:"text"` + PlainText *bool `url:"plainText,omitempty"` +} + +type ModifyComments struct { + Text string `url:"text"` + PlainText *bool `url:"plainText,omitempty"` +} diff --git a/parameters/contacts.go b/parameters/contacts.go new file mode 100644 index 0000000..b28f3f3 --- /dev/null +++ b/parameters/contacts.go @@ -0,0 +1,23 @@ +package wrikeparams + +type QueryContacts struct { + Me *bool `url:"me,omitempty"` // Required in some queries + Metadata *Metadata `url:"metadata,omitempty"` + Deleted *bool `url:"deleted,omitempty"` + Fields *[]string `url:"fields,omitempty"` + UpdatedDate *DateOrRange `url:"updatedDate,omitempty"` +} + +type ModifyContacts struct { + Metadata *Metadata `url:"metadata,omitempty"` + CurrentBillRate *struct { + RateSource *string `url:"rateSource,omitempty"` + RateValue *string `url:"rateValue,omitempty"` + } `url:"currentBillRate,omitempty"` + CurrentCostRate *struct { + RateSource *string `url:"rateSource,omitempty"` + RateValue *string `url:"rateValue,omitempty"` + } `url:"currentCostRate,omitempty"` + JobRoleId *string `url:"jobRoleId,omitempty"` + Fields *[]string `url:"fields,omitempty"` +} diff --git a/parameters/customFields.go b/parameters/customFields.go new file mode 100644 index 0000000..0a7e84b --- /dev/null +++ b/parameters/customFields.go @@ -0,0 +1,41 @@ +package wrikeparams + +type CreateCustomFields struct { + Title string `url:"title"` + Type string `url:"type"` + SpaceId *string `url:"spaceId,omitempty"` + Shareds *[]string `url:"shareds,omitempty"` + Settings *struct { + InheritanceType *string `url:"inheritanceType,omitempty"` + DecimalPlaces *int `url:"decimalPlaces,omitempty"` + UseThousandsSeparator *bool `url:"useThousandsSeparator,omitempty"` + Currency *string `url:"currency,omitempty"` + Aggregation *string `url:"aggregation,omitempty"` + Values *[]string `url:"values,omitempty"` + Options *[]string `url:"options,omitempty"` + OptionColorsEnabled *bool `url:"optionColorsEnabled,omitempty"` + AllowedOtherValues *bool `url:"allowedOtherValues,omitempty"` + Contacts *[]string `url:"contacts,omitempty"` + } `url:"settings,omitempty"` +} + +type ModifyCustomFields struct { + Title *string `url:"title,omitempty"` + Type *string `url:"type,omitempty"` + ChangeScope *string `url:"changeScope,omitempty"` + SpaceId *string `url:"spaceId,omitempty"` + AddShareds *[]string `url:"addShareds,omitempty"` + RemoveShareds *[]string `url:"removeShareds,omitempty"` + Settings *struct { + InheritanceType *string `url:"inheritanceType,omitempty"` + DecimalPlaces *int `url:"decimalPlaces,omitempty"` + UseThousandsSeparator *bool `url:"useThousandsSeparator,omitempty"` + Currency *string `url:"currency,omitempty"` + Aggregation *string `url:"aggregation,omitempty"` + Values *[]string `url:"values,omitempty"` + Options *[]string `url:"options,omitempty"` + OptionColorsEnabled *bool `url:"optionColorsEnabled,omitempty"` + AllowedOtherValues *bool `url:"allowedOtherValues,omitempty"` + Contacts *[]string `url:"contacts,omitempty"` + } `url:"settings,omitempty"` +} \ No newline at end of file diff --git a/parameters/folders.go b/parameters/folders.go index b070d40..b81e9bb 100644 --- a/parameters/folders.go +++ b/parameters/folders.go @@ -1,57 +1,57 @@ package wrikeparams type QueryFolders struct { - Permalink string `url:"permalink,omitempty"` - Descendants bool `url:"descendants,omitempty"` - Metadata Metadata `url:"metadata,omitempty"` - CustomField CustomField `url:"customField,omitempty"` - UpdatedDate DateOrRange `url:"updatedDate,omitempty"` - Project bool `url:"project,omitempty"` - Delete bool `url:"deleted,omitempty"` - ContractTypes []string `url:"contractTypes,omitempty"` - Fields []string `url:"fields,omitempty"` + Permalink *string `url:"permalink,omitempty"` + Descendants *bool `url:"descendants,omitempty"` + Metadata *Metadata `url:"metadata,omitempty"` + CustomField *CustomField `url:"customField,omitempty"` + UpdatedDate *DateOrRange `url:"updatedDate,omitempty"` + Project *bool `url:"project,omitempty"` + Delete *bool `url:"deleted,omitempty"` + ContractTypes *[]string `url:"contractTypes,omitempty"` + Fields *[]string `url:"fields,omitempty"` } type CreateFolders struct { - Title string `url:"title,omitempty"` - Description string `url:"description,omitempty"` - Shareds []string `url:"shareds,omitempty"` - Metadata []Metadata `url:"metadata,omitempty"` - CustomFields []CustomField `url:"customFields,omitempty"` - CustomColumns []string `url:"customColumns,omitempty"` - Project Project `url:"project,omitempty"` - Fields []string `url:"fields,omitempty"` + Title string `url:"title"` + Description *string `url:"description,omitempty"` + Shareds *[]string `url:"shareds,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` + CustomFields *[]CustomField `url:"customFields,omitempty"` + CustomColumns *[]string `url:"customColumns,omitempty"` + Project *Project `url:"project,omitempty"` + Fields *[]string `url:"fields,omitempty"` } type CreateFoldersCopy struct { - Parent string `url:"parent,omitempty"` - Title string `url:"title,omitempty"` - TitlePrefix string `url:"titlePrefix,omitempty"` - CopyDescriptions bool `url:"copyDescriptions,omitempty"` - CopyResponsibles bool `url:"copyResponsibles,omitempty"` - AddResponsibles []string `url:"addResponsibles,omitempty"` - RemoveResponsibles []string `url:"removeResponsibles,omitempty"` - CopyCustomFields bool `url:"copyCustomFields,omitempty"` - CopyCustomStatuses bool `url:"copyCustomStatuses,omitempty"` - CopyStatuses bool `url:"copyStatuses,omitempty"` - CopyParents bool `url:"copyParents,omitempty"` - RescheduleDate string `url:"rescheduleDate,omitempty"` - RescheduleMode string `url:"rescheduleMode,omitempty"` - EntryLimit int `url:"entryLimit,omitempty"` - AddShareds []string `url:"addShareds,omitempty"` - RemoveShareds []string `url:"removeShareds,omitempty"` + Parent string `url:"parent"` + Title string `url:"title"` + TitlePrefix *string `url:"titlePrefix,omitempty"` + CopyDescriptions *bool `url:"copyDescriptions,omitempty"` + CopyResponsibles *bool `url:"copyResponsibles,omitempty"` + AddResponsibles *[]string `url:"addResponsibles,omitempty"` + RemoveResponsibles *[]string `url:"removeResponsibles,omitempty"` + CopyCustomFields *bool `url:"copyCustomFields,omitempty"` + CopyCustomStatuses *bool `url:"copyCustomStatuses,omitempty"` + CopyStatuses *bool `url:"copyStatuses,omitempty"` + CopyParents *bool `url:"copyParents,omitempty"` + RescheduleDate *string `url:"rescheduleDate,omitempty"` + RescheduleMode *string `url:"rescheduleMode,omitempty"` + EntryLimit *int `url:"entryLimit,omitempty"` + AddShareds *[]string `url:"addShareds,omitempty"` + RemoveShareds *[]string `url:"removeShareds,omitempty"` } type ModifyFolders struct { - Title string `url:"title,omitempty"` - Description string `url:"description,omitempty"` - AddParents []string `url:"addParents,omitempty"` - RemoveParents []string `url:"removeParents,omitempty"` - Metadata []Metadata `url:"metadata,omitempty"` - Restore bool `url:"restore,omitempty"` - CustomFields []CustomField `url:"customFields,omitempty"` - CustomColumns []string `url:"customColumns,omitempty"` - ClearCustomColumns bool `url:"clearCustomColumns,omitempty"` - Project Project `url:"project,omitempty"` - Fields []string `url:"fields,omitempty"` + Title *string `url:"title,omitempty"` + Description *string `url:"description,omitempty"` + AddParents *[]string `url:"addParents,omitempty"` + RemoveParents *[]string `url:"removeParents,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` + Restore *bool `url:"restore,omitempty"` + CustomFields *[]CustomField `url:"customFields,omitempty"` + CustomColumns *[]string `url:"customColumns,omitempty"` + ClearCustomColumns *bool `url:"clearCustomColumns,omitempty"` + Project *Project `url:"project,omitempty"` + Fields *[]string `url:"fields,omitempty"` } diff --git a/parameters/groups.go b/parameters/groups.go new file mode 100644 index 0000000..d1fb43f --- /dev/null +++ b/parameters/groups.go @@ -0,0 +1,39 @@ +package wrikeparams + +type QueryGroups struct { + Metadata *Metadata `url:"metadata,omitempty"` + PageSize *float64 `url:"pageSize,omitempty"` + PageToken *string `url:"pageToken,omitempty"` + Fields *[]string `url:"fields,omitempty"` +} + +type CreateGroups struct { + Title string `url:"title"` + Members *[]string `url:"members,omitempty"` + Parent *string `url:"parent,omitempty"` + Avatar *Avatar `url:"avatar,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` +} + +type ModifyGroupsBulk struct { + Members []struct { + Id string `url:"id"` + AddMembers *string `url:"addMembers,omitempty"` + RemoveMembers *string `url:"removeMembers,omitempty"` + } `url:"members"` +} + +type ModifyGroups struct { + Title *string `url:"title,omitempty"` + AddMembers *[]string `url:"addMembers,omitempty"` + RemoveMembers *[]string `url:"removeMembers,omitempty"` + AddInvitations *[]string `url:"addInvitations,omitempty"` + RemoveInvitations *[]string `url:"removeInvitations,omitempty"` + Parent *string `url:"parent,omitempty"` + Avatar *Avatar `url:"avatar,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` +} + +type DeleteGroups struct { + Test *bool `url:"test,omitempty"` +} diff --git a/parameters/invitations.go b/parameters/invitations.go new file mode 100644 index 0000000..af15c88 --- /dev/null +++ b/parameters/invitations.go @@ -0,0 +1,17 @@ +package wrikeparams + +type CreateInvitations struct { + Email string `url:"email"` + FirstName *string `url:"firstName,omitempty"` + LastName *string `url:"lastName,omitempty"` + Role *string `url:"role,omitempty"` + External *bool `url:"external,omitempty"` + Subject *string `url:"subject,omitempty"` + Message *string `url:"message,omitempty"` +} + +type ModifyInvitaions struct { + Resend *string `url:"resend,omitempty"` + Role *string `url:"role,omitempty"` + External *bool `url:"external,omitempty"` +} diff --git a/parameters/sharedParamaters.go b/parameters/sharedParamaters.go index 5355d36..a906d21 100644 --- a/parameters/sharedParamaters.go +++ b/parameters/sharedParamaters.go @@ -47,6 +47,11 @@ type Project struct { EndDate string `url:"endDate,omitempty"` ContractType string `url:"contractType,omitempty"` Budget float64 `url:"budget,omitempty"` - OwnersAdd []string `url:"ownersAdd,omitempty"` - OwnersRemove []string `url:"ownersRemove,omitempty"` + OwnersAdd []string `url:"ownersAdd,omitempty"` + OwnersRemove []string `url:"ownersRemove,omitempty"` +} + +type Avatar struct { + Letters string `url:"letters,omitempty"` + Color string `url:"color,omitempty"` } diff --git a/parameters/tasks.go b/parameters/tasks.go index 74a9403..580160a 100644 --- a/parameters/tasks.go +++ b/parameters/tasks.go @@ -1,81 +1,81 @@ package wrikeparams type QueryTasks struct { - Descendants bool `url:"descendants,omitempty"` - Title string `url:"title,omitempty"` - Status []string `url:"status,omitempty"` - Importance string `url:"importance,omitempty"` - StartDate DateOrRange `url:"startDate,omitempty"` - DueDate DateOrRange `url:"dueDate,omitempty"` - ScheduledDate DateOrRange `url:"scheduledDate,omitempty"` - CreatedDate DateOrRange `url:"createdDate,omitempty"` - UpdatedDate DateOrRange `url:"updatedDate,omitempty"` - CompletedDate DateOrRange `url:"completedDate,omitempty"` - Authors []string `url:"authors,omitempty"` - Responsibles []string `url:"responsibles,omitempty"` - Permalink string `url:"permalink,omitempty"` - Type string `url:"type,omitempty"` - Limit int `url:"limit,omitempty"` - SortField string `url:"sortField,omitempty"` - SortOrder string `url:"sortOrder,omitempty"` - SubTasks bool `url:"subTasks,omitempty"` - PageSize int `url:"pageSize,omitempty"` - NextPageToken string `url:"nextPageToken,omitempty"` - Metadata Metadata `url:"metadata,omitempty"` - CustomField CustomField `url:"customField,omitempty"` - CustomStatuses []string `url:"customStatuses,omitempty"` - BillingTypes []string `url:"billingTypes,omitempty"` - Fields []string `url:"fields,omitempty"` + Descendants *bool `url:"descendants,omitempty"` + Title *string `url:"title,omitempty"` + Status *[]string `url:"status,omitempty"` + Importance *string `url:"importance,omitempty"` + StartDate *DateOrRange `url:"startDate,omitempty"` + DueDate *DateOrRange `url:"dueDate,omitempty"` + ScheduledDate *DateOrRange `url:"scheduledDate,omitempty"` + CreatedDate *DateOrRange `url:"createdDate,omitempty"` + UpdatedDate *DateOrRange `url:"updatedDate,omitempty"` + CompletedDate *DateOrRange `url:"completedDate,omitempty"` + Authors *[]string `url:"authors,omitempty"` + Responsibles *[]string `url:"responsibles,omitempty"` + Permalink *string `url:"permalink,omitempty"` + Type *string `url:"type,omitempty"` + Limit *int `url:"limit,omitempty"` + SortField *string `url:"sortField,omitempty"` + SortOrder *string `url:"sortOrder,omitempty"` + SubTasks *bool `url:"subTasks,omitempty"` + PageSize *int `url:"pageSize,omitempty"` + NextPageToken *string `url:"nextPageToken,omitempty"` + Metadata *Metadata `url:"metadata,omitempty"` + CustomField *CustomField `url:"customField,omitempty"` + CustomStatuses *[]string `url:"customStatuses,omitempty"` + BillingTypes *[]string `url:"billingTypes,omitempty"` + Fields *[]string `url:"fields,omitempty"` } type CreateTasks struct { - Title string `url:"title,omitempty"` - Description string `url:"description,omitempty"` - Status string `url:"status,omitempty"` - Importance string `url:"importance,omitempty"` - Dates TaskDates `url:"dates,omitempty"` - Shareds []string `url:"shareds,omitempty"` - Parents []string `url:"parents,omitempty"` - Responsibles []string `url:"responsibles,omitempty"` - ResponsiblePlaceholders []string `url:"resopnsiblePlaceholders,omitempty"` - Followers []string `url:"followers,omitempty"` - Follow bool `url:"follow,omitempty"` - PriorityBefore string `url:"priorityBefore,omitempty"` - PriorityAfter string `url:"priorityAfter,omitempty"` - SuperTasks []string `url:"superTasks,omitempty"` - Metadata []Metadata `url:"metadata,omitempty"` - CustomFields []CustomField `url:"customFields,omitempty"` - CustomStatus string `url:"customStatus,omitempty"` - EffortAllocation EffortAllocation `url:"effortAllocation,omitempty"` - BillingType string `url:"billingType,omitempty"` - Fields []string `url:"fields,omitempty"` + Title string `url:"title"` + Description *string `url:"description,omitempty"` + Status *string `url:"status,omitempty"` + Importance *string `url:"importance,omitempty"` + Dates *TaskDates `url:"dates,omitempty"` + Shareds *[]string `url:"shareds,omitempty"` + Parents *[]string `url:"parents,omitempty"` + Responsibles *[]string `url:"responsibles,omitempty"` + ResponsiblePlaceholders *[]string `url:"resopnsiblePlaceholders,omitempty"` + Followers *[]string `url:"followers,omitempty"` + Follow *bool `url:"follow,omitempty"` + PriorityBefore *string `url:"priorityBefore,omitempty"` + PriorityAfter *string `url:"priorityAfter,omitempty"` + SuperTasks *[]string `url:"superTasks,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` + CustomFields *[]CustomField `url:"customFields,omitempty"` + CustomStatus *string `url:"customStatus,omitempty"` + EffortAllocation *EffortAllocation `url:"effortAllocation,omitempty"` + BillingType *string `url:"billingType,omitempty"` + Fields *[]string `url:"fields,omitempty"` } type ModifyTasks struct { - Title string `url:"title,omitempty"` - Description string `url:"description,omitempty"` - Status string `url:"status,omitempty"` - Importance string `url:"importance,omitempty"` - Dates TaskDates `url:"dates,omitempty"` - AddParents []string `url:"addParents,omitempty"` - RemoveParents []string `url:"removeParents,omitempty"` - AddShareds []string `url:"addShareds,omitempty"` - RemoveShareds []string `url:"removeShareds,omitempty"` - AddResponsibles []string `url:"addResponsibles,omitempty"` - RemoveResponsibles []string `url:"removeResponsibles,omitempty"` - AddResponsiblePlaceholders []string `url:"addResopnsiblePlaceholders,omitempty"` - RemoveResponsiblePlaceholders []string `url:"removeResopnsiblePlaceholders,omitempty"` - AddFollowers []string `url:"addFollowers,omitempty"` - Follow bool `url:"follow,omitempty"` - PriorityBefore string `url:"priorityBefore,omitempty"` - PriorityAfter string `url:"priorityAfter,omitempty"` - AddSuperTasks []string `url:"addSuperTasks,omitempty"` - RemoveSuperTasks []string `url:"removeSuperTasks,omitempty"` - Metadata []Metadata `url:"metadata,omitempty"` - CustomFields []CustomField `url:"customFields,omitempty"` - CustomStatus string `url:"customStatus,omitempty"` - Restore bool `url:"restore,omitempty"` - EffortAllocation EffortAllocation `url:"effortAllocation,omitempty"` - BillingType string `url:"billingType,omitempty"` - Fields []string `url:"fields,omitempty"` + Title *string `url:"title,omitempty"` + Description *string `url:"description,omitempty"` + Status *string `url:"status,omitempty"` + Importance *string `url:"importance,omitempty"` + Dates *TaskDates `url:"dates,omitempty"` + AddParents *[]string `url:"addParents,omitempty"` + RemoveParents *[]string `url:"removeParents,omitempty"` + AddShareds *[]string `url:"addShareds,omitempty"` + RemoveShareds *[]string `url:"removeShareds,omitempty"` + AddResponsibles *[]string `url:"addResponsibles,omitempty"` + RemoveResponsibles *[]string `url:"removeResponsibles,omitempty"` + AddResponsiblePlaceholders *[]string `url:"addResopnsiblePlaceholders,omitempty"` + RemoveResponsiblePlaceholders *[]string `url:"removeResopnsiblePlaceholders,omitempty"` + AddFollowers *[]string `url:"addFollowers,omitempty"` + Follow *bool `url:"follow,omitempty"` + PriorityBefore *string `url:"priorityBefore,omitempty"` + PriorityAfter *string `url:"priorityAfter,omitempty"` + AddSuperTasks *[]string `url:"addSuperTasks,omitempty"` + RemoveSuperTasks *[]string `url:"removeSuperTasks,omitempty"` + Metadata *[]Metadata `url:"metadata,omitempty"` + CustomFields *[]CustomField `url:"customFields,omitempty"` + CustomStatus *string `url:"customStatus,omitempty"` + Restore *bool `url:"restore,omitempty"` + EffortAllocation *EffortAllocation `url:"effortAllocation,omitempty"` + BillingType *string `url:"billingType,omitempty"` + Fields *[]string `url:"fields,omitempty"` } \ No newline at end of file diff --git a/parameters/users.go b/parameters/users.go new file mode 100644 index 0000000..f283fcb --- /dev/null +++ b/parameters/users.go @@ -0,0 +1,9 @@ +package wrikeparams + +type ModifyUsers struct { + Profile struct { + AccountId string `url:"accountId"` + Role string `url:"profile"` + External *bool `url:"external,omitempty"` + } `url:"profile"` +} diff --git a/parameters/workflows.go b/parameters/workflows.go new file mode 100644 index 0000000..fd6841d --- /dev/null +++ b/parameters/workflows.go @@ -0,0 +1,19 @@ +package wrikeparams + +type CreateWorkflows struct { + Name string `url:"name"` +} + +type ModifyWorkflows struct { + Name *string `url:"name,omitempty"` + Hidden *bool `url:"hidden,omitempty"` + CustomStatus *struct { + ID *string `url:"id,omitempty"` + Name *string `url:"name,omitempty"` + StandardName *bool `url:"standardName,omitempty"` + Color *string `url:"color,omitempty"` + Standard *bool `url:"standard,omitempty"` + Group *string `url:"group,omitempty"` + Hidden *bool `url:"hidden,omitempty"` + } `url:"customStatus,omitempty"` +} diff --git a/response/account.go b/response/account.go new file mode 100644 index 0000000..5817f9f --- /dev/null +++ b/response/account.go @@ -0,0 +1,57 @@ +package wrikeresponse + +import "encoding/json" + +func AccountFromJSON(data []byte) (Account, error) { + var item Account + err := json.Unmarshal(data, &item) + return item, err +} + +type Account struct { + Kind string `json:"kind"` + Data []struct { + Id string `json:"id"` + Name string `json:"name"` + DateFormat string `json:"dateFormat"` + FirstDayOfWeek string `json:"firstDayOfWeek"` + WorkDays []string `json:"workDays"` + RootFolderId string `json:"rootFolderId"` + RecycleBinId string `json:"recycleBinId"` + CreatedDate string `json:"createdDate"` + Subscription struct { + Type string `json:"type"` + Suspended bool `json:"suspended"` + Paid bool `json:"paid"` + UserLimit int `json:"userLimit"` + } `json:"subscription"` + Metadata []struct { + Key string `json:"key"` + Value string `json:"value"` + } `json:"metadata"` + CustomFields []struct { + ID string `json:"id"` + AccountID string `json:"accountId"` + Title string `json:"title"` + Type string `json:"type"` + SpaceId string `json:"spaceId"` + SharedIds []string `json:"sharedIds"` + Settings struct { + InheritanceType string `json:"inheritanceType"` + DecimalPlaces int `json:"decimalPlaces"` + UseThousandsSeparator bool `json:"useThousandsSeparator"` + Currency string `json:"currency"` + Aggregation string `json:"aggregation"` + Values []string `json:"values"` + Options []string `json:"options"` + OptionColorsEnabled bool `json:"optionColorsEnabled"` + AllowedOtherValues bool `json:"allowedOtherValues"` + Contacts []string `json:"contacts"` + ReadOnly bool `json:"readOnly"` + AllowTime bool `json:"allowTime"` + Timezone string `json:"timezone"` + } `json:"settings"` + } `json:"customFields"` + JoinedDate string `json:"joinedDate"` + } `json:"data"` +} diff --git a/response/comments.go b/response/comments.go new file mode 100644 index 0000000..0c2e84f --- /dev/null +++ b/response/comments.go @@ -0,0 +1,31 @@ +package wrikeresponse + +import "encoding/json" + +func CommentsFromJSON(data []byte) (Comments, error) { + var item Comments + err := json.Unmarshal(data, &item) + return item, err +} + +type Comments struct { + Kind string `json:"kind"` + Data []struct { + Id string `json:"id"` + AuthorId string `json:"authorId"` + Text string `json:"text"` + UpdatedDate string `json:"updatedDate"` + CreatedDate string `json:"createdDate"` + TaskId string `json:"taskId,omitempty"` + FolderId string `json:"folderId,omitempty"` + Type string `json:"type"` + EmailSubject string `json:"emailSubject"` + Direction string `json:"direction"` + ExternalRequester struct { + Id string `json:"id"` + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + Email string `json:"email"` + } `json:"externalRequester"` + } `json:"data"` +} diff --git a/response/contacts.go b/response/contacts.go new file mode 100644 index 0000000..927f03f --- /dev/null +++ b/response/contacts.go @@ -0,0 +1,63 @@ +package wrikeresponse + +import "encoding/json" + +func ContactsFromJSON(data []byte) (Contacts, error) { + var item Contacts + err := json.Unmarshal(data, &item) + return item, err +} + +type Contacts struct { + Kind string `json:"kind,omitempty"` + Data []struct { + Id string `json:"id,omitempty"` + FirstName string `json:"firstName,omitempty"` + LastName string `json:"lastName,omitempty"` + Type string `json:"type,omitempty"` + Profiles []struct { + AccountID string `json:"accountId,omitempty"` + Role string `json:"role,omitempty"` + External bool `json:"external,omitempty"` + Admin bool `json:"admin,omitempty"` + Owner bool `json:"owner,omitempty"` + } `json:"profiles,omitempty"` + AvatarURL string `json:"avatarUrl,omitempty"` + Timezone string `json:"timezone,omitempty"` + Locale string `json:"locale,omitempty"` + Deleted bool `json:"deleted,omitempty"` + Me bool `json:"me,omitempty,omitempty"` + MemberIds []string `json:"memberIds,omitempty"` + Metadata []struct { + Key string `json:"key,omitempty"` + Value string `json:"value,omitempty"` + } `json:"metadata,omitempty"` + MyTeam bool `json:"myTeam,omitempty"` + Title string `json:"title,omitempty"` + CompanyName string `json:"companyName,omitempty"` + Phone string `json:"phone,omitempty"` + Location string `json:"location,omitempty"` + WorkScheduleId string `json:"workScheduleId,omitempty"` + CurrentBillRate struct { + RateSource string `json:"rateSource,omitempty"` + RateValue string `json:"rateValue,omitempty"` + } `json:"currentBillRate,omitempty"` + CurrentCostRate struct { + RateSource string `json:"rateSource,omitempty"` + RateValue string `json:"rateValue,omitempty"` + } `json:"currentCostRate,omitempty"` + JobRoleId string `json:"jobRoleId,omitempty"` + BillRateHistory []struct { + RateSource string `json:"rateSource,omitempty"` + RateValue int `json:"rateValue,omitempty"` + StartDate string `json:"startDate,omitempty"` + EndDate string `json:"endDate,omitempty"` + } `json:"billRateHistory,omitempty"` + CostRateHistory []struct { + RateSource string `json:"rateSource,omitempty"` + RateValue int `json:"rateValue,omitempty"` + StartDate string `json:"startDate,omitempty"` + EndDate string `json:"endDate,omitempty"` + } `json:"costRateHistory,omitempty"` + } `json:"data,omitempty"` +} diff --git a/response/customFields.go b/response/customFields.go new file mode 100644 index 0000000..66b7579 --- /dev/null +++ b/response/customFields.go @@ -0,0 +1,27 @@ +package wrikeresponse + +import "encoding/json" + +func CustomFieldsFromJSON(data []byte) (CustomFields, error) { + var item CustomFields + err := json.Unmarshal(data, &item) + return item, err +} + +type CustomFields struct { + Kind string `json:"kind"` + Data []struct { + ID string `json:"id"` + AccountID string `json:"accountId"` + Title string `json:"title"` + Type string `json:"type"` + SharedIds []interface{} `json:"sharedIds"` + Settings struct { + InheritanceType string `json:"inheritanceType"` + DecimalPlaces int `json:"decimalPlaces"` + UseThousandsSeparator bool `json:"useThousandsSeparator"` + Aggregation string `json:"aggregation"` + ReadOnly bool `json:"readOnly"` + } `json:"settings"` + } `json:"data"` +} \ No newline at end of file diff --git a/response/groups.go b/response/groups.go new file mode 100644 index 0000000..189198a --- /dev/null +++ b/response/groups.go @@ -0,0 +1,27 @@ +package wrikeresponse + +import "encoding/json" + +func GroupsFromJSON(data []byte) (Groups, error) { + var item Groups + err := json.Unmarshal(data, &item) + return item, err +} + +type Groups struct { + Kind string `json:"kind,omitempty"` + Data []struct { + Id string `json:"id,omitempty"` + AccountId string `json:"accountId,omitempty"` + Title string `json:"title,omitempty"` + MemberIds []string `json:"memberIds,omitempty"` + ChildIds []string `json:"childIds,omitempty"` + ParentIds []string `json:"parentIds,omitempty"` + AvatarURL string `json:"avatarUrl,omitempty"` + MyTeam bool `json:"myTeam,omitempty"` + Metadata []struct { + Key string `json:"key,omitempty"` + Value string `json:"value,omitempty"` + } `json:"metadata,omitempty"` + } `json:"data,omitempty"` +} diff --git a/response/invitations.go b/response/invitations.go new file mode 100644 index 0000000..9b0f00e --- /dev/null +++ b/response/invitations.go @@ -0,0 +1,26 @@ +package wrikeresponse + +import "encoding/json" + +func InvitationsFromJSON(data []byte) (Invitations, error) { + var item Invitations + err := json.Unmarshal(data, &item) + return item, err +} + +type Invitations struct { + Kind string `json:"kind,omitempty"` + Data []struct { + Id string `json:"id,omitempty"` + AccountId string `json:"accountId,omitempty"` + FirstName string `json:"firstName,omitempty"` + LastName string `json:"lastName,omitempty"` + Email string `json:"email,omitempty"` + Status string `json:"status,omitempty"` + InviterUserId string `json:"inviterUserId,omitempty"` + InvitationDate string `json:"invitationDate,omitempty"` + ResolvedDate string `json:"resolvedDate,omitempty"` + Role string `json:"role,omitempty"` + External bool `json:"external,omitempty"` + } `json:"data,omitempty"` +} diff --git a/response/users.go b/response/users.go new file mode 100644 index 0000000..bf77d34 --- /dev/null +++ b/response/users.go @@ -0,0 +1,43 @@ +package wrikeresponse + +import "encoding/json" + +func UsersFromJSON(data []byte) (Users, error) { + var item Users + err := json.Unmarshal(data, &item) + return item, err +} + +type Users struct { + Kind string `json:"kind,omitempty"` + Data []struct { + ID string `json:"id,omitempty"` + FirstName string `json:"firstName,omitempty"` + LastName string `json:"lastName,omitempty"` + Type string `json:"type,omitempty"` + Profiles []struct { + AccountID string `json:"accountId,omitempty"` + Email string `json:"email,omitempty"` + Role string `json:"role,omitempty"` + External bool `json:"external,omitempty"` + Admin bool `json:"admin,omitempty"` + Owner bool `json:"owner,omitempty"` + } `json:"profiles,omitempty"` + AvatarURL string `json:"avatarUrl,omitempty"` + Timezone string `json:"timezone,omitempty"` + Locale string `json:"locale,omitempty"` + Deleted bool `json:"deleted,omitempty"` + Me bool `json:"me,omitempty"` + MemberIds []string `json:"memberIds,omitempty"` + Metadata []struct { + Key string `json:"key,omitempty"` + Value string `json:"value,omitempty"` + } `json:"metadata,omitempty"` + MyTeam bool `json:"myTeam,omitempty"` + Title string `json:"title,omitempty"` + CompanyName string `json:"companyName,omitempty"` + Phone string `json:"phone,omitempty"` + Location string `json:"location,omitempty"` + WorkScheduleId string `json:"workScheduleId,omitempty"` + } `json:"data,omitempty"` +} \ No newline at end of file diff --git a/response/workflows.go b/response/workflows.go new file mode 100644 index 0000000..fe2aad6 --- /dev/null +++ b/response/workflows.go @@ -0,0 +1,29 @@ +package wrikeresponse + +import "encoding/json" + +func WorkflowsFromJSON(data []byte) (Workflows, error) { + var item Workflows + err := json.Unmarshal(data, &item) + return item, err +} + +type Workflows struct { + Kind string `json:"kind"` + Data []struct { + Id string `json:"id"` + SpaceId string `json:"spaceId"` + Name string `json:"name"` + Standard bool `json:"standard"` + Hidden bool `json:"hidden"` + CustomStatuses []struct { + ID string `json:"id"` + Name string `json:"name"` + StandardName bool `json:"standardName"` + Color string `json:"color"` + Standard bool `json:"standard"` + Group string `json:"group"` + Hidden bool `json:"hidden"` + } `json:"customStatuses"` + } `json:"data"` +} \ No newline at end of file diff --git a/tasks.go b/tasks.go index 3132b2a..a2f4d04 100644 --- a/tasks.go +++ b/tasks.go @@ -6,92 +6,92 @@ import ( "strings" params "github.com/TGoers-FNSB/WrikeGo/parameters" - types "github.com/TGoers-FNSB/WrikeGo/response" + resp "github.com/TGoers-FNSB/WrikeGo/response" query "github.com/google/go-querystring/query" ) -func QueryTasks(config Config, params params.QueryTasks) (types.Tasks, error) { +func QueryTasks(config Config, params params.QueryTasks) (resp.Tasks, error) { path := "/tasks" body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func QueryTasksInFolder(config Config, params params.QueryTasks, pathId string) (types.Tasks, error) { +func QueryTasksInFolder(config Config, params params.QueryTasks, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/folders/%s/tasks", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func QueryTasksInSpace(config Config, params params.QueryTasks, pathId string) (types.Tasks, error) { +func QueryTasksInSpace(config Config, params params.QueryTasks, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/spaces/%s/tasks", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func QueryTasksByIds(config Config, params params.QueryTasks, pathId []string) (types.Tasks, error) { +func QueryTasksByIds(config Config, params params.QueryTasks, pathId []string) (resp.Tasks, error) { path := fmt.Sprintf("/tasks/%s", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func QueryTasksFieldsHistoryByIds(config Config, params params.QueryTasks, pathId []string) (types.Tasks, error) { +func QueryTasksFieldsHistoryByIds(config Config, params params.QueryTasks, pathId []string) (resp.Tasks, error) { path := fmt.Sprintf("/tasks/%s/tasks_history", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Get(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func CreateTaskInFolder(config Config, params params.CreateTasks, pathId string) (types.Tasks, error) { +func CreateTaskInFolder(config Config, params params.CreateTasks, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/folders/%s/tasks", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Post(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func ModifyTaskById(config Config, params params.ModifyTasks, pathId string) (types.Tasks, error) { +func ModifyTaskById(config Config, params params.ModifyTasks, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/tasks/%s", pathId) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Put(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func ModifyTasksByIds(config Config, params params.ModifyTasks, pathId []string) (types.Tasks, error) { +func ModifyTasksByIds(config Config, params params.ModifyTasks, pathId []string) (resp.Tasks, error) { path := fmt.Sprintf("/tasks/%s", strings.Join(pathId, ",")) body, err := query.Values(params) if err != nil { log.Println(err) } response, _ := Put(config, path, body) - return types.TasksFromJSON(response) + return resp.TasksFromJSON(response) } -func DeleteTaskById(config Config, pathId string) (types.Tasks, error) { +func DeleteTaskById(config Config, pathId string) (resp.Tasks, error) { path := fmt.Sprintf("/tasks/%s", pathId) - response, _ := Delete(config, path) - return types.TasksFromJSON(response) + response, _ := Delete(config, path, nil) + return resp.TasksFromJSON(response) } \ No newline at end of file diff --git a/users.go b/users.go new file mode 100644 index 0000000..f3e3685 --- /dev/null +++ b/users.go @@ -0,0 +1,26 @@ +package wrikego + +import ( + "fmt" + "log" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryUserById(config Config, pathId string) (resp.Users, error) { + path := fmt.Sprintf("/users/%s", pathId) + response, _ := Get(config, path, nil) + return resp.UsersFromJSON(response) +} + +func ModifyUserById(config Config, params params.ModifyUsers, pathId string) (resp.Users, error) { + path := fmt.Sprintf("/users/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.UsersFromJSON(response) +} \ No newline at end of file diff --git a/workflows.go b/workflows.go new file mode 100644 index 0000000..3bb80fb --- /dev/null +++ b/workflows.go @@ -0,0 +1,36 @@ +package wrikego + +import ( + "fmt" + "log" + + params "github.com/TGoers-FNSB/WrikeGo/parameters" + resp "github.com/TGoers-FNSB/WrikeGo/response" + query "github.com/google/go-querystring/query" +) + +func QueryWorkflows(config Config) (resp.Workflows, error) { + path := "/workflows" + response, _ := Get(config, path, nil) + return resp.WorkflowsFromJSON(response) +} + +func CreateWorkflow(config Config, params params.CreateWorkflows) (resp.Workflows, error) { + path := "/workflows" + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Post(config, path, body) + return resp.WorkflowsFromJSON(response) +} + +func ModifyWorkflow(config Config, params params.CreateWorkflows, pathId string) (resp.Workflows, error) { + path := fmt.Sprintf("/workflows/%s", pathId) + body, err := query.Values(params) + if err != nil { + log.Println(err) + } + response, _ := Put(config, path, body) + return resp.WorkflowsFromJSON(response) +} \ No newline at end of file