Skip to content

Commit

Permalink
Added gift card support
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri Mosseri committed Dec 9, 2015
1 parent ab651b3 commit e49ee40
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 10 deletions.
17 changes: 15 additions & 2 deletions Riskified.SDK.Sample/OrderTransmissionExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private static Order GenerateOrder(int orderNum)

var items = new[]
{
new LineItem(title: "Bag",price: 55.44,quantityPurchased: 1,productId: 48484,sku: "1272727"),
new LineItem(title: "Bag",price: 55.44,quantityPurchased: 1,productId: 48484,sku: "1272727",deliveredTo: DeliveredToType.StorePickup),
new LineItem(title: "Monster", price: 22.3, quantityPurchased: 3, seller: new Seller(customer: customer,correspondence: 1, priceNegotiated: true, startingPrice: 120)),
// Events Tickets Industry
new LineItem(title: "Concert",
Expand All @@ -372,7 +372,20 @@ private static Order GenerateOrder(int orderNum)
eventCountry: "USA",
eventCountryCode: "US",
latitude: 0,
longitude: 0)
longitude: 0),
// Digital Goods (giftcard) industry
new LineItem(title: "Concert",
price: 123,
quantityPurchased: 1,
sender_name: "John",
display_name: "JohnJohn",
photo_uploaded: true,
photo_url: "http://my_pic_url",
greeting_photo_url: "http://my_greeting_pic_url",
message: "Happy Birthday",
greeting_message: "Happy Birthday from John",
card_type: "regular",
card_sub_type: "birthday"),
};

var discountCodes = new[] { new DiscountCode(moneyDiscountSum: 7, code: "1") };
Expand Down
72 changes: 66 additions & 6 deletions Riskified.SDK/Model/OrderElements/LineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class LineItem : IJsonSerializable
/// <param name="sku">The stock keeping unit of the product (optional)</param>
public LineItem(string title,
double price,
int quantityPurchased,
int quantityPurchased,

//optional
int? productId = null,
string sku = null,
string condition = null,
bool? requiresShipping = null,
Seller seller = null,
string sender_name = null,
string display_name = null,
DeliveredToType deliveredTo = DeliveredToType.ShippingAddress,
DeliveredToType? deliveredTo = null,

// These are for events tickets industry
string category = null,
Expand All @@ -37,7 +37,18 @@ public LineItem(string title,
string eventCountry = null,
string eventCountryCode = null,
float? latitude = null,
float? longitude = null)
float? longitude = null,

// These are for digital goods (gift card) industry
string sender_name = null,
string display_name = null,
bool photo_uploaded = false,
string photo_url = null,
string greeting_photo_url = null,
string message = null,
string greeting_message = null,
string card_type = null,
string card_sub_type = null)
{

Title = title;
Expand Down Expand Up @@ -66,6 +77,13 @@ public LineItem(string title,
// Digital Goods (gift cards)
SenderName = sender_name;
DisplayName = display_name;
PhotoUploaded = photo_uploaded;
PhotoUrl = photo_url;
GreetingPhotoUrl = greeting_photo_url;
Message = message;
GreetingMessage = greeting_message;
CardType = card_type;
CardSubtype = card_sub_type;
}

/// <summary>
Expand Down Expand Up @@ -198,7 +216,7 @@ public void Validate(Validations validationType = Validations.Weak)
/// </summary>
[JsonProperty(PropertyName = "delivered_to")]
[JsonConverter(typeof(StringEnumConverter))]
public DeliveredToType DeliveredTo { get; set; }
public DeliveredToType? DeliveredTo { get; set; }

/// <summary>
/// The digital good's (giftcard) sender name.
Expand All @@ -211,5 +229,47 @@ public void Validate(Validations validationType = Validations.Weak)
/// </summary>
[JsonProperty(PropertyName = "display_name")]
public string DisplayName { get; set; }

/// <summary>
/// Is the gift card sender added a photo.
/// </summary>
[JsonProperty(PropertyName = "photo_uploaded")]
public bool PhotoUploaded { get; set; }

/// <summary>
/// The digital good's (giftcard) sender photo's url.
/// </summary>
[JsonProperty(PropertyName = "photo_url")]
public string PhotoUrl { get; set; }

/// <summary>
/// The digital good's (giftcard) greeting's photo url.
/// </summary>
[JsonProperty(PropertyName = "greeting_photo_url")]
public string GreetingPhotoUrl { get; set; }

/// <summary>
/// The digital good's (giftcard) message.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }

/// <summary>
/// The digital good's (giftcard) greeting message.
/// </summary>
[JsonProperty(PropertyName = "greeting_message")]
public string GreetingMessage { get; set; }

/// <summary>
/// The digital good's (giftcard) type.
/// </summary>
[JsonProperty(PropertyName = "card_type")]
public string CardType { get; set; }

/// <summary>
/// The digital good's (giftcard) sub type.
/// </summary>
[JsonProperty(PropertyName = "card_subtype")]
public string CardSubtype { get; set; }
}
}
4 changes: 2 additions & 2 deletions Riskified.SDK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.4.1")]
[assembly: AssemblyFileVersion("2.0.4.1")]
[assembly: AssemblyVersion("2.0.4.2")]
[assembly: AssemblyFileVersion("2.0.4.2")]

0 comments on commit e49ee40

Please sign in to comment.