Skip to content

Commit 92aa99a

Browse files
authored
Merge pull request Riskified#38 from rich-spitkovsky-riskified/registry_type
Registry type
2 parents e31b6e2 + 1381034 commit 92aa99a

3 files changed

Lines changed: 49 additions & 25 deletions

File tree

riskified-sample/src/main/java/com/riskified/samples/orderClient/SimpleClient.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static void main(String[] arg) throws FieldBadFormatException {
1717

1818
try {
1919
// Riskified client parameters can be set in the constructor, like this:
20-
// RiskifiedClient client = new RiskifiedClient("<shop_url>", "<auth_token>", Environment.SANDBOX);
20+
// RiskifiedClient client = new RiskifiedClient("<shop_url>", "<auth_token>", Environment.SANDBOX);
2121
// Or according 'riskified_sdk.properties' configuration file, like this:
2222
RiskifiedClient client = new RiskifiedClient();
2323

@@ -33,18 +33,18 @@ public static void main(String[] arg) throws FieldBadFormatException {
3333
System.out.println("category: " + resCreateOrder.getOrder().getCategory());
3434

3535
} catch (RiskifiedError e) {
36-
printError(e);
36+
printError(e);
3737
} catch (HttpResponseException e) {
38-
printError(e);
38+
printError(e);
3939
} catch (ClientProtocolException e) {
40-
printError(e);
40+
printError(e);
4141
} catch (IOException e) {
42-
printError(e);
42+
printError(e);
4343
}
4444
}
45-
45+
4646
private static void printError(Exception e) {
47-
System.out.println("[Sample failed]");
47+
System.out.println("[Sample failed]");
4848
e.printStackTrace();
4949
}
5050

@@ -73,7 +73,8 @@ private static Order generateOrder() {
7373
order.setCustomer(customer);
7474

7575
LineItem lineItem = new LineItem(200, 4, "ACME Spring", "AAA2");
76-
76+
lineItem.setRegistryType(RegistryType.other);
77+
7778
TravelLineItem travelLineItem = new TravelLineItem(340, 1, "Flight from Israel to France", "211", "B11", 1, 1);
7879
travelLineItem.setDeparturePortCode("LLBG");
7980
travelLineItem.setDepartureCountryCode("IL");
@@ -87,7 +88,7 @@ private static Order generateOrder() {
8788
travelLineItem.setCarrierCode("AF");
8889
travelLineItem.setCarrierName("Air France");
8990
travelLineItem.setRequiresShipping(false);
90-
91+
9192
order.setLineItems(Arrays.asList(new LineItem(100, 1, "ACME Widget", "101"), lineItem, travelLineItem));
9293

9394
Passenger passenger = new Passenger("john","smith");
@@ -100,20 +101,21 @@ private static Order generateOrder() {
100101
passenger.setDocumentIssueDate(getDate(1988, Calendar.MARCH, 5));
101102
passenger.setDocumentExpirationDate(getDate(2020, Calendar.MARCH, 5));
102103
passenger.setPassengerType("Adult");
103-
104+
104105
order.setPassengers(Arrays.asList(passenger));
105-
106+
106107
Seller seller = new Seller(customer);
107108
seller.setPriceNegotiated(true);
108109
seller.setStartingPrice(400);
109-
110-
110+
111+
111112
order.setDiscountCodes(Arrays.asList(new DiscountCode(19.95, "12")));
112113

113114
order.setShippingLines(Arrays.asList(new ShippingLine(123, "free")));
114115

115116
order.setPaymentDetails(new CreditCardPaymentDetails("370002", "y", "n", "xxxx-xxxx-xxxx-1234", "VISA"));
116117

118+
117119
Address address = new Address("John", "Doe", "108 Main Street", "NYC", "1234567", "United States");
118120
address.setCompany("Kansas Computers");
119121
address.setCountryCode("US");
@@ -136,22 +138,22 @@ private static Order generateOrder() {
136138

137139
Custom custom = new Custom("D2C");
138140
order.setCustom(custom);
139-
141+
140142
return order;
141143
}
142144

143145
private static Date getDate(int year, int month, int day) {
144-
return getDate(year, month, day, 0, 0, 0);
146+
return getDate(year, month, day, 0, 0, 0);
145147
}
146-
148+
147149
private static Date getDate(int year, int month, int day, int hour, int minute, int second) {
148-
Calendar cal = Calendar.getInstance();
149-
cal.set(Calendar.YEAR, year);
150-
cal.set(Calendar.MONTH, month);
151-
cal.set(Calendar.DAY_OF_MONTH, day);
152-
cal.set(Calendar.HOUR_OF_DAY, hour);
153-
cal.set(Calendar.MINUTE, minute);
154-
cal.set(Calendar.SECOND, second);
155-
return cal.getTime();
150+
Calendar cal = Calendar.getInstance();
151+
cal.set(Calendar.YEAR, year);
152+
cal.set(Calendar.MONTH, month);
153+
cal.set(Calendar.DAY_OF_MONTH, day);
154+
cal.set(Calendar.HOUR_OF_DAY, hour);
155+
cal.set(Calendar.MINUTE, minute);
156+
cal.set(Calendar.SECOND, second);
157+
return cal.getTime();
156158
}
157159
}

riskified-sdk/src/main/java/com/riskified/models/LineItem.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class LineItem implements IValidated {
3434
private String size;
3535
private Date deliveredAt;
3636
private String deliveredTo;
37+
private RegistryType registryType;
3738

3839

3940
public LineItem(double price, int quantity, String title) {
@@ -284,6 +285,12 @@ public void setDeliveredTo(String deliveredTo) {
284285
this.deliveredTo = deliveredTo;
285286
}
286287

287-
288+
public RegistryType getRegistryType() { return registryType; }
289+
290+
public void setRegistryType(RegistryType registryType) { this.registryType = registryType; }
291+
292+
293+
294+
288295

289296
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
package com.riskified.models;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public enum RegistryType {
7+
8+
@SerializedName("wedding")
9+
wedding,
10+
@SerializedName("baby")
11+
baby,
12+
@SerializedName("other")
13+
other
14+
15+
}

0 commit comments

Comments
 (0)