start docs

This commit is contained in:
Adickes 2015-11-28 09:30:55 -05:00
parent 5c563dcb27
commit 64a60daa25
4 changed files with 323 additions and 13 deletions

View file

@ -89,7 +89,7 @@ TEMPLATE_DIRS = (
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi_co_db',
'NAME': 'pokeapi_test',
'USER': 'root',
'PASSWORD': 'pokeapi',
'HOST': 'localhost',

287
pokemon_v2/README.md Normal file
View file

@ -0,0 +1,287 @@
# Pokeapi V2 API Reference
## APIs and Responses
### Abilities
---
```
api/v2/ability/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this ability resource | integer
name | The name for this ability resource | string
is_main_series | Whether or not this ability originated in the main series of the video games | boolean
generation | The generation this ability originated in | APIResource
names | The name of this ability listed in different languages | [Name]
effect_entries | The effect of this ability listed in different languages | [VerboseEffect]
effect_changes | A list of changes in the effect of this ability across version groups | [AbilityEffectChange]
flavor_text_entries | The flavor text of this ability listed in different languages | [VersionSpecificFlavorText] TODO
pokemon | A list of pokemon this ability might belong to | [AbilityPokemonMap]
#### AbilityEffectChange
Name | Description | Data Type
---- | ----------- | ---------
effect_entries | The previous effect of this ability listed in different languages | [Effect]
version_group | The version group in which the previous effect of this ability originated | APIReference
#### AbilityPokemonMap
Name | Description | Data Type
---- | ----------- | ---------
is_hidden | Whether or not this a hidden ability for the referenced pokemon | boolean
slot | Pokemon have 3 ability 'slots' which hold references to possible abilities they could have. This is the slot of this ability for the referenced pokemon. | integer
pokemon | The pokemon this ability could belong to | APIReference
### Berries
---
```
api/v2/berry/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this berry resource | integer
name | The name for this berry resource | string
growth_time | TODO | integer
max_harvest | TODO | integer
natural_gift_power | The strength of this powers natural gift | integer
size | The size of this berry | integer
smoothness | The smoothness rating of this berry | integer
soil_dryness | TODO | integer
firmness | The firmness of this berry | APIReference
flavors | A list of references to each flavor a berry can have and the potency of each of those flavors in regard to this berry | [BerryFlavorMap]
item | Berries are actually items. This is a reference to the item specific data for this berry. | APIReference
natural_gift_type | A reference to the elemental type of a this berry TODO | APIReference
#### BerryFlavorMap
Name | Description | Data Type
---- | ----------- | ---------
potency | How powerful the referenced flavor is for this berry | integer
flavor | The referenced berry flavor | APIReference
### Berry Firmnesses
---
```
api/v2/berry-firmness/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this berry firmness resource | integer
name | The name for this berry firmness resource | string
berries | A list of the berries with this firmness | [APIReference]
names | The name of this berry firmness listed in different languages | [Name]
### Berry Flavors
---
```
api/v2/berry-flavor/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this berry flavor resource | integer
name | The name for this berry flavor resource | string
berries | A list of the berries with this flavor | [APIReference]
contest_type | TODO | APIReference
names | The name of this berry flavor listed in different languages | [Name]
### Characteristics
---
```
api/v2/characteristic/{id}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this characteristic resource | integer
gene_modulo | The remainder of the highest stat divided by 5 TODO | integer
possible_values | The possible values of the highest stat that would result in a pokemon recieving this characteristic when divided by the gene modulo | [integer]
descriptions | The descriptions of this characteristic listed in different languages | [Description]
### Contest Type
---
```
api/v2/contest-type/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this contest type resource | integer
name | The name for this contest type resource | string
berry_flavor | TODO | APIReference
names | The name of this contest type listed in different languages | [Name]
### Contest Effect
---
```
api/v2/contest-effect/{id}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this contest type resource | integer
appeal | The level of appeal this effect has TODO | string
jam | TODO | APIReference
effect_entries | The result of this contest effect listed in different languages | [Effect]
flavor_text_entries | The flavor text of this contest effect listed in different languages | [FlavorText]
### Egg Group
---
```
api/v2/egg-group/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this egg group resource | integer
name | The name for this egg group resource | string
names | The name of this egg group listed in different languages | [Name]
pokemon_species | A list of all pokemon species that are categorized under this egg group
### Encounter Method
---
```
api/v2/encounter-method/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this encounter method resource | integer
name | The name for this encounter method resource | string
order | The order index of this encounter method within the main game series data | integer
names | The name of this encounter method listed in different languages | [Name]
### Encounter Conditions
---
```
api/v2/encounter-condition/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this encounter condition resource | integer
name | The name for this encounter condition resource | string
names | The name of this encounter method listed in different languages | [Name]
values | A list of possible values for this encounter condition | [APIReference]
### Encounter Condition Values TODO (These should probably be renamed "states")
---
```
api/v2/encounter-condition-value/{id or name}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this encounter condition value resource | integer
name | The name for this encounter condition value resource | string
condition | The condition this encounter condition value pertains to | [APIReference]
names | The name of this encounter method listed in different languages | [Name]
### Evolution Chain
---
```
api/v2/encounter-chain/{id}
```
Name | Description | Data Type
---- | ----------- | ---------
id | The identifier for this evolution chain resource | integer
baby_trigger_item | The item that a pokemon would be holding when mating that would trigger the egg hatching a baby pokemon rather than a basic pokemon | APIReference
chain | The base link object. Each link contains evolution details for a pokemon in the chain. Each link references the next pokemon in the natural evolution order. | Link
#### Chain
Name | Description | Data Type
---- | ----------- | ---------
is_baby | Whether or not this link is for a baby pokemon. This would only ever be true on the base link. | boolean
species | The pokemon species at this point in the evolution chain | APIReference
evolution_details | All details regarding
evolves_to | A List of chain objects. These contain details of the species this pokemon species evolves into
## Common Models
#### APIResource
Name | Description | Data Type
---- | ----------- | ---------
name | The name of the referenced resource | string
url | The url of the referenced resource | string
#### Description
Name | Description | Data Type
---- | ----------- | ---------
description | The localized description for an api resource in a specific language | string
language | The language this name is in | APIResource
#### Effect
Name | Description | Data Type
---- | ----------- | ---------
effect | The localized effect text for an api resource in a specific language | string
language | The language this effect is in | APIResource
#### FlavorText
Name | Description | Data Type
---- | ----------- | ---------
flavor_text | The localized name for an api resource in a specific language | string
language | The language this name is in | APIResource
#### Name
Name | Description | Data Type
---- | ----------- | ---------
name | The localized name for an api resource in a specific language | string
language | The language this name is in | APIResource
#### VerboseEffect
Name | Description | Data Type
---- | ----------- | ---------
effect | The localized effect text for an api resource in a specific language | string
short_effect | The localized effect text in brief | string
language | The language this effect is in | APIResource
#### VersionSpecificFlavorText TODO
Name | Description | Data Type
---- | ----------- | ---------
flavor_text | The localized name for an api resource in a specific language | string
language | The language this name is in | APIResource

View file

@ -964,13 +964,13 @@ class AbilityEffectTextSerializer(serializers.ModelSerializer):
class AbilityFlavorTextSerializer(serializers.ModelSerializer):
text = serializers.CharField(source="flavor_text")
flavor_text = serializers.CharField()
language = LanguageSummarySerializer()
version_group = VersionGroupSummarySerializer()
class Meta:
model = AbilityFlavorText
fields = ('text', 'version_group', 'language')
fields = ('flavor_text', 'language', 'version_group')
class AbilityChangeEffectTextSerializer(serializers.ModelSerializer):
@ -1005,9 +1005,10 @@ class AbilityDetailSerializer(serializers.ModelSerializer):
effect_entries = AbilityEffectTextSerializer(many=True, read_only=True, source="abilityeffecttext")
flavor_text_entries = AbilityFlavorTextSerializer(many=True, read_only=True, source="abilityflavortext")
# flavor_text_entries = serializers.SerializerMethodField('get_flavor_text')
names = AbilityNameSerializer(many=True, read_only=True, source="abilityname")
generation = GenerationSummarySerializer()
changes = AbilityChangeSerializer(many=True, read_only=True, source="abilitychange")
effect_changes = AbilityChangeSerializer(many=True, read_only=True, source="abilitychange")
pokemon = serializers.SerializerMethodField('get_ability_pokemon')
class Meta:
@ -1018,10 +1019,10 @@ class AbilityDetailSerializer(serializers.ModelSerializer):
'is_main_series',
'generation',
'names',
'effect_entries',
'effect_entries',
'effect_changes',
'flavor_text_entries',
'pokemon',
'changes'
)
def get_ability_pokemon(self, obj):
@ -1036,6 +1037,28 @@ class AbilityDetailSerializer(serializers.ModelSerializer):
return pokemon
# def get_flavor_text(self, obj):
# version_objects = VersionGroup.objects.all()
# version_data = VersionGroupSummarySerializer(version_objects, many=True, context=self.context).data
# flavor_texts = AbilityFlavorText.objects.filter(ability=obj)
# group_ids = flavor_texts.values('flavor').distinct()
# entries = []
# for group_id in group_ids:
# id = group_id['version_group']
# texts = flavor_texts.filter(version_group=id)
# detail = OrderedDict()
# detail['version_group'] = version_data[id-1]
# detail['entries'] = AbilityFlavorTextSerializer(texts, many=True, context=self.context).data
# entries.append(detail)
# return entries
######################
@ -2677,7 +2700,7 @@ class EvolutionChainDetailSerializer(serializers.ModelSerializer):
entry['is_baby'] = species['is_baby']
entry['species'] = summary_data[index]
if evolution_data: entry['evolution_details'] = evolution_data
entry['evolution_details'] = evolution_data or None
entry['evolves_to'] = []
# Keep track of previous entries for complex chaining

View file

@ -2364,7 +2364,7 @@ class APITests(APIData, APITestCase):
self.assertEqual(response.data['effect_entries'][0]['language']['name'], ability_effect_text.language.name)
self.assertEqual(response.data['effect_entries'][0]['language']['url'], '{}{}/language/{}/'.format(test_host, api_v2, ability_effect_text.language.pk))
# flavor text params
self.assertEqual(response.data['flavor_text_entries'][0]['text'], ability_flavor_text.flavor_text)
self.assertEqual(response.data['flavor_text_entries'][0]['flavor_text'], ability_flavor_text.flavor_text)
self.assertEqual(response.data['flavor_text_entries'][0]['version_group']['name'], ability_flavor_text.version_group.name)
self.assertEqual(response.data['flavor_text_entries'][0]['language']['name'], ability_flavor_text.language.name)
self.assertEqual(response.data['flavor_text_entries'][0]['language']['url'], '{}{}/language/{}/'.format(test_host, api_v2, ability_flavor_text.language.pk))
@ -2372,11 +2372,11 @@ class APITests(APIData, APITestCase):
self.assertEqual(response.data['generation']['name'], ability.generation.name)
self.assertEqual(response.data['generation']['url'], '{}{}/generation/{}/'.format(test_host, api_v2, ability.generation.pk))
# change params
self.assertEqual(response.data['changes'][0]['version_group']['name'], ability_change.version_group.name)
self.assertEqual(response.data['changes'][0]['version_group']['url'], '{}{}/version-group/{}/'.format(test_host, api_v2, ability_change.version_group.pk))
self.assertEqual(response.data['changes'][0]['effect_entries'][0]['effect'], ability_change_effect_text.effect)
self.assertEqual(response.data['changes'][0]['effect_entries'][0]['language']['name'], ability_change_effect_text.language.name)
self.assertEqual(response.data['changes'][0]['effect_entries'][0]['language']['url'], '{}{}/language/{}/'.format(test_host, api_v2, ability_change_effect_text.language.pk))
self.assertEqual(response.data['effect_changes'][0]['version_group']['name'], ability_change.version_group.name)
self.assertEqual(response.data['effect_changes'][0]['version_group']['url'], '{}{}/version-group/{}/'.format(test_host, api_v2, ability_change.version_group.pk))
self.assertEqual(response.data['effect_changes'][0]['effect_entries'][0]['effect'], ability_change_effect_text.effect)
self.assertEqual(response.data['effect_changes'][0]['effect_entries'][0]['language']['name'], ability_change_effect_text.language.name)
self.assertEqual(response.data['effect_changes'][0]['effect_entries'][0]['language']['url'], '{}{}/language/{}/'.format(test_host, api_v2, ability_change_effect_text.language.pk))
# pokemon params
self.assertEqual(response.data['pokemon'][0]['is_hidden'], pokemon_ability.is_hidden)
self.assertEqual(response.data['pokemon'][0]['slot'], pokemon_ability.slot)