Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Child classes

Spectre edited this page Jul 13, 2021 · 4 revisions

Child classes

Every type of Entity has an associated Child class. The base class is called GenericChildClass, from which the following classes are subclassed:

  • Location
  • Character
  • Family
  • Organisation
  • Timeline
  • Race
  • Note
  • Map
  • Tag
  • Quest
  • Journal
  • Item
  • Event
  • Ability
  • Calendar

To learn more, read the Kanka API documentation.


Attributes

client: KankaClient object this Child is part of.

parent: Entity object this child is part of.

base_url URL pointing to the endpoint the specific type of Child uses.

data: Nested Object that holds the Child data. All children have the following attributes:

  • id
  • type
  • entity_id
  • name
  • entry
  • entry_parsed
  • image
  • image_full
  • image_thumb
  • tags
  • focus_x
  • focus_y
  • has_custom_image
  • is_template
  • is_private
  • created_by
  • created_at
  • updated_by
  • updated_at

Additionally, each Child subclass has specific attributes. A full list is available in the Kanka API documentation.


Methods

@classmethod
def from_id(client: KankaClient, entity_id: int, parent: Entity = None)

client: KankaClient object this Child is part of.

child_id: Entity ID of the Entity to be requested.

parent Existing Entity object this Child is part of. If If none is given, it is requested when first needed.

returns: Child object.


@classmethod
def from_json(client: KankaClient, content: Union[str, dict], parent: Entity = None)

client: KankaClient object this Child is part of.

content: Either a json string or a dictionary representing a Child object.

parent Existing Entity object this Child is part of. If If none is given, it is requested when first needed.

returns: Child object.


def post(self, json_data: str = None, **kwargs)

json_data: json string with parameters to post. Overrides existing attributes. To see accepted and required values, consult the Kanka API documentation.

kwargs individual parameters to post. Overrides existing attributes and json_data.

returns: requests.Response object


def patch(self, json_data: str = None, **kwargs)

json_data: json string with parameters to post. Overrides existing attributes. To see accepted and required values, consult the Kanka API documentation.

kwargs individual parameters to post. Overrides existing attributes and json_data.

returns: requests.Response object


def delete(self)

returns: requests.Response object


def get_image(self)

returns: file-like object of the Child image

Clone this wiki locally