Skip to content

Commit fb2a94e

Browse files
authored
Merge pull request #12 from PokeAPI/beckett
Uses Beckett API Client Framework
2 parents 37870ad + 96c3094 commit fb2a94e

File tree

14 files changed

+417
-25
lines changed

14 files changed

+417
-25
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*.so
55

66
# Packages
7-
*.egg
7+
*.egg*
8+
*.cache
89
*.egg-info
910
dist
1011
build

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ language: python
44

55
python:
66
- "2.7"
7-
- "pypy"
87

98
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
109
install: pip install -r requirements.txt
1110

1211
# command to run tests, e.g. python setup.py test
13-
script: python setup.py test
12+
script: py.test test

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
0.2.0 (2016-06-11)
7+
++++++++++++++++++
8+
9+
* Beckett API Client framework added
10+
611
0.1.2 (2014-1-3)
712
++++++++++++++++++
813

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014, Paul Hallett
1+
Copyright (c) 2016, Paul Hallett
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lint:
2727
flake8 pykemon tests
2828

2929
test:
30-
python setup.py test
30+
py.test tests/
3131

3232
test-all:
3333
tox

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ Even simpler:
3232
.. code-block:: python
3333
3434
>>> import pykemon
35-
>>> pykemon.get(pokemon='bulbasaur')
36-
<Pokemon - Bulbasaur>
37-
>>> p = pykemon.get(pokemon_id=1)
38-
<Pokemon - Bulbasaur>
39-
>>> pykemon.get(move_id=15)
40-
<Move - cut>
35+
>>> client = pykemon.V1Client()
36+
>>> p = client.get_pokemon(uid=1)
37+
[<Pokemon - Bulbasaur>]
4138
4239
4340
Features

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
Welcome to Pykemon's documentation!
7-
======================================
7+
===================================
88

99
Contents:
1010

docs/usage.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ To use Pykemon in a project::
66

77
>>> import pykemon
88

9+
=======
10+
New API
11+
=======
12+
13+
Since version 0.2.0, Pykemon now works with `Beckett <https://phalt.github.io/beckett>`_, an easy to use API Client Framework::
14+
15+
>>> client = pykemon.V1Client()
16+
>>> bulba = client.get_pokemon(uid=1)[0]
17+
<Pokemon | Bulbasaur>
18+
>>> bulba.name
19+
Bulbasaur
20+
21+
The following methods work with this client and all take a `uid` parameter:
22+
23+
* get_pokemon
24+
* get_move
25+
* get_sprite
26+
* get_ability
27+
* get_game
28+
* get_type
29+
* get_egg
30+
31+
32+
================
33+
Version 0.1* API
34+
================
35+
936
Then you can start grabbing stuff from the API::
1037

1138
>>> pykemon.get(pokemon='mew')
@@ -57,4 +84,3 @@ The Pokemon resource can also be requested using the name:
5784
<Pokemon - Rotom>
5885

5986
Make sure you use lower case strings!
60-

pykemon/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
__author__ = 'Paul Hallett'
55
__email__ = 'hello@phalt.co'
6-
__version__ = '0.1.2'
7-
__copyright__ = 'Copyright Paul Hallett 2014'
6+
__version__ = '0.2.0'
7+
__copyright__ = 'Copyright Paul Hallett 2016'
88
__license__ = 'BSD'
99

10-
from api import get
11-
from exceptions import ResourceNotFoundError
10+
from api import get, V1Client # NOQA
11+
from exceptions import ResourceNotFoundError # NOQA
1212

1313

1414
"""

pykemon/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
User interaction with this package is done through this file.
77
"""
88

9+
from beckett.clients import BaseClient
10+
911
from request import CHOICES
1012
from request import make_request
1113

14+
from .resources import (
15+
MoveResource, PokemonResource, TypeResource, AbilityResource, EggResource,
16+
DescriptionResource, SpriteResource, GameResource
17+
)
18+
1219

1320
def get(**kwargs):
1421
"""
@@ -36,3 +43,20 @@ def get(**kwargs):
3643

3744
else:
3845
raise ValueError('An invalid argument was passed')
46+
47+
48+
class V1Client(BaseClient):
49+
50+
class Meta(BaseClient.Meta):
51+
name = 'pykemon-v1-client'
52+
base_url = 'http://pokeapi.co/api/v1'
53+
resources = (
54+
MoveResource,
55+
PokemonResource,
56+
TypeResource,
57+
AbilityResource,
58+
EggResource,
59+
DescriptionResource,
60+
SpriteResource,
61+
GameResource,
62+
)

0 commit comments

Comments
 (0)