Copyright (c) 2012 CloudMine LLC, http://cloudmine.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software")...
If you think the Android project cloudmine-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.cloudmine.api.rest;
//fromwww.java2s.comimport com.cloudmine.api.CMApiCredentials;
import com.cloudmine.api.CMSessionToken;
import com.cloudmine.api.LibrarySpecificClassCreator;
import com.cloudmine.api.rest.callbacks.Callback;
import com.cloudmine.api.rest.callbacks.PaymentResponseCallback;
import com.cloudmine.api.rest.response.PaymentResponse;
import org.apache.http.client.methods.HttpPost;
/**
* <br>Copyright CloudMine LLC. All rights reserved
* <br> See LICENSE file included with SDK for details.
*/publicclass AndroidUserCMWebService extends UserCMWebService {
publicstatic AndroidUserCMWebService getService(CMSessionToken token) {
return getService(CMApiCredentials.getApplicationIdentifier(), CMApiCredentials.getApplicationApiKey(), token);
}
publicstatic AndroidUserCMWebService getService(String appId, String apiKey, CMSessionToken token) {
returnnew AndroidUserCMWebService(new CMURLBuilder(appId).user(), token, LibrarySpecificClassCreator.getCreator().getAsynchronousHttpClient());
}
/**
* Provides access to a specific users data.
*
* @param baseUrl the base URL to hit; this should be something like https://api.cloudmine.me/v1/app/{appid}/user
* @param token the users token that represents a logged in session; acquire by using CMWebService.login
* @param asynchronousHttpClient This should probably be the AndroidAsynchronousHttpClient, but you may provide your own implementation of the interface
*/
AndroidUserCMWebService(CMURLBuilder baseUrl, CMSessionToken token, AsynchronousHttpClient asynchronousHttpClient) {
super(baseUrl, token, asynchronousHttpClient);
}
publicvoid asyncChargeCardRequest(int cardPosition, String cartJson, Callback<PaymentResponse> callback){
String url = baseUrl.copy().notUser().addAction("payments").addAction("transaction").addAction("charge").asUrlString();
HttpPost paymentPost = new HttpPost(url);
addCloudMineHeader(paymentPost);
addJson(paymentPost, "{ \"cart\":" + cartJson + ", \"paymentInfo\":{\"index\":" + cardPosition + ", \"type\":\"card\"}}");
executeAsyncCommand(paymentPost, callback, PaymentResponseCallback.CONSTRUCTOR);
}
}