From 3bf8a08b5982df7b5adef3fe6af51758ffe5533c Mon Sep 17 00:00:00 2001 From: Mehmet Gungoren Date: Fri, 8 Oct 2021 11:41:44 +0300 Subject: [PATCH] implement update creative set api --- asa/creative_sets.go | 18 ++++++++++++++++++ asa/creative_sets_test.go | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/asa/creative_sets.go b/asa/creative_sets.go index f19e8e6..d7a4085 100644 --- a/asa/creative_sets.go +++ b/asa/creative_sets.go @@ -374,3 +374,21 @@ func (s *CreativeSetsService) AssignCreativeSetsToAdGroup(ctx context.Context, c return res, resp, err } + +// CreativeSetUpdate is the details of an update to a Creative Set request +// +// https://developer.apple.com/documentation/apple_search_ads/creativesetupdate +type CreativeSetUpdate struct { + Name string `json:"name"` +} + +// UpdateCreativeSets Updates a Creative Set name using an identifier +// +// https://developer.apple.com/documentation/apple_search_ads/update_creative_sets +func (s *CreativeSetsService) UpdateCreativeSets(ctx context.Context, creativeSetID int64, request *CreativeSetUpdate) (*CreativeSetResponse, *Response, error) { + url := fmt.Sprintf("creativesets/%d", creativeSetID) + res := new(CreativeSetResponse) + resp, err := s.client.put(ctx, url, request, res) + + return res, resp, err +} diff --git a/asa/creative_sets_test.go b/asa/creative_sets_test.go index cf77504..9efce2d 100644 --- a/asa/creative_sets_test.go +++ b/asa/creative_sets_test.go @@ -76,3 +76,11 @@ func TestAssignCreativeSetsToAdGroup(t *testing.T) { return client.CreativeSets.AssignCreativeSetsToAdGroup(ctx, 1, 99, &AssignAdGroupCreativeSetRequest{}) }) } + +func TestUpdateCreativeSets(t *testing.T) { + t.Parallel() + + testEndpointWithResponse(t, "{}", &CreativeSetResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) { + return client.CreativeSets.UpdateCreativeSets(ctx, 1001, &CreativeSetUpdate{}) + }) +}