Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.2 #6

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
@@ -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)
}
5 changes: 3 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
83 changes: 83 additions & 0 deletions comments.go
Original file line number Diff line number Diff line change
@@ -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)
}
51 changes: 51 additions & 0 deletions contacts.go
Original file line number Diff line number Diff line change
@@ -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)
}
43 changes: 43 additions & 0 deletions customFields.go
Original file line number Diff line number Diff line change
@@ -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)
}
48 changes: 24 additions & 24 deletions folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading