Class: ZombieBattleground::Api::Client
- Inherits:
-
Object
- Object
- ZombieBattleground::Api::Client
- Defined in:
- lib/zombie_battleground/api/client.rb
Overview
The API Client for Zombie Battleground
Instance Method Summary collapse
-
#card_request(**args) ⇒ ZombieBattleground::Api::Responses::GetCardResponse
Queries for a Card.
-
#cards_request(**args) ⇒ ZombieBattleground::Api::Responses::GetCardsResponse
Queries for Cards.
-
#deck_request(**args) ⇒ ZombieBattleground::Api::Responses::GetDeckResponse
Queries for a Deck.
-
#decks_request(**args) ⇒ ZombieBattleground::Api::Responses::GetDecksResponse
Queries for Decks.
-
#initialize ⇒ ZombieBattleground::Api::Client
constructor
Creates a new client.
-
#match_request(**args) ⇒ ZombieBattleground::Api::Responses::GetMatchResponse
Queries for a Match.
-
#matches_request(**args) ⇒ ZombieBattleground::Api::Responses::GetMatchesResponse
Queries for Matches.
Constructor Details
#initialize ⇒ ZombieBattleground::Api::Client
Creates a new client
47 48 49 50 |
# File 'lib/zombie_battleground/api/client.rb', line 47 def initialize @endpoint = 'https://api.loom.games/zb' @api_version = 'v1' end |
Instance Method Details
#card_request(**args) ⇒ ZombieBattleground::Api::Responses::GetCardResponse
Queries for a Card
238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/zombie_battleground/api/client.rb', line 238 def card_request(**args) request = ZombieBattleground::Api::Requests::GetCardRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get card = ZombieBattleground::Api::Responses::GetCardResponse.new(response) raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, card) unless card.valid? card end |
#cards_request(**args) ⇒ ZombieBattleground::Api::Responses::GetCardsResponse
Queries for Cards
208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/zombie_battleground/api/client.rb', line 208 def cards_request(**args) remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid) request = ZombieBattleground::Api::Requests::GetCardsRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get cards = ZombieBattleground::Api::Responses::GetCardsResponse.new(response) cards.remove_invalid = remove_invalid raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, cards) unless cards.valid? cards end |
#deck_request(**args) ⇒ ZombieBattleground::Api::Responses::GetDeckResponse
Queries for a Deck
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/zombie_battleground/api/client.rb', line 105 def deck_request(**args) request = ZombieBattleground::Api::Requests::GetDeckRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get deck = ZombieBattleground::Api::Responses::GetDeckResponse.new(response) raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, deck) unless deck.valid? deck end |
#decks_request(**args) ⇒ ZombieBattleground::Api::Responses::GetDecksResponse
Queries for Decks
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/zombie_battleground/api/client.rb', line 76 def decks_request(**args) remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid) request = ZombieBattleground::Api::Requests::GetDecksRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get decks = ZombieBattleground::Api::Responses::GetDecksResponse.new(response) decks.remove_invalid = remove_invalid raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, decks) unless decks.valid? decks end |
#match_request(**args) ⇒ ZombieBattleground::Api::Responses::GetMatchResponse
Queries for a Match
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/zombie_battleground/api/client.rb', line 168 def match_request(**args) request = ZombieBattleground::Api::Requests::GetMatchRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get match = ZombieBattleground::Api::Responses::GetMatchResponse.new(response) raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, match) unless match.valid? match end |
#matches_request(**args) ⇒ ZombieBattleground::Api::Responses::GetMatchesResponse
Queries for Matches
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/zombie_battleground/api/client.rb', line 139 def matches_request(**args) remove_invalid = args[:remove_invalid].nil? ? true : args.delete(:remove_invalid) request = ZombieBattleground::Api::Requests::GetMatchesRequest.new args.each { |key, val| request.send("#{key}=", val) } raise ZombieBattleground::Api::Errors::InvalidInput, request.errors. unless request.valid? response = connection(uri: request.uri, params: request.params).get matches = ZombieBattleground::Api::Responses::GetMatchesResponse.new(response) matches.remove_invalid = remove_invalid raise ZombieBattleground::Api::Errors::InvalidResponse.new(response, matches) unless matches.valid? matches end |