Skip to content

Commit

Permalink
Fix TNT-40917 Zero numeric values not included in serialized Delivery…
Browse files Browse the repository at this point in the history
… request (#18)

* Fix TNT-40917 Zero numeric values not included in serialized Delivery request

* Fix security vulnerabilities in dev dependencies
  • Loading branch information
XDex authored May 12, 2021
1 parent a99e09c commit ff97305
Show file tree
Hide file tree
Showing 40 changed files with 499 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Source/Adobe.Target.Delivery/Adobe.Target.Delivery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RestSharp" Version="106.11.4" />
<PackageReference Include="Polly" Version="7.2.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions Source/Adobe.Target.Delivery/Client/ClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public static Multimap<string, string> ParameterToMultiMap(string collectionForm
parameters.Add(name, ParameterToString(item));
}
}
else if (value is IDictionary dictionary)
{
if(collectionFormat == "deepObject") {
foreach (DictionaryEntry entry in dictionary)
{
parameters.Add(name + "[" + entry.Key + "]", ParameterToString(entry.Value));
}
}
else {
foreach (DictionaryEntry entry in dictionary)
{
parameters.Add(entry.Key.ToString(), ParameterToString(entry.Value));
}
}
}
else
{
parameters.Add(name, ParameterToString(value));
Expand Down
1 change: 1 addition & 0 deletions Source/Adobe.Target.Delivery/Model/AnalyticsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Adobe.Target.Delivery.Model
[DataContract(Name = "AnalyticsRequest")]
public partial class AnalyticsRequest : IEquatable<AnalyticsRequest>, IValidatableObject
{

/// <summary>
/// Gets or Sets Logging
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/AudienceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public partial class AudienceManager : IEquatable<AudienceManager>, IValidatable
/// </summary>
/// <param name="locationHint">DCS location hint. Used to determine which AAM DCS Endpoint to hit in order to retrieve the profile. .</param>
/// <param name="blob">AAM Blob. Used to send additional data to AAM. Validation * Cannot be blank. .</param>
public AudienceManager(int locationHint = default(int), string blob = default(string))
public AudienceManager(int? locationHint = default(int?), string blob = default(string))
{
this.LocationHint = locationHint;
this.Blob = blob;
Expand All @@ -50,7 +50,7 @@ public partial class AudienceManager : IEquatable<AudienceManager>, IValidatable
/// </summary>
/// <value>DCS location hint. Used to determine which AAM DCS Endpoint to hit in order to retrieve the profile. </value>
[DataMember(Name = "locationHint", EmitDefaultValue = false)]
public int LocationHint { get; set; }
public int? LocationHint { get; set; }

/// <summary>
/// AAM Blob. Used to send additional data to AAM. Validation * Cannot be blank.
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/AuthenticatedState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ namespace Adobe.Target.Delivery.Model
/// <summary>
/// Defines AuthenticatedState
/// </summary>

[JsonConverter(typeof(StringEnumConverter))]

public enum AuthenticatedState
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/ChannelType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace Adobe.Target.Delivery.Model
/// Specifies the channel for the request. Only activities with the matching channel will be evaluated.
/// </summary>
/// <value>Specifies the channel for the request. Only activities with the matching channel will be evaluated. </value>

[JsonConverter(typeof(StringEnumConverter))]

public enum ChannelType
{
/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions Source/Adobe.Target.Delivery/Model/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Adobe.Target.Delivery.Model
[DataContract(Name = "Context")]
public partial class Context : IEquatable<Context>, IValidatableObject
{

/// <summary>
/// Gets or Sets Channel
/// </summary>
Expand All @@ -58,7 +59,7 @@ protected Context() { }
/// <param name="timeOffsetInMinutes">Specifies minutes from UTC for specific client.</param>
/// <param name="userAgent">User-Agent should be sent only via this property. HTTP header User-Agent is ignored..</param>
/// <param name="beacon">In case beacon &#x3D; true is provided in the request, the server will return a 204 No Content response with no response body. (default to false).</param>
public Context(ChannelType channel = default(ChannelType), MobilePlatform mobilePlatform = default(MobilePlatform), Application application = default(Application), Screen screen = default(Screen), Window window = default(Window), Browser browser = default(Browser), Address address = default(Address), Geo geo = default(Geo), double timeOffsetInMinutes = default(double), string userAgent = default(string), bool beacon = false)
public Context(ChannelType channel = default(ChannelType), MobilePlatform mobilePlatform = default(MobilePlatform), Application application = default(Application), Screen screen = default(Screen), Window window = default(Window), Browser browser = default(Browser), Address address = default(Address), Geo geo = default(Geo), double? timeOffsetInMinutes = default(double?), string userAgent = default(string), bool beacon = false)
{
this.Channel = channel;
this.MobilePlatform = mobilePlatform;
Expand Down Expand Up @@ -120,7 +121,7 @@ protected Context() { }
/// </summary>
/// <value>Specifies minutes from UTC for specific client</value>
[DataMember(Name = "timeOffsetInMinutes", EmitDefaultValue = false)]
public double TimeOffsetInMinutes { get; set; }
public double? TimeOffsetInMinutes { get; set; }

/// <summary>
/// User-Agent should be sent only via this property. HTTP header User-Agent is ignored.
Expand All @@ -133,7 +134,7 @@ protected Context() { }
/// In case beacon &#x3D; true is provided in the request, the server will return a 204 No Content response with no response body.
/// </summary>
/// <value>In case beacon &#x3D; true is provided in the request, the server will return a 204 No Content response with no response body. </value>
[DataMember(Name = "beacon", EmitDefaultValue = false)]
[DataMember(Name = "beacon", EmitDefaultValue = true)]
public bool Beacon { get; set; }

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Source/Adobe.Target.Delivery/Model/CustomerId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Adobe.Target.Delivery.Model
[DataContract(Name = "CustomerId")]
public partial class CustomerId : IEquatable<CustomerId>, IValidatableObject
{

/// <summary>
/// Gets or Sets AuthenticatedState
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/DecisioningMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ namespace Adobe.Target.Delivery.Model
/// <summary>
/// Defines DecisioningMethod
/// </summary>

[JsonConverter(typeof(StringEnumConverter))]

public enum DecisioningMethod
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/DeliveryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected DeliveryRequest() { }
/// <param name="notifications">Notifications for the displayed content, clicked selectors, and/or visited views or mboxes..</param>
/// <param name="qaMode">qaMode.</param>
/// <param name="preview">preview.</param>
public DeliveryRequest(string requestId = default(string), string impressionId = default(string), VisitorId id = default(VisitorId), long environmentId = default(long), Property property = default(Property), Trace trace = default(Trace), Context context = default(Context), ExperienceCloud experienceCloud = default(ExperienceCloud), ExecuteRequest execute = default(ExecuteRequest), PrefetchRequest prefetch = default(PrefetchRequest), Telemetry telemetry = default(Telemetry), List<Notification> notifications = default(List<Notification>), QAMode qaMode = default(QAMode), Preview preview = default(Preview))
public DeliveryRequest(string requestId = default(string), string impressionId = default(string), VisitorId id = default(VisitorId), long? environmentId = default(long?), Property property = default(Property), Trace trace = default(Trace), Context context = default(Context), ExperienceCloud experienceCloud = default(ExperienceCloud), ExecuteRequest execute = default(ExecuteRequest), PrefetchRequest prefetch = default(PrefetchRequest), Telemetry telemetry = default(Telemetry), List<Notification> notifications = default(List<Notification>), QAMode qaMode = default(QAMode), Preview preview = default(Preview))
{
// to ensure "context" is required (not null)
this.Context = context ?? throw new ArgumentNullException("context is a required property for DeliveryRequest and cannot be null");
Expand Down Expand Up @@ -100,7 +100,7 @@ protected DeliveryRequest() { }
/// </summary>
/// <value>Valid client environment id. If not specified host will be determined base on the provided host.</value>
[DataMember(Name = "environmentId", EmitDefaultValue = false)]
public long EnvironmentId { get; set; }
public long? EnvironmentId { get; set; }

/// <summary>
/// Gets or Sets Property
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/DeliveryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
/// <param name="execute">execute.</param>
/// <param name="prefetch">prefetch.</param>
/// <param name="notifications">notifications.</param>
public DeliveryResponse(int status = default(int), string requestId = default(string), VisitorId id = default(VisitorId), string _client = default(string), string edgeHost = default(string), ExecuteResponse execute = default(ExecuteResponse), PrefetchResponse prefetch = default(PrefetchResponse), NotificationResponse notifications = default(NotificationResponse))
public DeliveryResponse(int? status = default(int?), string requestId = default(string), VisitorId id = default(VisitorId), string _client = default(string), string edgeHost = default(string), ExecuteResponse execute = default(ExecuteResponse), PrefetchResponse prefetch = default(PrefetchResponse), NotificationResponse notifications = default(NotificationResponse))
{
this.Status = status;
this.RequestId = requestId;
Expand All @@ -61,7 +61,7 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
/// Gets or Sets Status
/// </summary>
[DataMember(Name = "status", EmitDefaultValue = false)]
public int Status { get; set; }
public int? Status { get; set; }

/// <summary>
/// ID of the processed request. If it&#39;s not sent in the request, a random ID (UUID) is generated and returned with the response.
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/DeviceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace Adobe.Target.Delivery.Model
/// Field is mandatory when Mobile Platform is specified. Only activities that match the specified deviceType or have the device type set to &#39;null&#39; will be evaluated. Ex if device type is &#39;phone&#39; in the delivery request, then only activities that have the device type equal to &#39;phone&#39; or set to &#39;null&#39; will be evaluated. An activity with &#39;null&#39; device type will be evaluated for requests for both, &#39;phone&#39; and &#39;tablet&#39;.
/// </summary>
/// <value>Field is mandatory when Mobile Platform is specified. Only activities that match the specified deviceType or have the device type set to &#39;null&#39; will be evaluated. Ex if device type is &#39;phone&#39; in the delivery request, then only activities that have the device type equal to &#39;phone&#39; or set to &#39;null&#39; will be evaluated. An activity with &#39;null&#39; device type will be evaluated for requests for both, &#39;phone&#39; and &#39;tablet&#39;. </value>

[JsonConverter(typeof(StringEnumConverter))]

public enum DeviceType
{
/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/Adobe.Target.Delivery/Model/Geo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class Geo : IEquatable<Geo>, IValidatableObject
/// <param name="stateCode">Alphanumeric characters representing the subdivision part from ISO 3166-2.</param>
/// <param name="city">City.</param>
/// <param name="zip">Zip/Postal Code.</param>
public Geo(string ipAddress = default(string), float latitude = default(float), float longitude = default(float), string countryCode = default(string), string stateCode = default(string), string city = default(string), string zip = default(string))
public Geo(string ipAddress = default(string), float? latitude = default(float?), float? longitude = default(float?), string countryCode = default(string), string stateCode = default(string), string city = default(string), string zip = default(string))
{
this.IpAddress = ipAddress;
this.Latitude = latitude;
Expand All @@ -67,14 +67,14 @@ public partial class Geo : IEquatable<Geo>, IValidatableObject
/// </summary>
/// <value>Latitude</value>
[DataMember(Name = "latitude", EmitDefaultValue = false)]
public float Latitude { get; set; }
public float? Latitude { get; set; }

/// <summary>
/// Longitude
/// </summary>
/// <value>Longitude</value>
[DataMember(Name = "longitude", EmitDefaultValue = false)]
public float Longitude { get; set; }
public float? Longitude { get; set; }

/// <summary>
/// Country code in ISO 3166-1 alpha-2 format
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/LoggingType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace Adobe.Target.Delivery.Model
/// Indicates whether integraion will be done via client side (from the client) or server side (edge servers)
/// </summary>
/// <value>Indicates whether integraion will be done via client side (from the client) or server side (edge servers) </value>

[JsonConverter(typeof(StringEnumConverter))]

public enum LoggingType
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/MboxRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected MboxRequest() { }
/// <param name="product">product.</param>
/// <param name="index">An index for the mboxes to be executed or prefetched. Mbox index is used for correlation between the mbox request with the mbox response, for either prefetch or execute responses. Index should be unique in the mbox list. (required).</param>
/// <param name="name">The name of the regional mbox to be evaluated. .</param>
public MboxRequest(Address address = default(Address), Dictionary<string, string> parameters = default(Dictionary<string, string>), Dictionary<string, string> profileParameters = default(Dictionary<string, string>), Order order = default(Order), Product product = default(Product), int index = default(int), string name = default(string))
public MboxRequest(Address address = default(Address), Dictionary<string, string> parameters = default(Dictionary<string, string>), Dictionary<string, string> profileParameters = default(Dictionary<string, string>), Order order = default(Order), Product product = default(Product), int? index = default(int?), string name = default(string))
{
this.Index = index;
this.Address = address;
Expand Down Expand Up @@ -97,7 +97,7 @@ protected MboxRequest() { }
/// </summary>
/// <value>An index for the mboxes to be executed or prefetched. Mbox index is used for correlation between the mbox request with the mbox response, for either prefetch or execute responses. Index should be unique in the mbox list. </value>
[DataMember(Name = "index", IsRequired = true, EmitDefaultValue = false)]
public int Index { get; set; }
public int? Index { get; set; }

/// <summary>
/// The name of the regional mbox to be evaluated.
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/MboxRequestAllOf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public partial class MboxRequestAllOf : IEquatable<MboxRequestAllOf>, IValidatab
/// </summary>
/// <param name="index">An index for the mboxes to be executed or prefetched. Mbox index is used for correlation between the mbox request with the mbox response, for either prefetch or execute responses. Index should be unique in the mbox list. .</param>
/// <param name="name">The name of the regional mbox to be evaluated. .</param>
public MboxRequestAllOf(int index = default(int), string name = default(string))
public MboxRequestAllOf(int? index = default(int?), string name = default(string))
{
this.Index = index;
this.Name = name;
Expand All @@ -50,7 +50,7 @@ public partial class MboxRequestAllOf : IEquatable<MboxRequestAllOf>, IValidatab
/// </summary>
/// <value>An index for the mboxes to be executed or prefetched. Mbox index is used for correlation between the mbox request with the mbox response, for either prefetch or execute responses. Index should be unique in the mbox list. </value>
[DataMember(Name = "index", EmitDefaultValue = false)]
public int Index { get; set; }
public int? Index { get; set; }

/// <summary>
/// The name of the regional mbox to be evaluated.
Expand Down
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Delivery/Model/MboxResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public partial class MboxResponse : IEquatable<MboxResponse>, IValidatableObject
/// <param name="metrics">Click metrics..</param>
/// <param name="analytics">analytics.</param>
/// <param name="trace">The object containing all trace data for the request, only present if the trace token was provided in the request. .</param>
public MboxResponse(int index = default(int), string name = default(string), List<Option> options = default(List<Option>), List<Metric> metrics = default(List<Metric>), AnalyticsResponse analytics = default(AnalyticsResponse), Dictionary<string, Object> trace = default(Dictionary<string, Object>))
public MboxResponse(int? index = default(int?), string name = default(string), List<Option> options = default(List<Option>), List<Metric> metrics = default(List<Metric>), AnalyticsResponse analytics = default(AnalyticsResponse), Dictionary<string, Object> trace = default(Dictionary<string, Object>))
{
this.Index = index;
this.Name = name;
Expand All @@ -58,7 +58,7 @@ public partial class MboxResponse : IEquatable<MboxResponse>, IValidatableObject
/// </summary>
/// <value>Indicates that the response is for mbox with the same index, as was specified in the prefetch or execute request. </value>
[DataMember(Name = "index", EmitDefaultValue = false)]
public int Index { get; set; }
public int? Index { get; set; }

/// <summary>
/// The name of the mbox. Since the same mbox name can be specified multiple times in the request it should be used in conjunction with the index.
Expand Down
1 change: 1 addition & 0 deletions Source/Adobe.Target.Delivery/Model/Metric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Adobe.Target.Delivery.Model
[DataContract(Name = "Metric")]
public partial class Metric : IEquatable<Metric>, IValidatableObject
{

/// <summary>
/// Gets or Sets Type
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/MetricType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace Adobe.Target.Delivery.Model
/// Notification type. Currently only click and display are supported.
/// </summary>
/// <value>Notification type. Currently only click and display are supported.</value>

[JsonConverter(typeof(StringEnumConverter))]

public enum MetricType
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions Source/Adobe.Target.Delivery/Model/MobilePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ namespace Adobe.Target.Delivery.Model
[DataContract(Name = "MobilePlatform")]
public partial class MobilePlatform : IEquatable<MobilePlatform>, IValidatableObject
{

/// <summary>
/// Gets or Sets DeviceType
/// </summary>
[DataMember(Name = "deviceType", IsRequired = true, EmitDefaultValue = false)]
public DeviceType DeviceType { get; set; }

/// <summary>
/// Gets or Sets PlatformType
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions Source/Adobe.Target.Delivery/Model/MobilePlatformType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace Adobe.Target.Delivery.Model
/// Only activities with the specified mobile platform type will be evaluated.
/// </summary>
/// <value>Only activities with the specified mobile platform type will be evaluated.</value>

[JsonConverter(typeof(StringEnumConverter))]

public enum MobilePlatformType
{
/// <summary>
Expand Down
Loading

0 comments on commit ff97305

Please sign in to comment.