1
0
telegram/answer_shipping_query.go

52 lines
1.6 KiB
Go
Raw Normal View History

package telegram
import json "github.com/pquerna/ffjson/ffjson"
type AnswerShippingQueryParameters struct {
// Unique identifier for the query to be answered
2017-10-06 07:55:54 +00:00
ShippingQueryID string `json:"shipping_query_id"`
// Required if ok is False. Error message in human readable form that
// explains why it is impossible to complete the order (e.g. "Sorry, delivery
// to your desired address is unavailable'). Telegram will display this
// message to the user.
ErrorMessage string `json:"error_message,omitempty"`
2017-10-06 07:55:54 +00:00
// Specify True if delivery to the specified address is possible and False
// if there are any problems (for example, if delivery to the specified
// address is not possible)
2017-10-06 08:46:30 +00:00
Ok bool `json:"ok"`
2017-10-06 07:55:54 +00:00
// Required if ok is True. A JSON-serialized array of available shipping
// options.
ShippingOptions []ShippingOption `json:"shipping_options,omitempty"`
}
2017-10-17 11:08:09 +00:00
func NewAnswerShippingQuery(shippingQueryID string, ok bool) *AnswerShippingQueryParameters {
return &AnswerShippingQueryParameters{
ShippingQueryID: shippingQueryID,
Ok: ok,
}
}
// AnswerShippingQuery reply to shipping queries.
//
2017-10-06 07:55:54 +00:00
// If you sent an invoice requesting a shipping address and the parameter
// is_flexible was specified, the Bot API will send an Update with a
// shipping_query field to the bot. On success, True is returned.
func (bot *Bot) AnswerShippingQuery(params *AnswerShippingQueryParameters) (bool, error) {
dst, err := json.Marshal(params)
if err != nil {
return false, err
}
2018-04-12 11:58:05 +00:00
resp, err := bot.request(dst, MethodAnswerShippingQuery)
if err != nil {
return false, err
}
var data bool
err = json.Unmarshal(*resp.Result, &data)
return data, err
}