Skip to content

Commit

Permalink
implement assign creative set to an adgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
gungoren committed Oct 8, 2021
1 parent 683ad93 commit f1f75fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions asa/creative_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,21 @@ func (s *CreativeSetsService) FindCreativeSets(ctx context.Context, params *Find

return res, resp, err
}

// AssignAdGroupCreativeSetRequest is the request to assign a Creative Set to an ad group
//
// https://developer.apple.com/documentation/apple_search_ads/assignadgroupcreativesetrequest
type AssignAdGroupCreativeSetRequest struct {
CreativeSetID int64 `json:"creativeSetID"`
}

// AssignCreativeSetsToAdGroup Creates a Creative Set assignment to an ad group
//
// https://developer.apple.com/documentation/apple_search_ads/assign_creative_sets_to_an_ad_group
func (s *CreativeSetsService) AssignCreativeSetsToAdGroup(ctx context.Context, campaignID int64, adgroupID int64, request *AssignAdGroupCreativeSetRequest) (*AdGroupCreativeSetResponse, *Response, error) {
url := fmt.Sprintf("campaigns/%d/adgroups/%d/adgroupcreativesets", campaignID, adgroupID)
res := new(AdGroupCreativeSetResponse)
resp, err := s.client.post(ctx, url, request, res)

return res, resp, err
}
8 changes: 8 additions & 0 deletions asa/creative_sets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ func TestFindCreativeSets(t *testing.T) {
return client.CreativeSets.FindCreativeSets(ctx, &FindCreativeSetRequest{})
})
}

func TestAssignCreativeSetsToAdGroup(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AdGroupCreativeSetResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.CreativeSets.AssignCreativeSetsToAdGroup(ctx, 1, 99, &AssignAdGroupCreativeSetRequest{})
})
}

0 comments on commit f1f75fd

Please sign in to comment.