namespace JustTrack
{
///
/// Represents an ad impression to be sent to the justtrack backend. This class is used to collect
/// data related to ad impressions, which can be utilized to calculate the ad revenue generated by
/// your app.
///
public class AdImpression
{
///
/// Gets the ad unit identifier.
///
internal string Unit { get; private set; }
///
/// Gets the SDK name that provided this ad impression.
///
internal string SdkName { get; private set; }
///
/// Gets the ad network that provided this ad impression.
///
internal string? Network { get; private set; } = null;
///
/// Gets the placement identifier for this ad impression.
///
internal string? Placement { get; private set; } = null;
///
/// Gets the test group identifier for A/B testing purposes.
///
internal string? TestGroup { get; private set; } = null;
///
/// Gets the segment name for this ad impression.
///
internal string? SegmentName { get; private set; } = null;
///
/// Gets the instance name for this ad impression.
///
internal string? InstanceName { get; private set; } = null;
///
/// Gets the bundle ID of the advertised app.
///
internal string? BundleId { get; private set; } = null;
///
/// Gets the revenue amount generated by this ad impression.
///
internal Money? Revenue { get; private set; } = null;
///
/// Initializes a new instance of the class.
///
/// The ad unit identifier.
/// The name of the SDK that provided this ad impression.
public AdImpression(string pUnit, string pSdkName)
{
this.Unit = pUnit;
this.SdkName = pSdkName;
}
///
/// Initializes a new instance of the class.
///
/// The ad unit type.
/// The name of the SDK that provided this ad impression.
public AdImpression(AdUnit pUnit, string pSdkName)
{
this.Unit = AdUnitInternalConversation.ToInternalString(pUnit);
this.SdkName = pSdkName;
}
///
/// Sets the network for this ad impression.
///
/// The name of the ad network which provided the ad. May be null.
/// This instance to allow for method chaining.
public AdImpression SetNetwork(string? pNetwork)
{
this.Network = pNetwork;
return this;
}
///
/// Sets the placement for this ad impression.
///
/// The placement of the ad. May be null.
/// This instance to allow for method chaining.
public AdImpression SetPlacement(string? pPlacement)
{
this.Placement = pPlacement;
return this;
}
///
/// Sets the test group for this ad impression.
///
/// The test group of the user if we are A/B testing. May be null.
/// This instance to allow for method chaining.
public AdImpression SetTestGroup(string? pTestGroup)
{
this.TestGroup = pTestGroup;
return this;
}
///
/// Sets the segment name for this ad impression.
///
/// The name of the segment of the ad. May be null.
/// This instance to allow for method chaining.
public AdImpression SetSegmentName(string? pSegmentName)
{
this.SegmentName = pSegmentName;
return this;
}
///
/// Sets the instance name for this ad impression.
///
/// The name of the instance of the ad. May be null.
/// This instance to allow for method chaining.
public AdImpression SetInstanceName(string? pInstanceName)
{
this.InstanceName = pInstanceName;
return this;
}
///
/// Sets the bundle ID for this ad impression.
///
/// The bundle ID of the advertised app. May be null.
/// This instance to allow for method chaining.
public AdImpression SetBundleId(string? pBundleId)
{
this.BundleId = pBundleId;
return this;
}
///
/// Sets the revenue for this ad impression.
///
/// The amount of revenue this ad generated. May be zero but must not be negative.
/// This instance to allow for method chaining.
public AdImpression SetRevenue(Money? pRevenue)
{
this.Revenue = pRevenue;
return this;
}
}
}