neuron-client 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -8
- data/lib/neuron-client/api.rb +5 -0
- data/lib/neuron-client/model/ad.rb +142 -0
- data/lib/neuron-client/model/ad_calculations.rb +325 -0
- data/lib/neuron-client/model/ad_zone.rb +45 -0
- data/lib/neuron-client/model/base.rb +233 -18
- data/lib/neuron-client/model/blocked_referer.rb +20 -0
- data/lib/neuron-client/model/blocked_user_agent.rb +21 -0
- data/lib/neuron-client/model/geo_target.rb +36 -0
- data/lib/neuron-client/model/pixel.rb +22 -0
- data/lib/neuron-client/model/report.rb +35 -0
- data/lib/neuron-client/model/s3_file.rb +30 -0
- data/lib/neuron-client/model/zone.rb +64 -0
- data/lib/neuron-client/model/zone_calculations.rb +37 -0
- data/lib/neuron-client/schema/ad.rb +406 -0
- data/lib/neuron-client/schema/ad_zone.rb +49 -0
- data/lib/neuron-client/schema/blocked_referer.rb +52 -0
- data/lib/neuron-client/schema/blocked_user_agent.rb +64 -0
- data/lib/neuron-client/schema/common.rb +220 -0
- data/lib/neuron-client/schema/event.rb +17 -0
- data/lib/neuron-client/schema/geo_target.rb +33 -0
- data/lib/neuron-client/schema/pixel.rb +39 -0
- data/lib/neuron-client/schema/report.rb +59 -0
- data/lib/neuron-client/schema/s3_file.rb +87 -0
- data/lib/neuron-client/schema/zone.rb +214 -0
- data/lib/neuron-client/version.rb +1 -1
- data/lib/neuron-client.rb +24 -59
- data/neuron-client.gemspec +3 -0
- data/spec/lib/admin_connection_spec.rb +234 -0
- data/spec/lib/api_spec.rb +41 -63
- data/spec/lib/model/ad_calculations_spec.rb +1146 -0
- data/spec/lib/model/ad_spec.rb +253 -0
- data/spec/lib/model/ad_zone_spec.rb +15 -0
- data/spec/lib/model/base_spec.rb +5 -83
- data/spec/lib/model/blocked_referer_spec.rb +36 -0
- data/spec/lib/model/blocked_user_agent_spec.rb +36 -0
- data/spec/lib/model/geo_target_spec.rb +28 -0
- data/spec/lib/model/pixel_spec.rb +36 -0
- data/spec/lib/model/report_spec.rb +17 -0
- data/spec/lib/{s3_file_spec.rb → model/s3_file_spec.rb} +6 -5
- data/spec/lib/model/zone_calculations_spec.rb +49 -0
- data/spec/lib/model/zone_spec.rb +155 -0
- data/spec/lib/schema/ad_spec.rb +515 -0
- data/spec/lib/schema/ad_zone_spec.rb +149 -0
- data/spec/lib/schema/blocked_referer_spec.rb +136 -0
- data/spec/lib/schema/blocked_user_agent_spec.rb +147 -0
- data/spec/lib/schema/geo_target_spec.rb +92 -0
- data/spec/lib/schema/pixel_spec.rb +125 -0
- data/spec/lib/schema/report_spec.rb +129 -0
- data/spec/lib/schema/s3_file_spec.rb +164 -0
- data/spec/lib/schema/zone_spec.rb +243 -0
- data/spec/spec_helper.rb +2 -1
- metadata +141 -121
- data/lib/neuron-client/model/admin/ad.rb +0 -22
- data/lib/neuron-client/model/admin/ad_zone.rb +0 -15
- data/lib/neuron-client/model/admin/base.rb +0 -91
- data/lib/neuron-client/model/admin/blocked_referer.rb +0 -12
- data/lib/neuron-client/model/admin/blocked_user_agent.rb +0 -12
- data/lib/neuron-client/model/admin/geo_target.rb +0 -16
- data/lib/neuron-client/model/admin/pixel.rb +0 -12
- data/lib/neuron-client/model/admin/report.rb +0 -15
- data/lib/neuron-client/model/admin/s3_file.rb +0 -12
- data/lib/neuron-client/model/admin/zone.rb +0 -15
- data/lib/neuron-client/model/common/ad.rb +0 -42
- data/lib/neuron-client/model/common/ad_calculations.rb +0 -329
- data/lib/neuron-client/model/common/ad_zone.rb +0 -17
- data/lib/neuron-client/model/common/base.rb +0 -67
- data/lib/neuron-client/model/common/blocked_referer.rb +0 -16
- data/lib/neuron-client/model/common/blocked_user_agent.rb +0 -16
- data/lib/neuron-client/model/common/geo_target.rb +0 -16
- data/lib/neuron-client/model/common/pixel.rb +0 -18
- data/lib/neuron-client/model/common/report.rb +0 -21
- data/lib/neuron-client/model/common/s3_file.rb +0 -16
- data/lib/neuron-client/model/common/zone.rb +0 -22
- data/lib/neuron-client/model/common/zone_calculations.rb +0 -41
- data/lib/neuron-client/model/membase/ad.rb +0 -49
- data/lib/neuron-client/model/membase/ad_zone.rb +0 -11
- data/lib/neuron-client/model/membase/blocked_referer.rb +0 -20
- data/lib/neuron-client/model/membase/blocked_user_agent.rb +0 -20
- data/lib/neuron-client/model/membase/geo_target.rb +0 -11
- data/lib/neuron-client/model/membase/pixel.rb +0 -22
- data/lib/neuron-client/model/membase/report.rb +0 -11
- data/lib/neuron-client/model/membase/s3_file.rb +0 -11
- data/lib/neuron-client/model/membase/zone.rb +0 -30
- data/lib/neuron-client/model/models.rb +0 -15
- data/spec/lib/model/admin/ad_spec.rb +0 -34
- data/spec/lib/model/admin/ad_zone_spec.rb +0 -19
- data/spec/lib/model/admin/base_spec.rb +0 -11
- data/spec/lib/model/admin/blocked_referer_spec.rb +0 -11
- data/spec/lib/model/admin/blocked_user_agent_spec.rb +0 -11
- data/spec/lib/model/admin/geo_target_spec.rb +0 -30
- data/spec/lib/model/admin/report_spec.rb +0 -21
- data/spec/lib/model/admin/s3_spec.rb +0 -11
- data/spec/lib/model/admin/zone_spec.rb +0 -21
- data/spec/lib/model/common/ad_calculations_spec.rb +0 -1151
- data/spec/lib/model/common/ad_spec.rb +0 -11
- data/spec/lib/model/common/ad_zone_spec.rb +0 -11
- data/spec/lib/model/common/base_spec.rb +0 -11
- data/spec/lib/model/common/blocked_referer_spec.rb +0 -11
- data/spec/lib/model/common/blocked_user_agent_spec.rb +0 -11
- data/spec/lib/model/common/geo_target_spec.rb +0 -11
- data/spec/lib/model/common/report_spec.rb +0 -11
- data/spec/lib/model/common/s3_spec.rb +0 -11
- data/spec/lib/model/common/zone_calculations_spec.rb +0 -54
- data/spec/lib/model/common/zone_spec.rb +0 -11
- data/spec/lib/model/membase/ad_spec.rb +0 -54
- data/spec/lib/model/membase/ad_zone_spec.rb +0 -11
- data/spec/lib/model/membase/base_spec.rb +0 -11
- data/spec/lib/model/membase/blocked_referer_spec.rb +0 -34
- data/spec/lib/model/membase/blocked_user_agent_spec.rb +0 -34
- data/spec/lib/model/membase/geo_target_spec.rb +0 -11
- data/spec/lib/model/membase/pixel_spec.rb +0 -34
- data/spec/lib/model/membase/report_spec.rb +0 -11
- data/spec/lib/model/membase/s3_spec.rb +0 -11
- data/spec/lib/model/membase/zone_spec.rb +0 -32
- data/spec/lib/old_spec.rb +0 -437
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'map'
|
2
|
+
require 'deep_merge/core'
|
3
|
+
require 'tzinfo'
|
4
|
+
|
5
|
+
module Neuron
|
6
|
+
module Schema
|
7
|
+
module Common
|
8
|
+
module ClassMethods
|
9
|
+
def schema
|
10
|
+
@schema ||= "#{self.name}::SCHEMA".constantize
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate!(schema_name, data)
|
14
|
+
JSON::Validator.validate!(schema.send(schema_name), data)
|
15
|
+
rescue Exception => e
|
16
|
+
puts "Data: #{data}"
|
17
|
+
raise e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.included(base)
|
22
|
+
base.extend(ClassMethods)
|
23
|
+
end
|
24
|
+
|
25
|
+
def object_type(name, properties)
|
26
|
+
Map.new(
|
27
|
+
:type => "object",
|
28
|
+
:additionalProperties => false,
|
29
|
+
:required => true,
|
30
|
+
:properties => {
|
31
|
+
name => {
|
32
|
+
:type => "object",
|
33
|
+
:required => true,
|
34
|
+
:additionalProperties => false,
|
35
|
+
:properties => properties
|
36
|
+
}
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def object_type_or_null(name, properties)
|
42
|
+
merged(object_type(name, properties), {:properties => {name => {:type => %w(object null)}}})
|
43
|
+
end
|
44
|
+
|
45
|
+
def merged(*hashes)
|
46
|
+
result = Map.new
|
47
|
+
hashes.each do |hash|
|
48
|
+
result = ::DeepMerge::deep_merge!(hash, result, {:preserve_unmergeables => false})
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
def choice_of(choices, overrides={})
|
54
|
+
merged({
|
55
|
+
:type => "string",
|
56
|
+
:enum => choices,
|
57
|
+
:required => true
|
58
|
+
}, overrides)
|
59
|
+
end
|
60
|
+
|
61
|
+
def one_of(*schemas)
|
62
|
+
merged({:type => schemas}, {})
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_of(schema, overrides={})
|
66
|
+
merged({
|
67
|
+
:type => "array",
|
68
|
+
:additionalItems => false,
|
69
|
+
:uniqueItems => true,
|
70
|
+
:required => true,
|
71
|
+
:items => schema
|
72
|
+
}, overrides)
|
73
|
+
end
|
74
|
+
|
75
|
+
def datetime(overrides={})
|
76
|
+
merged({
|
77
|
+
:type => "string",
|
78
|
+
:format => "date-time",
|
79
|
+
:pattern => "^\\d{4}-[01]?\\d-[0-3]?\\dT[012]?\\d:[0-5]?\\d:[0-5]?\\dZ$",
|
80
|
+
:required => true
|
81
|
+
}, overrides)
|
82
|
+
end
|
83
|
+
|
84
|
+
def errors
|
85
|
+
merged({
|
86
|
+
:type => "object",
|
87
|
+
:required => true,
|
88
|
+
:additionalProperties => {
|
89
|
+
:type => "array",
|
90
|
+
:minItems => 1,
|
91
|
+
:items => {
|
92
|
+
:type => "string",
|
93
|
+
:required => true
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}, {})
|
97
|
+
end
|
98
|
+
|
99
|
+
def id(overrides={})
|
100
|
+
merged({
|
101
|
+
:type => %w(integer string),
|
102
|
+
:required => true,
|
103
|
+
:pattern => "^\\d+$"
|
104
|
+
}, overrides)
|
105
|
+
end
|
106
|
+
|
107
|
+
def integer(overrides={})
|
108
|
+
merged({
|
109
|
+
:type => %w(integer string),
|
110
|
+
:required => true,
|
111
|
+
:pattern => "^\\-?\\d+$"
|
112
|
+
}, overrides)
|
113
|
+
end
|
114
|
+
|
115
|
+
def missing_or_null
|
116
|
+
merged({
|
117
|
+
:type => "null",
|
118
|
+
:required => false
|
119
|
+
}, {})
|
120
|
+
end
|
121
|
+
|
122
|
+
def missing_or_null_or_empty_hash
|
123
|
+
merged({
|
124
|
+
:type => %w(object null),
|
125
|
+
:additionalProperties => false,
|
126
|
+
:required => false
|
127
|
+
}, {})
|
128
|
+
end
|
129
|
+
|
130
|
+
def nonnull_string(overrides={})
|
131
|
+
merged({
|
132
|
+
:type => "string",
|
133
|
+
:maxLength => 255,
|
134
|
+
:required => "true"
|
135
|
+
}, overrides)
|
136
|
+
end
|
137
|
+
|
138
|
+
def null
|
139
|
+
merged({
|
140
|
+
:type => "null",
|
141
|
+
:required => true
|
142
|
+
}, {})
|
143
|
+
end
|
144
|
+
|
145
|
+
def nullable_string(overrides={})
|
146
|
+
merged({
|
147
|
+
:type => %w(string null),
|
148
|
+
:maxLength => 255,
|
149
|
+
:required => true
|
150
|
+
}, overrides)
|
151
|
+
end
|
152
|
+
|
153
|
+
def parameters(parameters, overrides={})
|
154
|
+
merged({
|
155
|
+
:type => "object",
|
156
|
+
:required => true,
|
157
|
+
:additionalProperties => false,
|
158
|
+
:properties => parameters
|
159
|
+
}, overrides)
|
160
|
+
end
|
161
|
+
|
162
|
+
def priority(overrides={})
|
163
|
+
merged({
|
164
|
+
:type => %w(integer string),
|
165
|
+
:required => true,
|
166
|
+
:minimum => 1,
|
167
|
+
:maximum => 10,
|
168
|
+
:enum => (1..10).to_a + (1..10).map(&:to_s)
|
169
|
+
}, overrides)
|
170
|
+
end
|
171
|
+
|
172
|
+
def slug(overrides={})
|
173
|
+
merged({
|
174
|
+
:type => "string",
|
175
|
+
:required => true,
|
176
|
+
:pattern => "^\\w+$",
|
177
|
+
:maxLength => 255,
|
178
|
+
:minLength => 1
|
179
|
+
}, overrides)
|
180
|
+
end
|
181
|
+
|
182
|
+
def timezone(overrides={})
|
183
|
+
choice_of(Neuron::Client::Ad::TIME_ZONES, overrides)
|
184
|
+
end
|
185
|
+
|
186
|
+
def url(overrides={})
|
187
|
+
merged({
|
188
|
+
:type => "string",
|
189
|
+
:format => "uri",
|
190
|
+
:pattern => "^https?:\/\/",
|
191
|
+
:maxLength => 2000,
|
192
|
+
:required => true
|
193
|
+
}, overrides)
|
194
|
+
end
|
195
|
+
|
196
|
+
def uuid(overrides={})
|
197
|
+
merged({
|
198
|
+
:type => "string",
|
199
|
+
:pattern => "^[a-z0-9]+$",
|
200
|
+
:maxlength => 25,
|
201
|
+
:required => true
|
202
|
+
}, overrides)
|
203
|
+
end
|
204
|
+
|
205
|
+
def weight(overrides={})
|
206
|
+
merged({
|
207
|
+
:type => %w(number string),
|
208
|
+
:required => true,
|
209
|
+
:minimum => -1000,
|
210
|
+
:maximum => 1000,
|
211
|
+
:pattern => "^\\-?\\d+(\\.\\d+)?$"
|
212
|
+
}, overrides)
|
213
|
+
end
|
214
|
+
|
215
|
+
def yes_no(overrides={})
|
216
|
+
choice_of(%w(Yes No), overrides)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Schema
|
3
|
+
class GeoTarget
|
4
|
+
include Common
|
5
|
+
|
6
|
+
SCHEMA = self.new
|
7
|
+
|
8
|
+
def index
|
9
|
+
@@index ||=
|
10
|
+
set_of(object_type("geo_target",
|
11
|
+
:id => id,
|
12
|
+
:abbreviation => nonnull_string,
|
13
|
+
:full_name => nonnull_string,
|
14
|
+
:geo_type => choice_of(Neuron::Client::GeoTarget::TYPES),
|
15
|
+
:name => nonnull_string,
|
16
|
+
:netacuity_id => integer
|
17
|
+
))
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
@@show ||=
|
22
|
+
object_type("geo_target",
|
23
|
+
:id => id,
|
24
|
+
:abbreviation => nonnull_string,
|
25
|
+
:full_name => nonnull_string,
|
26
|
+
:geo_type => choice_of(Neuron::Client::GeoTarget::TYPES),
|
27
|
+
:name => nonnull_string,
|
28
|
+
:netacuity_id => integer
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Schema
|
3
|
+
class Pixel
|
4
|
+
include Common
|
5
|
+
|
6
|
+
SCHEMA = self.new
|
7
|
+
|
8
|
+
def index
|
9
|
+
@@index ||=
|
10
|
+
set_of(object_type("pixel",
|
11
|
+
:id => id
|
12
|
+
))
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@@create ||=
|
17
|
+
object_type_or_null("pixel",
|
18
|
+
:ad_ids => set_of(id, :required => false)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
@@show ||=
|
24
|
+
object_type("pixel",
|
25
|
+
:id => id,
|
26
|
+
:ad_ids => set_of(id)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
@@update ||=
|
32
|
+
object_type("pixel",
|
33
|
+
:id => id,
|
34
|
+
:ad_ids => set_of(id)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Schema
|
3
|
+
class Report
|
4
|
+
include Common
|
5
|
+
|
6
|
+
SCHEMA = self.new
|
7
|
+
|
8
|
+
def index
|
9
|
+
@@index ||=
|
10
|
+
set_of(object_type("report",
|
11
|
+
:id => id,
|
12
|
+
:template => choice_of(Neuron::Client::Report::TEMPLATES),
|
13
|
+
:state => choice_of(Neuron::Client::Report::STATES)
|
14
|
+
))
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@@create ||=
|
19
|
+
object_type("report",
|
20
|
+
:template => choice_of(Neuron::Client::Report::TEMPLATES),
|
21
|
+
:parameters => report_parameters
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
@@show ||=
|
27
|
+
object_type("report",
|
28
|
+
:id => id,
|
29
|
+
:template => choice_of(Neuron::Client::Report::TEMPLATES),
|
30
|
+
:state => choice_of(Neuron::Client::Report::STATES),
|
31
|
+
:parameters => report_parameters,
|
32
|
+
:started_at => datetime(:type => %w(string null)),
|
33
|
+
:finished_at => datetime(:type => %w(string null)),
|
34
|
+
:accessed_at => datetime(:type => %w(string null)),
|
35
|
+
:created_at => datetime,
|
36
|
+
:updated_at => datetime
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def report_parameters
|
43
|
+
parameters({
|
44
|
+
:start => datetime,
|
45
|
+
:end => datetime
|
46
|
+
}, {
|
47
|
+
:patternProperties => {
|
48
|
+
'^\\w{1,255}$' => {
|
49
|
+
:type => "string",
|
50
|
+
:required => true,
|
51
|
+
:minLength => 1,
|
52
|
+
:maxLength => 255
|
53
|
+
}
|
54
|
+
}
|
55
|
+
})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Schema
|
3
|
+
class S3File
|
4
|
+
include Common
|
5
|
+
|
6
|
+
SCHEMA = self.new
|
7
|
+
|
8
|
+
def index
|
9
|
+
@@index ||=
|
10
|
+
set_of(object_type("s3_file", merged(CORE_PROPERTIES, SHOW_PROPERTIES)))
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
@@create ||=
|
15
|
+
object_type("s3_file", CORE_PROPERTIES)
|
16
|
+
end
|
17
|
+
|
18
|
+
def show
|
19
|
+
@@show ||=
|
20
|
+
object_type("s3_file", merged(CORE_PROPERTIES, SHOW_PROPERTIES))
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
@@update ||=
|
25
|
+
object_type("s3_file", {
|
26
|
+
:id => id,
|
27
|
+
:bucket => SCHEMA.bucket(:required => false),
|
28
|
+
:filename => SCHEMA.filename(:required => false),
|
29
|
+
:filesize => SCHEMA.filesize(:required => false),
|
30
|
+
:purpose => SCHEMA.choice_of(Neuron::Client::S3File::PURPOSE_CHOICES, :required => false)
|
31
|
+
})
|
32
|
+
end
|
33
|
+
|
34
|
+
# --------------------
|
35
|
+
|
36
|
+
def bucket(overrides={})
|
37
|
+
merged({
|
38
|
+
:description => "The name of the Amazon S3 bucket",
|
39
|
+
:type => "string",
|
40
|
+
:pattern => "^[a-z\\d]([a-z\\d\\-]*[a-z\\d])?(\\.[a-z\\d]([a-z\\d\\-]*[a-z\\d])?)*$",
|
41
|
+
:minLength => 3,
|
42
|
+
:maxLength => 63,
|
43
|
+
:required => true
|
44
|
+
}, overrides)
|
45
|
+
end
|
46
|
+
|
47
|
+
def filename(overrides={})
|
48
|
+
merged({
|
49
|
+
:description => "The full name of the file within the Amazon S3 bucket",
|
50
|
+
:type => "string",
|
51
|
+
:minLength => 3,
|
52
|
+
:maxLength => 255,
|
53
|
+
:required => true
|
54
|
+
}, overrides)
|
55
|
+
end
|
56
|
+
|
57
|
+
def filesize(overrides={})
|
58
|
+
merged({
|
59
|
+
:type => %w(integer string null),
|
60
|
+
:required => true,
|
61
|
+
:minimum => 1,
|
62
|
+
:exclusiveMinimum => false,
|
63
|
+
:pattern => "^[1-9]\\d*$"
|
64
|
+
}, overrides)
|
65
|
+
end
|
66
|
+
|
67
|
+
# --------------------
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
CORE_PROPERTIES =
|
72
|
+
{
|
73
|
+
:bucket => SCHEMA.bucket,
|
74
|
+
:filename => SCHEMA.filename,
|
75
|
+
:filesize => SCHEMA.filesize,
|
76
|
+
:purpose => SCHEMA.choice_of(Neuron::Client::S3File::PURPOSE_CHOICES)
|
77
|
+
}
|
78
|
+
|
79
|
+
SHOW_PROPERTIES =
|
80
|
+
{
|
81
|
+
:id => SCHEMA.id,
|
82
|
+
:created_at => SCHEMA.datetime,
|
83
|
+
:updated_at => SCHEMA.datetime
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
module Neuron
|
2
|
+
module Schema
|
3
|
+
class Zone
|
4
|
+
include Common
|
5
|
+
|
6
|
+
SCHEMA = self.new
|
7
|
+
|
8
|
+
def index
|
9
|
+
@@index ||=
|
10
|
+
set_of(object_type("zone",
|
11
|
+
:id => uuid,
|
12
|
+
:name => nullable_string
|
13
|
+
))
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@@create ||=
|
18
|
+
one_of(
|
19
|
+
create_redirect,
|
20
|
+
create_iris,
|
21
|
+
create_vast
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
@@show ||=
|
27
|
+
one_of(
|
28
|
+
show_redirect,
|
29
|
+
show_iris,
|
30
|
+
show_vast
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@@update ||=
|
36
|
+
one_of(
|
37
|
+
update_redirect,
|
38
|
+
update_iris,
|
39
|
+
update_vast
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# --------------------
|
44
|
+
|
45
|
+
def create_redirect
|
46
|
+
@@create_redirect ||=
|
47
|
+
object_type("zone", merged(CREATE_PROPERTIES,{
|
48
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::REDIRECT]),
|
49
|
+
}))
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_iris
|
53
|
+
@@create_iris ||=
|
54
|
+
object_type("zone", merged(CREATE_PROPERTIES,{
|
55
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::IRIS]),
|
56
|
+
:template_slug => SCHEMA.choice_of(Neuron::Client::Zone::TEMPLATE_SLUGS),
|
57
|
+
:mute => SCHEMA.yes_no,
|
58
|
+
:autoplay => SCHEMA.yes_no,
|
59
|
+
:channel => SCHEMA.channel,
|
60
|
+
:expand => SCHEMA.yes_no,
|
61
|
+
:text_overlay => SCHEMA.yes_no,
|
62
|
+
:nami_feed_url => SCHEMA.url(:type => %w(string null), :required => false)
|
63
|
+
}))
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_vast
|
67
|
+
@@create_vast ||=
|
68
|
+
object_type("zone", merged(CREATE_PROPERTIES,{
|
69
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::VAST]),
|
70
|
+
}))
|
71
|
+
end
|
72
|
+
|
73
|
+
def show_redirect
|
74
|
+
@@show_redirect ||=
|
75
|
+
object_type("zone", merged(SHOW_PROPERTIES,{
|
76
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::REDIRECT]),
|
77
|
+
}))
|
78
|
+
end
|
79
|
+
|
80
|
+
def show_iris
|
81
|
+
@@show_iris ||=
|
82
|
+
object_type("zone", merged(SHOW_PROPERTIES,{
|
83
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::IRIS]),
|
84
|
+
:template_slug => SCHEMA.choice_of(Neuron::Client::Zone::TEMPLATE_SLUGS),
|
85
|
+
:mute => SCHEMA.yes_no,
|
86
|
+
:autoplay => SCHEMA.yes_no,
|
87
|
+
:channel => SCHEMA.channel,
|
88
|
+
:expand => SCHEMA.yes_no,
|
89
|
+
:text_overlay => SCHEMA.yes_no,
|
90
|
+
:nami_feed_url => SCHEMA.url(:type => %w(string null))
|
91
|
+
}))
|
92
|
+
end
|
93
|
+
|
94
|
+
def show_vast
|
95
|
+
@@show_vast ||=
|
96
|
+
object_type("zone", merged(SHOW_PROPERTIES,{
|
97
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::VAST]),
|
98
|
+
}))
|
99
|
+
end
|
100
|
+
|
101
|
+
def update_redirect
|
102
|
+
@@update_redirect ||=
|
103
|
+
object_type("zone", merged(UPDATE_PROPERTIES,{
|
104
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::REDIRECT], :required => false),
|
105
|
+
}))
|
106
|
+
end
|
107
|
+
|
108
|
+
def update_iris
|
109
|
+
@@update_iris ||=
|
110
|
+
object_type("zone", merged(UPDATE_PROPERTIES,{
|
111
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::IRIS], :required => false),
|
112
|
+
:template_slug => SCHEMA.choice_of(Neuron::Client::Zone::TEMPLATE_SLUGS, :required => false),
|
113
|
+
:mute => SCHEMA.yes_no(:required => false),
|
114
|
+
:autoplay => SCHEMA.yes_no(:required => false),
|
115
|
+
:channel => SCHEMA.channel(:required => false),
|
116
|
+
:expand => SCHEMA.yes_no(:required => false),
|
117
|
+
:text_overlay => SCHEMA.yes_no(:required => false),
|
118
|
+
:nami_feed_url => SCHEMA.url(:type => %w(string null), :required => false)
|
119
|
+
}))
|
120
|
+
end
|
121
|
+
|
122
|
+
def update_vast
|
123
|
+
@@update_vast ||=
|
124
|
+
object_type("zone", merged(UPDATE_PROPERTIES,{
|
125
|
+
:response_type => SCHEMA.choice_of([Neuron::Client::Zone::VAST], :required => false),
|
126
|
+
}))
|
127
|
+
end
|
128
|
+
|
129
|
+
# --------------------
|
130
|
+
|
131
|
+
def ad_links(overrides={})
|
132
|
+
merged({
|
133
|
+
:type => "object",
|
134
|
+
:required => true,
|
135
|
+
:additionalProperties => false,
|
136
|
+
:patternProperties => {
|
137
|
+
"^[0-9]+$" => {
|
138
|
+
:description => "property name is an ad id",
|
139
|
+
:type => "object",
|
140
|
+
:required => true,
|
141
|
+
:additionalProperties => false,
|
142
|
+
:properties => {
|
143
|
+
:priority => priority,
|
144
|
+
:weight => weight
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}, overrides)
|
149
|
+
end
|
150
|
+
|
151
|
+
def channel(overrides={})
|
152
|
+
merged({
|
153
|
+
:type => "string",
|
154
|
+
:pattern => "^\\w+$",
|
155
|
+
:minLength => 1,
|
156
|
+
:maxLength => 255
|
157
|
+
}, overrides)
|
158
|
+
end
|
159
|
+
|
160
|
+
# --------------------
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
|
165
|
+
CREATE_PROPERTIES =
|
166
|
+
{
|
167
|
+
:name => SCHEMA.nullable_string(:required => false),
|
168
|
+
:ad_links => SCHEMA.ad_links(:required => false),
|
169
|
+
:response_type => SCHEMA.choice_of([], :required => true),
|
170
|
+
:template_slug => SCHEMA.missing_or_null,
|
171
|
+
:mute => SCHEMA.missing_or_null,
|
172
|
+
:autoplay => SCHEMA.missing_or_null,
|
173
|
+
:channel => SCHEMA.missing_or_null,
|
174
|
+
:expand => SCHEMA.missing_or_null,
|
175
|
+
:text_overlay => SCHEMA.missing_or_null,
|
176
|
+
:nami_feed_url => SCHEMA.missing_or_null,
|
177
|
+
}
|
178
|
+
|
179
|
+
SHOW_PROPERTIES =
|
180
|
+
{
|
181
|
+
:id => SCHEMA.uuid(:required => true),
|
182
|
+
:created_at => SCHEMA.datetime(:required => true),
|
183
|
+
:updated_at => SCHEMA.datetime(:required => true),
|
184
|
+
|
185
|
+
:name => SCHEMA.nullable_string(:required => true),
|
186
|
+
:ad_links => SCHEMA.ad_links(:required => true),
|
187
|
+
:response_type => SCHEMA.choice_of([], :required => true),
|
188
|
+
:template_slug => SCHEMA.missing_or_null,
|
189
|
+
:mute => SCHEMA.missing_or_null,
|
190
|
+
:autoplay => SCHEMA.missing_or_null,
|
191
|
+
:channel => SCHEMA.missing_or_null,
|
192
|
+
:expand => SCHEMA.missing_or_null,
|
193
|
+
:text_overlay => SCHEMA.missing_or_null,
|
194
|
+
:nami_feed_url => SCHEMA.missing_or_null,
|
195
|
+
}
|
196
|
+
|
197
|
+
UPDATE_PROPERTIES =
|
198
|
+
{
|
199
|
+
:id => SCHEMA.uuid(:required => true),
|
200
|
+
|
201
|
+
:name => SCHEMA.nullable_string(:required => false),
|
202
|
+
:ad_links => SCHEMA.ad_links(:required => false),
|
203
|
+
:response_type => SCHEMA.choice_of([], :required => false),
|
204
|
+
:template_slug => SCHEMA.missing_or_null,
|
205
|
+
:mute => SCHEMA.missing_or_null,
|
206
|
+
:autoplay => SCHEMA.missing_or_null,
|
207
|
+
:channel => SCHEMA.missing_or_null,
|
208
|
+
:expand => SCHEMA.missing_or_null,
|
209
|
+
:text_overlay => SCHEMA.missing_or_null,
|
210
|
+
:nami_feed_url => SCHEMA.missing_or_null,
|
211
|
+
}
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|