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


Java Customer類代碼示例

本文整理匯總了Java中io.sphere.sdk.customers.Customer的典型用法代碼示例。如果您正苦於以下問題:Java Customer類的具體用法?Java Customer怎麽用?Java Customer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Customer類屬於io.sphere.sdk.customers包,在下文中一共展示了Customer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildUpdateActions

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
private List<UpdateAction<Customer>> buildUpdateActions(final Customer customer, final MyPersonalDetailsFormData formData) {
    final List<UpdateAction<Customer>> updateActions = new ArrayList<>();
    final CustomerName customerName = formData.customerName();
    if (!Objects.equals(customer.getTitle(), customerName.getTitle())) {
        updateActions.add(SetTitle.of(customerName.getTitle()));
    }
    if (!Objects.equals(customer.getFirstName(), customerName.getFirstName())) {
        updateActions.add(SetFirstName.of(customerName.getFirstName()));
    }
    if (!Objects.equals(customer.getLastName(), customerName.getLastName())) {
        updateActions.add(SetLastName.of(customerName.getLastName()));
    }
    if (!Objects.equals(customer.getEmail(), formData.email())) {
        updateActions.add(ChangeEmail.of(formData.email()));
    }
    return updateActions;
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:18,代碼來源:DefaultMyPersonalDetailsControllerAction.java

示例2: buildUpdateActions

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
private List<UpdateAction<Cart>> buildUpdateActions(final Cart cart, @Nullable final Customer customer) {
    final List<UpdateAction<Cart>> updateActions = new ArrayList<>();
    final boolean hasDifferentCountry = !country.equals(cart.getCountry());
    if (hasDifferentCountry) {
        final Address shippingAddress = Optional.ofNullable(cart.getShippingAddress())
                .map(address -> address.withCountry(country))
                .orElseGet(() -> Address.of(country));
        updateActions.add(SetShippingAddress.of(shippingAddress));
        updateActions.add(SetCountry.of(country));
    }
    final boolean hasNoCustomerEmail = customer != null && cart.getCustomerEmail() == null;
    if (hasNoCustomerEmail) {
        updateActions.add(SetCustomerEmail.of(customer.getEmail()));
    }
    return updateActions;
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:17,代碼來源:CartFieldsUpdaterControllerComponent.java

示例3: CreatePaymentDataImpl

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
public CreatePaymentDataImpl(SphereClient client,
                             PaymentMethodInfo paymentMethodInfo,
                             Cart c,
                             String reference,
                             Map<String, String> config,
                             @Nullable Customer customer,
                             @Nullable HttpRequestInfo requestInfo) {
    super(client, config);

    this.paymentMethodInfo = paymentMethodInfo;
    this.cart = c;
    this.reference = reference;
    this.customer = customer;
    this.httpRequestInfo = requestInfo;
}
 
開發者ID:commercetools,項目名稱:commercetools-payment-integration-java,代碼行數:16,代碼來源:CreatePaymentDataImpl.java

示例4: setup

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
@Before
public void setup() {
    mockClient = mock(SphereClient.class);
    mockCart = mock(Cart.class);
    mockCustomer = mock(Customer.class);
    mockRequestInfo = mock(HttpRequestInfo.class);

    when(mockClient.toString()).thenReturn(CLIENT_TO_STRING);
    when(mockCart.toString()).thenReturn(CART_TO_STRING);
    when(mockCustomer.toString()).thenReturn(CUSTOMER_TO_STRING);
    when(mockRequestInfo.toString()).thenReturn(REQUEST_TO_STRING);
}
 
開發者ID:commercetools,項目名稱:commercetools-payment-integration-java,代碼行數:13,代碼來源:CreatePaymentDataTest.java

示例5: newViewModelInstance

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
@Override
protected MyPersonalDetailsPageContent newViewModelInstance(final Customer customer, final Form<? extends MyPersonalDetailsFormData> form) {
    return new MyPersonalDetailsPageContent();
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:5,代碼來源:MyPersonalDetailsPageContentFactory.java

示例6: fillPersonalDetailsForm

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
protected void fillPersonalDetailsForm(final MyPersonalDetailsPageContent viewModel, final Customer customer, final Form<? extends MyPersonalDetailsFormData> form) {
    viewModel.setPersonalDetailsForm(form);
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:4,代碼來源:MyPersonalDetailsPageContentFactory.java

示例7: createPayment

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
private CompletionStage<Payment> createPayment(final PaymentMethodsWithCart paymentMethodsWithCart, final CheckoutPaymentFormData formData) {
    final Cart cart = paymentMethodsWithCart.getCart();
    final PaymentMethodInfo paymentMethod = findPaymentMethod(paymentMethodsWithCart.getPaymentMethods(), formData);
    final PaymentDraft paymentDraft = PaymentDraftBuilder.of(cart.getTotalPrice())
            .paymentMethodInfo(paymentMethod)
            .customer(Optional.ofNullable(cart.getCustomerId()).map(Customer::referenceOfId).orElse(null))
            .build();
    return getSphereClient().execute(PaymentCreateCommand.of(paymentDraft));
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:10,代碼來源:DefaultCheckoutPaymentControllerAction.java

示例8: buildCustomerSignInResult

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
private CustomerSignInResult buildCustomerSignInResult(final Customer customer, @Nullable final Cart cart) {
    return new CustomerSignInResult() {
        @Override
        public Customer getCustomer() {
            return customer;
        }

        @Nullable
        @Override
        public Cart getCart() {
            return cart;
        }
    };
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:15,代碼來源:CartFieldsUpdaterControllerComponent.java

示例9: requireMyOrder

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
default CompletionStage<Result> requireMyOrder(final Customer customer, final String orderNumber, final Function<Order, CompletionStage<Result>> nextAction) {
    return getMyOrderFinder().apply(customer, orderNumber)
            .thenComposeAsync(orderOpt -> orderOpt
                            .map(nextAction)
                            .orElseGet(this::handleNotFoundMyOrder),
                    HttpExecution.defaultContext());
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:8,代碼來源:WithRequiredMyOrder.java

示例10: buildRequest

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
protected OrderQuery buildRequest(final Customer customer, final String identifier) {
    return OrderQuery.of().byCustomerId(customer.getId())
            .plusPredicates(order -> order.orderNumber().is(identifier))
            .plusExpansionPaths(order -> order.shippingInfo().shippingMethod())
            .plusExpansionPaths(order -> order.paymentInfo().payments())
            .withLimit(1);
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:8,代碼來源:MyOrderFinderByCustomer.java

示例11: executeRequest

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
protected final CompletionStage<Customer> executeRequest(final Customer customer, final CustomerUpdateCommand baseCommand) {
    final CustomerUpdateCommand command = CustomerUpdateCommandHook.runHook(getHookRunner(), baseCommand);
    if (!command.getUpdateActions().isEmpty()) {
        return getSphereClient().execute(command)
                .thenApplyAsync(updatedCustomer -> {
                    CustomerUpdatedHook.runHook(getHookRunner(), updatedCustomer);
                    return updatedCustomer;
                }, HttpExecution.defaultContext());
    } else {
        return completedFuture(customer);
    }
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:13,代碼來源:AbstractCustomerUpdateExecutor.java

示例12: handleClientErrorFailedAction

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
@Override
public CompletionStage<Result> handleClientErrorFailedAction(final Customer input, final Form<? extends ChangePasswordFormData> form, final ClientErrorException clientErrorException) {
    if (isCustomerInvalidCurrentPasswordError(clientErrorException)) {
        saveFormError(form, "Invalid current password"); // TODO i18n
        return showFormPageWithErrors(input, form);
    } else {
        return WithContentFormFlow.super.handleClientErrorFailedAction(input, form, clientErrorException);
    }
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:10,代碼來源:SunriseChangePasswordController.java

示例13: storeAssociatedData

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
@Override
protected void storeAssociatedData(final Customer customer) {
    session.overwriteObjectByKey(userInfoSessionKey, userInfoViewModelFactory.create(customer));
    session.overwriteValueByKey(customerIdSessionKey, customer.getId());
    session.overwriteValueByKey(customerEmailSessionKey, customer.getEmail());
    final String customerGroupId = Optional.ofNullable(customer.getCustomerGroup())
            .map(Reference::getId)
            .orElse(null);
    session.overwriteValueByKey(customerGroupIdSessionKey, customerGroupId);
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:11,代碼來源:DefaultCustomerInSession.java

示例14: requireCustomer

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
default CompletionStage<Result> requireCustomer(final Function<Customer, CompletionStage<Result>> nextAction) {
    return getCustomerFinder().get()
            .thenComposeAsync(customer -> customer
                            .map(nextAction)
                            .orElseGet(this::handleNotFoundCustomer),
                    HttpExecution.defaultContext());
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:8,代碼來源:WithRequiredCustomer.java

示例15: apply

import io.sphere.sdk.customers.Customer; //導入依賴的package包/類
@Override
public CompletionStage<Optional<Address>> apply(final Customer customer, final String identifier) {
    final Optional<Address> addressOpt = customer.getAddresses().stream()
            .filter(a -> Objects.equals(a.getId(), identifier))
            .findAny();
    addressOpt.ifPresent(address -> AddressLoadedHook.runHook(hookRunner, address));
    return completedFuture(addressOpt);
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-java,代碼行數:9,代碼來源:AddressFinderById.java


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