コード例 #1
0
 @Override
 public void validate() throws TelegramApiValidationException {
   if (id == null || id.isEmpty()) {
     throw new TelegramApiValidationException("ID parameter can't be empty", this);
   }
   if (gifFileId == null || gifFileId.isEmpty()) {
     throw new TelegramApiValidationException("GifFileId parameter can't be empty", this);
   }
   if (inputMessageContent != null) {
     inputMessageContent.validate();
   }
   if (replyMarkup != null) {
     replyMarkup.validate();
   }
 }
コード例 #2
0
 @Override
 public JSONObject toJson() {
   JSONObject jsonObject = new JSONObject();
   jsonObject.put(TYPE_FIELD, type);
   jsonObject.put(ID_FIELD, this.id);
   jsonObject.put(GIF_FILE_ID_FIELD, gifFileId);
   if (title != null) {
     jsonObject.put(TITLE_FIELD, this.title);
   }
   if (caption != null) {
     jsonObject.put(CAPTION_FIELD, this.caption);
   }
   if (replyMarkup != null) {
     jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup.toJson());
   }
   if (inputMessageContent != null) {
     jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
   }
   return jsonObject;
 }
コード例 #3
0
  @Override
  public JSONObject toJson() {
    JSONObject jsonObject = new JSONObject();

    jsonObject.put(TYPE_FIELD, type);
    jsonObject.put(ID_FIELD, this.id);
    jsonObject.put(PHOTOURL_FIELD, this.photoUrl);
    if (mimeType != null) {
      jsonObject.put(MIMETYPE_FIELD, this.mimeType);
    }
    if (photoWidth != null) {
      jsonObject.put(PHOTOWIDTH_FIELD, this.photoWidth);
    }
    if (photoHeight != null) {
      jsonObject.put(PHOTOHEIGHT_FIELD, this.photoHeight);
    }
    if (description != null) {
      jsonObject.put(DESCRIPTION_FIELD, this.description);
    }
    if (thumbUrl != null) {
      jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
    }
    if (title != null) {
      jsonObject.put(TITLE_FIELD, this.title);
    }
    if (caption != null) {
      jsonObject.put(CAPTION_FIELD, this.caption);
    }
    if (replyMarkup != null) {
      jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup.toJson());
    }
    if (inputMessageContent != null) {
      jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent.toJson());
    }

    return jsonObject;
  }