zombie_battleground-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile.lock +29 -11
- data/README.md +4 -0
- data/Rakefile +62 -5
- data/lib/zombie_battleground/api.rb +108 -8
- data/lib/zombie_battleground/api/client.rb +157 -23
- data/lib/zombie_battleground/api/errors.rb +28 -0
- data/lib/zombie_battleground/api/models/card.rb +272 -32
- data/lib/zombie_battleground/api/models/deck.rb +234 -46
- data/lib/zombie_battleground/api/models/match.rb +211 -33
- data/lib/zombie_battleground/api/models/simple_card.rb +47 -11
- data/lib/zombie_battleground/api/requests/get_card_request.rb +45 -10
- data/lib/zombie_battleground/api/requests/get_cards_request.rb +203 -27
- data/lib/zombie_battleground/api/requests/get_deck_request.rb +43 -13
- data/lib/zombie_battleground/api/requests/get_decks_request.rb +141 -23
- data/lib/zombie_battleground/api/requests/get_match_request.rb +43 -13
- data/lib/zombie_battleground/api/requests/get_matches_request.rb +125 -21
- data/lib/zombie_battleground/api/requests/request_helper.rb +24 -10
- data/lib/zombie_battleground/api/responses/get_card_response.rb +50 -16
- data/lib/zombie_battleground/api/responses/get_cards_response.rb +103 -33
- data/lib/zombie_battleground/api/responses/get_deck_response.rb +49 -17
- data/lib/zombie_battleground/api/responses/get_decks_response.rb +103 -33
- data/lib/zombie_battleground/api/responses/get_match_response.rb +49 -17
- data/lib/zombie_battleground/api/responses/get_matches_response.rb +103 -33
- data/lib/zombie_battleground/api/responses/response_helper.rb +32 -16
- data/lib/zombie_battleground/api/validation_helper.rb +497 -0
- data/lib/zombie_battleground/api/version.rb +5 -1
- data/zombie_battleground-api.gemspec +6 -0
- metadata +71 -1
@@ -9,29 +9,61 @@ require 'zombie_battleground/api/responses/response_helper'
|
|
9
9
|
|
10
10
|
module ZombieBattleground
|
11
11
|
class Api
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
class Responses
|
13
|
+
##
|
14
|
+
# Response validator for GetMatch
|
15
|
+
class GetMatchResponse
|
16
|
+
include ActiveModel::Validations
|
17
|
+
include ZombieBattleground::Api::ValidationHelper
|
18
|
+
include ZombieBattleground::Api::Responses::ResponseHelper
|
18
19
|
|
19
|
-
|
20
|
+
##
|
21
|
+
# @!attribute [r] match
|
22
|
+
# the match
|
23
|
+
#
|
24
|
+
# @return [ZombieBattleground::Api::Models::Match]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# response.match #=> ZombieBattleground::Api::Models::Match
|
28
|
+
#
|
29
|
+
# @api public
|
30
|
+
attr_reader :match
|
20
31
|
|
21
|
-
|
32
|
+
validate :match_is_a_match
|
22
33
|
|
23
|
-
|
24
|
-
|
34
|
+
##
|
35
|
+
# Creates a new GetMatchResponse
|
36
|
+
#
|
37
|
+
# @param response [Faraday::Response] Faraday response from endpoint
|
38
|
+
#
|
39
|
+
# @return [ZombieBattleground::Api::GetMatchResponse]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# response = ZombieBattleground::Api::GetMatchResponse.new(faraday_response)
|
43
|
+
# # => ZombieBattleground::Api::GetMatchResponse
|
44
|
+
#
|
45
|
+
# @api public
|
46
|
+
def initialize(response)
|
47
|
+
handle_errors(response)
|
25
48
|
|
26
|
-
|
27
|
-
|
49
|
+
@match = ZombieBattleground::Api::Models::Match.new(JSON.parse(response.body))
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
28
53
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
54
|
+
##
|
55
|
+
# Validator for match attribute
|
56
|
+
#
|
57
|
+
# @return [void]
|
58
|
+
#
|
59
|
+
# @api private
|
60
|
+
def match_is_a_match
|
61
|
+
return if @match.is_a?(ZombieBattleground::Api::Models::Match) &&
|
62
|
+
@match.valid? &&
|
63
|
+
@match.errors.size.zero?
|
33
64
|
|
34
|
-
|
65
|
+
errors.add(:match, 'match must be a Match')
|
66
|
+
end
|
35
67
|
end
|
36
68
|
end
|
37
69
|
end
|
@@ -9,44 +9,114 @@ require 'zombie_battleground/api/responses/response_helper'
|
|
9
9
|
|
10
10
|
module ZombieBattleground
|
11
11
|
class Api
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
12
|
+
class Responses
|
13
|
+
##
|
14
|
+
# Response validator for GetMatches
|
15
|
+
class GetMatchesResponse
|
16
|
+
include ActiveModel::Validations
|
17
|
+
include ZombieBattleground::Api::ValidationHelper
|
18
|
+
include ZombieBattleground::Api::Responses::ResponseHelper
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute [r] total
|
22
|
+
# the total number of results available
|
23
|
+
#
|
24
|
+
# @return [Integer]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# response.total #=> 1505
|
28
|
+
#
|
29
|
+
# @api public
|
30
|
+
attr_reader :total
|
31
|
+
|
32
|
+
##
|
33
|
+
# @!attribute [r] page
|
34
|
+
# the page number of the results
|
35
|
+
#
|
36
|
+
# @return [Integer]
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# response.page #=> 1
|
40
|
+
#
|
41
|
+
# @api public
|
42
|
+
attr_reader :page
|
43
|
+
|
44
|
+
##
|
45
|
+
# @!attribute [r] limit
|
46
|
+
# the limit of results for the page
|
47
|
+
#
|
48
|
+
# @return [Integer]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# response.limit #=> 100
|
52
|
+
#
|
53
|
+
# @api public
|
54
|
+
attr_reader :limit
|
55
|
+
|
56
|
+
##
|
57
|
+
# @!attribute [r] matches
|
58
|
+
# the matches found for the page and limit
|
59
|
+
#
|
60
|
+
# @return [Array<ZombieBattleground::Api::Models::Match>]
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# response.matches #=> [ZombieBattleground::Api::Models::Match]
|
64
|
+
#
|
65
|
+
# @api public
|
66
|
+
attr_reader :matches
|
67
|
+
|
68
|
+
validate :total_is_a_non_negative_integer
|
69
|
+
validate :page_is_a_non_negative_integer
|
70
|
+
validate :limit_is_a_non_negative_integer
|
71
|
+
validate :matches_is_an_array_of_match
|
72
|
+
|
73
|
+
##
|
74
|
+
# Creates a new GetMatchesResponse
|
75
|
+
#
|
76
|
+
# @param response [Faraday::Response] Faraday response from endpoint
|
77
|
+
#
|
78
|
+
# @return [ZombieBattleground::Api::GetMatchesResponse]
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# response = ZombieBattleground::Api::GetMatchesResponse.new(faraday_response)
|
82
|
+
# # => ZombieBattleground::Api::GetMatchesResponse
|
83
|
+
#
|
84
|
+
# @api public
|
85
|
+
def initialize(response)
|
86
|
+
handle_errors(response)
|
87
|
+
|
88
|
+
JSON.parse(response.body).each do |key, value|
|
89
|
+
if key == 'matches'
|
90
|
+
instance_variable_set(
|
91
|
+
"@#{key}".to_sym, value.map { |match| ZombieBattleground::Api::Models::Match.new(match) }
|
92
|
+
)
|
93
|
+
else
|
94
|
+
instance_variable_set("@#{key}".to_sym, value)
|
95
|
+
end
|
34
96
|
end
|
35
97
|
end
|
36
|
-
end
|
37
98
|
|
38
|
-
|
39
|
-
unless @matches.is_a?(Array)
|
40
|
-
errors.add(:matches, 'Matchs must be an array')
|
41
|
-
return
|
42
|
-
end
|
99
|
+
private
|
43
100
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
101
|
+
##
|
102
|
+
# Validator for matches attribute
|
103
|
+
#
|
104
|
+
# @return [void]
|
105
|
+
#
|
106
|
+
# @api private
|
107
|
+
def matches_is_an_array_of_match
|
108
|
+
unless @matches.is_a?(Array)
|
109
|
+
errors.add(:matches, 'Matchs must be an array')
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
@matches.each do |match|
|
114
|
+
next if match.is_a?(ZombieBattleground::Api::Models::Match) &&
|
115
|
+
match.valid? &&
|
116
|
+
match.errors.size.zero?
|
48
117
|
|
49
|
-
|
118
|
+
errors.add(:matches, 'matches must be an array of Match')
|
119
|
+
end
|
50
120
|
end
|
51
121
|
end
|
52
122
|
end
|
@@ -4,24 +4,40 @@ require 'zombie_battleground/api/errors'
|
|
4
4
|
|
5
5
|
module ZombieBattleground
|
6
6
|
class Api
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
class Responses
|
8
|
+
##
|
9
|
+
# Provides generic methods for response validator classes
|
10
|
+
module ResponseHelper
|
11
|
+
private
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
##
|
14
|
+
# Raises errors as needed from the response status code
|
15
|
+
#
|
16
|
+
# @param response [Faraday::Response] Faraday response from endpoint
|
17
|
+
#
|
18
|
+
# @return [void]
|
19
|
+
#
|
20
|
+
# @raise [ZombieBattleground::Api::Errors::NotFound, ZombieBattleground::Api::Errors::ServiceUnavailable,
|
21
|
+
# ZombieBattleground::Api::Errors::BadRequest, ZombieBattleground::Api::Errors::InternalServerError,
|
22
|
+
# ZombieBattleground::Api::Errors::UnknownResponse]
|
23
|
+
#
|
24
|
+
# @api private
|
25
|
+
def handle_errors(response)
|
26
|
+
return if response.status == 200
|
27
|
+
|
28
|
+
case response.status
|
29
|
+
when 404
|
30
|
+
raise ZombieBattleground::Api::Errors::NotFound, response.body
|
31
|
+
when 503
|
32
|
+
raise ZombieBattleground::Api::Errors::ServiceUnavailable, response.body
|
33
|
+
when 400..499
|
34
|
+
raise ZombieBattleground::Api::Errors::BadRequest, response.body
|
35
|
+
when 500..599
|
36
|
+
raise ZombieBattleground::Api::Errors::InternalServerError, response.body
|
37
|
+
end
|
23
38
|
|
24
|
-
|
39
|
+
raise ZombieBattleground::Api::Errors::UnknownResponse, response.body
|
40
|
+
end
|
25
41
|
end
|
26
42
|
end
|
27
43
|
end
|
@@ -5,12 +5,35 @@ module ZombieBattleground
|
|
5
5
|
##
|
6
6
|
# Validation helpers for sanitizing inputs and ouputs
|
7
7
|
module ValidationHelper
|
8
|
+
private
|
9
|
+
|
10
|
+
##
|
11
|
+
# Appends an error to the model if the value is not the expected class
|
12
|
+
#
|
13
|
+
# @param target [Symbol]
|
14
|
+
# @param value [Object]
|
15
|
+
# @param nullable [Boolean]
|
16
|
+
# @param klass [Class]
|
17
|
+
#
|
18
|
+
# @return [void]
|
19
|
+
#
|
20
|
+
# @api private
|
8
21
|
def value_is_a_class(target:, value:, nullable:, klass:)
|
9
22
|
return if (nullable && value.nil?) || value.is_a?(klass)
|
10
23
|
|
11
24
|
errors.add(target, "#{target} must be a #{klass}")
|
12
25
|
end
|
13
26
|
|
27
|
+
##
|
28
|
+
# Appends an error to the model if the value is not String
|
29
|
+
#
|
30
|
+
# @param target [Symbol]
|
31
|
+
# @param value [Object]
|
32
|
+
# @param nullable [Boolean]
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
#
|
36
|
+
# @api private
|
14
37
|
def value_is_a_string(target:, value:, nullable: true)
|
15
38
|
value_is_a_class(
|
16
39
|
target: target,
|
@@ -20,6 +43,16 @@ module ZombieBattleground
|
|
20
43
|
)
|
21
44
|
end
|
22
45
|
|
46
|
+
##
|
47
|
+
# Appends an error to the model if the value is not Time
|
48
|
+
#
|
49
|
+
# @param target [Symbol]
|
50
|
+
# @param value [Object]
|
51
|
+
# @param nullable [Boolean]
|
52
|
+
#
|
53
|
+
# @return [void]
|
54
|
+
#
|
55
|
+
# @api private
|
23
56
|
def value_is_a_time(target:, value:, nullable: true)
|
24
57
|
value_is_a_class(
|
25
58
|
target: target,
|
@@ -29,6 +62,16 @@ module ZombieBattleground
|
|
29
62
|
)
|
30
63
|
end
|
31
64
|
|
65
|
+
##
|
66
|
+
# Appends an error to the model if the value is not Integer
|
67
|
+
#
|
68
|
+
# @param target [Symbol]
|
69
|
+
# @param value [Object]
|
70
|
+
# @param nullable [Boolean]
|
71
|
+
#
|
72
|
+
# @return [void]
|
73
|
+
#
|
74
|
+
# @api private
|
32
75
|
def value_is_an_integer(target:, value:, nullable: true)
|
33
76
|
value_is_a_class(
|
34
77
|
target: target,
|
@@ -38,6 +81,16 @@ module ZombieBattleground
|
|
38
81
|
)
|
39
82
|
end
|
40
83
|
|
84
|
+
##
|
85
|
+
# Appends an error to the model if the value is a negative Integer
|
86
|
+
#
|
87
|
+
# @param target [Symbol]
|
88
|
+
# @param value [Object]
|
89
|
+
# @param nullable [Boolean]
|
90
|
+
#
|
91
|
+
# @return [void]
|
92
|
+
#
|
93
|
+
# @api private
|
41
94
|
def value_is_a_non_negative_integer(target:, value:, nullable: true)
|
42
95
|
value_is_an_integer(target: target, value: value, nullable: nullable)
|
43
96
|
return unless errors.messages.empty?
|
@@ -47,298 +100,742 @@ module ZombieBattleground
|
|
47
100
|
errors.add(target, "#{target} must be not negative")
|
48
101
|
end
|
49
102
|
|
103
|
+
##
|
104
|
+
# Appends an error to the model if id is a negative Integer
|
105
|
+
#
|
106
|
+
# @return [void]
|
107
|
+
#
|
108
|
+
# @api private
|
50
109
|
def id_is_a_non_negative_integer
|
51
110
|
value_is_a_non_negative_integer(target: :id, value: id)
|
52
111
|
end
|
53
112
|
|
113
|
+
##
|
114
|
+
# Appends an error to the model if id is a negative Integer or nil
|
115
|
+
#
|
116
|
+
# @return [void]
|
117
|
+
#
|
118
|
+
# @api private
|
54
119
|
def id_is_a_non_negative_integer_and_not_null
|
55
120
|
value_is_a_non_negative_integer(target: :id, value: id, nullable: false)
|
56
121
|
end
|
57
122
|
|
123
|
+
##
|
124
|
+
# Appends an error to the model if user_id is not a String
|
125
|
+
#
|
126
|
+
# @return [void]
|
127
|
+
#
|
128
|
+
# @api private
|
58
129
|
def user_id_is_a_string
|
59
130
|
value_is_a_string(target: :user_id, value: user_id)
|
60
131
|
end
|
61
132
|
|
133
|
+
##
|
134
|
+
# Appends an error to the model if user_id is not a String or nil
|
135
|
+
#
|
136
|
+
# @return [void]
|
137
|
+
#
|
138
|
+
# @api private
|
62
139
|
def user_id_is_a_string_and_not_null
|
63
140
|
value_is_a_string(target: :user_id, value: user_id, nullable: false)
|
64
141
|
end
|
65
142
|
|
143
|
+
##
|
144
|
+
# Appends an error to the model if deck_id is a negative Integer
|
145
|
+
#
|
146
|
+
# @return [void]
|
147
|
+
#
|
148
|
+
# @api private
|
66
149
|
def deck_id_is_a_non_negative_integer
|
67
150
|
value_is_a_non_negative_integer(target: :deck_id, value: deck_id)
|
68
151
|
end
|
69
152
|
|
153
|
+
##
|
154
|
+
# Appends an error to the model if deck_id is a negative Integer or nil
|
155
|
+
#
|
156
|
+
# @return [void]
|
157
|
+
#
|
158
|
+
# @api private
|
70
159
|
def deck_id_is_a_non_negative_integer_and_not_null
|
71
160
|
value_is_a_non_negative_integer(target: :deck_id, value: deck_id, nullable: false)
|
72
161
|
end
|
73
162
|
|
163
|
+
##
|
164
|
+
# Appends an error to the model if name is not a String
|
165
|
+
#
|
166
|
+
# @return [void]
|
167
|
+
#
|
168
|
+
# @api private
|
74
169
|
def name_is_a_string
|
75
170
|
value_is_a_string(target: :name, value: name)
|
76
171
|
end
|
77
172
|
|
173
|
+
##
|
174
|
+
# Appends an error to the model if name is not a String or nil
|
175
|
+
#
|
176
|
+
# @return [void]
|
177
|
+
#
|
178
|
+
# @api private
|
78
179
|
def name_is_a_string_and_not_null
|
79
180
|
value_is_a_string(target: :name, value: name, nullable: false)
|
80
181
|
end
|
81
182
|
|
183
|
+
##
|
184
|
+
# Appends an error to the model if hero_id is a negative Integer
|
185
|
+
#
|
186
|
+
# @return [void]
|
187
|
+
#
|
188
|
+
# @api private
|
82
189
|
def hero_id_is_a_non_negative_integer
|
83
190
|
value_is_a_non_negative_integer(target: :hero_id, value: hero_id)
|
84
191
|
end
|
85
192
|
|
193
|
+
##
|
194
|
+
# Appends an error to the model if hero_id is a negative Integer or nil
|
195
|
+
#
|
196
|
+
# @return [void]
|
197
|
+
#
|
198
|
+
# @api private
|
86
199
|
def hero_id_is_a_non_negative_integer_and_not_null
|
87
200
|
value_is_a_non_negative_integer(target: :hero_id, value: hero_id, nullable: false)
|
88
201
|
end
|
89
202
|
|
203
|
+
##
|
204
|
+
# Appends an error to the model if primary_skill_id is a negative Integer
|
205
|
+
#
|
206
|
+
# @return [void]
|
207
|
+
#
|
208
|
+
# @api private
|
90
209
|
def primary_skill_id_is_a_non_negative_integer
|
91
210
|
value_is_a_non_negative_integer(target: :primary_skill_id, value: primary_skill_id)
|
92
211
|
end
|
93
212
|
|
213
|
+
##
|
214
|
+
# Appends an error to the model if primary_skill_id is a negative Integer or nil
|
215
|
+
#
|
216
|
+
# @return [void]
|
217
|
+
#
|
218
|
+
# @api private
|
94
219
|
def primary_skill_id_is_a_non_negative_integer_and_not_null
|
95
220
|
value_is_a_non_negative_integer(target: :primary_skill_id, value: primary_skill_id, nullable: false)
|
96
221
|
end
|
97
222
|
|
223
|
+
##
|
224
|
+
# Appends an error to the model if secondary_skill_id is a negative Integer
|
225
|
+
#
|
226
|
+
# @return [void]
|
227
|
+
#
|
228
|
+
# @api private
|
98
229
|
def secondary_skill_id_is_a_non_negative_integer
|
99
230
|
value_is_a_non_negative_integer(target: :secondary_skill_id, value: secondary_skill_id)
|
100
231
|
end
|
101
232
|
|
233
|
+
##
|
234
|
+
# Appends an error to the model if secondary_skill_id is a negative Integer or nil
|
235
|
+
#
|
236
|
+
# @return [void]
|
237
|
+
#
|
238
|
+
# @api private
|
102
239
|
def secondary_skill_id_is_a_non_negative_integer_and_not_null
|
103
240
|
value_is_a_non_negative_integer(target: :secondary_skill_id, value: secondary_skill_id, nullable: false)
|
104
241
|
end
|
105
242
|
|
243
|
+
##
|
244
|
+
# Appends an error to the model if version is not a String
|
245
|
+
#
|
246
|
+
# @return [void]
|
247
|
+
#
|
248
|
+
# @api private
|
106
249
|
def version_is_a_string
|
107
250
|
value_is_a_string(target: :version, value: version)
|
108
251
|
end
|
109
252
|
|
253
|
+
##
|
254
|
+
# Appends an error to the model if version is not a String or nil
|
255
|
+
#
|
256
|
+
# @return [void]
|
257
|
+
#
|
258
|
+
# @api private
|
110
259
|
def version_is_a_string_and_not_null
|
111
260
|
value_is_a_string(target: :version, value: version, nullable: false)
|
112
261
|
end
|
113
262
|
|
263
|
+
##
|
264
|
+
# Appends an error to the model if total is a negative Integer
|
265
|
+
#
|
266
|
+
# @return [void]
|
267
|
+
#
|
268
|
+
# @api private
|
114
269
|
def total_is_a_non_negative_integer
|
115
270
|
value_is_a_non_negative_integer(target: :total, value: total)
|
116
271
|
end
|
117
272
|
|
273
|
+
##
|
274
|
+
# Appends an error to the model if total is a negative Integer or nil
|
275
|
+
#
|
276
|
+
# @return [void]
|
277
|
+
#
|
278
|
+
# @api private
|
118
279
|
def total_is_a_non_negative_integer_and_not_null
|
119
280
|
value_is_a_non_negative_integer(target: :total, value: total, nullable: false)
|
120
281
|
end
|
121
282
|
|
283
|
+
##
|
284
|
+
# Appends an error to the model if page is a negative Integer
|
285
|
+
#
|
286
|
+
# @return [void]
|
287
|
+
#
|
288
|
+
# @api private
|
122
289
|
def page_is_a_non_negative_integer
|
123
290
|
value_is_a_non_negative_integer(target: :page, value: page)
|
124
291
|
end
|
125
292
|
|
293
|
+
##
|
294
|
+
# Appends an error to the model if page is a negative Integer or nil
|
295
|
+
#
|
296
|
+
# @return [void]
|
297
|
+
#
|
298
|
+
# @api private
|
126
299
|
def page_is_a_non_negative_integer_and_not_null
|
127
300
|
value_is_a_non_negative_integer(target: :page, value: page, nullable: false)
|
128
301
|
end
|
129
302
|
|
303
|
+
##
|
304
|
+
# Appends an error to the model if limit is a negative Integer
|
305
|
+
#
|
306
|
+
# @return [void]
|
307
|
+
#
|
308
|
+
# @api private
|
130
309
|
def limit_is_a_non_negative_integer
|
131
310
|
value_is_a_non_negative_integer(target: :limit, value: limit)
|
132
311
|
end
|
133
312
|
|
313
|
+
##
|
314
|
+
# Appends an error to the model if limit is a negative Integer or nil
|
315
|
+
#
|
316
|
+
# @return [void]
|
317
|
+
#
|
318
|
+
# @api private
|
134
319
|
def limit_is_a_non_negative_integer_and_not_null
|
135
320
|
value_is_a_non_negative_integer(target: :limit, value: limit, nullable: false)
|
136
321
|
end
|
137
322
|
|
323
|
+
##
|
324
|
+
# Appends an error to the model if card_name is not a String
|
325
|
+
#
|
326
|
+
# @return [void]
|
327
|
+
#
|
328
|
+
# @api private
|
138
329
|
def card_name_is_a_string
|
139
330
|
value_is_a_string(target: :card_name, value: card_name)
|
140
331
|
end
|
141
332
|
|
333
|
+
##
|
334
|
+
# Appends an error to the model if card_name is not a String or nil
|
335
|
+
#
|
336
|
+
# @return [void]
|
337
|
+
#
|
338
|
+
# @api private
|
142
339
|
def card_name_is_a_string_and_not_null
|
143
340
|
value_is_a_string(target: :card_name, value: card_name, nullable: false)
|
144
341
|
end
|
145
342
|
|
343
|
+
##
|
344
|
+
# Appends an error to the model if amount is a negative Integer
|
345
|
+
#
|
346
|
+
# @return [void]
|
347
|
+
#
|
348
|
+
# @api private
|
146
349
|
def amount_is_a_non_negative_integer
|
147
350
|
value_is_a_non_negative_integer(target: :amount, value: amount)
|
148
351
|
end
|
149
352
|
|
353
|
+
##
|
354
|
+
# Appends an error to the model if amount is a negative Integer or nil
|
355
|
+
#
|
356
|
+
# @return [void]
|
357
|
+
#
|
358
|
+
# @api private
|
150
359
|
def amount_is_a_non_negative_integer_and_not_null
|
151
360
|
value_is_a_non_negative_integer(target: :amount, value: amount, nullable: false)
|
152
361
|
end
|
153
362
|
|
363
|
+
##
|
364
|
+
# Appends an error to the model if sender_address is not a String
|
365
|
+
#
|
366
|
+
# @return [void]
|
367
|
+
#
|
368
|
+
# @api private
|
154
369
|
def sender_address_is_a_string
|
155
370
|
value_is_a_string(target: :sender_address, value: sender_address)
|
156
371
|
end
|
157
372
|
|
373
|
+
##
|
374
|
+
# Appends an error to the model if sender_address is not a String or nil
|
375
|
+
#
|
376
|
+
# @return [void]
|
377
|
+
#
|
378
|
+
# @api private
|
158
379
|
def sender_address_is_a_string_and_not_null
|
159
380
|
value_is_a_string(target: :sender_address, value: sender_address, nullable: false)
|
160
381
|
end
|
161
382
|
|
383
|
+
##
|
384
|
+
# Appends an error to the model if created_at is not a Time
|
385
|
+
#
|
386
|
+
# @return [void]
|
387
|
+
#
|
388
|
+
# @api private
|
162
389
|
def created_at_is_a_time
|
163
390
|
value_is_a_time(target: :created_at, value: created_at)
|
164
391
|
end
|
165
392
|
|
393
|
+
##
|
394
|
+
# Appends an error to the model if created_at is not a Time or nil
|
395
|
+
#
|
396
|
+
# @return [void]
|
397
|
+
#
|
398
|
+
# @api private
|
166
399
|
def created_at_is_a_time_and_not_null
|
167
400
|
value_is_a_time(target: :created_at, value: created_at, nullable: false)
|
168
401
|
end
|
169
402
|
|
403
|
+
##
|
404
|
+
# Appends an error to the model if updated_at is not a Time
|
405
|
+
#
|
406
|
+
# @return [void]
|
407
|
+
#
|
408
|
+
# @api private
|
170
409
|
def updated_at_is_a_time
|
171
410
|
value_is_a_time(target: :updated_at, value: updated_at)
|
172
411
|
end
|
173
412
|
|
413
|
+
##
|
414
|
+
# Appends an error to the model if updated_at is not a Time or nil
|
415
|
+
#
|
416
|
+
# @return [void]
|
417
|
+
#
|
418
|
+
# @api private
|
174
419
|
def updated_at_is_a_time_and_not_null
|
175
420
|
value_is_a_time(target: :updated_at, value: updated_at, nullable: false)
|
176
421
|
end
|
177
422
|
|
423
|
+
##
|
424
|
+
# Appends an error to the model if block_height is a negative Integer
|
425
|
+
#
|
426
|
+
# @return [void]
|
427
|
+
#
|
428
|
+
# @api private
|
178
429
|
def block_height_is_a_non_negative_integer
|
179
430
|
value_is_a_non_negative_integer(target: :block_height, value: block_height)
|
180
431
|
end
|
181
432
|
|
433
|
+
##
|
434
|
+
# Appends an error to the model if block_height is a negative Integer or nil
|
435
|
+
#
|
436
|
+
# @return [void]
|
437
|
+
#
|
438
|
+
# @api private
|
182
439
|
def block_height_is_a_non_negative_integer_and_not_null
|
183
440
|
value_is_a_non_negative_integer(target: :block_height, value: block_height, nullable: false)
|
184
441
|
end
|
185
442
|
|
443
|
+
##
|
444
|
+
# Appends an error to the model if player1_id is not a String
|
445
|
+
#
|
446
|
+
# @return [void]
|
447
|
+
#
|
448
|
+
# @api private
|
186
449
|
def player1_id_is_a_string
|
187
450
|
value_is_a_string(target: :player1_id, value: player1_id)
|
188
451
|
end
|
189
452
|
|
453
|
+
##
|
454
|
+
# Appends an error to the model if player1_id is not a String or nil
|
455
|
+
#
|
456
|
+
# @return [void]
|
457
|
+
#
|
458
|
+
# @api private
|
190
459
|
def player1_id_is_a_string_and_not_null
|
191
460
|
value_is_a_string(target: :player1_id, value: player1_id, nullable: false)
|
192
461
|
end
|
193
462
|
|
463
|
+
##
|
464
|
+
# Appends an error to the model if player2_id is not a String
|
465
|
+
#
|
466
|
+
# @return [void]
|
467
|
+
#
|
468
|
+
# @api private
|
194
469
|
def player2_id_is_a_string
|
195
470
|
value_is_a_string(target: :player2_id, value: player2_id)
|
196
471
|
end
|
197
472
|
|
473
|
+
##
|
474
|
+
# Appends an error to the model if player2_id is not a String or nil
|
475
|
+
#
|
476
|
+
# @return [void]
|
477
|
+
#
|
478
|
+
# @api private
|
198
479
|
def player2_id_is_a_string_and_not_null
|
199
480
|
value_is_a_string(target: :player2_id, value: player2_id, nullable: false)
|
200
481
|
end
|
201
482
|
|
483
|
+
##
|
484
|
+
# Appends an error to the model if player1_deck_id is a negative Integer
|
485
|
+
#
|
486
|
+
# @return [void]
|
487
|
+
#
|
488
|
+
# @api private
|
202
489
|
def player1_deck_id_is_a_non_negative_integer
|
203
490
|
value_is_a_non_negative_integer(target: :player1_deck_id, value: player1_deck_id)
|
204
491
|
end
|
205
492
|
|
493
|
+
##
|
494
|
+
# Appends an error to the model if player1_deck_id is a negative Integer or nil
|
495
|
+
#
|
496
|
+
# @return [void]
|
497
|
+
#
|
498
|
+
# @api private
|
206
499
|
def player1_deck_id_is_a_non_negative_integer_and_not_null
|
207
500
|
value_is_a_non_negative_integer(target: :player1_deck_id, value: player1_deck_id, nullable: false)
|
208
501
|
end
|
209
502
|
|
503
|
+
##
|
504
|
+
# Appends an error to the model if player2_deck_id is a negative Integer
|
505
|
+
#
|
506
|
+
# @return [void]
|
507
|
+
#
|
508
|
+
# @api private
|
210
509
|
def player2_deck_id_is_a_non_negative_integer
|
211
510
|
value_is_a_non_negative_integer(target: :player2_deck_id, value: player2_deck_id)
|
212
511
|
end
|
213
512
|
|
513
|
+
##
|
514
|
+
# Appends an error to the model if player2_deck_id is a negative Integer or nil
|
515
|
+
#
|
516
|
+
# @return [void]
|
517
|
+
#
|
518
|
+
# @api private
|
214
519
|
def player2_deck_id_is_a_non_negative_integer_and_not_null
|
215
520
|
value_is_a_non_negative_integer(target: :player2_deck_id, value: player2_deck_id, nullable: false)
|
216
521
|
end
|
217
522
|
|
523
|
+
##
|
524
|
+
# Appends an error to the model if random_seed is a negative Integer
|
525
|
+
#
|
526
|
+
# @return [void]
|
527
|
+
#
|
528
|
+
# @api private
|
218
529
|
def random_seed_is_a_non_negative_integer
|
219
530
|
value_is_a_non_negative_integer(target: :random_seed, value: random_seed)
|
220
531
|
end
|
221
532
|
|
533
|
+
##
|
534
|
+
# Appends an error to the model if random_seed is a negative Integer or nil
|
535
|
+
#
|
536
|
+
# @return [void]
|
537
|
+
#
|
538
|
+
# @api private
|
222
539
|
def random_seed_is_a_non_negative_integer_and_not_null
|
223
540
|
value_is_a_non_negative_integer(target: :random_seed, value: random_seed, nullable: false)
|
224
541
|
end
|
225
542
|
|
543
|
+
##
|
544
|
+
# Appends an error to the model if status is not a String
|
545
|
+
#
|
546
|
+
# @return [void]
|
547
|
+
#
|
548
|
+
# @api private
|
226
549
|
def status_is_a_string
|
227
550
|
value_is_a_string(target: :status, value: status)
|
228
551
|
end
|
229
552
|
|
553
|
+
##
|
554
|
+
# Appends an error to the model if status is not a String or nil
|
555
|
+
#
|
556
|
+
# @return [void]
|
557
|
+
#
|
558
|
+
# @api private
|
230
559
|
def status_is_a_string_and_not_null
|
231
560
|
value_is_a_string(target: :status, value: status, nullable: false)
|
232
561
|
end
|
233
562
|
|
563
|
+
##
|
564
|
+
# Appends an error to the model if winner_id is not a String
|
565
|
+
#
|
566
|
+
# @return [void]
|
567
|
+
#
|
568
|
+
# @api private
|
234
569
|
def winner_id_is_a_string
|
235
570
|
value_is_a_string(target: :winner_id, value: winner_id)
|
236
571
|
end
|
237
572
|
|
573
|
+
##
|
574
|
+
# Appends an error to the model if winner_id is not a String or nil
|
575
|
+
#
|
576
|
+
# @return [void]
|
577
|
+
#
|
578
|
+
# @api private
|
238
579
|
def winner_id_is_a_string_and_not_null
|
239
580
|
value_is_a_string(target: :winner_id, value: winner_id, nullable: false)
|
240
581
|
end
|
241
582
|
|
583
|
+
##
|
584
|
+
# Appends an error to the model if mould_id is not a String
|
585
|
+
#
|
586
|
+
# @return [void]
|
587
|
+
#
|
588
|
+
# @api private
|
242
589
|
def mould_id_is_a_string
|
243
590
|
value_is_a_string(target: :mould_id, value: mould_id)
|
244
591
|
end
|
245
592
|
|
593
|
+
##
|
594
|
+
# Appends an error to the model if mould_id is not a String or nil
|
595
|
+
#
|
596
|
+
# @return [void]
|
597
|
+
#
|
598
|
+
# @api private
|
246
599
|
def mould_id_is_a_string_and_not_null
|
247
600
|
value_is_a_string(target: :mould_id, value: mould_id, nullable: false)
|
248
601
|
end
|
249
602
|
|
603
|
+
##
|
604
|
+
# Appends an error to the model if kind is not a String
|
605
|
+
#
|
606
|
+
# @return [void]
|
607
|
+
#
|
608
|
+
# @api private
|
250
609
|
def kind_is_a_string
|
251
610
|
value_is_a_string(target: :kind, value: kind)
|
252
611
|
end
|
253
612
|
|
613
|
+
##
|
614
|
+
# Appends an error to the model if kind is not a String or nil
|
615
|
+
#
|
616
|
+
# @return [void]
|
617
|
+
#
|
618
|
+
# @api private
|
254
619
|
def kind_is_a_string_and_not_null
|
255
620
|
value_is_a_string(target: :kind, value: kind, nullable: false)
|
256
621
|
end
|
257
622
|
|
623
|
+
##
|
624
|
+
# Appends an error to the model if set is not a String
|
625
|
+
#
|
626
|
+
# @return [void]
|
627
|
+
#
|
628
|
+
# @api private
|
258
629
|
def set_is_a_string
|
259
630
|
value_is_a_string(target: :set, value: set)
|
260
631
|
end
|
261
632
|
|
633
|
+
##
|
634
|
+
# Appends an error to the model if set is not a String or nil
|
635
|
+
#
|
636
|
+
# @return [void]
|
637
|
+
#
|
638
|
+
# @api private
|
262
639
|
def set_is_a_string_and_not_null
|
263
640
|
value_is_a_string(target: :set, value: set, nullable: false)
|
264
641
|
end
|
265
642
|
|
643
|
+
##
|
644
|
+
# Appends an error to the model if description is not a String
|
645
|
+
#
|
646
|
+
# @return [void]
|
647
|
+
#
|
648
|
+
# @api private
|
266
649
|
def description_is_a_string
|
267
650
|
value_is_a_string(target: :description, value: description)
|
268
651
|
end
|
269
652
|
|
653
|
+
##
|
654
|
+
# Appends an error to the model if description is not a String or nil
|
655
|
+
#
|
656
|
+
# @return [void]
|
657
|
+
#
|
658
|
+
# @api private
|
270
659
|
def description_is_a_string_and_not_null
|
271
660
|
value_is_a_string(target: :description, value: description, nullable: false)
|
272
661
|
end
|
273
662
|
|
663
|
+
##
|
664
|
+
# Appends an error to the model if rank is not a String
|
665
|
+
#
|
666
|
+
# @return [void]
|
667
|
+
#
|
668
|
+
# @api private
|
274
669
|
def rank_is_a_string
|
275
670
|
value_is_a_string(target: :rank, value: rank)
|
276
671
|
end
|
277
672
|
|
673
|
+
##
|
674
|
+
# Appends an error to the model if rank is not a String or nil
|
675
|
+
#
|
676
|
+
# @return [void]
|
677
|
+
#
|
678
|
+
# @api private
|
278
679
|
def rank_is_a_string_and_not_null
|
279
680
|
value_is_a_string(target: :rank, value: rank, nullable: false)
|
280
681
|
end
|
281
682
|
|
683
|
+
##
|
684
|
+
# Appends an error to the model if type is not a String
|
685
|
+
#
|
686
|
+
# @return [void]
|
687
|
+
#
|
688
|
+
# @api private
|
282
689
|
def type_is_a_string
|
283
690
|
value_is_a_string(target: :type, value: type)
|
284
691
|
end
|
285
692
|
|
693
|
+
##
|
694
|
+
# Appends an error to the model if type is not a String or nil
|
695
|
+
#
|
696
|
+
# @return [void]
|
697
|
+
#
|
698
|
+
# @api private
|
286
699
|
def type_is_a_string_and_not_null
|
287
700
|
value_is_a_string(target: :type, value: type, nullable: false)
|
288
701
|
end
|
289
702
|
|
703
|
+
##
|
704
|
+
# Appends an error to the model if rarity is not a String
|
705
|
+
#
|
706
|
+
# @return [void]
|
707
|
+
#
|
708
|
+
# @api private
|
290
709
|
def rarity_is_a_string
|
291
710
|
value_is_a_string(target: :rarity, value: rarity)
|
292
711
|
end
|
293
712
|
|
713
|
+
##
|
714
|
+
# Appends an error to the model if rarity is not a String or nil
|
715
|
+
#
|
716
|
+
# @return [void]
|
717
|
+
#
|
718
|
+
# @api private
|
294
719
|
def rarity_is_a_string_and_not_null
|
295
720
|
value_is_a_string(target: :rarity, value: rarity, nullable: false)
|
296
721
|
end
|
297
722
|
|
723
|
+
##
|
724
|
+
# Appends an error to the model if frame is not a String
|
725
|
+
#
|
726
|
+
# @return [void]
|
727
|
+
#
|
728
|
+
# @api private
|
298
729
|
def frame_is_a_string
|
299
730
|
value_is_a_string(target: :frame, value: frame)
|
300
731
|
end
|
301
732
|
|
733
|
+
##
|
734
|
+
# Appends an error to the model if frame is not a String or nil
|
735
|
+
#
|
736
|
+
# @return [void]
|
737
|
+
#
|
738
|
+
# @api private
|
302
739
|
def frame_is_a_string_and_not_null
|
303
740
|
value_is_a_string(target: :frame, value: frame, nullable: false)
|
304
741
|
end
|
305
742
|
|
743
|
+
##
|
744
|
+
# Appends an error to the model if damage is a negative Integer
|
745
|
+
#
|
746
|
+
# @return [void]
|
747
|
+
#
|
748
|
+
# @api private
|
306
749
|
def damage_is_a_non_negative_integer
|
307
750
|
value_is_a_non_negative_integer(target: :damage, value: damage)
|
308
751
|
end
|
309
752
|
|
753
|
+
##
|
754
|
+
# Appends an error to the model if damage is a negative Integer or nil
|
755
|
+
#
|
756
|
+
# @return [void]
|
757
|
+
#
|
758
|
+
# @api private
|
310
759
|
def damage_is_a_non_negative_integer_and_not_null
|
311
760
|
value_is_a_non_negative_integer(target: :damage, value: damage, nullable: false)
|
312
761
|
end
|
313
762
|
|
763
|
+
##
|
764
|
+
# Appends an error to the model if health is a negative Integer
|
765
|
+
#
|
766
|
+
# @return [void]
|
767
|
+
#
|
768
|
+
# @api private
|
314
769
|
def health_is_a_non_negative_integer
|
315
770
|
value_is_a_non_negative_integer(target: :health, value: health)
|
316
771
|
end
|
317
772
|
|
773
|
+
##
|
774
|
+
# Appends an error to the model if health is a negative Integer or nil
|
775
|
+
#
|
776
|
+
# @return [void]
|
777
|
+
#
|
778
|
+
# @api private
|
318
779
|
def health_is_a_non_negative_integer_and_not_null
|
319
780
|
value_is_a_non_negative_integer(target: :health, value: health, nullable: false)
|
320
781
|
end
|
321
782
|
|
783
|
+
##
|
784
|
+
# Appends an error to the model if cost is a negative Integer
|
785
|
+
#
|
786
|
+
# @return [void]
|
787
|
+
#
|
788
|
+
# @api private
|
322
789
|
def cost_is_a_non_negative_integer
|
323
790
|
value_is_a_non_negative_integer(target: :cost, value: cost)
|
324
791
|
end
|
325
792
|
|
793
|
+
##
|
794
|
+
# Appends an error to the model if cost is a negative Integer or nil
|
795
|
+
#
|
796
|
+
# @return [void]
|
797
|
+
#
|
798
|
+
# @api private
|
326
799
|
def cost_is_a_non_negative_integer_and_not_null
|
327
800
|
value_is_a_non_negative_integer(target: :cost, value: cost, nullable: false)
|
328
801
|
end
|
329
802
|
|
803
|
+
##
|
804
|
+
# Appends an error to the model if ability is not a String
|
805
|
+
#
|
806
|
+
# @return [void]
|
807
|
+
#
|
808
|
+
# @api private
|
330
809
|
def ability_is_a_string
|
331
810
|
value_is_a_string(target: :ability, value: ability)
|
332
811
|
end
|
333
812
|
|
813
|
+
##
|
814
|
+
# Appends an error to the model if ability is not a String or nil
|
815
|
+
#
|
816
|
+
# @return [void]
|
817
|
+
#
|
818
|
+
# @api private
|
334
819
|
def ability_is_a_string_and_not_null
|
335
820
|
value_is_a_string(target: :ability, value: ability, nullable: false)
|
336
821
|
end
|
337
822
|
|
823
|
+
##
|
824
|
+
# Appends an error to the model if image_url is not a String
|
825
|
+
#
|
826
|
+
# @return [void]
|
827
|
+
#
|
828
|
+
# @api private
|
338
829
|
def image_url_is_a_string
|
339
830
|
value_is_a_string(target: :image_url, value: image_url)
|
340
831
|
end
|
341
832
|
|
833
|
+
##
|
834
|
+
# Appends an error to the model if image_url is not a String or nil
|
835
|
+
#
|
836
|
+
# @return [void]
|
837
|
+
#
|
838
|
+
# @api private
|
342
839
|
def image_url_is_a_string_and_not_null
|
343
840
|
value_is_a_string(target: :image_url, value: image_url, nullable: false)
|
344
841
|
end
|