From a98caf7af8c961b0f7efc2226fc76e5325a27f5b Mon Sep 17 00:00:00 2001 From: Allan Bush Date: Thu, 8 Aug 2019 13:01:28 -0700 Subject: [PATCH] New build target that's compatible with Unity The only reliable (for il2cpp builds on mobile devices) newtonsoft JSON.NET library for Unity is based on version 8.0 (https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347) Create a .net 4.5 build target for Unity export Using the older 8.0 version of JSON.NET for this target to match what's supported in Unity Add explicate json property names Removing NamingStrategyType references as that feature isn't availble in JSON.NET version 8.0 --- Src/Recombee.ApiClient/Bindings/Bookmark.cs | 7 +++++-- Src/Recombee.ApiClient/Bindings/CartAddition.cs | 9 +++++++-- Src/Recombee.ApiClient/Bindings/DetailView.cs | 8 ++++++-- Src/Recombee.ApiClient/Bindings/Entity.cs | 2 ++ Src/Recombee.ApiClient/Bindings/Group.cs | 3 +-- Src/Recombee.ApiClient/Bindings/GroupItem.cs | 4 ++-- Src/Recombee.ApiClient/Bindings/Item.cs | 3 +-- Src/Recombee.ApiClient/Bindings/Logic.cs | 4 ++-- Src/Recombee.ApiClient/Bindings/PropertyInfo.cs | 4 ++-- Src/Recombee.ApiClient/Bindings/Purchase.cs | 10 ++++++++-- Src/Recombee.ApiClient/Bindings/Rating.cs | 8 ++++++-- Src/Recombee.ApiClient/Bindings/Series.cs | 3 +-- Src/Recombee.ApiClient/Bindings/SeriesItem.cs | 5 +++-- Src/Recombee.ApiClient/Bindings/User.cs | 3 +-- Src/Recombee.ApiClient/Bindings/ViewPortion.cs | 9 +++++++-- Src/Recombee.ApiClient/Recombee.ApiClient.csproj | 5 +++-- 16 files changed, 57 insertions(+), 30 deletions(-) diff --git a/Src/Recombee.ApiClient/Bindings/Bookmark.cs b/Src/Recombee.ApiClient/Bindings/Bookmark.cs index 0cc46ac..cbe8da2 100644 --- a/Src/Recombee.ApiClient/Bindings/Bookmark.cs +++ b/Src/Recombee.ApiClient/Bindings/Bookmark.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Bookmark Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Bookmark: RecombeeBinding { private readonly string userId; /// User who bookmarked the item + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Bookmarked item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} @@ -30,18 +30,21 @@ public string ItemId private readonly DateTime? timestamp; /// UTC timestamp of the bookmark as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timestamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly string recommId; /// If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Bindings/CartAddition.cs b/Src/Recombee.ApiClient/Bindings/CartAddition.cs index b881fdc..5937e11 100644 --- a/Src/Recombee.ApiClient/Bindings/CartAddition.cs +++ b/Src/Recombee.ApiClient/Bindings/CartAddition.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// CartAddition Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class CartAddition: RecombeeBinding { private readonly string userId; /// User who added the item to the cart + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Item added to the cart + [JsonProperty("itemId")] public string ItemId { get {return itemId;} @@ -30,30 +30,35 @@ public string ItemId private readonly DateTime? timestamp; /// UTC timestamp of the cart addition as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timeStamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly double? amount; /// Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2. + [JsonProperty("amount")] public double? Amount { get {return amount;} } private readonly double? price; /// Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given. + [JsonProperty("price")] public double? Price { get {return price;} } private readonly string recommId; /// If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Bindings/DetailView.cs b/Src/Recombee.ApiClient/Bindings/DetailView.cs index 27fc4de..cdfa0f0 100644 --- a/Src/Recombee.ApiClient/Bindings/DetailView.cs +++ b/Src/Recombee.ApiClient/Bindings/DetailView.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// DetailView Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class DetailView: RecombeeBinding { private readonly string userId; /// User who viewed the item + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Viewed item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} @@ -30,24 +30,28 @@ public string ItemId private readonly DateTime? timestamp; /// UTC timestamp of the view as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timestamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly long? duration; /// Duration of the view + [JsonProperty("duration")] public long? Duration { get {return duration;} } private readonly string recommId; /// If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Bindings/Entity.cs b/Src/Recombee.ApiClient/Bindings/Entity.cs index 205988c..20477c1 100644 --- a/Src/Recombee.ApiClient/Bindings/Entity.cs +++ b/Src/Recombee.ApiClient/Bindings/Entity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Newtonsoft.Json; namespace Recombee.ApiClient.Bindings { @@ -9,6 +10,7 @@ public abstract class Entity: RecombeeBinding private readonly Dictionary values; /// Values of properties + [JsonProperty("values")] public Dictionary Values { get diff --git a/Src/Recombee.ApiClient/Bindings/Group.cs b/Src/Recombee.ApiClient/Bindings/Group.cs index 44591f5..de15cf4 100644 --- a/Src/Recombee.ApiClient/Bindings/Group.cs +++ b/Src/Recombee.ApiClient/Bindings/Group.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Group Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Group: Entity { private readonly string groupId; /// Id of the group + [JsonProperty("groupId")] public string GroupId { get {return groupId;} diff --git a/Src/Recombee.ApiClient/Bindings/GroupItem.cs b/Src/Recombee.ApiClient/Bindings/GroupItem.cs index 32224c0..1832475 100644 --- a/Src/Recombee.ApiClient/Bindings/GroupItem.cs +++ b/Src/Recombee.ApiClient/Bindings/GroupItem.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// GroupItem Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class GroupItem: RecombeeBinding { private readonly string itemType; /// `item` iff the regular item from the catalog is to be inserted, `group` iff group is inserted as the item. + [JsonProperty("itemType")] public string ItemType { get {return itemType;} } private readonly string itemId; /// ID of the item iff `itemType` is `item`. ID of the group iff `itemType` is `group`. + [JsonProperty("itemId")] public string ItemId { get {return itemId;} diff --git a/Src/Recombee.ApiClient/Bindings/Item.cs b/Src/Recombee.ApiClient/Bindings/Item.cs index 2e90b3a..e7d2130 100644 --- a/Src/Recombee.ApiClient/Bindings/Item.cs +++ b/Src/Recombee.ApiClient/Bindings/Item.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Item Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Item: Entity { private readonly string itemId; /// Id of the item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} diff --git a/Src/Recombee.ApiClient/Bindings/Logic.cs b/Src/Recombee.ApiClient/Bindings/Logic.cs index 8d70561..d467764 100644 --- a/Src/Recombee.ApiClient/Bindings/Logic.cs +++ b/Src/Recombee.ApiClient/Bindings/Logic.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Logic Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Logic: RecombeeBinding { private readonly string name; /// Name of the logic that should be used + [JsonProperty("name")] public string Name { get {return name;} } private readonly Dictionary settings; /// Parameters passed to the logic + [JsonProperty("settings")] public Dictionary Settings { get {return settings;} diff --git a/Src/Recombee.ApiClient/Bindings/PropertyInfo.cs b/Src/Recombee.ApiClient/Bindings/PropertyInfo.cs index 36cfe48..4d5fa49 100644 --- a/Src/Recombee.ApiClient/Bindings/PropertyInfo.cs +++ b/Src/Recombee.ApiClient/Bindings/PropertyInfo.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// PropertyInfo Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class PropertyInfo: RecombeeBinding { private readonly string name; /// Name of the property + [JsonProperty("name")] public string Name { get {return name;} } private readonly string type; /// Type of the property + [JsonProperty("type")] public string Type { get {return type;} diff --git a/Src/Recombee.ApiClient/Bindings/Purchase.cs b/Src/Recombee.ApiClient/Bindings/Purchase.cs index 833ad07..57163c2 100644 --- a/Src/Recombee.ApiClient/Bindings/Purchase.cs +++ b/Src/Recombee.ApiClient/Bindings/Purchase.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Purchase Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Purchase: RecombeeBinding { private readonly string userId; /// User who purchased the item + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Purchased item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} @@ -30,36 +30,42 @@ public string ItemId private readonly DateTime? timestamp; /// UTC timestamp of the purchase as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timestamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly double? amount; /// Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2. + [JsonProperty("amount")] public double? Amount { get {return amount;} } private readonly double? price; /// Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given. + [JsonProperty("price")] public double? Price { get {return price;} } private readonly double? profit; /// Your profit from the purchased item. The profit is natural in e-commerce domain (for example if `user-x` purchases `item-y` for $100 and the gross margin is 30 %, then the profit is $30), but is applicable also in other domains (for example at a news company it may be income from displayed advertisement on article page). If `amount` is greater than 1, sum of profit of all the items should be given. + [JsonProperty("profit")] public double? Profit { get {return profit;} } private readonly string recommId; /// If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Bindings/Rating.cs b/Src/Recombee.ApiClient/Bindings/Rating.cs index b591395..9dbf023 100644 --- a/Src/Recombee.ApiClient/Bindings/Rating.cs +++ b/Src/Recombee.ApiClient/Bindings/Rating.cs @@ -5,23 +5,23 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Rating Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Rating: RecombeeBinding { private readonly string userId; /// User who submitted the rating + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Rated item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} @@ -30,24 +30,28 @@ public string ItemId private readonly DateTime? timestamp; /// UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timestamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly double rating; /// Rating rescaled to interval [-1.0,1.0], where -1.0 means the worst rating possible, 0.0 means neutral, and 1.0 means absolutely positive rating. For example, in the case of 5-star evaluations, rating = (numStars-3)/2 formula may be used for the conversion. + [JsonProperty("ratingValue")] public double RatingValue { get {return rating;} } private readonly string recommId; /// If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Bindings/Series.cs b/Src/Recombee.ApiClient/Bindings/Series.cs index f53f693..b233b27 100644 --- a/Src/Recombee.ApiClient/Bindings/Series.cs +++ b/Src/Recombee.ApiClient/Bindings/Series.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// Series Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class Series: Entity { private readonly string seriesId; /// Id of the series + [JsonProperty("seriesId")] public string SeriesId { get {return seriesId;} diff --git a/Src/Recombee.ApiClient/Bindings/SeriesItem.cs b/Src/Recombee.ApiClient/Bindings/SeriesItem.cs index 3c200b0..b9bd0d9 100644 --- a/Src/Recombee.ApiClient/Bindings/SeriesItem.cs +++ b/Src/Recombee.ApiClient/Bindings/SeriesItem.cs @@ -5,29 +5,30 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// SeriesItem Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class SeriesItem: RecombeeBinding { private readonly string itemType; /// `item` iff the regular item from the catalog is to be inserted, `series` iff series is inserted as the item. + [JsonProperty("itemType")] public string ItemType { get {return itemType;} } private readonly string itemId; /// ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`. + [JsonProperty("itemId")] public string ItemId { get {return itemId;} } private readonly double time; /// Time index used for sorting items in the series. According to time, items are sorted within series in ascending order. In the example of TV show episodes, the episode number is a natural choice to be passed as time. + [JsonProperty("time")] public double Time { get {return time;} diff --git a/Src/Recombee.ApiClient/Bindings/User.cs b/Src/Recombee.ApiClient/Bindings/User.cs index 4576ef1..055dcf1 100644 --- a/Src/Recombee.ApiClient/Bindings/User.cs +++ b/Src/Recombee.ApiClient/Bindings/User.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// User Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class User: Entity { private readonly string userId; /// Id of the user + [JsonProperty("userId")] public string UserId { get {return userId;} diff --git a/Src/Recombee.ApiClient/Bindings/ViewPortion.cs b/Src/Recombee.ApiClient/Bindings/ViewPortion.cs index f3624ba..2f1032e 100644 --- a/Src/Recombee.ApiClient/Bindings/ViewPortion.cs +++ b/Src/Recombee.ApiClient/Bindings/ViewPortion.cs @@ -5,35 +5,37 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using Recombee.ApiClient.Util; namespace Recombee.ApiClient.Bindings { /// ViewPortion Binding - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class ViewPortion: RecombeeBinding { private readonly string userId; /// User who viewed a portion of the item + [JsonProperty("userId")] public string UserId { get {return userId;} } private readonly string itemId; /// Viewed item + [JsonProperty("itemId")] public string ItemId { get {return itemId;} } private readonly double portion; /// Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the really viewed part of the item, no matter seeking, so for example if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`. + [JsonProperty("portion")] public double Portion { get {return portion;} } private readonly string sessionId; /// ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language). + [JsonProperty("sessionId")] public string SessionId { get {return sessionId;} @@ -42,18 +44,21 @@ public string SessionId private readonly DateTime? timestamp; /// UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. [JsonConverter(typeof(EpochJsonReader))] + [JsonProperty("timestamp")] public DateTime? Timestamp { get {return timestamp;} } private readonly string recommId; /// If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation. + [JsonProperty("recommId")] public string RecommId { get {return recommId;} } private readonly Dictionary additionalData; /// A dictionary of additional data for the interaction. + [JsonProperty("additionalData")] public Dictionary AdditionalData { get {return additionalData;} diff --git a/Src/Recombee.ApiClient/Recombee.ApiClient.csproj b/Src/Recombee.ApiClient/Recombee.ApiClient.csproj index 22328e5..ceb93ce 100644 --- a/Src/Recombee.ApiClient/Recombee.ApiClient.csproj +++ b/Src/Recombee.ApiClient/Recombee.ApiClient.csproj @@ -1,9 +1,10 @@  - netstandard1.3;netcoreapp1.1;netcoreapp2.0 + net452;netstandard1.3;netcoreapp1.1;netcoreapp2.0 - + +