Skip to content

Commit

Permalink
Merge pull request #6 from TGoers-FNSB/dev
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
TristanGoers authored Sep 26, 2023
2 parents 1040f8c + 901202c commit a59a0a8
Show file tree
Hide file tree
Showing 30 changed files with 1,029 additions and 163 deletions.
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

0 comments on commit a59a0a8

Please sign in to comment.