answerShippingQuery method

Future<bool> answerShippingQuery(
  1. String shipping_query_id,
  2. bool ok, {
  3. List<ShippingOption>? shipping_options,
  4. String? error_message,
})
inherited

Use this method to reply to shipping queries.

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.

https://core.telegram.org/bots/api#answershippingquery

Implementation

Future<bool> answerShippingQuery(String shipping_query_id, bool ok,
    {List<ShippingOption>? shipping_options, String? error_message}) async {
  if (!ok && (shipping_options == null || error_message == null)) {
    return Future.error(TelegramException(
        'Attribute \'shipping_options\' and \'error_message\' can not be null when \'ok\' = false'));
  }
  var requestUrl = _apiUri('answerShippingQuery');
  var body = <String, dynamic>{
    'shipping_query_id': shipping_query_id,
    'ok': ok,
    'shipping_options':
        shipping_options == null ? null : jsonEncode(shipping_options),
    'error_message': error_message,
  };
  return await HttpClient.httpPost(requestUrl, body: body);
}