42 // If lopt.All is true, several requests will be made until the API server |
42 // If lopt.All is true, several requests will be made until the API server |
43 // has nothing to return. |
43 // has nothing to return. |
44 func (mc *Client) getMultipleStatuses(endPoint string, params apiCallParams, lopt *LimitParams) ([]Status, error) { |
44 func (mc *Client) getMultipleStatuses(endPoint string, params apiCallParams, lopt *LimitParams) ([]Status, error) { |
45 var statuses []Status |
45 var statuses []Status |
46 var links apiLinks |
46 var links apiLinks |
47 if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &statuses); err != nil { |
47 if err := mc.apiCall("v1/"+endPoint, rest.Get, params, lopt, &links, &statuses); err != nil { |
48 return nil, err |
48 return nil, err |
49 } |
49 } |
50 if lopt != nil { // Fetch more pages to reach our limit |
50 if lopt != nil { // Fetch more pages to reach our limit |
51 var statusSlice []Status |
51 var statusSlice []Status |
52 for (lopt.All || lopt.Limit > len(statuses)) && links.next != nil { |
52 for (lopt.All || lopt.Limit > len(statuses)) && links.next != nil { |
53 newlopt := links.next |
53 newlopt := links.next |
54 links = apiLinks{} |
54 links = apiLinks{} |
55 if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil { |
55 if err := mc.apiCall("v1/"+endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil { |
56 return nil, err |
56 return nil, err |
57 } |
57 } |
58 statuses = append(statuses, statusSlice...) |
58 statuses = append(statuses, statusSlice...) |
59 statusSlice = statusSlice[:0] // Clear struct |
59 statusSlice = statusSlice[:0] // Clear struct |
60 } |
60 } |
81 } |
81 } |
82 |
82 |
83 endPoint += "/" + op |
83 endPoint += "/" + op |
84 } |
84 } |
85 |
85 |
86 return mc.apiCall(endPoint, rest.Get, nil, nil, nil, data) |
86 return mc.apiCall("v1/"+endPoint, rest.Get, nil, nil, nil, data) |
87 } |
87 } |
88 |
88 |
89 // updateStatusData updates the statuses |
89 // updateStatusData updates the statuses |
90 // The operation 'op' can be empty or "status" (to post a status), "delete" |
90 // The operation 'op' can be empty or "status" (to post a status), "delete" |
91 // (for deleting a status), "reblog"/"unreblog", "favourite"/"unfavourite", |
91 // (for deleting a status), "reblog"/"unreblog", "favourite"/"unfavourite", |
153 if opts.Visibility != "" { |
153 if opts.Visibility != "" { |
154 params["visibility"] = opts.Visibility |
154 params["visibility"] = opts.Visibility |
155 } |
155 } |
156 } |
156 } |
157 |
157 |
158 return mc.apiCall(endPoint, method, params, nil, nil, data) |
158 return mc.apiCall("v1/"+endPoint, method, params, nil, nil, data) |
159 } |
159 } |
160 |
160 |
161 // GetStatus returns a status |
161 // GetStatus returns a status |
162 // The returned status can be nil if there is an error or if the |
162 // The returned status can be nil if there is an error or if the |
163 // requested ID does not exist. |
163 // requested ID does not exist. |