Documentation ¶
Index ¶
Constants ¶
Variables ¶
var ErrNotUS = errors.New("this API only works for devices in the US")
ErrNotUS is an error indicating that the requeting user does not reside in the USA
var ErrUnknownZipcode = errors.New("unknown zipcode")
ErrUnknownZipcode is set when the Alexa API returns 204 staus code saying that the device has no zipcode stored in their system
Functions ¶
func ResponseText ¶
func ResponseText(msg string) interface{}
ResponseText creates a response message to send to an alexa request
Types ¶
type API ¶
type API interface {
DeviceZip(ctx context.Context, deviceID, apiAccessToken string) (string, error)
}
API loads zipcodes for devices
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an api for interacting with the Alexa HTTP Client
func NewAPI ¶
func NewAPI() *Client
NewAPI creates a new API that connects to the Alexa API for retrieving zipcodes for deviceIDs provided with requests
func (*Client) DeviceZip ¶
DeviceZip gets the zipcode from the amazon alexa request using the API instructions found here https://developer.amazon.com/docs/custom-skills/device-address-api.html
Accept: application/json Authorization: Bearer {apiAccessToken} GET https://api.amazonalexa.com/v1/devices/{deviceId}/settings/address/countryAndPostalCode
type Request ¶
type Request struct { Version string `json:"version"` Session struct { New bool `json:"new"` SessionID string `json:"sessionId"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` Attributes struct { Key string `json:"key"` } `json:"attributes"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken"` Permissions struct { ConsentToken string `json:"consentToken"` } `json:"permissions"` } `json:"user"` } `json:"session"` Context struct { System struct { Device struct { DeviceID string `json:"deviceId"` SupportedInterfaces struct { AudioPlayer struct { } `json:"AudioPlayer"` } `json:"supportedInterfaces"` } `json:"device"` Application struct { ApplicationID string `json:"applicationId"` } `json:"application"` User struct { UserID string `json:"userId"` AccessToken string `json:"accessToken"` Permissions struct { ConsentToken string `json:"consentToken"` } `json:"permissions"` } `json:"user"` APIEndpoint string `json:"apiEndpoint"` APIAccessToken string `json:"apiAccessToken"` } `json:"System"` AudioPlayer struct { PlayerActivity string `json:"playerActivity"` Token string `json:"token"` OffsetInMilliseconds int `json:"offsetInMilliseconds"` } `json:"AudioPlayer"` } `json:"context"` Request RequestBody `json:"request"` }
Request is found here https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html
type RequestBody ¶
type RequestBody struct { Type string `json:"type"` RequestID string `json:"requestId"` Intent struct { Name string `json:"name"` Slots struct { Condition struct { Value string `json:"value"` } `json:"condition"` Time struct { Value string `json:"value"` } `json:"time"` Day struct { Value string `json:"value"` } `json:"day"` } `json:"slots"` } `json:"intent"` Locale string `json:"locale"` Timestamp time.Time `json:"timestamp"` }
RequestBody is the body of the specific request
type TimeSpan ¶
TimeSpan is a period of time indicating a start time, a Span, and a count
type WeatherRequest ¶
WeatherRequest is a formatted RequestBody
func ParseWeatherRequest ¶
func ParseWeatherRequest(r RequestBody, loc *time.Location) WeatherRequest
ParseWeatherRequest parses the RequestBody as a WeatherRequest