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));
}
});
}
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;
}
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());
}
}
Aggregations