Skip to content

Commit d471be8

Browse files
Update fields values to be stored in const (#29)
1 parent 1f69b99 commit d471be8

19 files changed

+28
-20
lines changed

controllers/boards_controller.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (bc *BoardsController) Fetch(boardSpec string) (*models.Board, error) {
2727
response := new(models.Response)
2828
response.Data = new(models.Board)
2929
resp, err := bc.wreckerClient.Get("/boards/"+boardSpec).
30-
URLParam("fields", "id,url,reason,counts,created_at,creator,description,image,privacy,name").
30+
URLParam("fields", models.BOARD_FIELDS).
3131
Into(response).
3232
Execute()
3333

@@ -61,7 +61,7 @@ func (bc *BoardsController) Create(boardName string, optionals *BoardCreateOptio
6161
response := new(models.Response)
6262
response.Data = new(models.Board)
6363
resp, err := bc.wreckerClient.Post("/boards/").
64-
URLParam("fields", "id,url,reason,counts,created_at,creator,description,image,privacy,name").
64+
URLParam("fields", models.BOARD_FIELDS).
6565
FormParam("name", boardName).
6666
FormParam("description", optionals.Description).
6767
Into(response).
@@ -98,7 +98,7 @@ func (bc *BoardsController) Update(boardSpec string, optionals *BoardUpdateOptio
9898
response := new(models.Response)
9999
response.Data = new(models.Board)
100100
resp, err := bc.wreckerClient.Patch("/boards/"+boardSpec+"/").
101-
URLParam("fields", "id,url,reason,counts,created_at,creator,description,image,privacy,name").
101+
URLParam("fields", models.BOARD_FIELDS).
102102
FormParam("name", optionals.Name).
103103
FormParam("description", optionals.Description).
104104
Into(response).

controllers/boards_pins_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (bpc *BoardsPinsController) Fetch(boardSpec string, optionals *BoardsPinsFe
3131
response := new(models.Response)
3232
response.Data = &[]models.Pin{}
3333
resp, err := bpc.wreckerClient.Get("/boards/"+boardSpec+"/pins/").
34-
URLParam("fields", "id,link,note,url,attribution,color,board,counts,created_at,creator,image,media,metadata,original_link").
34+
URLParam("fields", models.PIN_FIELDS).
3535
Into(response).
3636
Execute()
3737

controllers/me_boards_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ func newMeBoardsController(wc *wrecker.Wrecker) *MeBoardsController {
2222

2323
// Fetch loads the authorized users boards
2424
// Endpoint: [GET] /v1/me/boards/
25-
func (mbc *MeBoardsController) Fetch() (*[]models.Board, error){
25+
func (mbc *MeBoardsController) Fetch() (*[]models.Board, error) {
2626
// Build + execute request
2727
response := new(models.Response)
2828
response.Data = &[]models.Board{}
2929
resp, err := mbc.wreckerClient.Get("/me/boards/").
30-
URLParam("fields", "id,name,url,counts,creator,description,created_at,image,privacy,reason").
30+
URLParam("fields", models.BOARD_FIELDS).
3131
Into(response).
3232
Execute()
3333

controllers/me_boards_suggested_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (mbsc *MeBoardsSuggestedController) Fetch(optionals *MeBoardsSuggestedFetch
3333
response := new(models.Response)
3434
response.Data = &[]models.Board{}
3535
request := mbsc.wreckerClient.Get("/me/boards/suggested/").
36-
URLParam("fields", "id,name,url,counts,creator,description,created_at,image,privacy,reason").
36+
URLParam("fields", models.BOARD_FIELDS).
3737
Into(response)
3838
if optionals.Count != 0 {
3939
request.URLParam("count", strconv.Itoa(int(optionals.Count)))

controllers/me_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (mc *MeController) Fetch() (*models.User, error) {
3737
response := new(models.Response)
3838
response.Data = new(models.User)
3939
resp, err := mc.wreckerClient.Get("/me/").
40-
URLParam("fields", "first_name,last_name,url,account_type,bio,counts,created_at,id,image,username").
40+
URLParam("fields", models.USER_FIELDS).
4141
Into(response).
4242
Execute()
4343

controllers/me_followers_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mfc *MeFollowersController) Fetch(optionals *MeFollowersFetchOptionals) (*
3131
response := new(models.Response)
3232
response.Data = &[]models.User{}
3333
request := mfc.wreckerClient.Get("/me/followers/").
34-
URLParam("fields", "first_name,id,last_name,url,account_type,bio,counts,created_at,image,username").
34+
URLParam("fields", models.USER_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_following_boards_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mfbc *MeFollowingBoardsController) Fetch(optionals *MeFollowingBoardsFetch
3131
response := new(models.Response)
3232
response.Data = &[]models.Board{}
3333
request := mfbc.wreckerClient.Get("/me/following/boards/").
34-
URLParam("fields", "id,name,url,counts,created_at,creator,description,image,privacy,reason").
34+
URLParam("fields", models.BOARD_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_following_interests_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mfic *MeFollowingInterestsController) Fetch(optionals *MeFollowingInterest
3131
response := new(models.Response)
3232
response.Data = &[]models.Interest{}
3333
request := mfic.wreckerClient.Get("/me/following/interests/").
34-
URLParam("fields", "id,name").
34+
URLParam("fields", models.INTEREST_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_following_users_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (c *MeFollowingUsersController) Fetch(optionals *FollowingUsersControllerFe
3131
response := new(models.Response)
3232
response.Data = &[]models.User{}
3333
request := c.wreckerClient.Get("/me/following/users/").
34-
URLParam("fields", "first_name,id,last_name,url,account_type,counts,bio,created_at,image,username").
34+
URLParam("fields", models.USER_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_likes_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mlc *MeLikesController) Fetch(optionals *MeLikesFetchOptionals) (*[]models
3131
response := new(models.Response)
3232
response.Data = &[]models.Pin{}
3333
request := mlc.wreckerClient.Get("/me/likes/").
34-
URLParam("fields", "id,link,note,url,attribution,board,color,counts,created_at,creator,image,media,metadata,original_link").
34+
URLParam("fields", models.PIN_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_pins_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mpc *MePinsController) Fetch(optionals *MePinsFetchOptionals) (*[]models.P
3131
response := new(models.Response)
3232
response.Data = &[]models.Pin{}
3333
request := mpc.wreckerClient.Get("/me/pins/").
34-
URLParam("fields", "id,link,note,url,attribution,board,color,counts,created_at,creator,image,media,metadata,original_link").
34+
URLParam("fields", models.PIN_FIELDS).
3535
Into(response)
3636
if optionals.Cursor != "" {
3737
request.URLParam("cursor", optionals.Cursor)

controllers/me_search_boards_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (msbc *MeSearchBoardsController) Fetch(query string, optionals *MeSearchBoa
3333
response := new(models.Response)
3434
response.Data = &[]models.Board{}
3535
request := msbc.wreckerClient.Get("/me/search/boards/").
36-
URLParam("fields", "id,name,url,counts,created_at,creator,description,privacy,image,reason").
36+
URLParam("fields", models.BOARD_FIELDS).
3737
URLParam("query", query).
3838
Into(response)
3939
if optionals.Cursor != "" {

controllers/me_search_pins_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (mspc *MeSearchPinsController) Fetch(query string, optionals *MeSearchPinsF
3333
response := new(models.Response)
3434
response.Data = &[]models.Pin{}
3535
request := mspc.wreckerClient.Get("/me/search/pins/").
36-
URLParam("fields", "attribution,board,color,counts,created_at,creator,id,image,link,media,metadata,note,original_link,url").
36+
URLParam("fields", models.PIN_FIELDS).
3737
URLParam("query", query).
3838
Into(response)
3939
if optionals.Cursor != "" {

controllers/pins_controller.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (pc *PinsController) Fetch(pinId string) (*models.Pin, error) {
2929
response.Data = new(models.Pin)
3030

3131
resp, err := pc.wreckerClient.Get("/pins/"+pinId+"/").
32-
URLParam("fields", "id,link,note,url,attribution,board,color,counts,created_at,creator,image,media,metadata,original_link").
32+
URLParam("fields", models.PIN_FIELDS).
3333
Into(response).
3434
Execute()
3535

@@ -65,7 +65,7 @@ func (pc *PinsController) Create(boardSpec string, note string, optionals *PinCr
6565
response := new(models.Response)
6666
response.Data = new(models.Pin)
6767
request := pc.wreckerClient.Post("/pins/").
68-
URLParam("fields", "id,link,note,url,attribution,board,color,counts,created_at,creator,image,media,metadata,original_link").
68+
URLParam("fields", models.PIN_FIELDS).
6969
FormParam("board", boardSpec).
7070
FormParam("note", note).
7171
Into(response)
@@ -124,7 +124,7 @@ func (pc *PinsController) Update(pinId string, optionals *PinUpdateOptionals) (*
124124
response := new(models.Response)
125125
response.Data = new(models.Pin)
126126
request := pc.wreckerClient.Patch("/pins/"+pinId+"/").
127-
URLParam("fields", "id,link,note,url,attribution,board,color,counts,created_at,creator,image,media,metadata,original_link").
127+
URLParam("fields", models.PIN_FIELDS).
128128
Into(response)
129129
if optionals.Board != "" {
130130
request.FormParam("board", optionals.Board)

controllers/users_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (uc *UsersController) Fetch(username string) (*models.User, error) {
2525
response.Data = new(models.User)
2626

2727
resp, err := uc.wreckerClient.Get("/users/"+username+"/").
28-
URLParam("fields", "first_name,last_name,url,account_type,bio,counts,created_at,image,username").
28+
URLParam("fields", models.USER_FIELDS).
2929
Into(response).
3030
Execute()
3131

models/board.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"github.com/BrandonRomano/iso8601"
55
)
66

7+
const BOARD_FIELDS = "id,url,reason,counts,created_at,creator,description,image,privacy,name"
8+
79
// Board is a struct that represents an individual board
810
// from the Pinterest API.
911
type Board struct {

models/interest.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package models
22

3+
const INTEREST_FIELDS = "id,name"
4+
35
// Interest is a struct that represents an individual interest
46
// from the Pinterest API.
57
type Interest struct {

models/pin.go

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package models
22

33
import "github.com/BrandonRomano/iso8601"
44

5+
const PIN_FIELDS = "id,link,note,url,attribution,color,board,counts,created_at,creator,image,media,metadata,original_link"
6+
57
type Pin struct {
68
Id string `json:"id"`
79
Link string `json:"link"`

models/user.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"github.com/BrandonRomano/iso8601"
55
)
66

7+
const USER_FIELDS = "first_name,last_name,url,account_type,bio,counts,created_at,id,image,username"
8+
79
// User is a struct that represents an individual user
810
// from the Pinterest API.
911
type User struct {

0 commit comments

Comments
 (0)