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)
| 454 | // |
| 455 | // Returns ENOTFOUND if the membership does not exist. |
| 456 | func (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. |
| 482 | func (s *DialService) AverageDialValueReport(ctx context.Context, start, end time.Time, interval time.Duration) (*wtf.DialValueReport, error) { |
nothing calls this directly
no test coverage detected