Back to project page wit-android-sdk.
The source code is released under:
/** * Copyright (c) 2014, Wit.ai, Inc. All rights reserved. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to * use, copy, modify, and distribute this software in source c...
If you think the Android project wit-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ai.wit.sdk; // w w w .j a v a 2 s . c om import android.net.Uri.Builder; import com.google.gson.Gson; import com.google.gson.JsonObject; /** * Created by aric on 10/28/14. */ public class WitRequest { public static String scheme = "https"; public static String authority = "api.wit.ai"; public static String version = "20141022"; private String _messageId = null; private IWitListener _witListener; private JsonObject _context; public WitRequest(IWitListener witListener, JsonObject context) { _witListener = witListener; _context = context; } public Builder getBase() { Builder uriBuilder = new Builder(); uriBuilder .scheme(scheme) .authority(authority) .appendQueryParameter("v", version); if (_messageId != null) { uriBuilder.appendQueryParameter("msg_id", _messageId); } return uriBuilder; } protected Builder buildUri(String endpoint) { Builder uriBuilder; String messageId = _witListener.witGenerateMessageId(); uriBuilder = this.getBase(); uriBuilder.appendPath(endpoint); if (_context != null) { Gson gson = new Gson(); String jsonContext = gson.toJson(_context); uriBuilder.appendQueryParameter("context", jsonContext); } if (messageId != null) { uriBuilder.appendQueryParameter("msg_id", messageId); } return uriBuilder; } }