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