wowapi 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/Gemfile +1 -3
- data/README.md +17 -40
- data/lib/wowapi/core_extensions/object/try.rb +3 -3
- data/lib/wowapi/exceptions/api_exception.rb +1 -0
- data/lib/wowapi/exceptions/auth_exception.rb +1 -0
- data/lib/wowapi/exceptions/no_credentials_exception.rb +1 -0
- data/lib/wowapi/exceptions/region_exception.rb +1 -0
- data/lib/wowapi/modules/guild.rb +11 -5
- data/lib/wowapi/version.rb +1 -1
- data/lib/wowapi/wowapi.rb +6 -1
- data/wowapi.gemspec +0 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a815973b1eb6200d1975606140a55a3345d0efc8
|
4
|
+
data.tar.gz: d8cabaf6a239f7f35c34904f12a86fcb999fc042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 805819f1915045afc074052dff53e43dc2b74ab521e68e7f3773cdaca14d7460d6147146f7c2ce781e0d73f47b4034144d534dbddaea74f2ee4e82c7ee7ed205
|
7
|
+
data.tar.gz: bab72ba9e28aad5a3188b914f6f655ecf7ca95dbfaba295bb62deba0503784a638d64a9fe9751de02e78d6dcee8dc983546efef8ff591f2c8d8b574dd94c5a85
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# WoWAPI
|
2
|
-
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/wowapi.svg)](https://badge.fury.io/rb/wowapi)
|
3
|
+
|
4
|
+
**EARLY STAGE DEVELOPMENT. HERE BE DRAGONS**
|
3
5
|
However, you are welcome to contribute and/or criticise (and/or) show me the way to handle things.
|
4
6
|
|
5
7
|
# What this is
|
@@ -11,24 +13,25 @@ This project began during a search for an easy-to-use gem that allows to access
|
|
11
13
|
|
12
14
|
## What does it do?
|
13
15
|
|
14
|
-
|
16
|
+
It gives you a pretty interface to Blizzard's Community API.
|
15
17
|
|
16
18
|
## How do I use this?
|
17
19
|
|
20
|
+
Before you start tinkering, I suggest generating *rDOC* documentation.
|
21
|
+
To do so, run `rdoc` in the root directory of Wowapi. Then navigate to doc/index.html in your browser, and voila - you have your offline documentation with all methods, classes and pretty-displayed README.md.
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
Guilds can take couple of arguments to query:
|
23
|
+
You may also browse *ri* documentation which installs by default when you install the gem. Just type `ri Wowapi`.
|
24
|
+
### Resources
|
22
25
|
|
23
|
-
|
24
|
-
*
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
_
|
31
|
-
|
26
|
+
We have different resources for different parts of the API. Each resource can be queried with query fields.
|
27
|
+
Currently, everything is returned as a Hash(*)
|
28
|
+
|
29
|
+
| Resource(s) | query fields | | | |
|
30
|
+
|:-----------: |:------------: |:-------------: |:----------: |:--------: |
|
31
|
+
| Guilds | :news | :achievements | :challenge | :members |
|
32
|
+
| | | | | |
|
33
|
+
| | | | | | _
|
34
|
+
* temporarily_ - see #1, #2, #3 @ ([git.3lab.re](https://git.3lab.re/marahin/wowapi/issues))
|
32
35
|
|
33
36
|
```
|
34
37
|
require 'wowapi'
|
@@ -44,32 +47,6 @@ api.guild('Argent Dawn', 'The Aspects')
|
|
44
47
|
|
45
48
|
```
|
46
49
|
|
47
|
-
#### Guild fields
|
48
|
-
|
49
|
-
* news ([pastebin](http://d.gimb.us/b/fe26c9f380477d3a0293072385e61cab.txt))
|
50
|
-
|
51
|
-
```
|
52
|
-
irb(main):005:0> api.guild 'Argent Dawn', 'The Aspects', :news
|
53
|
-
=> {"lastModified"=>1472853622000, "name"=>"The Aspects", "realm"=>"Argent Dawn", "battlegroup"=>"Reckoning / Abrechnung", "level"=>25, "side"=>1, "achievementPoints"=>1590, "emblem"=>{"icon"=>140, "iconColor"=>"ffdfa55a", "iconColorId"=>16, "border"=>1, "borderColor"=>"fff9cc30", "borderColorId"=>16, "backgroundColor"=>"ff232323", "backgroundColorId"=>45}, "news"=>[{"type"=>"itemLoot", "character"=>"Tormenthowl", "timestamp"=>1472858400000, "itemId"=>124325, "context"=>"raid-mythic", "bonusLists"=>[1799, 1502]}, {"type"=>"itemLoot", "character"=>"Tormenthowl", "timestamp"=>1472858400000, "itemId"=>113900, "context"=>"raid-mythic", "bonusLists"=>[567]}, {"type"=>"itemLoot", "character"=>"Humbakos", "timestamp"=>1472857980000, "itemId"=>130132, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Seszel", "timestamp"=>1472854680000, "itemId"=>131799, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Kurrash", "timestamp"=>1472854500000, "itemId"=>132970, "context"=>"quest-reward", "bonusLists"=>[767, 1734]}, {"type"=>"itemLoot", "character"=>"Greenzog", "timestamp"=>1472853960000, "itemId"=>131921, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Humbakos", "timestamp"=>1472853480000, "itemId"=>121660, "context"=>"quest-reward", "bonusLists"=>[768, 1740]}, {"type"=>"itemLoot", "character"=>"Dzidu", "timestamp"=>1472853060000, "itemId"=>138418, "context"=>"", "bonusLists"=>[1794, 1735]}, $$__***<<< A LOT OF DATA ... >>>***__$$ {"type"=>"itemLoot", "character"=>"Olvarus", "timestamp"=>1472248680000, "itemId"=>109970, "context"=>"dungeon-mythic", "bonusLists"=>[43, 642, 643]}, {"type"=>"playerAchievement", "character"=>"Guldav", "timestamp"=>1472247960000, "context"=>"", "bonusLists"=>[], "achievement"=>{"id"=>13, "title"=>"Level 80", "points"=>10, "description"=>"Reach level 80.", "rewardItems"=>[], "icon"=>"achievement_level_80", "criteria"=>[{"id"=>5212, "description"=>"Reach level 80", "orderIndex"=>1, "max"=>80}], "accountWide"=>false, "factionId"=>2}}]}
|
54
|
-
|
55
|
-
```
|
56
|
-
|
57
|
-
* achievements
|
58
|
-
|
59
|
-
(to be filled)
|
60
|
-
|
61
|
-
* challenge
|
62
|
-
|
63
|
-
(to be filled)
|
64
|
-
|
65
|
-
* members
|
66
|
-
|
67
|
-
(to be filled)
|
68
|
-
|
69
|
-
* __combined__
|
70
|
-
|
71
|
-
(to be filled)
|
72
|
-
|
73
50
|
|
74
51
|
You can easily combine fields.
|
75
52
|
# Support & requirements
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# A simple .try method for Object,
|
2
|
-
# which mimics the Rails one (probably poorly)
|
3
|
-
|
4
1
|
module CoreExtensions
|
5
2
|
module Object
|
3
|
+
# Simple shim that adds .try(:symbol)
|
4
|
+
# method for Object, mimicing ActiveSupport one
|
5
|
+
# (probably poorly, todo: rewrite?)
|
6
6
|
def try(method)
|
7
7
|
begin
|
8
8
|
self.send(method)
|
data/lib/wowapi/modules/guild.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
class Wowapi
|
2
2
|
module Modules
|
3
|
+
# Guild module which handles all guild API actions
|
4
|
+
# note: this _probably_ should be handled with
|
5
|
+
# some kind of GuildClass, see:
|
6
|
+
# https://git.3lab.re/marahin/wowapi/issues/1
|
3
7
|
module Guild
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
8
|
+
# Asks Blizzard API for Guild resource
|
9
|
+
# with (any) given fields
|
10
|
+
# Example:
|
11
|
+
# ```
|
12
|
+
# api.guild 'Argent Dawn', 'The Aspects', :members, :news, ...
|
13
|
+
# ```
|
14
|
+
# Currently returns Hash
|
9
15
|
def guild(realm, name, *args)
|
10
16
|
args = args.map{|n| n.to_s if n.is_a?(Symbol) }
|
11
17
|
res = get 'guild/', "#{realm}/#{name}?fields=#{args.join('%2C')}"
|
data/lib/wowapi/version.rb
CHANGED
data/lib/wowapi/wowapi.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'json'
|
3
|
-
require 'pry'
|
4
3
|
require 'wowapi/core_extensions/object/try'
|
5
4
|
require 'wowapi/exceptions'
|
6
5
|
require 'wowapi/version'
|
@@ -27,6 +26,8 @@ class Wowapi
|
|
27
26
|
yield self if block_given?
|
28
27
|
end
|
29
28
|
|
29
|
+
# Method to handle all requests, properly
|
30
|
+
# interpreting HTTP answer & returning it's response
|
30
31
|
def get(path, params = {})
|
31
32
|
res = make_request(path, params)
|
32
33
|
if !(res.status.include?('200') or res.status.include?(200)) && ! Wowapi.fail_silently
|
@@ -37,6 +38,8 @@ class Wowapi
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
41
|
+
# Making open-uri request, catching exceptions
|
42
|
+
# and returning data back to #get method
|
40
43
|
def make_request(path, params)
|
41
44
|
begin
|
42
45
|
raise Wowapi::NoCredentialsException unless public_key
|
@@ -47,6 +50,8 @@ class Wowapi
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
53
|
+
# Returns URL for particular region
|
54
|
+
# or throws an exception if region is nonexistent
|
50
55
|
def base_url
|
51
56
|
case self.region
|
52
57
|
when :eu
|
data/wowapi.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wowapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Matusz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: pry
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
82
|
version: '0'
|
97
83
|
requirements: []
|
98
84
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.4.5.1
|
100
86
|
signing_key:
|
101
87
|
specification_version: 4
|
102
88
|
summary: World of Warcraft API
|