createInvoiceLink method

FutureOr<Map> createInvoiceLink({
  1. required Map parameters,
  2. required TelegramClientCallApiInvoke callApiInvoke,
})

method CreateInvoiceLink

Implementation

FutureOr<Map> createInvoiceLink({
  required Map parameters,
  required TelegramClientCallApiInvoke callApiInvoke,
}) async {
  // "@type": "createInvoiceLink",
  // "title": "slebew",
  // "description": "slennew",
  // "payload": "salpDlpd",
  // "currency": "XTR",
  // "prices": [
  //   {
  //     "label": "Slebewff",
  //     "amount": 1,
  //   }
  // ]
  if (parameters["prices"] is List == false) {
    parameters["prices"] = {};
  }

  Map request_parameters = <dynamic, dynamic>{
    "@type": "createInvoiceLink",
    "invoice": <dynamic, dynamic>{
      "@type": "inputMessageInvoice",
      "title": parameters["title"],
      "description": parameters["description"],
      "payload": parameters["payload"]
          .toString()
          .general_lib_utils_encryptToBase64(),
      "invoice": <dynamic, dynamic>{
        "@type": "invoice",
        "currency": parameters["currency"],
        "price_parts": (parameters["prices"] as List)
            .map((e) {
              if (e is Map == false) {
                return null;
              }
              Map<dynamic, dynamic> json_data_price = <dynamic, dynamic>{
                "@type": "labeledPricePart",
                ...e,
              };
              return json_data_price;
            })
            .whereType<Map>()
            .toList(),
      },
    }
  };

  Map message_send = await callApiInvoke(
    parameters: request_parameters,
  );
  message_send["result"] = message_send["url"];
  return message_send;
}