Documentation ¶
Index ¶
- Constants
- func WithAccessToken(ctx context.Context, accessToken string) func(*Client) error
- func WithEnvVars(c *Client) error
- func WithHTTPClient(client *http.Client) func(*Client) error
- func WithHTTPHeaders(headers map[string]string) func(*Client) error
- func WithHost(host string) func(*Client) error
- func WithVersion(version string) func(*Client) error
- type Ad
- type AdAccount
- type AdAccountResponse
- type AdAccountService
- type AdResponse
- type AdService
- func (ad *AdService) Delete(ctx context.Context, adId string) error
- func (ad *AdService) Get(ctx context.Context, adId string) (*Ad, error)
- func (ad *AdService) ListByAdAccount(ctx context.Context, adAccountId string) ([]*Ad, error)
- func (ad *AdService) ListByAdSquad(ctx context.Context, adSquadId string) ([]*Ad, error)
- type AdSquad
- type AdSquadResponse
- type AdSquadService
- func (adsqd *AdSquadService) Delete(ctx context.Context, adSquadId string) error
- func (adsqd *AdSquadService) Get(ctx context.Context, adSquadId string) (*AdSquad, error)
- func (adsqd *AdSquadService) ListByAdAccount(ctx context.Context, adAccountId string) ([]*AdSquad, error)
- func (adsqd *AdSquadService) ListByCampaign(ctx context.Context, campaignId string) ([]*AdSquad, error)
- type Campaign
- type CampaignMeasurementSpec
- type CampaignResponse
- type CampaignService
- type Client
- type ErrBadRequest
- type ErrForbidden
- type ErrGone
- type ErrInternalServerError
- type ErrMethodNotAllowed
- type ErrNotAcceptable
- type ErrNotFound
- type ErrServiceUnavailable
- type ErrTooManyRequests
- type ErrUnauthorized
- type FundingSource
- type FundingSourceResponse
- type FundingSourceService
- type GetAdAccountsResponse
- type GetAdSquadsResponse
- type GetAdsResponse
- type GetCampaignsResponse
- type GetFundingSourcesResponse
- type GetMeasurementsResponse
- type GetOrganizationsResponse
- type MeasurementService
- type MeasurementStats
- type Organization
- type OrganizationResponse
- type OrganizationService
- type TotalStat
- type TotalStats
- type User
- type UserService
Constants ¶
const ( // DefaultSnapchatHost is the default host address to use for calls to the snapchat ads api DefaultSnapchatHost = `https://adsapi.snapchat.com` // DefaultSnapchatVersion is the default version to use for calls to the snapchat ads api DefaultSnapchatVersion = `v1` )
Variables ¶
This section is empty.
Functions ¶
func WithAccessToken ¶
WithAccessToken allows the user to provide an access token to use for authorization
func WithEnvVars ¶
WithEnvVars allows retrieves host/version from environment variables
func WithHTTPClient ¶
WithHTTPClient allows user to provide a custom client
func WithHTTPHeaders ¶
WithHTTPHeaders allows the user to specify custom headers to be used with all requests
func WithVersion ¶
WithVersion allows the user to use a custom snapchat ads api version
Types ¶
type Ad ¶
type Ad struct { // Id is the id representing a single ad Id string `json:"id"` // AdSquadId is the id of the ad squad that the ad is under AdSquadId string `json:"ad_squad_id"` // CreativeId is the id of the creative associated with the ad CreativeId string `json:"creative_id"` // Name is the name of the ad Name string `json:"name"` // Status is the status of the ad Status string `json:"status"` // ReviewStatus is the status of the ad's review process ReviewStatus string `json:"review_status"` // ReviewStatusReason will contain a reason for rejection if an ad was rejected ReviewStatusReason string `json:"review_status_reason"` // Type is the type of the ad Type string `json:"type"` // CreatedAt is the time when the campaign was created CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the campaign was last updated UpdatedAt time.Time `json:"updated_at"` }
Ad represents an ad in the snapchat ads api
type AdAccount ¶
type AdAccount struct { // Id is the unique id associated with the ad account Id string `json:"id"` // Name is the name associated with the ad account Name string `json:"name"` // OrganizationId is the id of the organization the user is associated with OrganizationId string `json:"organization_id"` // Timezone is the timezone that is associated with the account Timezone string `json:"timezone"` // Type is the type of ad account Type string `json:"type"` // LifetimeSpendCapMicro is the lifetime spend limit for the account LifetimeSpendCapMicro int64 `json:"lifetime_spend_cap_micro"` // AdvertiserOrganizationId is the organization id of the advertiser selected AdvertiserOrganizationId string `json:"advertiser_organization_id"` // Advertiser is the name of the advertiser associated with the account Advertiser string `json:"advertiser"` // Currency is the type of currency associated with the ad account Currency string `json:"currency"` // FundingSourceIds is a list of funding source ids associated with the ad account FundingSourceIds []string `json:"funding_source_ids"` }
AdAccount represents an ad account in the snapchat ads api
type AdAccountResponse ¶
type AdAccountResponse struct { // SubRequestStatus is the status of this specific ad account request SubRequestStatus string `json:"sub_request_status"` // AdAccount is the object representing an ad account AdAccount AdAccount `json:"adaccount"` }
AdAccountResponse is the individual organization object in the response for calls to get ad accounts
type AdAccountService ¶
type AdAccountService service
AdAccountService provides functions for interacting with snapchat ad accounts
type AdResponse ¶
AdResponse is the object for a single ad response
type AdService ¶
type AdService service
AdService provides functions for interacting with snapchat ads
func (*AdService) ListByAdAccount ¶
ListByAdAccount will return all of the ads associated with the given ad account id
type AdSquad ¶
type AdSquad struct { // Id is the id representing a single ad squad Id string `json:"id"` // CampaignId is the id of the campaign this ad squad is associated with CampaignId string `json:"campaign_id"` // BidMicro the max bid (micro-currency) BidMicro int64 `json:"bid_micro"` // BillingEvent is the billing event associated with the ad squad BillingEvent string `json:"billing_event"` // DailyBudgetMicro is the daily spend budget (micro-currency) DailyBudgetMicro int64 `json:"daily_budget_micro"` // EndTime is the ending time of the ad squad EndTime time.Time `json:"end_time"` // StartTime is the starting time of the ad squad StartTime time.Time `json:"start_time"` // Name is the name of the ad squad Name string `json:"name"` // OptimizationGoal is the optimization goal of the ad squad OptimizationGoal string `json:"optimization_goal"` // Placement is the placement for the ad squad Placement string `json:"placement"` // Status is the status of the ad squad Status string `json:"status"` // Targeting is the targeting spec of the ad squad //Targeting string `json:"targeting"` // might not be a string // IncludedContentType is a list of content types that will be included in this ad squad IncludedContentType []string `json:"included_content_types"` // ExcludedContentType is a list of content types that will be excluded in this ad squad ExcludedContentType []string `json:"excluded_content_types"` // CapAndExclusionConfig is the frequency cap and exclusion spec //CapAndExclusionConfig string `json:"cap_and_exclusion_config"` // might not be a string // LifetimeBudgetMicro is the lifetime spend budget of the ad squad (micro-currency) LifetimeBudgetMicro int64 `json:"lifetime_budget_micro"` // AdSchedulingConfig is the schedule for running ads on this adsquad //AdSchedulingConfig string `json:"ad_scheduling_config"` // might not be a string // Type is the type of ad squad Type string `json:"type"` }
AdSquad represents an ad squad in the snapchat ads api
type AdSquadResponse ¶
type AdSquadResponse struct { SubRequestStatus string `json:"sub_request_status"` AdSquad AdSquad `json:"adsquad"` }
AdSquadResponse is the object for a single ad squad response
type AdSquadService ¶
type AdSquadService service
AdSquadService provides functions for interacting with snapchat ad squads
func (*AdSquadService) Delete ¶
func (adsqd *AdSquadService) Delete(ctx context.Context, adSquadId string) error
Delete deletes a specific ad squad
func (*AdSquadService) ListByAdAccount ¶
func (adsqd *AdSquadService) ListByAdAccount(ctx context.Context, adAccountId string) ([]*AdSquad, error)
ListByAdAccount retrieves all ad squads associated a specified ad account id
func (*AdSquadService) ListByCampaign ¶
func (adsqd *AdSquadService) ListByCampaign(ctx context.Context, campaignId string) ([]*AdSquad, error)
ListByCampaign retrieves all ad squads associated a specified campaign id
type Campaign ¶
type Campaign struct { // Id is the id representing a single campaign Id string `json:"id"` // AdAccountId is the Ad Account ID that this campaign is under AdAccountId string `json:"ad_account_id"` // Name is the name of the campaign Name string `json:"name"` // Status is the status of the campaign (ACTIVE, PAUSED) Status string `json:"status"` // MeasurementSpec contains the apps to be tracked for this campaign MeasurementSpec CampaignMeasurementSpec `json:"measurement_spec"` // EndTime is the time when the campaign will end EndTime time.Time `json:"end_time"` // StartTime is the time when the campaign will start StartTime time.Time `json:"start_time"` // CreatedAt is the time when the campaign was created CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the campaign was last updated UpdatedAt time.Time `json:"updated_at"` // DailyBudgetMicro is the daily spend cap for the campaign(micro-currency) DailyBudgetMicro int64 `json:"daily_budget_micro"` // LifetimeSpendCapMicro is the lifetime spend cap for the campaign (microcurrency) LifetimeSpendCapMicro int64 `json:"lifetime_spend_cap_micro"` // contains filtered or unexported fields }
Campaign has a business objective and organizes Ad Squads
type CampaignMeasurementSpec ¶
type CampaignMeasurementSpec struct { // IosAppId is the ios app id of the app to use for measurement tracking IosAppId string `json:"ios_app_id"` // AndroidAppUrl is the android app url of the app to use for measurement tracking AndroidAppUrl string `json:"android_app_url"` }
CampaignMeasurementSpec contains the apps to be tracked for this campaign
type CampaignResponse ¶
type CampaignResponse struct { SubRequestStatus string `json:"sub_request_status"` Campaign Campaign `json:"campaign"` }
CampaignResponse is the object for a single campaign response
type CampaignService ¶
type CampaignService service
CampaignService has methods for interacting with campaigns in snapchat
func (*CampaignService) Delete ¶
func (cmp *CampaignService) Delete(ctx context.Context, campaignId string) error
Delete deletes a specific campaign
type Client ¶
type Client struct { // Users is the service used to get the authenticated user Users *UserService // Organizations is the service used to interact with organizations Organizations *OrganizationService // AdAccounts is the service used to interact with ad accounts AdAccounts *AdAccountService // Campaigns is the service used to interact with campaigns Campaigns *CampaignService // FundingSources is the service used to interact with campaigns FundingSources *FundingSourceService // AdSquads is the service used to interact with ad squads AdSquads *AdSquadService // Ads is the service used to interact with ads Ads *AdService // Measurements is the service used to interact with ads Measurements *MeasurementService // contains filtered or unexported fields }
Client is used to perform all operations with the snapchat ads api
func (*Client) GetCustomHTTPHeaders ¶
GetCustomHTTPHeaders returns custom http headers stored by the client
type ErrBadRequest ¶
type ErrBadRequest struct{}
ErrBadRequest is the error returned when the api returns a 400 status code
func (*ErrBadRequest) Error ¶
func (err *ErrBadRequest) Error() string
type ErrForbidden ¶
type ErrForbidden struct{}
ErrForbidden is the error returned when the api returns a 403 status code
func (*ErrForbidden) Error ¶
func (err *ErrForbidden) Error() string
type ErrGone ¶
type ErrGone struct{}
ErrGone is the error returned when the api returns a 410 status code
type ErrInternalServerError ¶
type ErrInternalServerError struct{}
ErrInternalServerError is the error returned when the api returns a 500 status code
func (*ErrInternalServerError) Error ¶
func (err *ErrInternalServerError) Error() string
type ErrMethodNotAllowed ¶
type ErrMethodNotAllowed struct{}
ErrMethodNotAllowed is the error returned when the api returns a 405 status code
func (*ErrMethodNotAllowed) Error ¶
func (err *ErrMethodNotAllowed) Error() string
type ErrNotAcceptable ¶
type ErrNotAcceptable struct{}
ErrNotAcceptable is the error returned when the api returns a 406 status code
func (*ErrNotAcceptable) Error ¶
func (err *ErrNotAcceptable) Error() string
type ErrNotFound ¶
type ErrNotFound struct{}
ErrNotFound is the error returned when the api returns a 404 status code
func (*ErrNotFound) Error ¶
func (err *ErrNotFound) Error() string
type ErrServiceUnavailable ¶
type ErrServiceUnavailable struct{}
ErrServiceUnavailable is the error returned when the api returns a 503 status code
func (*ErrServiceUnavailable) Error ¶
func (err *ErrServiceUnavailable) Error() string
type ErrTooManyRequests ¶
type ErrTooManyRequests struct{}
ErrTooManyRequests is the error returned when the api returns a 429 status code
func (*ErrTooManyRequests) Error ¶
func (err *ErrTooManyRequests) Error() string
type ErrUnauthorized ¶
type ErrUnauthorized struct{}
ErrUnauthorized is the error returned when the api returns a 401 status code
func (*ErrUnauthorized) Error ¶
func (err *ErrUnauthorized) Error() string
type FundingSource ¶
type FundingSource struct { // Id is the unique id associated with the funding source Id string `json:"id"` // Type is the type of funding source Type string `json:"type"` // Status is the status of the funding source Status string `json:"status"` // BudgetSpentMicro is the total budget spent (micro-currency) BudgetSpentMicro int64 `json:"budget_spent_micro"` // Currency is the type of currency associated with the funding source Currency string `json:"currency"` // TotalBudgetMicro is the total budget (micro-currency) TotalBudgetMicro int64 `json:"total_budget_micro"` // AvailableCreditMicro is the amount of credit available (micro-currency) AvailableCreditMicro int64 `json:"available_credit_micro"` // CardType is the type of credit card associated with this funding source CardType string `json:"card_type"` // Name is the name of the funding source Name string `json:"name"` // Last4 is the last four digits of the credit card associated with this funding source Last4 string `json:"last_4"` // ExpirationYear is the expiration year of the credit card associated with this funding source ExpirationYear string `json:"expiration_year"` // ExpirationMonth is the expiration year of the credit card associated with this funding source ExpirationMonth string `json:"expiration_month"` // DailySpendLimitMicro is the daily spend limit for the credit card associated with this funding source (micro-currency) DailySpendLimitMicro int64 `json:"daily_spend_limit_micro"` // DailySpendLimitMicro is the currency of the daily spend limit for the credit card associated with this funding source DailySpendLimitCurrency string `json:"daily_spend_limit_currency"` // ValueMicro is the value of the coupon (micro-currency) ValueMicro int64 `json:"value_micro"` // StartDate is the start date of the coupon StartDate time.Time `json:"start_date"` // EndDate is the end date of the coupon EndDate time.Time `json:"end_date"` // Email is the email associated with the funding source Email string `json:"email"` // CreatedAt is the time when the funding source was created CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the funding source was last updated UpdatedAt time.Time `json:"updated_at"` }
FundingSource represents a funding source in the snapchat ads api
type FundingSourceResponse ¶
type FundingSourceResponse struct { SubRequestStatus string `json:"sub_request_status"` FundingSource FundingSource `json:"fundingsource"` }
FundingSourceResponse is the object for a single funding source response
type FundingSourceService ¶
type FundingSourceService service
FundingSourceService provides functions for interacting with snapchat funding sources
func (*FundingSourceService) Get ¶
func (fnd *FundingSourceService) Get(ctx context.Context, fundingSourceId string) (*FundingSource, error)
Get retrieves a specific funding source
func (*FundingSourceService) List ¶
func (fnd *FundingSourceService) List(ctx context.Context, organizationId string) ([]*FundingSource, error)
List retrieves all funding sources associated with the specified organization
type GetAdAccountsResponse ¶
type GetAdAccountsResponse struct { // RequestStatus is the status of the get ad account request RequestStatus string `json:"request_status"` // RequestId is the id associated with the request RequestId string `json:"request_id"` // AdAccounts is a list of individual ad account responses AdAccounts []*AdAccountResponse `json:"adaccounts"` }
GetAdAccountsResponse is the response object for calls to get ad accounts
type GetAdSquadsResponse ¶
type GetAdSquadsResponse struct { RequestStatus string `json:"request_status"` RequestId string `json:"request_id"` AdSquads []*AdSquadResponse `json:"adsquads"` }
GetAdSquadsResponse is the response object returned when getting ad squads
type GetAdsResponse ¶
type GetAdsResponse struct { RequestStatus string `json:"request_status"` RequestId string `json:"request_id"` Ads []*AdResponse `json:"ads"` }
GetAdsResponse is the response object returned when getting ads
type GetCampaignsResponse ¶
type GetCampaignsResponse struct { RequestStatus string `json:"request_status"` RequestId string `json:"request_id"` Campaigns []*CampaignResponse `json:"campaigns"` }
GetCampaignsResponse is the response object returned when getting campaigns
type GetFundingSourcesResponse ¶
type GetFundingSourcesResponse struct { RequestStatus string `json:"request_status"` RequestId string `json:"request_id"` FundingSources []*FundingSourceResponse `json:"fundingsources"` }
GetFundingSourcesResponse struct { is the response object returned when getting funding sources
type GetMeasurementsResponse ¶
type GetMeasurementsResponse struct { RequestStatus string `json:"request_status"` // the status of the request RequestId string `json:"request_id"` // the id of the request TotalStats []*TotalStats `json:"total_stats"` // the object containing total stats for this entity }
GetMeasurementsResponse is the response object for get measurement requests
type GetOrganizationsResponse ¶
type GetOrganizationsResponse struct { RequestStatus string `json:"request_status"` RequestId string `json:"request_id"` Organizations []*OrganizationResponse `json:"organizations"` }
GetOrganizationsResponse is the response object for calls to get organizations
type MeasurementService ¶
type MeasurementService service
MeasurementService provides functions for getting snapchat measurement metrics
func (*MeasurementService) GetStatsForAdSquad ¶
func (measurement *MeasurementService) GetStatsForAdSquad(ctx context.Context, adSquadId string) (*GetMeasurementsResponse, error)
GetStatsForAdSquad returns the measurement metrics for the given ad squad
type MeasurementStats ¶
type MeasurementStats struct { Impressions int `json:"impressions"` // number of impressions Swipes int `json:"swipes"` // number of swipe-ups Spend int64 `json:"spend"` // amount spent (micro-currency) FirstQuartile int `json:"quartile_1"` // number of video views to 25% SecondQuartile int `json:"quartile_2"` // number of video views to 50% ThirdQuartile int `json:"quartile_3"` // number of video views to 75% ScreenTimeMillis int64 `json:"screen_time_millis"` // total time spent on top snap ad (milliseconds) ViewCompletion int `json:"view_completion"` // the number of views to completion VideoViews int `json:"video_views"` // the total number of impressions that meet the qualifying video view criteria of at least 2 seconds of consecutive watch time or a swipe up action on the Top Snap }
MeasurementStats is the object actually containing the measurement metrics
type Organization ¶
type Organization struct { // Id is the unique id associated with the organization Id string `json:"id"` // Name is the name of the organization Name string `json:"name"` // AddressLine1 is the street address associated with the organization AddressLine1 string `json:"address_line_1"` // Locality is the region/city associated with the account Locality string `json:"locality"` // AdministrativeDistrictLevel1 is the region/state associated with the organization AdministrativeDistrictLevel1 string `json:"administrative_district_level_1"` // County is the country associated with the organization Country string `json:"country"` // PostalCode is the postal code associated with the organization PostalCode string `json:"postal_code"` // Type is the type of organization Type string `json:"type"` // CreatedAt is the time when the organization was created CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the organization was last updated UpdatedAt time.Time `json:"updated_at"` }
Organization represents an organization in the snapchat ads api
type OrganizationResponse ¶
type OrganizationResponse struct { SubRequestStatus string `json:"sub_request_status"` Organization Organization `json:"organization"` }
OrganizationResponse is the individual organization object in the response for calls to get organizations
type OrganizationService ¶
type OrganizationService service
OrganizationService provides functions for interacting with snapchat organizations
func (*OrganizationService) Get ¶
func (org *OrganizationService) Get(ctx context.Context, organizationId string) (*Organization, error)
Get returns a single organization associated with the provided organization id
func (*OrganizationService) List ¶
func (org *OrganizationService) List(ctx context.Context) ([]*Organization, error)
List returns all organizations associated with the authenticated user
type TotalStat ¶
type TotalStat struct { Id string `json:"id"` // the id of the entity Type string `json:"type"` // the type of the entity Granularity string `json:"granularity"` // the level of granulatiry for stats reporting Stats MeasurementStats `json:"stats"` // the object containing actual metrics }
TotalStat is an object that contains the total metrics for the requested entity
type TotalStats ¶
type TotalStats struct { SubRequestStatus string `json:"sub_request_status"` TotalStat TotalStat `json:"total_stat"` }
TotalStats is a wrapper object for the stats response
type User ¶
type User struct { // Id is the unique id associated with the user Id string `json:"id"` // Email is the email associated with the user Email string `json:"email"` // OrganizationId is the id of the organization associated with the user OrganizationId string `json:"organization_id"` // DisplayName is the display name of the user DisplayName string `json:"display_name"` // CreatedAt is the time when the user was created CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the user was last updated UpdatedAt time.Time `json:"updated_at"` }
User represents a user in the snapchat ads api
type UserService ¶
type UserService service
UserService provides functions for interacting with snapchat users
func (*UserService) GetAuthenticatedUser ¶
func (usr *UserService) GetAuthenticatedUser(ctx context.Context) (*User, error)
GetAuthenticatedUser returns the user that is currently authenticated