Skip to content

Commit b314a18

Browse files
committed
Merge branch 'release/1.7.0'
2 parents 08ecece + 92fe01f commit b314a18

File tree

5 files changed

+1384
-1297
lines changed

5 files changed

+1384
-1297
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.channelape</groupId>
66
<artifactId>shopify-sdk</artifactId>
7-
<version>1.6.0</version>
7+
<version>1.7.0</version>
88

99
<name>Shopify SDK</name>
1010
<description>Java SDK for Shopify REST API.</description>

src/main/java/com/shopify/model/ShopifyOrderCreationRequest.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ public static interface MetafieldsStep {
4040
}
4141

4242
public static interface ShippingLinesStep {
43-
BuildStep withShippingLines(List<ShopifyShippingLine> shippingLines);
43+
OptionalsStep withShippingLines(List<ShopifyShippingLine> shippingLines);
4444
}
4545

46-
public static interface BuildStep {
46+
public static interface OptionalsStep {
47+
OptionalsStep withNoteAttributes(final List<ShopifyAttribute> noteAttributes);
48+
49+
OptionalsStep withNote(final String note);
50+
51+
OptionalsStep withFinancialStatus(final String financialStatus);
52+
4753
ShopifyOrderCreationRequest build();
4854
}
4955

@@ -60,7 +66,7 @@ private ShopifyOrderCreationRequest(final ShopifyOrder request) {
6066
}
6167

6268
private static class Steps implements ProcessedAtStep, NameStep, CustomerStep, MetafieldsStep, LineItemsStep,
63-
ShippingAddressStep, BillingAddressStep, ShippingLinesStep, BuildStep {
69+
ShippingAddressStep, BillingAddressStep, ShippingLinesStep, OptionalsStep {
6470

6571
private final ShopifyOrder request = new ShopifyOrder();
6672

@@ -118,11 +124,29 @@ public CustomerStep withName(final String name) {
118124
}
119125

120126
@Override
121-
public BuildStep withShippingLines(final List<ShopifyShippingLine> shippingLines) {
127+
public OptionalsStep withShippingLines(final List<ShopifyShippingLine> shippingLines) {
122128
request.setShippingLines(shippingLines);
123129
return this;
124130
}
125131

132+
@Override
133+
public OptionalsStep withNoteAttributes(final List<ShopifyAttribute> noteAttributes) {
134+
request.setNoteAttributes(noteAttributes);
135+
return this;
136+
}
137+
138+
@Override
139+
public OptionalsStep withNote(final String note) {
140+
request.setNote(note);
141+
return this;
142+
}
143+
144+
@Override
145+
public OptionalsStep withFinancialStatus(final String financialStatus) {
146+
request.setFinancialStatus(financialStatus);
147+
return this;
148+
}
149+
126150
}
127151

128152
}

src/test/java/com/shopify/ShopifySdkDriver.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Collections;
1212
import java.util.List;
1313
import java.util.Random;
14+
import java.util.UUID;
1415
import java.util.concurrent.TimeUnit;
1516
import java.util.stream.Collectors;
1617

@@ -29,6 +30,7 @@
2930
import com.shopify.model.MetafieldValueType;
3031
import com.shopify.model.Shop;
3132
import com.shopify.model.ShopifyAddress;
33+
import com.shopify.model.ShopifyAttribute;
3234
import com.shopify.model.ShopifyCustomer;
3335
import com.shopify.model.ShopifyCustomerUpdateRequest;
3436
import com.shopify.model.ShopifyFulfillment;
@@ -53,6 +55,7 @@
5355
import com.shopify.model.ShopifyRefundLineItem;
5456
import com.shopify.model.ShopifyRefundRoot;
5557
import com.shopify.model.ShopifyRefundShippingDetails;
58+
import com.shopify.model.ShopifyShippingLine;
5659
import com.shopify.model.ShopifyTransaction;
5760
import com.shopify.model.ShopifyVariant;
5861
import com.shopify.model.ShopifyVariantMetafieldCreationRequest;
@@ -557,11 +560,32 @@ public void givenSomeOrderWhenCreatingOrderThenCreateOrder() throws JsonProcessi
557560
shopifyAddress.setProvinceCode("PA");
558561
shopifyAddress.setZip("92387423");
559562

563+
final ShopifyShippingLine shopifyShippingLine1 = new ShopifyShippingLine();
564+
shopifyShippingLine1.setId("123");
565+
shopifyShippingLine1.setPrice(new BigDecimal(42.11));
566+
shopifyShippingLine1.setSource("some-source");
567+
shopifyShippingLine1.setTitle("some-title");
568+
shopifyShippingLine1.setCode("sc");
569+
final List<ShopifyShippingLine> shopifyShippingLines = Arrays.asList(shopifyShippingLine1);
570+
571+
final ShopifyAttribute shopifyAttribute1 = new ShopifyAttribute();
572+
shopifyAttribute1.setName("some-name1");
573+
shopifyAttribute1.setValue("some-value1");
574+
final ShopifyAttribute shopifyAttribute2 = new ShopifyAttribute();
575+
shopifyAttribute2.setName("some-name2");
576+
shopifyAttribute2.setValue("some-value2");
577+
final ShopifyAttribute shopifyAttribute3 = new ShopifyAttribute();
578+
shopifyAttribute3.setName("some-name3");
579+
shopifyAttribute3.setValue("some-value3");
580+
final List<ShopifyAttribute> someNoteAttributes = Arrays.asList(shopifyAttribute1, shopifyAttribute2,
581+
shopifyAttribute3);
582+
560583
final ShopifyOrderCreationRequest shopifyOrderCreationRequest = ShopifyOrderCreationRequest.newBuilder()
561-
.withProcessedAt(new DateTime()).withName("some-cool-po-number").withCustomer(shopifyCustomer)
584+
.withProcessedAt(new DateTime()).withName(UUID.randomUUID().toString()).withCustomer(shopifyCustomer)
562585
.withLineItems(Arrays.asList(shopifyLineItem1)).withShippingAddress(shopifyAddress)
563586
.withBillingAddress(shopifyAddress).withMetafields(Collections.emptyList())
564-
.withShippingLines(Collections.emptyList()).build();
587+
.withShippingLines(shopifyShippingLines).withFinancialStatus("pending").withNote("some-note123")
588+
.withNoteAttributes(someNoteAttributes).build();
565589
final ObjectMapper mapper = new ObjectMapper();
566590
mapper.setSerializationInclusion(Include.NON_NULL);
567591
final String dtoAsString = mapper.writeValueAsString(shopifyOrderCreationRequest);

src/test/java/com/shopify/ShopifySdkTest.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.shopify.model.Shop;
5252
import com.shopify.model.ShopifyAccessTokenRoot;
5353
import com.shopify.model.ShopifyAddress;
54+
import com.shopify.model.ShopifyAttribute;
5455
import com.shopify.model.ShopifyCustomer;
5556
import com.shopify.model.ShopifyCustomerRoot;
5657
import com.shopify.model.ShopifyCustomerUpdateRequest;
@@ -1871,7 +1872,22 @@ public void givenSomeValidAccessTokenAndSubdomainAndValidRequestAndCreatingOrder
18711872
shippingLine1.setTitle("Testing Title");
18721873
shippingLine1.setPrice(new BigDecimal(4.33));
18731874
shopifyOrder.setShippingLines(Arrays.asList(shippingLine1));
1874-
1875+
shopifyOrder.setFinancialStatus("pending");
1876+
shopifyOrder.setNote("Some note");
1877+
1878+
final ShopifyAttribute shopifyAttribute1 = new ShopifyAttribute();
1879+
shopifyAttribute1.setName("some-name1");
1880+
shopifyAttribute1.setValue("some-value1");
1881+
final ShopifyAttribute shopifyAttribute2 = new ShopifyAttribute();
1882+
shopifyAttribute2.setName("some-name2");
1883+
shopifyAttribute2.setValue("some-value2");
1884+
final ShopifyAttribute shopifyAttribute3 = new ShopifyAttribute();
1885+
shopifyAttribute3.setName("some-name3");
1886+
shopifyAttribute3.setValue("some-value3");
1887+
final List<ShopifyAttribute> someNoteAttributes = Arrays.asList(shopifyAttribute1, shopifyAttribute2,
1888+
shopifyAttribute3);
1889+
1890+
shopifyOrder.setNoteAttributes(someNoteAttributes);
18751891
shopifyOrderRoot.setOrder(shopifyOrder);
18761892

18771893
final String expectedResponseBodyString = getJsonString(ShopifyOrderRoot.class, shopifyOrderRoot);
@@ -1887,7 +1903,8 @@ public void givenSomeValidAccessTokenAndSubdomainAndValidRequestAndCreatingOrder
18871903
final ShopifyOrderCreationRequest shopifyOrderRequest = ShopifyOrderCreationRequest.newBuilder()
18881904
.withProcessedAt(processedAt).withName("123456").withCustomer(shopifyCustomer)
18891905
.withLineItems(shopifyLineItems).withShippingAddress(address).withBillingAddress(address)
1890-
.withMetafields(Collections.emptyList()).withShippingLines(Arrays.asList(shippingLine1)).build();
1906+
.withMetafields(Collections.emptyList()).withShippingLines(Arrays.asList(shippingLine1))
1907+
.withFinancialStatus("pending").withNote("Some note").withNoteAttributes(someNoteAttributes).build();
18911908
final ShopifyOrder actualShopifyOrder = shopifySdk.createOrder(shopifyOrderRequest);
18921909

18931910
assertEquals("123456", actualRequestBody.getContent().get("order").get("name").asText());
@@ -1920,6 +1937,22 @@ public void givenSomeValidAccessTokenAndSubdomainAndValidRequestAndCreatingOrder
19201937
assertEquals(0, actualRequestBody.getContent().get("order").get("line_items").path(1)
19211938
.get("fulfillable_quantity").asInt());
19221939

1940+
assertEquals("pending", actualRequestBody.getContent().get("order").get("financial_status").asText());
1941+
assertEquals("Some note", actualRequestBody.getContent().get("order").get("note").asText());
1942+
assertEquals(3, actualRequestBody.getContent().get("order").get("note_attributes").size());
1943+
assertEquals(someNoteAttributes.get(0).getName(),
1944+
actualRequestBody.getContent().get("order").get("note_attributes").path(0).get("name").asText());
1945+
assertEquals(someNoteAttributes.get(0).getValue(),
1946+
actualRequestBody.getContent().get("order").get("note_attributes").path(0).get("value").asText());
1947+
assertEquals(someNoteAttributes.get(1).getName(),
1948+
actualRequestBody.getContent().get("order").get("note_attributes").path(1).get("name").asText());
1949+
assertEquals(someNoteAttributes.get(1).getValue(),
1950+
actualRequestBody.getContent().get("order").get("note_attributes").path(1).get("value").asText());
1951+
assertEquals(someNoteAttributes.get(2).getName(),
1952+
actualRequestBody.getContent().get("order").get("note_attributes").path(2).get("name").asText());
1953+
assertEquals(someNoteAttributes.get(2).getValue(),
1954+
actualRequestBody.getContent().get("order").get("note_attributes").path(2).get("value").asText());
1955+
19231956
assertEquals("Customer-Id", actualRequestBody.getContent().get("order").get("customer").get("id").asText());
19241957
assertEquals("Ryan", actualRequestBody.getContent().get("order").get("customer").get("first_name").asText());
19251958
assertEquals("Kazokas", actualRequestBody.getContent().get("order").get("customer").get("last_name").asText());

0 commit comments

Comments
 (0)