当前位置: 首页>>代码示例>>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;未经允许,请勿转载。