List of usage examples for com.facebook.react.bridge Callback invoke
public void invoke(Object... args);
From source file:ph.com.globe.connect.BinarySms.java
License:Open Source License
/** * Sends binary message request./* w ww . j av a2 s.c o m*/ * * @param userDataHeader user data header * @param dataCodingScheme data coding scheme * @param receiverAddress receiver address * @param binaryMessage binary message * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void sendBinaryMessage(String userDataHeader, int dataCodingScheme, String receiverAddress, String binaryMessage, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // get the url String url = this.buildUrl(this.SMS_BIN_URL); // set base data Map<String, Object> data = new HashMap<>(); // set outbound binary messsage request data Map<String, Object> obmr = new HashMap<>(); // set message Map<String, String> msg = new HashMap<>(); // set sender address obmr.put("senderAddress", this.senderAddress); // set binary message msg.put("message", binaryMessage); // set user data header obmr.put("userDataHeader", userDataHeader); // set data coding scheme obmr.put("dataCodingScheme", Integer.toString(dataCodingScheme)); // set address obmr.put("address", receiverAddress); // set outbound binary message obmr.put("outboundBinaryMessage", new org.json.JSONObject(msg)); // set to base data data.put("outboundBinaryMessageRequest", new org.json.JSONObject(obmr)); // send request new HttpRequest() // set url .setUrl(url) // set data .setData(data) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // execute async post .execute("post"); }
From source file:ph.com.globe.connect.Location.java
License:Open Source License
/** * Get location request.//from w ww. j av a 2 s . co m * * @param address subscriber address * @param requestedAccuracy request accuracy * @param success * @param error * @return HttpResponse * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void getLocation(String address, int requestedAccuracy, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // try parsing url try { // initialize url builder URIBuilder builder = new URIBuilder(this.LOCATION_URL); // set access token parameter builder.setParameter("access_token", this.accessToken); // set address parameter builder.setParameter("address", address); // set requested accuracy parameter builder.setParameter("requestedAccuracy", Integer.toString(requestedAccuracy)); // build the url String url = builder.build().toString(); // send request new HttpRequest() // set url .setUrl(url) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // send get request .execute("get"); } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } }
From source file:ph.com.globe.connect.Payment.java
License:Open Source License
/** * Sends payment request.//w w w. j a v a2 s . c o m * * @param amount payment amount * @param description payment description * @param endUserId end user id * @param referenceCode custom reference code * @param transactionOperationStatus resource state * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void sendPaymentRequest(double amount, String description, String endUserId, String referenceCode, String transactionOperationStatus, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // build url String url = this.buildUrl(this.PAYMENT_URL); // set base data Map<String, Object> data = new HashMap<>(); // set amount data.put("amount", String.format("%.2f", amount)); // set description data.put("description", description); // set end user id data.put("endUserId", endUserId); // set reference code data.put("referenceCode", referenceCode); // set transaction operation status data.put("transactionOperationStatus", transactionOperationStatus); // send request new HttpRequest() // set url .setUrl(url) // set data .setData(data) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // execute async post .execute("post"); }
From source file:ph.com.globe.connect.Payment.java
License:Open Source License
/** * Get last reference code request.//from w w w. j a v a 2 s . c om * * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ @ReactMethod public void getLastReferenceCode(final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // build url String url = this.buildUrl(this.LAST_REF_URL, this.appId, this.appSecret); // send request new HttpRequest() // set url .setUrl(url) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // send get request .execute("get"); }
From source file:ph.com.globe.connect.Sms.java
License:Open Source License
/** * Sends an outbound sms request.//from w ww . java2s .c om * * @param clientCorrelator client correlator * @param message outbound message * @param receiverAddress receiver address * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void sendMessage(String clientCorrelator, String message, String receiverAddress, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // get the url String url = this.buildUrl(this.SMS_MT_URL); // set base data Map<String, Object> data = new HashMap<>(); // set OutboundSMSMessageRequest data Map<String, Object> osmr = new HashMap<>(); // set message data Map<String, String> msg = new HashMap<>(); // set client correlator if (clientCorrelator != null) { osmr.put("client_correlator", clientCorrelator); } // set sender address osmr.put("senderAddress", "tel:" + this.senderAddress); // set message data msg.put("message", message); // set message osmr.put("outboundSMSTextMessage", new org.json.JSONObject(msg)); // set address osmr.put("address", new org.json.JSONArray(Arrays.asList(new String[] { "tel:" + receiverAddress }))); // set the outbound sms request data data.put("outboundSMSMessageRequest", new org.json.JSONObject(osmr)); // send request new HttpRequest() // set url .setUrl(url) // set data .setData(data) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // execute async post .execute("post"); }
From source file:ph.com.globe.connect.Subscriber.java
License:Open Source License
/** * Get subscriber balance request./*from w w w . jav a 2 s . co m*/ * * @param address subscriber address * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void getSubscriberBalance(String address, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // set request url String url = this.SUBSCRIBER_URL; // build url try { // initialize url builder URIBuilder builder = new URIBuilder(url); // set access token parameter builder.setParameter("access_token", this.accessToken); // set the address builder.setParameter("address", address); // build the url url = builder.build().toString(); } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } // send request new HttpRequest() // set url .setUrl(url) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // send get request .execute("get"); }
From source file:ph.com.globe.connect.Subscriber.java
License:Open Source License
/** * Get subscriber reload amount.//from w ww . j a v a 2 s. co m * * @param address subscriber address * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void getSubscriberReloadAmount(String address, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // set request url String url = this.SUBSCRIBER_RA_URL; // build url try { // initialize url builder URIBuilder builder = new URIBuilder(url); // set access token parameter builder.setParameter("access_token", this.accessToken); // set the address builder.setParameter("address", address); // build the url url = builder.build().toString(); } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } // send request new HttpRequest() // set url .setUrl(url) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // send get request .execute("get"); }
From source file:ph.com.globe.connect.Ussd.java
License:Open Source License
/** * Send USSD Request./* w w w . ja va 2s. c o m*/ * * @param senderAddress sender address * @param ussdMessage ussd message * @param address subscriber address * @param flash final message flag * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void sendUssdRequest(String senderAddress, String ussdMessage, String address, boolean flash, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // build url String url = this.buildUrl(this.USSD_SEND_NI_URL); // set base data Map<String, Object> data = new HashMap<>(); // set outbound ussd message request Map<String, Object> oumr = new HashMap<>(); // set message data Map<String, String> msg = new HashMap<>(); // set sender address oumr.put("senderAddress", senderAddress); // set address oumr.put("address", address); // set flash oumr.put("flash", flash); // set message msg.put("message", ussdMessage); // set message oumr.put("outboundUSSDMessage", new org.json.JSONObject(msg)); // set on base data data.put("outboundUSSDMessageRequest", new org.json.JSONObject(oumr)); // send request new HttpRequest() // set url .setUrl(url) // set data .setData(data) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // execute async post .execute("post"); }
From source file:ph.com.globe.connect.Ussd.java
License:Open Source License
/** * Reply USSD Request./* w ww .j a v a 2 s .com*/ * * @param sessionId session id * @param senderAddress sender address * @param address subscriber address * @param flash final message flag * @param success * @param error * @return void * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public void replyUssdRequest(String sessionId, String senderAddress, String address, boolean flash, final Callback success, final Callback error) throws ApiException, HttpRequestException, HttpResponseException { // build url String url = this.buildUrl(this.USSD_REPLY_MT_URL); // set base data Map<String, Object> data = new HashMap<>(); // set outbound ussd message request Map<String, Object> oumr = new HashMap<>(); // set message data Map<String, String> msg = new HashMap<>(); // set sender address oumr.put("senderAddress", senderAddress); // set address oumr.put("address", address); // set session id oumr.put("sessionID", sessionId); // set flash oumr.put("flash", flash); // set message msg.put("message", ussdMessage); // set message oumr.put("outboundUSSDMessage", new org.json.JSONObject(msg)); // set on base data data.put("outboundUSSDMessageRequest", new org.json.JSONObject(oumr)); // send request new HttpRequest() // set url .setUrl(url) // set data .setData(data) // set async handler .setAsyncHandler(new AsyncHandler() { @Override public void response(HttpResponse response) throws HttpResponseException { // try parsing try { // send response success.invoke(response.convertJsonToMap(response.getJsonResponse())); } catch (HttpResponseException e) { error.invoke(e.getMessage()); } } }) // execute async post .execute("post"); }