1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.data.adselection.datahandlers;
18 
19 import android.adservices.common.AdSelectionSignals;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.net.Uri;
23 
24 import com.android.adservices.data.adselection.CustomAudienceSignals;
25 
26 import com.google.auto.value.AutoValue;
27 
28 
29 /** Data class representing the data required to computing reporting URIs. */
30 @AutoValue
31 public abstract class ReportingComputationData {
32 
33     /** The buyer decision logic JS containing the reporting computation logic. */
34     @NonNull
getBuyerDecisionLogicJs()35     public abstract String getBuyerDecisionLogicJs();
36 
37     /** The URI from where to fetch the buyer decision logic JS. */
38     @Nullable
getBuyerDecisionLogicUri()39     public abstract Uri getBuyerDecisionLogicUri();
40 
41     /** The contextual signals related to the buyer used in the ad selection run. */
42     @Nullable
getBuyerContextualSignals()43     public abstract AdSelectionSignals getBuyerContextualSignals();
44 
45     /** The contextual signals related to the seller used in the ad selection run. */
46     @NonNull
getSellerContextualSignals()47     public abstract AdSelectionSignals getSellerContextualSignals();
48 
49     /** The Custom Audience signals of the ad which won the ad selection run. */
50     @NonNull
getWinningCustomAudienceSignals()51     public abstract CustomAudienceSignals getWinningCustomAudienceSignals();
52 
53     /** The render uri of the ad which won the ad selection run */
54     @NonNull
getWinningRenderUri()55     public abstract Uri getWinningRenderUri();
56 
57     /** The bid of the ad which won the ad selection run */
getWinningBid()58     public abstract double getWinningBid();
59 
60     /** Returns a builder for {@link ReportingComputationData}. */
61     @NonNull
builder()62     public static Builder builder() {
63         return new AutoValue_ReportingComputationData.Builder();
64     }
65 
66     /** Builder for {@link ReportingComputationData}. */
67     @AutoValue.Builder
68     public abstract static class Builder {
69 
70         /** Sets the buyer decision logic JS containing the reporting computation logic. */
setBuyerDecisionLogicJs(@onNull String buyerDecisionLogicJs)71         public abstract Builder setBuyerDecisionLogicJs(@NonNull String buyerDecisionLogicJs);
72 
73         /** Sets the URI from where to fetch the buyer decision logic JS. */
setBuyerDecisionLogicUri(@ullable Uri buyerDecisionLogicUri)74         public abstract Builder setBuyerDecisionLogicUri(@Nullable Uri buyerDecisionLogicUri);
75 
76         /** Sets the contextual signals related to the buyer used in the ad selection run. */
setBuyerContextualSignals( @ullable AdSelectionSignals buyerContextualSignals)77         public abstract Builder setBuyerContextualSignals(
78                 @Nullable AdSelectionSignals buyerContextualSignals);
79 
80         /** Sets the contextual signals related to the seller used in the ad selection run. */
setSellerContextualSignals( @onNull AdSelectionSignals sellerContextualSignals)81         public abstract Builder setSellerContextualSignals(
82                 @NonNull AdSelectionSignals sellerContextualSignals);
83 
84         /** Sets the Custom Audience signals of the ad which won the ad selection run */
setWinningCustomAudienceSignals( @onNull CustomAudienceSignals customAudienceSignals)85         public abstract Builder setWinningCustomAudienceSignals(
86                 @NonNull CustomAudienceSignals customAudienceSignals);
87 
88         /** Sets the render uri of the ad which won the ad selection run. */
setWinningRenderUri(@onNull Uri winningRenderUri)89         public abstract Builder setWinningRenderUri(@NonNull Uri winningRenderUri);
90 
91         /** Sets the bid of the ad which won the ad selection run */
setWinningBid(double winningBid)92         public abstract Builder setWinningBid(double winningBid);
93 
94         /** Builds a {@link ReportingComputationData} object. */
95         @NonNull
build()96         public abstract ReportingComputationData build();
97     }
98 }
99