Search in sources :

Example 1 with Account

use of com.arm.mbed.cloud.sdk.accountmanagement.model.Account in project mbed-cloud-sdk-java by ARMmbed.

the class AccountManagement method updateAccount.

/**
 * Updates details of account associated with current API key.
 * <p>
 * Example:
 *
 * <pre>
 * {@code Account account = accountManagementApi.getAccount()
 *     account.setCity("Austin");
 *     accoujnt.setState("Texas");
 *     account.setCountry("US");
 *
 *     accountManagementApi.updateAccount(account);
 * }
 * </pre>
 *
 * @param account
 *            The account object to update.
 * @return updated account.
 * @throws MbedCloudException
 *             if a problem occurred during request processing.
 */
@API
@Nullable
public Account updateAccount(@NonNull Account account) throws MbedCloudException {
    checkNotNull(account, TAG_ACCOUNT);
    checkModelValidity(account, TAG_ACCOUNT);
    final Account finalAccount = account;
    return CloudCaller.call(this, "updateAccount()", AccountAdapter.getMapper(), new CloudCall<AccountInfo>() {

        @Override
        public Call<AccountInfo> call() {
            return endpoint.getAdmin().updateMyAccount(AccountAdapter.reverseMap(finalAccount));
        }
    });
}
Also used : Account(com.arm.mbed.cloud.sdk.accountmanagement.model.Account) CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) Call(retrofit2.Call) AccountInfo(com.arm.mbed.cloud.sdk.internal.iam.model.AccountInfo) API(com.arm.mbed.cloud.sdk.annotations.API) Nullable(com.arm.mbed.cloud.sdk.annotations.Nullable)

Example 2 with Account

use of com.arm.mbed.cloud.sdk.accountmanagement.model.Account in project mbed-cloud-sdk-java by ARMmbed.

the class AccountAdapter method map.

/**
 * Maps account objects.
 *
 * @param accountInfo
 *            accountInfo.
 * @return an account.
 */
public static Account map(AccountInfo accountInfo) {
    if (accountInfo == null) {
        return null;
    }
    final Account account = new Account(accountInfo.getId(), toStatus(accountInfo.getStatus()), accountInfo.getCustomerNumber(), accountInfo.getSalesContact(), accountInfo.getContractNumber(), accountInfo.getReferenceNote(), accountInfo.getTier(), TranslationUtils.toDate(accountInfo.getCreatedAt()), TranslationUtils.toDate(accountInfo.getUpgradedAt()), TranslationUtils.toDate(accountInfo.getUpdatedAt()), accountInfo.getLimits(), PolicyAdapter.mapList(accountInfo.getPolicies()), accountInfo.getTemplateId(), accountInfo.getReason());
    account.setDisplayName(accountInfo.getDisplayName());
    account.setContact(accountInfo.getContact());
    account.setCompany(accountInfo.getCompany());
    account.setPhoneNumber(accountInfo.getPhoneNumber());
    account.setPostcode(accountInfo.getPostalCode());
    account.setAddressLine1(accountInfo.getAddressLine1());
    account.setAddressLine2(accountInfo.getAddressLine2());
    account.setCity(accountInfo.getCity());
    account.setState(accountInfo.getState());
    account.setCountry(accountInfo.getCountry());
    account.setEmail(accountInfo.getEmail());
    account.setAliases(accountInfo.getAliases());
    account.setCustomProperties(accountInfo.getAccountProperties());
    account.setExpiryWarning(TranslationUtils.toLong(accountInfo.getExpirationWarningThreshold(), Account.DEFAULT_EXPIRY_WARNING));
    account.setMultifactorAuthenticationStatus(toMultifactorAuthenticationStatus(accountInfo.getMfaStatus()));
    account.setNotificationEmails(accountInfo.getNotificationEmails());
    return account;
}
Also used : Account(com.arm.mbed.cloud.sdk.accountmanagement.model.Account)

Example 3 with Account

use of com.arm.mbed.cloud.sdk.accountmanagement.model.Account in project mbed-cloud-sdk-java by ARMmbed.

the class AccountManagementExamples method getAccount.

/**
 * Gets details of the account associated with this API key.
 */
@Example
public void getAccount() {
    ConnectionOptions config = Configuration.get();
    AccountManagement api = new AccountManagement(config);
    try {
        Account thisAccount;
        thisAccount = api.getAccount();
        log("This account", thisAccount);
    } catch (Exception e) {
        logError("last API Metadata", api.getLastApiMetadata());
        fail(e.getMessage());
    }
}
Also used : Account(com.arm.mbed.cloud.sdk.accountmanagement.model.Account) ConnectionOptions(com.arm.mbed.cloud.sdk.common.ConnectionOptions) AccountManagement(com.arm.mbed.cloud.sdk.AccountManagement) AbstractExample(utils.AbstractExample) Example(utils.Example)

Aggregations

Account (com.arm.mbed.cloud.sdk.accountmanagement.model.Account)3 AccountManagement (com.arm.mbed.cloud.sdk.AccountManagement)1 API (com.arm.mbed.cloud.sdk.annotations.API)1 Nullable (com.arm.mbed.cloud.sdk.annotations.Nullable)1 CloudCall (com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall)1 ConnectionOptions (com.arm.mbed.cloud.sdk.common.ConnectionOptions)1 AccountInfo (com.arm.mbed.cloud.sdk.internal.iam.model.AccountInfo)1 Call (retrofit2.Call)1 AbstractExample (utils.AbstractExample)1 Example (utils.Example)1