Class: Neuron::Schema::Ad

Inherits:
Object show all
Includes:
Common
Defined in:
lib/neuron-client/schema/ad.rb

Constant Summary collapse

SCHEMA =
self.new

Instance Method Summary collapse

Methods included from Common

#choice_of, #datetime, #errors, #id, included, #integer, #merged, #missing_or_null, #missing_or_null_or_empty_hash, #nonnull_string, #null, #nullable_string, #object_type, #object_type_or_null, #one_of, #parameters, #priority, #set_of, #slug, #timezone, #url, #uuid, #weight, #yes_no

Instance Method Details

#companion_ad_html(overrides = {}) ⇒ Object




158
159
160
161
162
163
# File 'lib/neuron-client/schema/ad.rb', line 158

def companion_ad_html(overrides={})
  merged({
    :type => %w(string null),
    :required => true
  }, overrides)
end

#createObject



16
17
18
19
20
21
22
23
24
# File 'lib/neuron-client/schema/ad.rb', line 16

def create
  @@create ||=
  one_of(
    create_redirect,
    create_video_ad,
    create_vast_network,
    create_acudeo_network
  )
end

#create_acudeo_networkObject



76
77
78
79
80
81
82
# File 'lib/neuron-client/schema/ad.rb', line 76

def create_acudeo_network
  @@create_acudeo_network ||=
  object_type("ad", merged(CREATE_PROPERTIES,{
    :response_type     => SCHEMA.choice_of([Neuron::Client::Ad::ACUDEO_NETWORK]),
    :acudeo_program_id => SCHEMA.slug,
  }))
end

#create_redirectObject




48
49
50
51
52
53
54
# File 'lib/neuron-client/schema/ad.rb', line 48

def create_redirect
  @@create_redirect ||=
  object_type("ad", merged(CREATE_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::REDIRECT]),
    :redirect_url  => SCHEMA.url,
  }))
end

#create_vast_networkObject



68
69
70
71
72
73
74
# File 'lib/neuron-client/schema/ad.rb', line 68

def create_vast_network
  @@create_vast_network ||=
  object_type("ad", merged(CREATE_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::VAST_NETWORK]),
    :vast_url      => SCHEMA.url,
  }))
end

#create_video_adObject



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/neuron-client/schema/ad.rb', line 56

def create_video_ad
  @@create_video_ad ||=
  object_type("ad", merged(CREATE_PROPERTIES,{
    :response_type      => SCHEMA.choice_of([Neuron::Client::Ad::VIDEO_AD]),
    :video_flv_url      => SCHEMA.url(:required => false),
    :clickthru_url      => SCHEMA.url(:required => false),
    :companion_ad_html  => SCHEMA.companion_ad_html(:required => false),
    :social_urls        => SCHEMA.social_urls(:required => false),
    :vast_tracker_urls  => SCHEMA.vast_tracker_urls(:required => false),
  }))
end

#daily_cap(overrides = {}) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/neuron-client/schema/ad.rb', line 165

def daily_cap(overrides={})
  merged({
    :type => %w(integer string null),
    :required => true,
    :minimum => 1,
    :exclusiveMinimum => false,
    :pattern => "^[1-9]\\d*$"
  }, overrides)
end

#day_partitions(overrides = {}) ⇒ Object



175
176
177
178
179
180
181
182
183
# File 'lib/neuron-client/schema/ad.rb', line 175

def day_partitions(overrides={})
  merged({
    :type => ["string","null"],
    :required => true,
    :minLength => 168,
    :maxLength => 168,
    :pattern => "^[TF]+$"
  }, overrides)
end

#frequency_cap(overrides = {}) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/neuron-client/schema/ad.rb', line 185

def frequency_cap(overrides={})
  merged({
    :type => ["object","null"],
    :additionalProperties => false,
    :required => true,
    :properties => {
      :limit => {
        :type => %w(integer string),
        :minimum => 1,
        :maximum => 10,
        :required => true,
        :enum => (1..10).to_a + (1..10).map(&:to_s)
      },
      :window => choice_of(Neuron::Client::Ad::FREQUENCY_CAP_WINDOWS)
    }
  }, overrides)
end

#geo_target_netacuity_ids(overrides = {}) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/neuron-client/schema/ad.rb', line 203

def geo_target_netacuity_ids(overrides={})
  properties = {}
  Neuron::Client::GeoTarget::TYPES.each do |geo_type|
    properties[geo_type] = set_of(integer, :required => false)
  end
  merged({
    :type => "object",
    :required => true,
    :additionalProperties => false,
    :properties => properties
  }, overrides)
end

#ideal_impressions_per_hour(overrides = {}) ⇒ Object



216
217
218
219
220
221
222
223
224
# File 'lib/neuron-client/schema/ad.rb', line 216

def ideal_impressions_per_hour(overrides={})
  merged({
    :type => %w(number string null),
    :required => true,
    :minimum => 0,
    :exclusiveMinimum => true,
    :pattern => "^\\d+(\\.\\d+)?$"
  }, overrides)
end

#indexObject



8
9
10
11
12
13
14
# File 'lib/neuron-client/schema/ad.rb', line 8

def index
  @@index ||=
  set_of(object_type("ad",
    :id => id,
    :name => nullable_string
  ))
end

#overall_cap(overrides = {}) ⇒ Object



226
227
228
229
230
231
232
233
234
# File 'lib/neuron-client/schema/ad.rb', line 226

def overall_cap(overrides={})
  merged({
    :type => %w(integer string null),
    :required => true,
    :minimum => 1,
    :exclusiveMinimum => false,
    :pattern => "^[1-9]\\d*$"
  }, overrides)
end

#showObject



26
27
28
29
30
31
32
33
34
# File 'lib/neuron-client/schema/ad.rb', line 26

def show
  @@show ||=
  one_of(
    show_redirect,
    show_video_ad,
    show_vast_network,
    show_acudeo_network
  )
end

#show_acudeo_networkObject



112
113
114
115
116
117
118
# File 'lib/neuron-client/schema/ad.rb', line 112

def show_acudeo_network
  @@show_acudeo_network ||=
  object_type("ad", merged(SHOW_PROPERTIES,{
    :response_type     => SCHEMA.choice_of([Neuron::Client::Ad::ACUDEO_NETWORK]),
    :acudeo_program_id => SCHEMA.slug,
  }))
end

#show_redirectObject



84
85
86
87
88
89
90
# File 'lib/neuron-client/schema/ad.rb', line 84

def show_redirect
  @@show_redirect ||=
  object_type("ad", merged(SHOW_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::REDIRECT]),
    :redirect_url  => SCHEMA.url,
  }))
end

#show_vast_networkObject



104
105
106
107
108
109
110
# File 'lib/neuron-client/schema/ad.rb', line 104

def show_vast_network
  @@show_vast_network ||=
  object_type("ad", merged(SHOW_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::VAST_NETWORK]),
    :vast_url      => SCHEMA.url,
  }))
end

#show_video_adObject



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/neuron-client/schema/ad.rb', line 92

def show_video_ad
  @@show_video_ad ||=
  object_type("ad", merged(SHOW_PROPERTIES,{
    :response_type      => SCHEMA.choice_of([Neuron::Client::Ad::VIDEO_AD]),
    :video_flv_url      => SCHEMA.url,
    :clickthru_url      => SCHEMA.url,
    :companion_ad_html  => SCHEMA.companion_ad_html,
    :social_urls        => SCHEMA.social_urls,
    :vast_tracker_urls  => SCHEMA.vast_tracker_urls,
  }))
end

#social_urls(overrides = {}) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/neuron-client/schema/ad.rb', line 236

def social_urls(overrides={})
  properties = {}
  Neuron::Client::Ad::SOCIAL_TYPES.each do |social_type|
    properties[social_type] = url(:required => false)
  end
  merged({
    :type => "object",
    :required => true,
    :additionalProperties => false,
    :properties => properties
  }, overrides)
end

#updateObject



36
37
38
39
40
41
42
43
44
# File 'lib/neuron-client/schema/ad.rb', line 36

def update
  @@update ||=
  one_of(
    update_redirect,
    update_video_ad,
    update_vast_network,
    update_acudeo_network
  )
end

#update_acudeo_networkObject



148
149
150
151
152
153
154
# File 'lib/neuron-client/schema/ad.rb', line 148

def update_acudeo_network
  @@update_acudeo_network ||=
  object_type("ad", merged(UPDATE_PROPERTIES,{
    :response_type     => SCHEMA.choice_of([Neuron::Client::Ad::ACUDEO_NETWORK], :required => false),
    :acudeo_program_id => SCHEMA.slug(:required => false),
  }))
end

#update_redirectObject



120
121
122
123
124
125
126
# File 'lib/neuron-client/schema/ad.rb', line 120

def update_redirect
  @@update_redirect ||=
  object_type("ad", merged(UPDATE_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::REDIRECT], :required => false),
    :redirect_url  => SCHEMA.url(:required => false),
  }))
end

#update_vast_networkObject



140
141
142
143
144
145
146
# File 'lib/neuron-client/schema/ad.rb', line 140

def update_vast_network
  @@update_vast_network ||=
  object_type("ad", merged(UPDATE_PROPERTIES,{
    :response_type => SCHEMA.choice_of([Neuron::Client::Ad::VAST_NETWORK], :required => false),
    :vast_url      => SCHEMA.url(:required => false),
  }))
end

#update_video_adObject



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/neuron-client/schema/ad.rb', line 128

def update_video_ad
  @@update_video_ad ||=
  object_type("ad", merged(UPDATE_PROPERTIES,{
    :response_type      => SCHEMA.choice_of([Neuron::Client::Ad::VIDEO_AD], :required => false),
    :video_flv_url      => SCHEMA.url(:required => false),
    :clickthru_url      => SCHEMA.url(:required => false),
    :companion_ad_html  => SCHEMA.companion_ad_html(:required => false),
    :social_urls        => SCHEMA.social_urls(:required => false),
    :vast_tracker_urls  => SCHEMA.vast_tracker_urls(:required => false),
  }))
end

#vast_tracker_urls(overrides = {}) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/neuron-client/schema/ad.rb', line 249

def vast_tracker_urls(overrides={})
  properties = {}
  Neuron::Client::Ad::VAST_TRACKER_TYPES.each do |tracker_type|
    properties[tracker_type] = set_of(url, :required => false)
  end
  merged({
    :type => "object",
    :required => true,
    :additionalProperties => false,
    :properties => properties
  }, overrides)
end


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/neuron-client/schema/ad.rb', line 262

def zone_links(overrides={})
  merged({
    :type => "object",
    :required => true,
    :additionalProperties => false,
    :patternProperties => {
      "^\\w+$" => {
        :description => "property name is a zone id",
        :type => "object",
        :required => true,
        :additionalProperties => false,
        :properties => {
          :priority => priority,
          :weight => weight
        }
      }
    }
  }, overrides)
end