forked from gungoren/apple-search-ads-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apps.go
64 lines (56 loc) · 2.41 KB
/
apps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
Copyright (C) 2021 Mehmet Gungoren.
This file is part of apple-search-ads-go, a package for working with Apple's
Search Ads API.
apple-search-ads-go is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
apple-search-ads-go is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with apple-search-ads-go. If not, see <http://www.gnu.org/licenses/>.
*/
package asa
import (
"context"
)
// AppService handles communication with build-related methods of the Apple Search Ads API
//
// https://developer.apple.com/documentation/apple_search_ads/search_apps_and_geolocations
type AppService service
// SearchAppsQuery defines query parameter for SearchApps endpoint.
type SearchAppsQuery struct {
Limit int32 `url:"limit,omitempty"`
Offset int32 `url:"offset,omitempty"`
Query string `url:"query,omitempty"`
ReturnOwnedApps bool `url:"returnOwnedApps,omitempty"`
}
// AppInfoListResponse is the response details of app search requests
//
// https://developer.apple.com/documentation/apple_search_ads/appinfolistresponse
type AppInfoListResponse struct {
AppInfos []*AppInfo `json:"data,omitempty"`
Error *ErrorResponseBody `json:"error,omitempty"`
Pagination *PageDetail `json:"pagination,omitempty"`
}
// AppInfo is the response to an app search request
//
// https://developer.apple.com/documentation/apple_search_ads/appinfo
type AppInfo struct {
AdamID int64 `json:"adamId,omitempty"`
AppName string `json:"appName,omitempty"`
CountryOrRegionCodes []string `json:"countryOrRegionCodes,omitempty"`
DeveloperName string `json:"developerName"`
}
// SearchApps Searches for iOS apps to promote in a campaign
//
// https://developer.apple.com/documentation/apple_search_ads/search_for_ios_apps
func (s *AppService) SearchApps(ctx context.Context, params *SearchAppsQuery) (*AppInfoListResponse, *Response, error) {
url := "search/apps"
res := new(AppInfoListResponse)
resp, err := s.client.get(ctx, url, ¶ms, res)
return res, resp, err
}