// AddRecipient method adds recipient to an alert at OpsGenie. func (cli *OpsGenieAlertClient) AddRecipient(req alerts.AddRecipientAlertRequest) (*alerts.AddRecipientAlertResponse, error) { req.APIKey = cli.apiKey resp, err := cli.sendRequest(cli.buildPostRequest(addRecipientAlertURL, req)) if resp == nil { return nil, err } defer resp.Body.Close() var addRecipientAlertResp alerts.AddRecipientAlertResponse if err = resp.Body.FromJsonTo(&addRecipientAlertResp); err != nil { message := "Server response can not be parsed, " + err.Error() logging.Logger().Warn(message) return nil, errors.New(message) } return &addRecipientAlertResp, nil }