Skip to content

Commit 36f7882

Browse files
author
Carlo Smouter
committed
Support new client credentials flow and deprecate the old api token flow.
1 parent 6cfd0ae commit 36f7882

File tree

16 files changed

+575
-381
lines changed

16 files changed

+575
-381
lines changed

.drone.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pipeline:
2+
build:
3+
image: python:${PYTHON_VERSION}-alpine3.8
4+
commands:
5+
- find . -name "*.py[co]" -delete
6+
- pip install --upgrade pip
7+
- pip install -e .
8+
- pip install -e .[tests]
9+
- py.test
10+
- find . -name "*.py[co]" -delete
11+
when:
12+
include: [ master, develop, feature/*, release/* ]
13+
matrix:
14+
PYTHON_VERSION:
15+
- "3.7"
16+
- "3.6"
17+
- "3.5"
18+
- "2.7"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## 2.0 (In Development)
4+
5+
* Deprecate 1.0 WowApi
6+
* Implement client credentials flow for OAuth authentication
7+
* Add dronefile for testing against multiple python versions
8+
* Add coverage to pytest
9+
* Add logging

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
python-wowapi
22
-----------------
3-
Copyright (c) 2013 python-wowapi | Carlo Smouter
3+
Copyright (c) 2018 python-wowapi | Carlo Smouter
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
include setup.py README.rst Makefile MANIFEST.in
1+
include setup.py
2+
include README.md
3+
include CHANGELOG.md
4+
include Makefile
5+
include MANIFEST.in
26
include LICENSE.txt
37
include Makefile
48
include pytest.ini

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# python-wowapi
2+
3+
Python-wowapi is a client library for interacting with the World of Warcraft
4+
Community API.
5+
6+
Documentation about installing and usage can be found at [python-wowapi.readthedocs.org](https://python-wowapi.readthedocs.org)
7+
8+
## Installing
9+
10+
```bash
11+
pip install python-wowapi
12+
```
13+
14+
## Usage
15+
16+
```python
17+
import os
18+
19+
from wowapi import WowApi
20+
21+
22+
api = WowApi(os.environ['WOW_CLIENT_ID'], os.environ['WOW_CLIENT_SECRET'])
23+
data = api.get_auctions('eu', 'silvermoon', locale='de_DE')
24+
print(data)
25+
```
26+
27+
## Development & Testing
28+
29+
```bash
30+
pip install -e .
31+
pip install -e .[tests]
32+
py.test
33+
```
34+
35+
## Drone test runner
36+
37+
```
38+
PYTHON_VERSION=3.7 drone exec
39+
PYTHON_VERSION=3.6 drone exec
40+
PYTHON_VERSION=3.5 drone exec
41+
PYTHON_VERSION=2.7 drone exec
42+
```
43+
44+
For more information about Drone, visit [Drone.io](https://drone.io/)

README.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444

4545
# General information about the project.
4646
project ='python-wowapi'
47-
copyright ='2013, Carlo Smouter'
47+
copyright ='2018, Carlo Smouter'
4848

4949
# The version info for the project you're documenting, acts as replacement for
5050
# |version| and |release|, also used in various other places throughout the
5151
# built documents.
5252
#
5353
# The short X.Y version.
54-
version = '1.0'
54+
version = '2.0'
5555
# The full version, including alpha/beta/rc tags.
56-
release = '1.0'
56+
release = '2.0'
5757

5858
# The language for content autogenerated by Sphinx. Refer to documentation
5959
# for a list of supported languages.

docs/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ Python-wowapi
33

44
Python-wowapi is a client library for interacting with the World of Warcraft Community API.
55

6+
This library requires a client-id and client secret for the Community API OAuth client credentials flow.
7+
68
For more information visit:
79

8-
- `Official API documentation <https://dev.battle.net/io-docs>`_
9-
- `Official API Forum <http://us.battle.net/forums/en/bnet/15051532/>`_
10+
- `Official API documentation <https://develop.battle.net/documentation>`_
11+
- `Official API Forum <https://us.battle.net/forums/en/bnet/15051532/>`_
1012

1113

1214
Usage
1315
-----
1416

15-
.. warning::
16-
`WOWAPI_APIKEY` has to be set as an environment variable before calling the api endpoints.
17-
1817
::
1918

2019
>>> from wowapi import WowApi
21-
>>> item = WowApi.get_item('eu', 9999)
20+
>>> api = WowApi('client-id', 'client-secret')
21+
>>> item = api.get_item('eu', 9999)
2222

2323
{
2424
"id": 9999,
@@ -31,7 +31,7 @@ Usage
3131

3232
::
3333

34-
>>> item = WowApi.get_item('eu', 9999, locale='de_DE')
34+
>>> item = api.get_item('eu', 9999, locale='de_DE')
3535

3636
{
3737
"id": 9999,

examples/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
import os
3+
from pprint import pprint
4+
5+
from wowapi import WowApi
6+
7+
8+
logger = logging.getLogger('wowapi')
9+
logger.setLevel(logging.INFO)
10+
handler = logging.StreamHandler()
11+
handler.setLevel(logging.INFO)
12+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
13+
handler.setFormatter(formatter)
14+
logger.addHandler(handler)
15+
16+
logger.info('WowApi example')
17+
18+
api = WowApi(os.environ['WOW_CLIENT_ID'], os.environ['WOW_CLIENT_SECRET'])
19+
data = api.get_auctions('eu', 'silvermoon', locale='de_DE')
20+
pprint(data)
21+
22+
data = api.get_realm_status('us')
23+
pprint(data)

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
2-
addopts = --tb=short --pep8 --flakes
2+
addopts = -vs --tb=short --pep8 --flakes --cov=wowapi --cov-config .coveragerc
33

44
python_files =
55
test_*.py

0 commit comments

Comments
 (0)