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

Method SetDialMembershipValue

http/dial.go:456–479  ·  view source on GitHub ↗

SetDialMembershipValue sets the value of the user's membership in a dial. This works the same as calling UpdateDialMembership() although it doesn't require that the user know their membership ID. Only the dial ID. Returns ENOTFOUND if the membership does not exist.

(ctx context.Context, dialID, value int)

Source from the content-addressed store, hash-verified

454//
455// Returns ENOTFOUND if the membership does not exist.
456func (s *DialService) SetDialMembershipValue(ctx context.Context, dialID, value int) error {
457 // Marshal value into JSON format.
458 body, err := json.Marshal(jsonSetDialMembershipValueRequest{Value: value})
459 if err != nil {
460 return err
461 }
462
463 // Create a request with API key.
464 req, err := s.Client.newRequest(ctx, "PUT", fmt.Sprintf("/dials/%d/membership", dialID), bytes.NewReader(body))
465 if err != nil {
466 return err
467 }
468
469 // Issue request. Any non-200 response is considered an error.
470 resp, err := http.DefaultClient.Do(req)
471 if err != nil {
472 return err
473 } else if resp.StatusCode != http.StatusOK {
474 return parseResponseError(resp)
475 }
476 defer resp.Body.Close()
477
478 return nil
479}
480
481// AverageDialValueReport is not implemented by the HTTP service.
482func (s *DialService) AverageDialValueReport(ctx context.Context, start, end time.Time, interval time.Duration) (*wtf.DialValueReport, error) {

Callers

nothing calls this directly

Implementers 3

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

Calls 3

parseResponseErrorFunction · 0.85
newRequestMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected