MCPcopy Index your code
hub / github.com/dnote/dnote / GetSyncFragment

Function GetSyncFragment

pkg/cli/client/client.go:278–300  ·  view source on GitHub ↗

GetSyncFragment gets a sync fragment response from the server

(ctx context.DnoteCtx, afterUSN int)

Source from the content-addressed store, hash-verified

276
277// GetSyncFragment gets a sync fragment response from the server
278func GetSyncFragment(ctx context.DnoteCtx, afterUSN int) (GetSyncFragmentResp, error) {
279 v := url.Values{}
280 v.Set("after_usn", strconv.Itoa(afterUSN))
281 queryStr := v.Encode()
282
283 path := fmt.Sprintf("/v3/sync/fragment?%s", queryStr)
284 res, err := doAuthorizedReq(ctx, "GET", path, "", nil)
285 if err != nil {
286 return GetSyncFragmentResp{}, errors.Wrap(err, "making the request")
287 }
288
289 body, err := io.ReadAll(res.Body)
290 if err != nil {
291 return GetSyncFragmentResp{}, errors.Wrap(err, "reading the response body")
292 }
293
294 var resp GetSyncFragmentResp
295 if err = json.Unmarshal(body, &resp); err != nil {
296 return resp, errors.Wrap(err, "unmarshalling the payload")
297 }
298
299 return resp, nil
300}
301
302// RespBook is the book in the response from the create book api
303type RespBook struct {

Callers 1

getSyncFragmentsFunction · 0.92

Calls 1

doAuthorizedReqFunction · 0.85

Tested by

no test coverage detected