All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.foxinmy.weixin4j.wxa.api.CustomMessageAdapters Maven / Gradle / Ivy

The newest version!
package com.foxinmy.weixin4j.wxa.api;

import java.util.HashMap;
import java.util.Map;

import com.foxinmy.weixin4j.tuple.NotifyTuple;
import com.foxinmy.weixin4j.wxa.model.custommessage.Command;
import com.foxinmy.weixin4j.wxa.model.custommessage.CustomMessage;

/**
 * Adapters for {@link CustomMessageApi}.
 *
 * @since 1.8
 */
final class CustomMessageAdapters {

	private CustomMessageAdapters() {
	}

	public static Map toMap(CustomMessage customMessage) {
		final NotifyTuple tuple = customMessage.getTuple();
		final String msgType = tuple.getMessageType();

		final Map params = new HashMap(3);
		params.put("touser", customMessage.getToUser());
		params.put("msgtype", msgType);
		params.put(msgType, tuple);

		return params;
	}

	public static Map toMap(String toUser, Command command) {
		final Map params = new HashMap(2);
		params.put("touser", toUser);
		params.put("command", command.toString());
		return params;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy