Developing RESTful APIs with Python and Flask

PHOTO EMBED

Thu Mar 03 2022 07:17:17 GMT+0000 (UTC)

Saved by @morristech #python

from marshmallow import post_load

from .transaction import Transaction, TransactionSchema
from .transaction_type import TransactionType


class Income(Transaction):
  def __init__(self, description, amount):
    super(Income, self).__init__(description, amount, TransactionType.INCOME)

  def __repr__(self):
    return '<Income(name={self.description!r})>'.format(self=self)


class IncomeSchema(TransactionSchema):
  @post_load
  def make_income(self, data):
    return Income(**data)
content_copyCOPY

https://auth0.com/blog/developing-restful-apis-with-python-and-flask/