@@ -38,14 +38,14 @@ func GetRootList(token, userId string) (*RootListResponse, int, error) {
38
38
data := RootListResponse {}
39
39
err = json .Unmarshal (body , & data )
40
40
if err != nil {
41
- fmt .Println ("could not read request response body" )
41
+ fmt .Println ("could not unmarshal JSON body" )
42
42
return nil , 0 , err
43
43
}
44
44
45
45
return & data , resp .StatusCode , nil
46
46
}
47
47
48
- func PostRootListChanges (ops []DeltaOps , baseRevision , token , userId string ) (string , int , error ) {
48
+ func PostRootListChanges (ops []DeltaOps , baseRevision , token , userId string ) (* RootListChangeResponse , int , error ) {
49
49
str := & ChangesPayload {
50
50
BaseRevision : baseRevision ,
51
51
Deltas : []ChangeDelta {
@@ -58,7 +58,7 @@ func PostRootListChanges(ops []DeltaOps, baseRevision, token, userId string) (st
58
58
jsonStr , err := json .Marshal (str )
59
59
if err != nil {
60
60
fmt .Printf ("Error: %s" , err )
61
- return "" , 0 , err
61
+ return nil , 0 , err
62
62
}
63
63
64
64
url := fmt .Sprintf ("https://spclient.wg.spotify.com/playlist/v2/user/%s/rootlist/changes" , userId )
@@ -73,17 +73,22 @@ func PostRootListChanges(ops []DeltaOps, baseRevision, token, userId string) (st
73
73
resp , err := client .Do (req )
74
74
if err != nil {
75
75
fmt .Println ("error during POST request" )
76
- return "" , 0 , err
76
+ return nil , 0 , err
77
77
}
78
78
79
79
body , err := ioutil .ReadAll (resp .Body )
80
80
if err != nil {
81
81
fmt .Println ("could not read request response body" )
82
- return "" , 0 , err
82
+ return nil , 0 , err
83
83
}
84
84
_ = resp .Body .Close ()
85
85
86
- res := string (body )
86
+ data := RootListChangeResponse {}
87
+ err = json .Unmarshal (body , & data )
88
+ if err != nil {
89
+ fmt .Println ("could not unmarshal JSON body" )
90
+ return nil , 0 , err
91
+ }
87
92
88
- return res , resp .StatusCode , nil
93
+ return & data , resp .StatusCode , nil
89
94
}
0 commit comments