answerShippingQuery method

Future<bool> answerShippingQuery(
  1. String shippingQueryId,
  2. bool ok, {
  3. List<ShippingOption>? shippingOptions,
  4. String? errorMessage,
})

Use this method to reply to shipping queries.

If you sent an invoice requesting a shipping address and the parameter isFlexible was specified, the Bot API will send an Update with a shippingQuery field to the bot.

On success, True is returned.

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

Implementation

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