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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/Gemfile.lock +29 -11
  4. data/README.md +4 -0
  5. data/Rakefile +62 -5
  6. data/lib/zombie_battleground/api.rb +108 -8
  7. data/lib/zombie_battleground/api/client.rb +157 -23
  8. data/lib/zombie_battleground/api/errors.rb +28 -0
  9. data/lib/zombie_battleground/api/models/card.rb +272 -32
  10. data/lib/zombie_battleground/api/models/deck.rb +234 -46
  11. data/lib/zombie_battleground/api/models/match.rb +211 -33
  12. data/lib/zombie_battleground/api/models/simple_card.rb +47 -11
  13. data/lib/zombie_battleground/api/requests/get_card_request.rb +45 -10
  14. data/lib/zombie_battleground/api/requests/get_cards_request.rb +203 -27
  15. data/lib/zombie_battleground/api/requests/get_deck_request.rb +43 -13
  16. data/lib/zombie_battleground/api/requests/get_decks_request.rb +141 -23
  17. data/lib/zombie_battleground/api/requests/get_match_request.rb +43 -13
  18. data/lib/zombie_battleground/api/requests/get_matches_request.rb +125 -21
  19. data/lib/zombie_battleground/api/requests/request_helper.rb +24 -10
  20. data/lib/zombie_battleground/api/responses/get_card_response.rb +50 -16
  21. data/lib/zombie_battleground/api/responses/get_cards_response.rb +103 -33
  22. data/lib/zombie_battleground/api/responses/get_deck_response.rb +49 -17
  23. data/lib/zombie_battleground/api/responses/get_decks_response.rb +103 -33
  24. data/lib/zombie_battleground/api/responses/get_match_response.rb +49 -17
  25. data/lib/zombie_battleground/api/responses/get_matches_response.rb +103 -33
  26. data/lib/zombie_battleground/api/responses/response_helper.rb +32 -16
  27. data/lib/zombie_battleground/api/validation_helper.rb +497 -0
  28. data/lib/zombie_battleground/api/version.rb +5 -1
  29. data/zombie_battleground-api.gemspec +6 -0
  30. metadata +71 -1
@@ -7,23 +7,53 @@ require 'zombie_battleground/api/requests/request_helper'
7
7
 
8
8
  module ZombieBattleground
9
9
  class Api
10
- ##
11
- # Request validator for GetDeck
12
- class GetDeckRequest
13
- include ActiveModel::Validations
14
- include ZombieBattleground::Api::ValidationHelper
15
- include ZombieBattleground::Api::RequestHelper
10
+ class Requests
11
+ ##
12
+ # Request validator for GetDeck
13
+ class GetDeckRequest
14
+ include ActiveModel::Validations
15
+ include ZombieBattleground::Api::ValidationHelper
16
+ include ZombieBattleground::Api::Requests::RequestHelper
16
17
 
17
- attr_accessor :id
18
+ ##
19
+ # @!attribute [r] id
20
+ # Deck's id
21
+ #
22
+ # @return [Integer]
23
+ #
24
+ # @example
25
+ # request.id #=> 1812
26
+ #
27
+ # @api public
28
+ attr_accessor :id
18
29
 
19
- validate :id_is_a_non_negative_integer
30
+ validate :id_is_a_non_negative_integer
20
31
 
21
- def uri
22
- "deck/#{id}"
23
- end
32
+ ##
33
+ # The URI for the endpoint
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # request.uri # => "deck/1812"
39
+ #
40
+ # @api public
41
+ def uri
42
+ "deck/#{id}"
43
+ end
24
44
 
25
- def params
26
- {}
45
+ ##
46
+ # Deck does not take params, return an empty Hash
47
+ #
48
+ # @return [Hash]
49
+ #
50
+ # @example
51
+ # request.params # => {}
52
+ #
53
+ # @api public
54
+ def params
55
+ {}
56
+ end
27
57
  end
28
58
  end
29
59
  end
@@ -7,29 +7,147 @@ require 'zombie_battleground/api/requests/request_helper'
7
7
 
8
8
  module ZombieBattleground
9
9
  class Api
10
- ##
11
- # Request validator for GetDecks
12
- class GetDecksRequest
13
- include ActiveModel::Validations
14
- include ZombieBattleground::Api::ValidationHelper
15
- include ZombieBattleground::Api::RequestHelper
16
-
17
- attr_accessor :id, :user_id, :deck_id, :name, :hero_id, :primary_skill_id,
18
- :secondary_skill_id, :version, :page, :limit
19
-
20
- validate :id_is_a_non_negative_integer
21
- validate :user_id_is_a_string
22
- validate :deck_id_is_a_non_negative_integer
23
- validate :name_is_a_string
24
- validate :hero_id_is_a_non_negative_integer
25
- validate :primary_skill_id_is_a_non_negative_integer
26
- validate :secondary_skill_id_is_a_non_negative_integer
27
- validate :version_is_a_string
28
- validate :page_is_a_non_negative_integer
29
- validate :limit_is_a_non_negative_integer
30
-
31
- def uri
32
- 'decks'
10
+ class Requests
11
+ ##
12
+ # Request validator for GetDecks
13
+ class GetDecksRequest
14
+ include ActiveModel::Validations
15
+ include ZombieBattleground::Api::ValidationHelper
16
+ include ZombieBattleground::Api::Requests::RequestHelper
17
+
18
+ # @!attribute [r] id
19
+ # Optionally set the Deck's id for filtered querying
20
+ #
21
+ # @return [Integer]
22
+ #
23
+ # @example
24
+ # request.id #=> 1
25
+ #
26
+ # @api public
27
+ attr_accessor :id
28
+
29
+ # @!attribute [r] user_id
30
+ # Optionally set the Deck's user_id for filtered querying
31
+ #
32
+ # @return [String]
33
+ #
34
+ # @example
35
+ # request.user_id #=> "ZombieSlayer_5699"
36
+ #
37
+ # @api public
38
+ attr_accessor :user_id
39
+
40
+ # @!attribute [r] deck_id
41
+ # Optionally set the Deck's deck_id for filtered querying
42
+ #
43
+ # @return [Integer]
44
+ #
45
+ # @example
46
+ # request.deck_id #=> 1
47
+ #
48
+ # @api public
49
+ attr_accessor :deck_id
50
+
51
+ # @!attribute [r] name
52
+ # Optionally set the Deck's name for filtered querying
53
+ #
54
+ # @return [String]
55
+ #
56
+ # @example
57
+ # request.name #=> "Buzzkill"
58
+ #
59
+ # @api public
60
+ attr_accessor :name
61
+
62
+ # @!attribute [r] hero_id
63
+ # Optionally set the Deck's hero_id for filtered querying
64
+ #
65
+ # @return [Integer]
66
+ #
67
+ # @example
68
+ # request.hero_id #=> 1
69
+ #
70
+ # @api public
71
+ attr_accessor :hero_id
72
+
73
+ # @!attribute [r] primary_skill_id
74
+ # Optionally set the Deck's primary_skill_id for filtered querying
75
+ #
76
+ # @return [Integer]
77
+ #
78
+ # @example
79
+ # request.primary_skill_id #=> 1
80
+ #
81
+ # @api public
82
+ attr_accessor :primary_skill_id
83
+
84
+ # @!attribute [r] secondary_skill_id
85
+ # Optionally set the Deck's secondary_skill_id for filtered querying
86
+ #
87
+ # @return [Integer]
88
+ #
89
+ # @example
90
+ # request.secondary_skill_id #=> 1
91
+ #
92
+ # @api public
93
+ attr_accessor :secondary_skill_id
94
+
95
+ # @!attribute [r] version
96
+ # Optionally set the Deck's version for filtered querying
97
+ #
98
+ # @return [String]
99
+ #
100
+ # @example
101
+ # request.version #=> "v3"
102
+ #
103
+ # @api public
104
+ attr_accessor :version
105
+
106
+ # @!attribute [r] page
107
+ # Optionally set the page number for filtered querying
108
+ #
109
+ # @return [Integer]
110
+ #
111
+ # @example
112
+ # request.page #=> 1
113
+ #
114
+ # @api public
115
+ attr_accessor :page
116
+
117
+ # @!attribute [r] limit
118
+ # Optionally set the limit for max Matches returned
119
+ #
120
+ # @return [Integer]
121
+ #
122
+ # @example
123
+ # request.limit #=> 100
124
+ #
125
+ # @api public
126
+ attr_accessor :limit
127
+
128
+ validate :id_is_a_non_negative_integer
129
+ validate :user_id_is_a_string
130
+ validate :deck_id_is_a_non_negative_integer
131
+ validate :name_is_a_string
132
+ validate :hero_id_is_a_non_negative_integer
133
+ validate :primary_skill_id_is_a_non_negative_integer
134
+ validate :secondary_skill_id_is_a_non_negative_integer
135
+ validate :version_is_a_string
136
+ validate :page_is_a_non_negative_integer
137
+ validate :limit_is_a_non_negative_integer
138
+
139
+ ##
140
+ # The URI for the endpoint
141
+ #
142
+ # @return [String]
143
+ #
144
+ # @example
145
+ # request.uri # => "decks"
146
+ #
147
+ # @api public
148
+ def uri
149
+ 'decks'
150
+ end
33
151
  end
34
152
  end
35
153
  end
@@ -7,23 +7,53 @@ require 'zombie_battleground/api/requests/request_helper'
7
7
 
8
8
  module ZombieBattleground
9
9
  class Api
10
- ##
11
- # Request validator for GetMatch
12
- class GetMatchRequest
13
- include ActiveModel::Validations
14
- include ZombieBattleground::Api::ValidationHelper
15
- include ZombieBattleground::Api::RequestHelper
10
+ class Requests
11
+ ##
12
+ # Request validator for GetMatch
13
+ class GetMatchRequest
14
+ include ActiveModel::Validations
15
+ include ZombieBattleground::Api::ValidationHelper
16
+ include ZombieBattleground::Api::Requests::RequestHelper
16
17
 
17
- attr_accessor :id
18
+ ##
19
+ # @!attribute [r] id
20
+ # Match's id
21
+ #
22
+ # @return [Integer]
23
+ #
24
+ # @example
25
+ # request.id #=> 1
26
+ #
27
+ # @api public
28
+ attr_accessor :id
18
29
 
19
- validate :id_is_a_non_negative_integer
30
+ validate :id_is_a_non_negative_integer
20
31
 
21
- def uri
22
- "match/#{id}"
23
- end
32
+ ##
33
+ # The URI for the endpoint
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # request.uri # => "match/1"
39
+ #
40
+ # @api public
41
+ def uri
42
+ "match/#{id}"
43
+ end
24
44
 
25
- def params
26
- {}
45
+ ##
46
+ # Match does not take params, return an empty Hash
47
+ #
48
+ # @return [Hash]
49
+ #
50
+ # @example
51
+ # request.params # => {}
52
+ #
53
+ # @api public
54
+ def params
55
+ {}
56
+ end
27
57
  end
28
58
  end
29
59
  end
@@ -7,27 +7,131 @@ require 'zombie_battleground/api/requests/request_helper'
7
7
 
8
8
  module ZombieBattleground
9
9
  class Api
10
- ##
11
- # Request validator for GetMatches
12
- class GetMatchesRequest
13
- include ActiveModel::Validations
14
- include ZombieBattleground::Api::ValidationHelper
15
- include ZombieBattleground::Api::RequestHelper
16
-
17
- attr_accessor :id, :player1_id, :player2_id, :status, :version, :winner_id,
18
- :total, :page, :limit
19
-
20
- validate :id_is_a_non_negative_integer
21
- validate :player1_id_is_a_string
22
- validate :player2_id_is_a_string
23
- validate :status_is_a_string
24
- validate :version_is_a_string
25
- validate :winner_id_is_a_string
26
- validate :page_is_a_non_negative_integer
27
- validate :limit_is_a_non_negative_integer
28
-
29
- def uri
30
- 'matches'
10
+ class Requests
11
+ ##
12
+ # Request validator for GetMatches
13
+ class GetMatchesRequest
14
+ include ActiveModel::Validations
15
+ include ZombieBattleground::Api::ValidationHelper
16
+ include ZombieBattleground::Api::Requests::RequestHelper
17
+
18
+ ##
19
+ # @!attribute [r] id
20
+ # Optionally set the Match's id for filtered querying
21
+ #
22
+ # @return [Integer]
23
+ #
24
+ # @example
25
+ # request.id #=> 1
26
+ #
27
+ # @api public
28
+ attr_accessor :id
29
+
30
+ ##
31
+ # @!attribute [r] player1_id
32
+ # Optionally set the Match's player1_id for filtered querying
33
+ #
34
+ # @return [String]
35
+ #
36
+ # @example
37
+ # request.player1_id #=> "ZombieSlayer_16601021609396167139295300949176"
38
+ #
39
+ # @api public
40
+ attr_accessor :player1_id
41
+
42
+ ##
43
+ # @!attribute [r] player2_id
44
+ # Optionally set the Match's player2_id for filtered querying
45
+ #
46
+ # @return [String]
47
+ #
48
+ # @example
49
+ # request.player2_id #=> "ZombieSlayer_16601021609396167139295300949176"
50
+ #
51
+ # @api public
52
+ attr_accessor :player2_id
53
+
54
+ ##
55
+ # @!attribute [r] status
56
+ # Optionally set the Match's status for filtered querying
57
+ #
58
+ # @return [String]
59
+ #
60
+ # @example
61
+ # request.status #=> "Ended"
62
+ #
63
+ # @api public
64
+ attr_accessor :status
65
+
66
+ ##
67
+ # @!attribute [r] version
68
+ # Optionally set the Match's version for filtered querying
69
+ #
70
+ # @return [String]
71
+ #
72
+ # @example
73
+ # request.version #=> "v3"
74
+ #
75
+ # @api public
76
+ attr_accessor :version
77
+
78
+ ##
79
+ # @!attribute [r] winner_id
80
+ # Optionally set the Match's winner_id for filtered querying
81
+ #
82
+ # @return [String]
83
+ #
84
+ # @example
85
+ # request.winner_id #=> "ZombieSlayer_16601021609396167139295300949176"
86
+ #
87
+ # @api public
88
+ attr_accessor :winner_id
89
+
90
+ ##
91
+ # @!attribute [r] page
92
+ # Optionally set the page number for filtered querying
93
+ #
94
+ # @return [Integer]
95
+ #
96
+ # @example
97
+ # request.page #=> 1
98
+ #
99
+ # @api public
100
+ attr_accessor :page
101
+
102
+ ##
103
+ # @!attribute [r] limit
104
+ # Optionally set the limit for max Matches returned
105
+ #
106
+ # @return [Integer]
107
+ #
108
+ # @example
109
+ # request.limit #=> 100
110
+ #
111
+ # @api public
112
+ attr_accessor :limit
113
+
114
+ validate :id_is_a_non_negative_integer
115
+ validate :player1_id_is_a_string
116
+ validate :player2_id_is_a_string
117
+ validate :status_is_a_string
118
+ validate :version_is_a_string
119
+ validate :winner_id_is_a_string
120
+ validate :page_is_a_non_negative_integer
121
+ validate :limit_is_a_non_negative_integer
122
+
123
+ ##
124
+ # The URI for the endpoint
125
+ #
126
+ # @return [String]
127
+ #
128
+ # @example
129
+ # request.uri # => "matches"
130
+ #
131
+ # @api public
132
+ def uri
133
+ 'matches'
134
+ end
31
135
  end
32
136
  end
33
137
  end