io.particle.android.sdk.cloud.models.SignUpInfo Java Examples
The following examples show how to use
io.particle.android.sdk.cloud.models.SignUpInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 6 votes |
/** * 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 } }
Example #2
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 6 votes |
/** * 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 ParticleLoginException(error); } }
Example #3
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 6 votes |
/** * 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 * @deprecated Use product id or product slug instead */ @WorkerThread @Deprecated 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); } }
Example #4
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 5 votes |
/** * Create new customer account on the Particle cloud and log in * * @param email Required user name, must be a valid email address * @param password Required password * @param productId Product id to use */ @WorkerThread public void signUpAndLogInWithCustomer(String email, String password, Integer productId) throws ParticleCloudException { try { signUpAndLogInWithCustomer(new SignUpInfo(email, password), productId); } catch (RetrofitError error) { throw new ParticleLoginException(error); } }
Example #5
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 5 votes |
/** * Create new customer account on the Particle cloud and log in * * @param email Required user name, must be a valid email address * @param password Required password * @param orgSlug Organization slug to use * @deprecated Use product id or product slug instead */ @WorkerThread @Deprecated public void signUpAndLogInWithCustomer(String email, String password, String orgSlug) throws ParticleCloudException { try { log.w("Use product id instead of organization slug."); signUpAndLogInWithCustomer(new SignUpInfo(email, password), orgSlug); } catch (RetrofitError error) { throw new ParticleCloudException(error); } }
Example #6
Source File: CreateAccountActivity.java From particle-android with Apache License 2.0 | 4 votes |
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); } }); }
Example #7
Source File: ApiDefs.java From spark-sdk-android with Apache License 2.0 | 4 votes |
@POST("/v1/users") Response signUp(@Body SignUpInfo signUpInfo);
Example #8
Source File: ApiDefs.java From spark-sdk-android with Apache License 2.0 | 4 votes |
@POST("/v1/products/{productId}/customers") Responses.LogInResponse signUpAndLogInWithCustomer(@Body SignUpInfo signUpInfo, @Path("productId") Integer productId);
Example #9
Source File: ApiDefs.java From spark-sdk-android with Apache License 2.0 | 4 votes |
@POST("/v1/orgs/{orgSlug}/customers") @Deprecated Responses.LogInResponse signUpAndLogInWithCustomer(@Body SignUpInfo signUpInfo, @Path("orgSlug") String orgSlug);
Example #10
Source File: CreateAccountActivity.java From spark-setup-android with Apache License 2.0 | 4 votes |
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); } }); }
Example #11
Source File: ParticleCloud.java From spark-sdk-android with Apache License 2.0 | 2 votes |
/** * 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 { signUpWithUser(new SignUpInfo(user, password)); }