/wowapi

Source: https://git.3lab.re/marahin/wowapi (GITHUB IS USED AS A MIRROR). Gem for easier consumption of Blizzard's Community World of Warcraft API

Primary LanguageRubyMIT LicenseMIT

WoWapi

Gem Version Build Status Code Climate Dependency Status security Inline docs

World of Warcraft API gem.
This gem is intended to help developers easily access Blizzards' Community API section of World of Warcraft.

Getting Started

Prerequisites

A supported, working version of Ruby.

Installing

You can obtain Wowapi in two ways:

Rubygems

gem install wowapi

Build yourself

  • clone the repo:
git clone https://git.3lab.re/marahin/wowapi.git
  • enter the directory:
cd wowapi
  • run bundler, so you have everything you need already:
bundle install
  • build gem:
gem build wowapi.gemspec
  • if build passes, install it from your local environment:
gem install --local wowapi**.gem

Examples

Rails

Bear in mind this is example code.

  • Create initializer called wowapi.rb in your Rails app's config/initializers directory,
  • fill it with following:
require 'wowapi'

## Set region (defaults to :eu)
## Wowapi.region = :us

## Create Api variable usable ANYWHERE in your Rails app
::Api = Wowapi.new do |config|
  config.public_key = 'your-public-apikey'
  ## config.secret_key = 'your-secret-key'
end

## Create your Guild name variable, usually GuildName or GuildNameApi that holds information about your guild.  
## ::YourGuildName = Api.guild('Realm', 'Guild name', :field1, :field2)
::Aspects = Api.guild('Argent Dawn', 'The Aspects', :members, :news)

Now, in any controller / view you can do:

  • controllers/pages_controller.rb
class PagesController < ApplicationController
  def index
    @news = Aspects.news
  end
end

  • in views:
@news.last(7).each do |news|
    ... 
end

Plain Ruby

require 'wowapi'

api = Wowapi.new do |config|
  config.public_key   = 'your-public-apikey'
  # config.secret_Key = 'optional-secret-key'
end

# returns guild profile
guild = api.guild('Argent Dawn', 'The Aspects')  

# returns guild profile & members list
guild = api.guild('Argent Dawn', 'The Aspects', :members) 
guild.members # Array of CharacterClass objects

# returns guild profile, members list & news
guild = api.guild('Argent Dawn', 'The Aspects', :members, :news)
guild.news # array of Hashes containing news
 
# returns character profile
character = api.character('Argent Dawn', 'Marahin')

Deployment

Nothing additional is required. Bear in mind that Wowapi only download & interprets data, but it does not provide any kind of persistent storage.
As an author I use this gem to develop my guild website, where I use nginx as an reverse proxy to puma instance with Rails app. I use redis to store Wowapi data and Clockwork queue, that is maintaining work of Sidekiq worker that periodically downloads data using Wowapi.

Supported Rubies

Everything >= 2.0.0 should work just fine. Below you can see a table with different MRI Ruby versions which we tested the gem on:

Ruby (MRI) Does it work?
1.9.3 No
2.0.0 Yes
2.2.0 Yes
2.2.3 Yes
2.3.0 Yes
2.3.1 Yes
jruby* Yes

Built With

We are using Travis CI to test each commit against Supported Rubies.

Contributing

Bugs: either drop an issue here or see IRC below
IRC: #wowapi on Freenode (click here to chat now)

I have a problem / want to help:

  • contact us through #wowapi on Freenode (or creator directly - me@marahin.pl),
  • if your idea / bugfix / change is approved, send a pull request or provide a link to your fork with it fixed,
  • you will be mentioned below in the Authors section

Versioning

SINCE 1.0.0 we use SemVer for versioning. For the versions available, see Releases or RubyGems.

Authors

  • Jan "marahin" Matusz - founder, creator, developer - marahin

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledgments