Yandex Mobile Ads
Loading...
Searching...
No Matches
AdRequestConfiguration.cs
Go to the documentation of this file.
1/*
2 * This file is a part of the Yandex Advertising Network
3 *
4 * Version for Unity (C) 2023 YANDEX
5 *
6 * You may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/
8 */
9
10using System;
11using System.Collections.Generic;
12using System.Diagnostics;
13
15{
20 {
24 public string AdUnitId { get; private set; }
25
29 public string Age { get; private set; }
30
34 public string ContextQuery { get; private set; }
35
39 public List<string> ContextTags { get; private set; }
40
44 public string Gender { get; private set; }
45
49 public Location Location { get; private set; }
50
54 public AdTheme AdTheme { get; private set; }
55
59 public Dictionary<string, string> Parameters { get; private set; }
60
61 private AdRequestConfiguration(Builder builder)
62 {
63 this.AdUnitId = builder.AdUnitId;
64 this.Age = builder.Age;
65 this.ContextQuery = builder.ContextQuery;
66
67 if (builder.ContextTags != null)
68 {
69 this.ContextTags = new List<string>(builder.ContextTags);
70 }
71
72 this.Gender = builder.Gender;
73 this.Location = builder.Location;
74 this.AdTheme = builder.AdTheme;
75
76 if (builder.Parameters != null)
77 {
78 this.Parameters = new Dictionary<string, string>(builder.Parameters);
79 }
80 }
81
85 public class Builder
86 {
87
88 internal string AdUnitId { get; private set; }
89
90 internal string Age { get; private set; }
91
92 internal string ContextQuery { get; private set; }
93
94 internal List<string> ContextTags { get; private set; }
95
96 internal string Gender { get; private set; }
97
98 internal Location Location { get; private set; }
99
100 internal AdTheme AdTheme { get; private set; }
101
102 internal Dictionary<string, string> Parameters { get; private set; }
103
108 public Builder(string adUnitId)
109 {
110 this.AdUnitId = adUnitId;
111 }
112
118 public Builder WithAge(string age)
119 {
120 this.Age = age;
121 return this;
122 }
123
129 public Builder WithContextQuery(string contextQuery)
130 {
131 this.ContextQuery = contextQuery;
132 return this;
133 }
134
140 public Builder WithContextTags(List<string> contextTags)
141 {
142 this.ContextTags = contextTags;
143 return this;
144 }
145
151 public Builder WithGender(string gender)
152 {
153 this.Gender = gender;
154 return this;
155 }
156
163 {
164 this.Location = location;
165 return this;
166 }
167
173 public Builder WithPreferredTheme(AdTheme preferredTheme)
174 {
175 this.AdTheme = preferredTheme;
176 return this;
177 }
178
184 public Builder WithParameters(Dictionary<string, string> parameters)
185 {
186 this.Parameters = parameters;
187 return this;
188 }
189
196 {
197 if (adRequestConfiguration != null)
198 {
199 this.ContextQuery = adRequestConfiguration.ContextQuery;
200 this.ContextTags = adRequestConfiguration.ContextTags;
201 this.Parameters = adRequestConfiguration.Parameters;
202 this.Location = adRequestConfiguration.Location;
203 this.Age = adRequestConfiguration.Age;
204 this.AdTheme = adRequestConfiguration.AdTheme;
205 this.Gender = adRequestConfiguration.Gender;
206 }
207 return this;
208 }
209
215 {
216 if (this.Parameters == null)
217 {
218 this.Parameters = new Dictionary<string, string>();
219 }
220 return new AdRequestConfiguration(this);
221 }
222 }
223 }
224}
A class responsible for creating AdRequest objects.
Builder WithAge(string age)
AdRequest Builder initialized with user's Age for targeting process.
Builder WithContextQuery(string contextQuery)
AdRequest Builder initialized with current user query entered inside app.
Builder WithPreferredTheme(AdTheme preferredTheme)
Sets preferred theme.
Builder WithContextTags(List< string > contextTags)
AdRequest Builder initialized with tags describing current user context inside app.
Builder(string adUnitId)
Instantiates a Builder instance.
AdRequestConfiguration Build()
Creates AdRequest based on current builder parameters.
Builder WithGender(string gender)
AdRequest Builder initialized with user's Gender for targeting process.
Builder WithParameters(Dictionary< string, string > parameters)
AdRequest Builder initialized with custom Parameters.
Builder WithAdRequestConfiguration(AdRequestConfiguration adRequestConfiguration)
AdRequest Builder initialized with AdRequest.
Builder WithLocation(Location location)
AdRequest Builder initialized with user's Location for targeting process.
A class with data for a targeted ad request.
string Gender
The string representation of user's gender. See the list of values in Gender.
string Age
The string representation of user's age.
string AdUnitId
The string representation of user's age.
List< string > ContextTags
An array of tags.Matches the context in which the ad will be displayed.
string ContextQuery
The search query that the user entered in the app.
Dictionary< string, string > Parameters
A set of arbitrary input parameters.
The gender of the user.
Definition Gender.cs:16
Current user location.
Definition Location.cs:18