gpt4 book ai didi

io.sphere.sdk.shippingmethods.ZoneRate.getShippingRates()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 19:55:31 28 4
gpt4 key购买 nike

本文整理了Java中io.sphere.sdk.shippingmethods.ZoneRate.getShippingRates()方法的一些代码示例,展示了ZoneRate.getShippingRates()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneRate.getShippingRates()方法的具体详情如下:
包路径:io.sphere.sdk.shippingmethods.ZoneRate
类名称:ZoneRate
方法名:getShippingRates

ZoneRate.getShippingRates介绍

暂无

代码示例

代码示例来源:origin: io.sphere.sdk.jvm/models

default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
  final Optional<ZoneRate> zoneRateOptional = getZoneRates().stream()
      .filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
      .findFirst();
  return zoneRateOptional
      .map(rate -> rate.getShippingRates())
      .orElse(Collections.emptyList());
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
  return getZoneRates().stream()
      .filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
      .findFirst()
      .map(rate -> rate.getShippingRates())
      .orElse(Collections.emptyList());
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
  return getZoneRates().stream()
      .filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
      .findFirst()
      .map(rate -> rate.getShippingRates())
      .orElse(Collections.emptyList());
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

default List<ShippingRate> getShippingRatesForZone(final Referenceable<Zone> zone) {
  return getZoneRates().stream()
      .filter(rate -> rate.getZone().hasSameIdAs(zone.toReference()))
      .findFirst()
      .map(rate -> rate.getShippingRates())
      .orElse(Collections.emptyList());
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void execution() throws Exception {
    withShippingMethodForGermany(client(), shippingMethod -> {
      final SphereRequest<List<ShippingMethod>> sphereRequest =
          new VrapRequestDecorator<>(ShippingMethodsByLocationGet.of(CountryCode.DE).withExpansionPaths(m -> m.zones()), "response");

      final List<ShippingMethod> shippingMethodsByLocation =
          client().executeBlocking(sphereRequest);
      assertThat(shippingMethodsByLocation).isNotEmpty();

      for (final ShippingMethod shippingMethodByLocation : shippingMethodsByLocation) {
        final List<ShippingRate> shippingRates = shippingMethodByLocation.getZoneRates().stream()
            .flatMap(zoneRate -> zoneRate.getShippingRates().stream())
            .collect(Collectors.toList());

        assertThat(shippingRates).areAtLeastOne(new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
        assertThat(shippingMethodByLocation.getZones()).isNotEmpty();
        assertThat(shippingMethodByLocation.getZones().get(0).getObj()).isNotNull();
      }
    });
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void createByJson() {
    withTaxCategory(client(), taxCategory -> {
      withZone(client(), zone -> {
        final JsonNodeReferenceResolver referenceResolver = new JsonNodeReferenceResolver();
        referenceResolver.addResourceByKey("standard-tax", taxCategory);
        referenceResolver.addResourceByKey("zone-id", zone);
        final ShippingMethodDraft draft = draftFromJsonResource("drafts-tests/shippingMethod.json", ShippingMethodDraft.class, referenceResolver);
        withShippingMethod(client(), draft, shippingMethod -> {
          assertThat(shippingMethod.getName()).isEqualTo("demo shipping method");
          assertThat(shippingMethod.getTaxCategory()).isEqualTo(taxCategory.toReference());
          final ZoneRate zoneRate = shippingMethod.getZoneRates().get(0);
          assertThat(zoneRate.getZone()).isEqualTo(zone.toReference());
          final ShippingRate shippingRate = zoneRate.getShippingRates().get(0);
          assertThat(shippingRate.getPrice()).isEqualTo(EURO_20);
        });
      }, COUNTRY_CODE);
    });
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void execution() throws Exception {
  withShippingMethodForGermany(client(), shippingMethod -> {
    withCart(client(), cart -> {
      final Cart cartWithShippingAddress = client().executeBlocking(CartUpdateCommand.of(cart, SetShippingAddress.of(GERMAN_ADDRESS)));
      final SphereRequest<List<ShippingMethod>> sphereRequest =
          new VrapRequestDecorator<>(ShippingMethodsByCartGet.of(cartWithShippingAddress).plusExpansionPaths(exp -> exp.taxCategory()), "response");
      final List<ShippingMethod> shippingMethods =
          client().executeBlocking(sphereRequest);
      assertThat(shippingMethods).isNotEmpty();
      for (final ShippingMethod cartShippingMethod : shippingMethods) {
        final List<ShippingRate> shippingRates = cartShippingMethod.getZoneRates().stream()
            .flatMap(zoneRate -> zoneRate.getShippingRates().stream())
            .collect(Collectors.toList());
        assertThat(shippingRates).areExactly(1, new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
        assertThat(cartShippingMethod.getTaxCategory().getObj()).isNotNull();
      }
      return cartWithShippingAddress;
    });
  });
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void shouldReturnShippingMethodWithMatchingPredicate() throws Exception {
    final CartPredicate cartPredicate = CartPredicate.of("customer.email=\"john@example.com\"");
    withUpdateableDynamicShippingMethodForGermany(client(), cartPredicate, shippingMethod -> {
      withCart(client(), cart -> {
        final List<UpdateActionImpl<Cart>> updateActions = Arrays.asList(SetShippingAddress.of(GERMAN_ADDRESS), SetCustomerEmail.of("john@example.com"));
        final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, updateActions));

        final SphereRequest<List<ShippingMethod>> sphereRequest =
            new VrapRequestDecorator<>(ShippingMethodsByCartGet.of(updatedCart), "response");

        final List<ShippingMethod> shippingMethods =
            client().executeBlocking(sphereRequest);
        assertThat(shippingMethods).isNotEmpty();

        for (final ShippingMethod cartShippingMethod : shippingMethods) {
          final List<ShippingRate> shippingRates = cartShippingMethod.getZoneRates().stream()
              .flatMap(zoneRate -> zoneRate.getShippingRates().stream())
              .collect(Collectors.toList());

          assertThat(shippingRates).areExactly(1, new Condition<>(ShippingRate::isMatching, "Shipping rate is matching"));
        }

        return updatedCart;
      });

      return shippingMethod;
    });
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

.findFirst()
    .get();
assertThat(zoneRate.getShippingRates()).isEmpty();

代码示例来源:origin: commercetools/commercetools-jvm-sdk

final ShippingRate oldShippingRate = zoneRate.getShippingRates().get(0);
final Reference<Zone> zone = zoneRate.getZone();
final ShippingMethod updatedShippingMethod = client().executeBlocking(ShippingMethodUpdateCommand.of(shippingMethod, asList(RemoveShippingRate.of(oldShippingRate, zone), AddShippingRate.of(ShippingRate.of(EURO_10, EURO_10), zone))));

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com