Skip to content

Commit

Permalink
Added delete goal req
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed May 22, 2021
1 parent 2665925 commit 926546c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
11 changes: 6 additions & 5 deletions definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type APIEnvironment string
const (

// defaultUserAgent is the default user agent for all requests
defaultUserAgent string = "go-tonicpow: v0.4.73"
defaultUserAgent string = "go-tonicpow: v0.4.74"

// Field key names for various model requests
fieldAdvertiserProfileID = "advertiser_profile_id"
Expand Down Expand Up @@ -358,14 +358,15 @@ type CampaignStatistics struct {
//
// For more information: https://docs.tonicpow.com/#75c837d5-3336-4d87-a686-d80c6f8938b9
type Conversion struct {
Amount float64 `json:"amount"`
Amount float64 `json:"amount,omitempty"`
CampaignID uint64 `json:"campaign_id"`
CustomDimensions string `json:"custom_dimensions"`
GoalID uint64 `json:"goal_id"`
GoalName string `json:"goal_name"`
ID uint64 `json:"ID,omitempty"`
PayoutAfter string `json:"payout_after"`
GoalName string `json:"goal_name,omitempty"`
ID uint64 `json:"id,omitempty"`
PayoutAfter string `json:"payout_after,omitempty"`
Status string `json:"status"`
StatusData string `json:"status_data"`
TxID string `json:"tx_id"`
UserID uint64 `json:"user_id"`
}
Expand Down
26 changes: 26 additions & 0 deletions goals.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,29 @@ func (c *Client) UpdateGoal(goal *Goal) (updatedGoal *Goal, err error) {
}
return
}

// DeleteGoal will delete an existing goal
//
// For more information: https://docs.tonicpow.com/
func (c *Client) DeleteGoal(goal *Goal) (deleted bool, err error) {

// Basic requirements
if goal.ID == 0 {
err = c.createError(fmt.Sprintf("missing required attribute: %s", fieldID), http.StatusBadRequest)
return
}

// Fire the Request
var response string
if response, err = c.Request(modelGoal, http.MethodDelete, goal); err != nil {
return
}

// Only a 200 is treated as a success
if err = c.Error(http.StatusOK, response); err != nil {
return
}

deleted = true
return
}

0 comments on commit 926546c

Please sign in to comment.