Documentation ¶
Index ¶
- Variables
- func CacheExpires(r *http.Response) time.Time
- type APIClient
- type APIKey
- type APIResponse
- type AudioProperty
- type BasicAuth
- type Configuration
- type DefaultApiService
- type Error
- type FileProperty
- type FromProperty
- type GenericOpenAPIError
- type ImageProperty
- type InboundMessage
- type InboundMessageFrom
- type InboundMessageMessage
- type InboundMessageMessageContent
- type InboundMessageTo
- type LocationProperty
- type MessageProperty
- type MessagePropertyContent
- type MessagePropertyMessenger
- type MessagePropertyViberServiceMsg
- type MessagePropertyWhatsapp
- type MessageStatus
- type MessageStatusError
- type MessageStatusUsage
- type NewMessage
- type Response
- type TemplateProperty
- type TemplatePropertyParameters
- type ToProperty
- type VideoProperty
Constants ¶
This section is empty.
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct { DefaultApi *DefaultApiService // contains filtered or unexported fields }
APIClient manages communication with the Messages API API v0.3.0 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) *APIClient
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangeBasePath ¶
Change base path to allow switching to mocks
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
type AudioProperty ¶
type AudioProperty struct { // The URL of the audio attachment. `messenger` supports .mp3. Url string `json:"url,omitempty"` }
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Configuration ¶
type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client }
func NewConfiguration ¶
func NewConfiguration() *Configuration
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
type DefaultApiService ¶
type DefaultApiService service
func (*DefaultApiService) NewMessage ¶
func (a *DefaultApiService) NewMessage(ctx context.Context, newMessage NewMessage) (Response, *http.Response, error)
DefaultApiService Send a Message
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param newMessage Send a Message.
@return Response
type Error ¶
type Error struct { Type string `json:"type"` Title string `json:"title"` Detail string `json:"detail"` Instance string `json:"instance"` }
The error format is standardized to the 4xx/5xx range with a code and a human readable explanation.
type FileProperty ¶
type FileProperty struct { // The URL of the file attachment. `messenger` supports a wide range of attachments including .zip, .csv and .pdf Url string `json:"url,omitempty"` }
type FromProperty ¶
type FromProperty struct { // The type of message that you want to send. Type string `json:"type"` // Your ID for the platform that you are sending from. **Messenger**: This value should be the `to.id` value you received in the inbound messenger event. **Viber**: This is your Service Message ID given to you by Nexmo Account Manager. To find out more please visit [nexmo.com/products/messages](https://www.nexmo.com/products/messages). Id string `json:"id,omitempty"` // **SMS**: The phone number of the message recipient in the [E.164](https://en.wikipedia.org/wiki/E.164) format. Don't use a leading + or 00 when entering a phone number, start with the country code, for example, 447700900000. **WhatsApp**: This is your WhatsApp Business Number given to you by Nexmo Account Manager. To find out more please visit [nexmo.com/products/messages](https://www.nexmo.com/products/messages). **MMS**: US shortcode Number string `json:"number,omitempty"` }
type GenericOpenAPIError ¶
type GenericOpenAPIError struct {
// contains filtered or unexported fields
}
GenericOpenAPIError Provides access to the body, error and model on returned errors.
func (GenericOpenAPIError) Body ¶
func (e GenericOpenAPIError) Body() []byte
Body returns the raw bytes of the response
func (GenericOpenAPIError) Error ¶
func (e GenericOpenAPIError) Error() string
Error returns non-empty string if there was an error.
func (GenericOpenAPIError) Model ¶
func (e GenericOpenAPIError) Model() interface{}
Model returns the unpacked model of the error
type ImageProperty ¶
type ImageProperty struct { // The URL of the image attachment. `messenger` supports .jpg, .png and .gif. `viber_service_msg` supports .jpg and .png. Url string `json:"url,omitempty"` }
type InboundMessage ¶
type InboundMessage struct { // The UUID of the message. MessageUuid string `json:"message_uuid"` To InboundMessageTo `json:"to"` From InboundMessageFrom `json:"from"` // The datetime of when the event occurred. Timestamp string `json:"timestamp"` Message InboundMessageMessage `json:"message,omitempty"` }
type InboundMessageFrom ¶
type InboundMessageMessage ¶
type InboundMessageMessage struct {
Content InboundMessageMessageContent `json:"content,omitempty"`
}
type InboundMessageMessageContent ¶
type InboundMessageMessageContent struct { // The type of message being received. Type string `json:"type,omitempty"` // The body of the message. Text string `json:"text,omitempty"` Image ImageProperty `json:"image,omitempty"` Audio AudioProperty `json:"audio,omitempty"` Video VideoProperty `json:"video,omitempty"` File FileProperty `json:"file,omitempty"` Location LocationProperty `json:"location,omitempty"` }
type InboundMessageTo ¶
type LocationProperty ¶
type LocationProperty struct { // The latitude of the location attachment. Lat string `json:"lat,omitempty"` // The longitude of the location attachment. Long string `json:"long,omitempty"` // Depending on the provider, this can either be the location on a map or the website of the business at this location. Url string `json:"url,omitempty"` // The address of the location attachment. Address string `json:"address,omitempty"` // The name of the location attachment. Name string `json:"name,omitempty"` }
type MessageProperty ¶
type MessageProperty struct { Content MessagePropertyContent `json:"content"` ViberServiceMsg *MessagePropertyViberServiceMsg `json:"viber_service_msg,omitempty"` Messenger *MessagePropertyMessenger `json:"messenger,omitempty"` Whatsapp *MessagePropertyWhatsapp `json:"whatsapp,omitempty"` }
type MessagePropertyContent ¶
type MessagePropertyContent struct { // The type of message that you are sending. **Messenger**: supports all types. **Viber Service Messages**: supports `image` and `text` and `custom`. **WhatsApp**: supports `template` and `text`. **SMS**: supports `text`. **MMS**: supports `image`. Type string `json:"type,omitempty"` // The text of the message. **Messenger**: Is limited to 640 characters **SMS** or **Viber**: Is 1000 characters **WhatsApp**: is 4096 characters Text string `json:"text,omitempty"` Image *ImageProperty `json:"image,omitempty"` Audio *AudioProperty `json:"audio,omitempty"` Video *VideoProperty `json:"video,omitempty"` File *FileProperty `json:"file,omitempty"` Template *TemplateProperty `json:"template,omitempty"` }
type MessagePropertyMessenger ¶
type MessagePropertyMessenger struct { // The use of different category tags enables the business to send messages for different use cases. For Facebook Messenger they need to comply with their [Messaging Types policy]( https://developers.facebook.com/docs/messenger-platform/send-messages#messaging_types). Nexmo maps our `category` to their `messaging_type`. If `message_tag` is used, then an additional `tag` for that type is mandatory. By default Nexmo sends the `response` category to Facebook Messenger. Category string `json:"category,omitempty"` // ‘A full list of the possible tags is available on [developers.facebook.com](https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags)' Tag string `json:"tag,omitempty"` }
type MessagePropertyViberServiceMsg ¶
type MessagePropertyViberServiceMsg struct { // The use of different category tags enables the business to send messages for different use cases. For Viber Service Messages the first message sent from a business to a user must be personal, informative & a targeted message - not promotional. By default Nexmo sends the `transaction` category to Viber Service Messages. Category string `json:"category,omitempty"` // Set the time-to-live of message to be delivered in seconds. i.e. if the message is not delivered in 600 seconds then delete the message. Ttl int32 `json:"ttl,omitempty"` // Viber-specific type definition. To use \"template\", please contact Nexmo Account Manager to setup your templates. To find out more please visit [nexmo.com/products/messages](https://www.nexmo.com/products/messages). Type string `json:"type,omitempty"` }
type MessagePropertyWhatsapp ¶
type MessagePropertyWhatsapp struct { // There are two policies that you can specify when sending an Message Template: `deterministic` and `fallback`. `deterministic` — Deliver the Message Template in exactly the language and locale asked for. `fallback` — Deliver the Message Template in the language that matches users language/locale setting on device. If one can not be found, deliver using the specified fallback language. Policy string `json:"policy,omitempty"` // We are using the industry standard, BCP 47, for locales. So in your API call to the /messages API you will need to put “en-GB” and this will refer to the “en_GB” template for WhatsApp. Locale string `json:"locale,omitempty"` }
type MessageStatus ¶
type MessageStatus struct { // The UUID of the message. MessageUuid string `json:"message_uuid"` To ToProperty `json:"to"` From FromProperty `json:"from"` // The datetime of when the event occurred. Timestamp string `json:"timestamp"` // The status of the message. The `read` message status is only available for `messenger` and `whatsapp`. Status string `json:"status"` Error MessageStatusError `json:"error,omitempty"` Usage MessageStatusUsage `json:"usage,omitempty"` // The client's reference. ClientRef string `json:"client_ref,omitempty"` }
type MessageStatusError ¶
type MessageStatusError struct { // The error code. See [our errors list](https://developer.nexmo.com/api-errors/messages-olympus) for a list of possible errors Code int32 `json:"code,omitempty"` // Text describing the error. See [our errors list](https://developer.nexmo.com/api-errors/messages-olympus) for a list of possible errors Reason string `json:"reason,omitempty"` }
type MessageStatusUsage ¶
type NewMessage ¶
type NewMessage struct { To ToProperty `json:"to"` From FromProperty `json:"from"` Message MessageProperty `json:"message"` // Client reference of up to 40 characters. The reference will be present in every message status. ClientRef string `json:"client_ref,omitempty"` }
type Response ¶
type Response struct { // The UUID of the message. MessageUuid string `json:"message_uuid"` }
type TemplateProperty ¶
type TemplateProperty struct { // The name of the template. Name string `json:"name,omitempty"` Parameters []TemplatePropertyParameters `json:"parameters,omitempty"` }
type TemplatePropertyParameters ¶
type TemplatePropertyParameters struct { // The parameters are an array. The first value being {{1}} in the template. Default string `json:"default,omitempty"` }
type ToProperty ¶
type ToProperty struct { // The type of message that you want to send. Type string `json:"type"` // **Messenger**: The ID of the message recipient. This value should be the `from.id` value you received in the inbound messenger event. Id string `json:"id,omitempty"` // **SMS**, **Viber**, **WhatsApp** or **MMS**: The phone number of the message recipient in the [E.164](https://en.wikipedia.org/wiki/E.164) format. Don't use a leading + or 00 when entering a phone number, start with the country code, for example, 447700900000. Number string `json:"number,omitempty"` }
type VideoProperty ¶
type VideoProperty struct { // The URL of the video attachment. `messenger` supports .mp4 Url string `json:"url,omitempty"` }
Source Files ¶
- api_default.go
- client.go
- configuration.go
- model_audio_property.go
- model_error.go
- model_file_property.go
- model_from_property.go
- model_image_property.go
- model_inbound_message.go
- model_inbound_message_from.go
- model_inbound_message_message.go
- model_inbound_message_message_content.go
- model_inbound_message_to.go
- model_location_property.go
- model_message_property.go
- model_message_property_content.go
- model_message_property_messenger.go
- model_message_property_viber_service_msg.go
- model_message_property_whatsapp.go
- model_message_status.go
- model_message_status_error.go
- model_message_status_usage.go
- model_new_message.go
- model_response.go
- model_template_property.go
- model_template_property_parameters.go
- model_to_property.go
- model_video_property.go
- response.go