You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

128 lines
4.0 KiB

  1. // Copyright (C) 2015 Google, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. using System.Collections.Generic;
  16. using GoogleMobileAds.Api.Mediation;
  17. namespace GoogleMobileAds.Api
  18. {
  19. public class AdRequest
  20. {
  21. public const string Version = "3.13.1";
  22. public const string TestDeviceSimulator = "SIMULATOR";
  23. private AdRequest(Builder builder)
  24. {
  25. this.TestDevices = new List<string>(builder.TestDevices);
  26. this.Keywords = new HashSet<string>(builder.Keywords);
  27. this.Birthday = builder.Birthday;
  28. this.Gender = builder.Gender;
  29. this.TagForChildDirectedTreatment = builder.ChildDirectedTreatmentTag;
  30. this.Extras = new Dictionary<string, string>(builder.Extras);
  31. this.MediationExtras = builder.MediationExtras;
  32. }
  33. public List<string> TestDevices { get; private set; }
  34. public HashSet<string> Keywords { get; private set; }
  35. public DateTime? Birthday { get; private set; }
  36. public Gender? Gender { get; private set; }
  37. public bool? TagForChildDirectedTreatment { get; private set; }
  38. public Dictionary<string, string> Extras { get; private set; }
  39. public List<MediationExtras> MediationExtras { get; private set; }
  40. public class Builder
  41. {
  42. public Builder()
  43. {
  44. this.TestDevices = new List<string>();
  45. this.Keywords = new HashSet<string>();
  46. this.Birthday = null;
  47. this.Gender = null;
  48. this.ChildDirectedTreatmentTag = null;
  49. this.Extras = new Dictionary<string, string>();
  50. this.MediationExtras = new List<MediationExtras>();
  51. }
  52. internal List<string> TestDevices { get; private set; }
  53. internal HashSet<string> Keywords { get; private set; }
  54. internal DateTime? Birthday { get; private set; }
  55. internal Gender? Gender { get; private set; }
  56. internal bool? ChildDirectedTreatmentTag { get; private set; }
  57. internal Dictionary<string, string> Extras { get; private set; }
  58. internal List<MediationExtras> MediationExtras { get; private set; }
  59. public Builder AddKeyword(string keyword)
  60. {
  61. this.Keywords.Add(keyword);
  62. return this;
  63. }
  64. public Builder AddTestDevice(string deviceId)
  65. {
  66. this.TestDevices.Add(deviceId);
  67. return this;
  68. }
  69. public AdRequest Build()
  70. {
  71. return new AdRequest(this);
  72. }
  73. public Builder SetBirthday(DateTime birthday)
  74. {
  75. this.Birthday = birthday;
  76. return this;
  77. }
  78. public Builder SetGender(Gender gender)
  79. {
  80. this.Gender = gender;
  81. return this;
  82. }
  83. public Builder AddMediationExtras(MediationExtras extras)
  84. {
  85. this.MediationExtras.Add(extras);
  86. return this;
  87. }
  88. public Builder TagForChildDirectedTreatment(bool tagForChildDirectedTreatment)
  89. {
  90. this.ChildDirectedTreatmentTag = tagForChildDirectedTreatment;
  91. return this;
  92. }
  93. public Builder AddExtra(string key, string value)
  94. {
  95. this.Extras.Add(key, value);
  96. return this;
  97. }
  98. }
  99. }
  100. }