Skip to content

Commit

Permalink
Merge pull request Riskified#38 from rich-spitkovsky-riskified/regist…
Browse files Browse the repository at this point in the history
…ry_type

Registry type
  • Loading branch information
arungopalRF authored May 23, 2019
2 parents e31b6e2 + 1381034 commit 92aa99a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void main(String[] arg) throws FieldBadFormatException {

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

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

} catch (RiskifiedError e) {
printError(e);
printError(e);
} catch (HttpResponseException e) {
printError(e);
printError(e);
} catch (ClientProtocolException e) {
printError(e);
printError(e);
} catch (IOException e) {
printError(e);
printError(e);
}
}

private static void printError(Exception e) {
System.out.println("[Sample failed]");
System.out.println("[Sample failed]");
e.printStackTrace();
}

Expand Down Expand Up @@ -73,7 +73,8 @@ private static Order generateOrder() {
order.setCustomer(customer);

LineItem lineItem = new LineItem(200, 4, "ACME Spring", "AAA2");

lineItem.setRegistryType(RegistryType.other);

TravelLineItem travelLineItem = new TravelLineItem(340, 1, "Flight from Israel to France", "211", "B11", 1, 1);
travelLineItem.setDeparturePortCode("LLBG");
travelLineItem.setDepartureCountryCode("IL");
Expand All @@ -87,7 +88,7 @@ private static Order generateOrder() {
travelLineItem.setCarrierCode("AF");
travelLineItem.setCarrierName("Air France");
travelLineItem.setRequiresShipping(false);

order.setLineItems(Arrays.asList(new LineItem(100, 1, "ACME Widget", "101"), lineItem, travelLineItem));

Passenger passenger = new Passenger("john","smith");
Expand All @@ -100,20 +101,21 @@ private static Order generateOrder() {
passenger.setDocumentIssueDate(getDate(1988, Calendar.MARCH, 5));
passenger.setDocumentExpirationDate(getDate(2020, Calendar.MARCH, 5));
passenger.setPassengerType("Adult");

order.setPassengers(Arrays.asList(passenger));

Seller seller = new Seller(customer);
seller.setPriceNegotiated(true);
seller.setStartingPrice(400);


order.setDiscountCodes(Arrays.asList(new DiscountCode(19.95, "12")));

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

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


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

Custom custom = new Custom("D2C");
order.setCustom(custom);

return order;
}

private static Date getDate(int year, int month, int day) {
return getDate(year, month, day, 0, 0, 0);
return getDate(year, month, day, 0, 0, 0);
}

private static Date getDate(int year, int month, int day, int hour, int minute, int second) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
return cal.getTime();
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
return cal.getTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class LineItem implements IValidated {
private String size;
private Date deliveredAt;
private String deliveredTo;
private RegistryType registryType;


public LineItem(double price, int quantity, String title) {
Expand Down Expand Up @@ -284,6 +285,12 @@ public void setDeliveredTo(String deliveredTo) {
this.deliveredTo = deliveredTo;
}


public RegistryType getRegistryType() { return registryType; }

public void setRegistryType(RegistryType registryType) { this.registryType = registryType; }





}
15 changes: 15 additions & 0 deletions riskified-sdk/src/main/java/com/riskified/models/RegistryType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

package com.riskified.models;

import com.google.gson.annotations.SerializedName;

public enum RegistryType {

@SerializedName("wedding")
wedding,
@SerializedName("baby")
baby,
@SerializedName("other")
other

}

0 comments on commit 92aa99a

Please sign in to comment.