MCPcopy
hub / github.com/benbjohnson/wtf / FindDials

Method FindDials

http/dial.go:363–391  ·  view source on GitHub ↗

FindDials retrieves a list of dials based on a filter. Only returns dials that the user owns or is a member of. Also returns a count of total matching dials which may different from the number of returned dials if the "Limit" field is set.

(ctx context.Context, filter wtf.DialFilter)

Source from the content-addressed store, hash-verified

361// dials which may different from the number of returned dials if the
362// "Limit" field is set.
363func (s *DialService) FindDials(ctx context.Context, filter wtf.DialFilter) ([]*wtf.Dial, int, error) {
364 // Marshal filter into JSON format.
365 body, err := json.Marshal(filter)
366 if err != nil {
367 return nil, 0, err
368 }
369
370 // Create request with API key.
371 req, err := s.Client.newRequest(ctx, "GET", "/dials", bytes.NewReader(body))
372 if err != nil {
373 return nil, 0, err
374 }
375
376 // Issue request. Any non-200 status code is considered an error.
377 resp, err := http.DefaultClient.Do(req)
378 if err != nil {
379 return nil, 0, err
380 } else if resp.StatusCode != http.StatusOK {
381 return nil, 0, parseResponseError(resp)
382 }
383 defer resp.Body.Close()
384
385 // Unmarshal result set of dials & total dial count.
386 var jsonResponse findDialsResponse
387 if err := json.NewDecoder(resp.Body).Decode(&jsonResponse); err != nil {
388 return nil, 0, err
389 }
390 return jsonResponse.Dials, jsonResponse.N, nil
391}
392
393// CreateDial creates a new dial and assigns the current user as the owner.
394// The owner will automatically be added as a member of the new dial.

Callers 1

TestDialIndexFunction · 0.95

Implementers 3

DialServicehttp/dial.go
DialServicemock/dial.go
DialServicesqlite/dial.go

Calls 3

parseResponseErrorFunction · 0.85
newRequestMethod · 0.80
CloseMethod · 0.65

Tested by 1

TestDialIndexFunction · 0.76