當前位置: 首頁>>代碼示例>>Java>>正文


Java SignUpInfo類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:23,代碼來源:ParticleCloud.java

示例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
    }
}
 
開發者ID:particle-iot,項目名稱:spark-sdk-android,代碼行數:31,代碼來源:ParticleCloud.java

示例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);
    }
}
 
開發者ID:particle-iot,項目名稱:spark-sdk-android,代碼行數:23,代碼來源:ParticleCloud.java

示例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);
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:15,代碼來源:ParticleCloud.java

示例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);
            }
        });
    }
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:49,代碼來源:CreateAccountActivity.java

示例6: signUp

import io.particle.android.sdk.cloud.models.SignUpInfo; //導入依賴的package包/類
@POST("/v1/users")
Response signUp(@Body SignUpInfo signUpInfo);
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:3,代碼來源:ApiDefs.java

示例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);
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:4,代碼來源:ApiDefs.java

示例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);
 
開發者ID:particle-iot,項目名稱:spark-sdk-android,代碼行數:4,代碼來源:ApiDefs.java

示例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);
        }
    });
}
 
開發者ID:particle-iot,項目名稱:spark-setup-android,代碼行數:48,代碼來源:CreateAccountActivity.java


注:本文中的io.particle.android.sdk.cloud.models.SignUpInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。