Documentation
¶
Index ¶
- Constants
- func GenerateClientSecret(keyID, teamID, clientID string, privateKey *ecdsa.PrivateKey, now time.Time, ...) (string, error)
- func MaxPageLimit(spec EndpointSpec) int
- func RemoveAllCredentials() error
- func RemoveCredentials(name string) error
- func SetDefaultCredentials(name string) error
- func ShouldBypassKeychain() bool
- func StoreCredentials(name string, credentials Credentials) error
- func StoreCredentialsConfig(name string, credentials Credentials) error
- func StoreCredentialsConfigAt(name string, credentials Credentials, path string) error
- type APIError
- type BodyKind
- type Client
- func (c *Client) AccessToken(ctx context.Context) (string, error)
- func (c *Client) Do(ctx context.Context, spec EndpointSpec, pathParams map[string]string, ...) (RawResponse, error)
- func (c *Client) PaginateAll(ctx context.Context, spec EndpointSpec, pathParams map[string]string, ...) (RawResponse, error)
- func (c *Client) Request(ctx context.Context, method, path string, query url.Values, ...) (RawResponse, error)
- type ClientOption
- type Credentials
- type EndpointSpec
- type PageDetail
- type ParamSpec
- type ParamType
- type RawResponse
- type StoredCredential
Constants ¶
const BaseURL = "https://api.searchads.apple.com/api/"
Variables ¶
This section is empty.
Functions ¶
func GenerateClientSecret ¶
func GenerateClientSecret(keyID, teamID, clientID string, privateKey *ecdsa.PrivateKey, now time.Time, lifetime time.Duration) (string, error)
GenerateClientSecret creates an Apple Ads OAuth client secret JWT.
func MaxPageLimit ¶
func MaxPageLimit(spec EndpointSpec) int
MaxPageLimit returns the endpoint-specific maximum page size.
func RemoveAllCredentials ¶
func RemoveAllCredentials() error
RemoveAllCredentials removes all Apple Ads credentials.
func RemoveCredentials ¶
RemoveCredentials removes one Apple Ads credential.
func SetDefaultCredentials ¶
SetDefaultCredentials switches the default Apple Ads profile.
func ShouldBypassKeychain ¶
func ShouldBypassKeychain() bool
ShouldBypassKeychain reports whether Apple Ads keychain usage is disabled.
func StoreCredentials ¶
func StoreCredentials(name string, credentials Credentials) error
StoreCredentials stores Apple Ads credentials in keychain when available.
func StoreCredentialsConfig ¶
func StoreCredentialsConfig(name string, credentials Credentials) error
StoreCredentialsConfig stores Apple Ads credentials in the active config file.
func StoreCredentialsConfigAt ¶
func StoreCredentialsConfigAt(name string, credentials Credentials, path string) error
StoreCredentialsConfigAt stores Apple Ads credentials in a specific config file.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Field string
Message string
MessageCode string
Detail string
}
APIError describes an Apple Ads API error response.
func (*APIError) HTTPStatusCode ¶ added in v1.260713.0
type BodyKind ¶
type BodyKind string
BodyKind describes the JSON body shape accepted by an Apple Ads endpoint.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an Apple Ads Campaign Management API client.
func NewClient ¶
func NewClient(credentials Credentials, opts ...ClientOption) (*Client, error)
NewClient constructs an Apple Ads API client.
func (*Client) AccessToken ¶
AccessToken returns a bearer token for diagnostics and auth token commands.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, spec EndpointSpec, pathParams map[string]string, query url.Values, body json.RawMessage) (RawResponse, error)
Do executes a documented Apple Ads endpoint.
func (*Client) PaginateAll ¶
func (c *Client) PaginateAll(ctx context.Context, spec EndpointSpec, pathParams map[string]string, query url.Values, startOffset, pageSize int, body json.RawMessage) (RawResponse, error)
PaginateAll fetches all pages for an offset-paginated endpoint.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL configures the Apple Ads API base URL.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient configures the HTTP client.
func WithNow ¶
func WithNow(now func() time.Time) ClientOption
WithNow configures the clock used by token caching.
func WithTokenURL ¶
func WithTokenURL(tokenURL string) ClientOption
WithTokenURL configures the OAuth token URL.
type Credentials ¶
type Credentials struct {
ClientID string
TeamID string
KeyID string
PrivateKeyPath string
PrivateKeyPEM string
AccessToken string
OrgID string
Profile string
}
Credentials contains resolved Apple Ads authentication inputs.
func GetCredentialsWithSource ¶
func GetCredentialsWithSource(profile string) (Credentials, string, error)
GetCredentialsWithSource resolves Apple Ads credentials by profile.
type EndpointSpec ¶
type EndpointSpec struct {
Name string
Method string
Path string
CommandPath []string
BodyKind BodyKind
BodyType string
ResponseType string
RequiresOrg bool
RequiresConfirm bool
PathParams []ParamSpec
QueryParams []ParamSpec
SupportsPaginate bool
DefaultListAlias bool
}
EndpointSpec is the single source of truth for the Apple Ads command and client surface.
func EndpointByCommandPath ¶
func EndpointByCommandPath(path ...string) (EndpointSpec, bool)
EndpointByCommandPath returns a spec by command path.
func EndpointSpecs ¶
func EndpointSpecs() []EndpointSpec
EndpointSpecs returns the current Apple Ads Campaign Management API v5 surface.
type PageDetail ¶
type PageDetail struct {
ItemsPerPage int `json:"itemsPerPage"`
StartIndex int `json:"startIndex"`
TotalResults int `json:"totalResults"`
}
PageDetail is the Apple Ads offset pagination envelope.
type ParamSpec ¶
type ParamSpec struct {
Name string
Flag string
Type ParamType
Required bool
Max int
Allowed []string
}
ParamSpec describes a documented Apple Ads path or query parameter.
type ParamType ¶
type ParamType string
ParamType describes the primitive type of a path or query parameter.
type RawResponse ¶
type RawResponse json.RawMessage
RawResponse preserves the Apple Ads response envelope.
func (RawResponse) MarshalJSON ¶
func (r RawResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
type StoredCredential ¶
type StoredCredential struct {
Credentials
Name string
IsDefault bool
Source string
SourcePath string
}
StoredCredential is an Apple Ads credential with storage metadata.
func ListCredentials ¶
func ListCredentials() ([]StoredCredential, error)
ListCredentials lists Apple Ads credentials.