Documentation
¶
Overview ¶
Package storekit implements Apple's In-App Purchase and StoreKit server APIs.
StoreKit API credentials are intentionally separate from App Store Connect API credentials. Retention Messaging signs a fresh JWT for every request.
Index ¶
- Constants
- 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
- func ValidateMessage(message Message) error
- func ValidateRealtimeURL(value string) error
- type APIError
- type Client
- func (c *Client) DeleteDefault(ctx context.Context, productID, locale string) error
- func (c *Client) DeleteImage(ctx context.Context, identifier string) error
- func (c *Client) DeleteMessage(ctx context.Context, identifier string) error
- func (c *Client) DeleteRealtimeURL(ctx context.Context) error
- func (c *Client) GetDefault(ctx context.Context, productID, locale string) (*DefaultMessageResponse, error)
- func (c *Client) GetPerformanceTestResult(ctx context.Context, requestID string) (*PerformanceTestResult, error)
- func (c *Client) GetRealtimeURL(ctx context.Context) (*RealtimeURLResponse, error)
- func (c *Client) ListImages(ctx context.Context) (*ImageListResponse, error)
- func (c *Client) ListMessages(ctx context.Context) (*MessageListResponse, error)
- func (c *Client) SetDefault(ctx context.Context, productID, locale, messageIdentifier string) (*DefaultMessageResponse, error)
- func (c *Client) SetRealtimeURL(ctx context.Context, realtimeURL string) (*RealtimeURLResponse, error)
- func (c *Client) StartPerformanceTest(ctx context.Context, originalTransactionID string) (*PerformanceTestStartResponse, error)
- func (c *Client) UploadImage(ctx context.Context, identifier string, size ImageSize, data []byte) error
- func (c *Client) UploadMessage(ctx context.Context, identifier string, message Message) error
- func (c *Client) Validate() error
- type ClientOption
- type Credentials
- type DefaultMessageResponse
- type Environment
- type HeaderPosition
- type ImageIdentifier
- type ImageListResponse
- type ImageSize
- type ImageState
- type Message
- type MessageBulletPoint
- type MessageIdentifier
- type MessageImage
- type MessageListResponse
- type MutationResult
- type PerformanceResponseTimes
- type PerformanceTestConfig
- type PerformanceTestResult
- type PerformanceTestStartResponse
- type RealtimeURLResponse
- type StoredCredential
Constants ¶
const ( ProductionBaseURL = "https://api.storekit.apple.com/inApps/v1/messaging" SandboxBaseURL = "https://api.storekit-sandbox.apple.com/inApps/v1/messaging" )
const ( StatePending = "PENDING" StateApproved = "APPROVED" StateRejected = "REJECTED" )
Variables ¶
This section is empty.
Functions ¶
func RemoveAllCredentials ¶
func RemoveAllCredentials() error
func RemoveCredentials ¶
func SetDefaultCredentials ¶
func ShouldBypassKeychain ¶
func ShouldBypassKeychain() bool
ShouldBypassKeychain reports whether StoreKit keychain access is disabled.
func StoreCredentials ¶
func StoreCredentials(name string, credentials Credentials) error
StoreCredentials stores a credential in the system keychain when available.
func StoreCredentialsConfig ¶
func StoreCredentialsConfig(name string, credentials Credentials) error
func StoreCredentialsConfigAt ¶
func StoreCredentialsConfigAt(name string, credentials Credentials, path string) error
func ValidateMessage ¶
ValidateMessage checks documented Retention Messaging limits before upload.
func ValidateRealtimeURL ¶
Types ¶
type APIError ¶
APIError describes an error returned by the Retention Messaging API.
func (*APIError) HTTPStatusCode ¶ added in v1.260713.0
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(credentials Credentials, environment Environment, opts ...ClientOption) (*Client, error)
func (*Client) DeleteDefault ¶
func (*Client) DeleteImage ¶
func (*Client) DeleteMessage ¶
func (*Client) GetDefault ¶
func (*Client) GetPerformanceTestResult ¶
func (*Client) GetRealtimeURL ¶
func (c *Client) GetRealtimeURL(ctx context.Context) (*RealtimeURLResponse, error)
func (*Client) ListImages ¶
func (c *Client) ListImages(ctx context.Context) (*ImageListResponse, error)
func (*Client) ListMessages ¶
func (c *Client) ListMessages(ctx context.Context) (*MessageListResponse, error)
func (*Client) SetDefault ¶
func (*Client) SetRealtimeURL ¶
func (*Client) StartPerformanceTest ¶
func (*Client) UploadImage ¶
func (*Client) UploadMessage ¶
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL overrides the complete Retention Messaging API base URL. It exists for tests and Apple-compatible proxies.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithNow ¶
func WithNow(now func() time.Time) ClientOption
type Credentials ¶
type Credentials struct {
KeyID string
IssuerID string
PrivateKeyPath string
PrivateKeyPEM string
BundleID string
Profile string
}
Credentials holds an In-App Purchase API key and its target app bundle ID.
func GetCredentialsWithSource ¶
func GetCredentialsWithSource(profile string) (Credentials, string, error)
type DefaultMessageResponse ¶
type DefaultMessageResponse struct {
MessageIdentifier string `json:"messageIdentifier"`
}
type Environment ¶
type Environment string
Environment selects the StoreKit server environment.
const ( Production Environment = "production" Sandbox Environment = "sandbox" )
func ParseEnvironment ¶
func ParseEnvironment(value string) (Environment, error)
ParseEnvironment validates a StoreKit environment.
type HeaderPosition ¶
type HeaderPosition string
HeaderPosition controls where the header appears in a retention message.
const ( HeaderAboveBody HeaderPosition = "ABOVE_BODY" HeaderAboveImage HeaderPosition = "ABOVE_IMAGE" )
type ImageIdentifier ¶
type ImageListResponse ¶
type ImageListResponse struct {
ImageIdentifiers []ImageIdentifier `json:"imageIdentifiers"`
}
type Message ¶
type Message struct {
Header string `json:"header"`
Body string `json:"body"`
Image *MessageImage `json:"image,omitempty"`
BulletPoints []MessageBulletPoint `json:"bulletPoints,omitempty"`
HeaderPosition HeaderPosition `json:"headerPosition,omitempty"`
}
type MessageBulletPoint ¶
type MessageIdentifier ¶
type MessageImage ¶
type MessageListResponse ¶
type MessageListResponse struct {
MessageIdentifiers []MessageIdentifier `json:"messageIdentifiers"`
}
type MutationResult ¶
type MutationResult struct {
Resource string `json:"resource"`
Identifier string `json:"identifier,omitempty"`
Action string `json:"action"`
Environment Environment `json:"environment"`
Success bool `json:"success"`
}
MutationResult is the stable CLI response for an empty successful mutation.
type PerformanceTestConfig ¶
type PerformanceTestResult ¶
type PerformanceTestResult struct {
Config PerformanceTestConfig `json:"config"`
Failures map[string]int32 `json:"failures,omitempty"`
NumPending int `json:"numPending,omitempty"`
RequestID string `json:"requestId,omitempty"`
ResponseTimes PerformanceResponseTimes `json:"responseTimes,omitempty"`
Result string `json:"result"`
SuccessRate int32 `json:"successRate,omitempty"`
Target string `json:"target,omitempty"`
}
type PerformanceTestStartResponse ¶
type PerformanceTestStartResponse struct {
Config PerformanceTestConfig `json:"config"`
RequestID string `json:"requestId"`
}
type RealtimeURLResponse ¶
type RealtimeURLResponse struct {
RealtimeURL string `json:"realtimeURL"`
}
type StoredCredential ¶
type StoredCredential struct {
Credentials `json:"-"`
Name string `json:"name"`
IsDefault bool `json:"default"`
Source string `json:"source"`
SourcePath string `json:"source_path,omitempty"`
}
func ListCredentials ¶
func ListCredentials() ([]StoredCredential, error)