本文整理汇总了Java中io.particle.android.sdk.cloud.models.SignUpInfo类的典型用法代码示例。如果您正苦于以下问题:Java SignUpInfo类的具体用法?Java SignUpInfo怎么用?Java SignUpInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SignUpInfo类属于io.particle.android.sdk.cloud.models包,在下文中一共展示了SignUpInfo类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signUpAndLogInWithCustomer
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
/**
* Create new customer account on the Particle cloud and log in
*
* @param signUpInfo Required sign up information, must contain a valid email address and password
* @param orgSlug Organization slug to use
*/
@WorkerThread
public void signUpAndLogInWithCustomer(SignUpInfo signUpInfo, String orgSlug)
throws ParticleCloudException {
if (!all(signUpInfo.getUsername(), signUpInfo.getPassword(), orgSlug)) {
throw new IllegalArgumentException(
"Email, password, and organization must all be specified");
}
signUpInfo.setGrantType("client_credentials");
try {
Responses.LogInResponse response = identityApi.signUpAndLogInWithCustomer(signUpInfo, orgSlug);
onLogIn(response, signUpInfo.getUsername(), signUpInfo.getPassword());
} catch (RetrofitError error) {
throw new ParticleCloudException(error);
}
}
示例2: signUpWithUser
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
/**
* Sign up with new account credentials to Particle cloud
*
* @param signUpInfo Required sign up information, must contain a valid email address and password
*/
@WorkerThread
public void signUpWithUser(SignUpInfo signUpInfo) throws ParticleCloudException {
try {
Response response = identityApi.signUp(signUpInfo);
String bodyString = new String(((TypedByteArray) response.getBody()).getBytes());
JSONObject obj = new JSONObject(bodyString);
//workaround for sign up bug - invalid credentials bug
if (obj.has("ok") && !obj.getBoolean("ok")) {
JSONArray arrJson = obj.getJSONArray("errors");
String[] arr = new String[arrJson.length()];
for (int i = 0; i < arrJson.length(); i++) {
arr[i] = arrJson.getString(i);
}
if (arr.length > 0) {
throw new ParticleCloudException(new Exception(arr[0]));
}
}
} catch (RetrofitError error) {
throw new ParticleCloudException(error);
} catch (JSONException ignore) {
//ignore - who cares if we're not getting error response
}
}
示例3: signUpAndLogInWithCustomer
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
/**
* Create new customer account on the Particle cloud and log in
*
* @param signUpInfo Required sign up information, must contain a valid email address and password
* @param productId Product id to use
*/
@WorkerThread
public void signUpAndLogInWithCustomer(SignUpInfo signUpInfo, Integer productId)
throws ParticleCloudException {
if (!all(signUpInfo.getUsername(), signUpInfo.getPassword(), productId)) {
throw new IllegalArgumentException(
"Email, password, and product id must all be specified");
}
signUpInfo.setGrantType("client_credentials");
try {
Responses.LogInResponse response = identityApi.signUpAndLogInWithCustomer(signUpInfo, productId);
onLogIn(response, signUpInfo.getUsername(), signUpInfo.getPassword());
} catch (RetrofitError error) {
throw new ParticleCloudException(error);
}
}
示例4: signUpWithUser
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
/**
* Sign up with new account credentials to Particle cloud
*
* @param user Required user name, must be a valid email address
* @param password Required password
*/
@WorkerThread
public void signUpWithUser(String user, String password) throws ParticleCloudException {
try {
identityApi.signUp(new SignUpInfo(user, password));
} catch (RetrofitError error) {
throw new ParticleCloudException(error);
}
}
示例5: attemptSignUp
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
private void attemptSignUp() {
AccountInfo accountInfo = new AccountInfo();
accountInfo.setFirstName(firstNameView.getText().toString());
accountInfo.setLastName(lastNameView.getText().toString());
accountInfo.setCompanyName(companyNameView.getText().toString());
accountInfo.setBusinessAccount(companyChoiceView.isChecked());
// Store values at the time of the signup attempt.
final String email = emailView.getText().toString();
final String password = passwordView.getText().toString();
SignUpInfo signUpInfo = new SignUpInfo(email, password, accountInfo);
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
ParticleUi.showParticleButtonProgress(this, R.id.action_create_account, true);
final ParticleCloud cloud = ParticleCloudSDK.getCloud();
createAccountTask = Async.executeAsync(cloud, new Async.ApiWork<ParticleCloud, Void>() {
@Override
public Void callApi(@NonNull ParticleCloud particleCloud) throws ParticleCloudException {
if (useOrganizationSignup && !useProductionSignup) {
throw new ParticleCloudException(new Exception("Organization is deprecated, use productMode instead."));
// particleCloud.signUpAndLogInWithCustomer(signUpInfo, getString(R.string.organization_slug));
} else if (useProductionSignup) {
int productId = getResources().getInteger(R.integer.product_id);
if (productId == 0) {
throw new ParticleCloudException(new Exception("Product id must be set when productMode is in use."));
}
particleCloud.signUpAndLogInWithCustomer(signUpInfo, "0");
} else {
particleCloud.signUpWithUser(signUpInfo);
}
return null;
}
@Override
public void onTaskFinished() {
createAccountTask = null;
}
@Override
public void onSuccess(@NonNull Void result) {
singUpTaskSuccess(email, password, accountInfo, cloud);
}
@Override
public void onFailure(@NonNull ParticleCloudException error) {
signUpTaskFailure(error);
}
});
}
示例6: signUp
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
@POST("/v1/users")
Response signUp(@Body SignUpInfo signUpInfo);
示例7: signUpAndLogInWithCustomer
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
@POST("/v1/orgs/{orgSlug}/customers")
Responses.LogInResponse signUpAndLogInWithCustomer(@Body SignUpInfo signUpInfo,
@Path("orgSlug") String orgSlug);
示例8: signUpAndLogInWithCustomer
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
@POST("/v1/products/{productId}/customers")
Responses.LogInResponse signUpAndLogInWithCustomer(@Body SignUpInfo signUpInfo,
@Path("productId") Integer productId);
示例9: attemptSignUp
import io.particle.android.sdk.cloud.models.SignUpInfo; //导入依赖的package包/类
private void attemptSignUp() {
AccountInfo accountInfo = new AccountInfo();
accountInfo.setFirstName(firstNameView.getText().toString());
accountInfo.setLastName(lastNameView.getText().toString());
accountInfo.setCompanyName(companyNameView.getText().toString());
accountInfo.setBusinessAccount(companyChoiceView.isChecked());
// Store values at the time of the signup attempt.
final String email = emailView.getText().toString();
final String password = passwordView.getText().toString();
SignUpInfo signUpInfo = new SignUpInfo(email, password, accountInfo);
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
ParticleUi.showParticleButtonProgress(this, R.id.action_create_account, true);
final ParticleCloud cloud = ParticleCloudSDK.getCloud();
createAccountTask = Async.executeAsync(cloud, new Async.ApiWork<ParticleCloud, Void>() {
@Override
public Void callApi(@NonNull ParticleCloud particleCloud) throws ParticleCloudException {
if (useOrganizationSignup && !useProductionSignup) {
throw new ParticleCloudException(new Exception("Organization is deprecated, use productMode instead."));
} else if (useProductionSignup) {
int productId = getResources().getInteger(R.integer.product_id);
if (productId == 0) {
throw new ParticleCloudException(new Exception("Product id must be set when productMode is in use."));
}
particleCloud.signUpAndLogInWithCustomer(signUpInfo, productId);
} else {
particleCloud.signUpWithUser(signUpInfo);
}
return null;
}
@Override
public void onTaskFinished() {
createAccountTask = null;
}
@Override
public void onSuccess(@NonNull Void result) {
singUpTaskSuccess(email, password, accountInfo, cloud);
}
@Override
public void onFailure(@NonNull ParticleCloudException error) {
signUpTaskFailure(error);
}
});
}