Skip to content

Commit

Permalink
100% coverage and easier API. Let's start features
Browse files Browse the repository at this point in the history
  • Loading branch information
John Shields committed Feb 15, 2019
1 parent 4efdaa4 commit 5c7d800
Show file tree
Hide file tree
Showing 27 changed files with 665 additions and 51 deletions.
25 changes: 24 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
zombie_battleground-api (0.2.1)
zombie_battleground-api (0.3.0)
activerecord
faraday
json
Expand All @@ -22,15 +22,26 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
ast (2.4.0)
coderay (1.1.2)
concurrent-ruby (1.1.4)
coveralls (0.8.22)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.4)
tins (~> 1.6)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
docile (1.3.1)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
gem-release (2.0.1)
hashdiff (0.3.8)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
Expand All @@ -48,6 +59,7 @@ GEM
pry-doc (1.0.0)
pry (~> 0.11)
yard (~> 0.9.11)
public_suffix (3.0.3)
rainbow (3.0.0)
rake (10.5.0)
rspec (3.8.0)
Expand All @@ -72,15 +84,24 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (0.19.4)
thread_safe (0.3.6)
tins (1.20.2)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.4.0)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
yard (0.9.18)
yardstick (0.9.9)
yard (~> 0.8, >= 0.8.7.2)
Expand All @@ -90,11 +111,13 @@ PLATFORMS

DEPENDENCIES
bundler (~> 1.16)
coveralls
gem-release
rake (~> 10.0)
rspec (~> 3.0)
rubocop
simplecov
webmock
yard
yardstick
zombie_battleground-api!
Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Gem Version](https://badge.fury.io/rb/zombie_battleground-api.svg)](https://badge.fury.io/rb/zombie_battleground-api)
[![Build Status](https://travis-ci.org/watmin/zombie_battleground-api.svg?branch=master)](https://travis-ci.org/watmin/zombie_battleground-api)
[![Coverage Status](https://coveralls.io/repos/github/watmin/zombie_battleground-api/badge.svg?branch=master)](https://coveralls.io/github/watmin/zombie_battleground-api?branch=master)

Ruby implementation of the Public API for Zombie Battleground

Expand All @@ -23,25 +24,33 @@ Or install it yourself as:

## Usage

See the [API documentation](https://www.rubydoc.info/gems/zombie_battleground-api/0.2.1).
See the [API documentation](https://www.rubydoc.info/gems/zombie_battleground-api/0.3.0).
Every API call returns a response object that contains a complete modeled Ruby object of the response.

Use the singleton class `ZombieBattleground::Api`

```ruby
require 'zombie_battleground-api/api'
require 'zombie_battleground/api'

ZombieBattleground::Api.decks(limit: 1)
ZombieBattleground::Api.decks_request(limit: 1)
# => ZombieBattleground::Api::Responses::GetDecksResponse

ZombieBattleground::Api.decks(limit: 1)
# => [ZombieBattleground::Api::Models::Decks]
```

Use the API client directly

```ruby
require 'zombie_battleground-api/api/client'
require 'zombie_battleground/api/client'

client = ZombieBattleground::Api::Client.new
client.decks(limit: 1) # => ZombieBattleground::Api::Responses::GetDecksResponse

client.decks_request(limit: 1)
# => ZombieBattleground::Api::Responses::GetDecksResponse

client.decks(limit: 1)
# => [ZombieBattleground::Api::Models::Decks]
```

## Development
Expand Down
171 changes: 148 additions & 23 deletions lib/zombie_battleground/api.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'zombie_battleground/api/version'
require 'zombie_battleground/api/client'

module ZombieBattleground
Expand All @@ -11,7 +10,7 @@ class Api

class << self
##
# Queries for Decks
# Queries for Decks and returns a modeled response
#
# @param id [Integer] Optionally filter on Deck id
# @param user_id [String] Optionally filter on Deck user_id
Expand All @@ -27,32 +26,73 @@ class << self
# @return [ZombieBattleground::Api::Responses::GetDecksResponse]
#
# @example
# response = ZombieBattleground::Api.decks(limit: 1)
# response # => ZombieBattleground::Api::Responses::GetDecksResponse
# response = ZombieBattleground::Api.decks_request(limit: 1)
# # => ZombieBattleground::Api::Responses::GetDecksResponse
#
# @api public
def decks_request(**args)
@client.decks_request(**args)
end

##
# Queries for Decks and returns the decks in the response
#
# @param id [Integer] Optionally filter on Deck id
# @param user_id [String] Optionally filter on Deck user_id
# @param deck_id [Integer] Optionally filter on Deck deck_id
# @param name [String] Optionally filter on Deck name
# @param hero_id [Integer] Optionally filter on Deck hero_id
# @param primary_skill_id [Integer] Optionally filter on Deck primary_skill_id
# @param secondary_skill_id [Integer] Optionally filter on Deck secondary_skill_id
# @param version [String] Optionally filter on Deck version
# @param page [Integer] Used for pagination of query results
# @param limit [Integer] Used for pagination of query results. Max 100
#
# @return [Array<ZombieBattleground::Api::Models::Deck>]
#
# @example
# decks = ZombieBattleground::Api.decks(limit: 1)
# # => [ZombieBattleground::Api::Models::Deck]
#
# @api public
def decks(**args)
@client.decks(**args)
@client.decks_request(**args).decks
end

##
# Queries for a Deck
# Queries for a Deck and returns the response
#
# @param id [Integer] Deck id to request
#
# @return [ZombieBattleground::Api::Responses::GetDeckResponse]
#
# @example
# response = ZombieBattleground::Api.deck(id: 1813)
# response # => ZombieBattleground::Api::Responses::GetDeckResponse
# response = ZombieBattleground::Api.deck_request(id: 1813)
# # => ZombieBattleground::Api::Responses::GetDeckResponse
#
# @api public
def deck_request(**args)
@client.deck_request(**args)
end

##
# Queries for a Deck and returns deck in the response
#
# @param id [Integer] Deck id to request
#
# @return [ZombieBattleground::Api::Models::Deck]
#
# @example
# deck = ZombieBattleground::Api.deck(id: 1813)
# # => ZombieBattleground::Api::Models::Deck
#
# @api public
def deck(**args)
@client.deck(**args)
@client.deck_request(**args).deck
end

##
# Queries for Matches
# Queries for Matches and returns the response
#
# @param id [Integer] Optionally filter on Match id
# @param player1_id [String] Optionally filter on Match player1_id
Expand All @@ -66,32 +106,71 @@ def deck(**args)
# @return [ZombieBattleground::Api::Responses::GetMatchesResponse]
#
# @example
# response = ZombieBattleground::Api.matches(limit: 1)
# response # => ZombieBattleground::Api::Responses::GetMatchesResponse
# response = ZombieBattleground::Api.matches_request(limit: 1)
# # => ZombieBattleground::Api::Responses::GetMatchesResponse
#
# @api public
def matches_request(**args)
@client.matches_request(**args)
end

##
# Queries for Matches and returns the matches in the response
#
# @param id [Integer] Optionally filter on Match id
# @param player1_id [String] Optionally filter on Match player1_id
# @param player2_id [String] Optionally filter on Match player2_id
# @param status [String] Optionally filter on Match status
# @param version [String] Optionally filter on Match version
# @param winner_id [String] Optionally filter on Match winner_id
# @param page [Integer] Used for pagination of query results
# @param limit [Integer] Used for pagination of query results. Max 100
#
# @return [Array<ZombieBattleground::Api::Models::Match>]
#
# @example
# matches = ZombieBattleground::Api.matches(limit: 1)
# # => ZombieBattleground::Api::Models::Match
#
# @api public
def matches(**args)
@client.matches(**args)
@client.matches_request(**args).matches
end

##
# Queries for a Match
# Queries for a Match and returns the response
#
# @param id [Integer] Match id to request
#
# @return [ZombieBattleground::Api::Responses::GetMatchResponse]
#
# @example
# response = ZombieBattleground::Api.match(id: 1454)
# response = ZombieBattleground::Api.match_request(id: 1454)
# response # => ZombieBattleground::Api::Responses::GetMatchResponse
#
# @api public
def match_request(**args)
@client.match_request(**args)
end

##
# Queries for a Match and returns the match in the response
#
# @param id [Integer] Match id to request
#
# @return [ZombieBattleground::Api::Models::Match]
#
# @example
# match = ZombieBattleground::Api.match(id: 1454)
# # => ZombieBattleground::Api::Models::Match
#
# @api public
def match(**args)
@client.match(**args)
@client.match_request(**args).match
end

##
# Queries for Cards
# Queries for Cards and returns the response
#
# @param id [Integer] Optionally filter on Card id
# @param mould_id [String] Optionally filter on Card mould_id
Expand All @@ -111,16 +190,45 @@ def match(**args)
# @return [ZombieBattleground::Api::Responses::GetCardsResponse]
#
# @example
# response = ZombieBattleground::Api.cards(limit: 1)
# response # => ZombieBattleground::Api::Responses::GetCardsResponse
# response = ZombieBattleground::Api.cards_request(limit: 1)
# # => ZombieBattleground::Api::Responses::GetCardsResponse
#
# @api public
def cards_request(**args)
@client.cards_request(**args)
end

##
# Queries for Cards and returns the cards in the response
#
# @param id [Integer] Optionally filter on Card id
# @param mould_id [String] Optionally filter on Card mould_id
# @param version [String] Optionally filter on Card version
# @param kind [String] Optionally filter on Card kind
# @param set [String] Optionally filter on Card set
# @param name [String] Optionally filter on Card name
# @param rank [String] Optionally filter on Card rank
# @param type [String] Optionally filter on Card type
# @param rarity [String] Optionally filter on Card rarity
# @param damage [Integer] Optionally filter on Card damage
# @param health [Integer] Optionally filter on Card health
# @param cost [Integer] Optionally filter on Card cost
# @param page [Integer] Used for pagination of query results
# @param limit [Integer] Used for pagination of query results. Max 100
#
# @return [Array<ZombieBattleground::Api::Models::Card>]
#
# @example
# cards = ZombieBattleground::Api.cards(limit: 1)
# # => [ZombieBattleground::Api::Models::Card]
#
# @api public
def cards(**args)
@client.cards(**args)
@client.cards_request(**args).cards
end

##
# Queries for a Card
# Queries for a Card and returns the response
#
# @param mould_id [String] Optionally filter on Card mould_id
# @param version [String] Optionally filter on Card version
Expand All @@ -129,11 +237,28 @@ def cards(**args)
#
# @example
# response = ZombieBattleground::Api.card(mould_id: 2, version: 'v3')
# response # => ZombieBattleground::Api::Responses::GetCardResponse
# # => ZombieBattleground::Api::Responses::GetCardResponse
#
# @api public
def card_request(**args)
@client.card_request(**args)
end

##
# Queries for a Card and returns the card in the response
#
# @param mould_id [String] Optionally filter on Card mould_id
# @param version [String] Optionally filter on Card version
#
# @return [ZombieBattleground::Api::Models::Card]
#
# @example
# card = ZombieBattleground::Api.card(mould_id: 2, version: 'v3')
# # => ZombieBattleground::Api::Models::Card
#
# @api public
def card(**args)
@client.card(**args)
@client.card_request(**args).card
end
end
end
Expand Down

0 comments on commit 5c7d800

Please sign in to comment.