Exemplo n.º 1
0
class LedgerActionsResource(BaseResource):

    get_schema = TimerangeLocationQuerySchema()
    put_schema = LedgerActionSchema()
    patch_schema = LedgerActionEditSchema()
    delete_schema = IntegerIdentifierSchema()

    @use_kwargs(get_schema, location='json_and_query')
    def get(
        self,
        from_timestamp: Timestamp,
        to_timestamp: Timestamp,
        location: Optional[Location],
        async_query: bool,
    ) -> Response:
        return self.rest_api.get_ledger_actions(
            from_ts=from_timestamp,
            to_ts=to_timestamp,
            location=location,
            async_query=async_query,
        )

    @use_kwargs(put_schema, location='json')
    def put(
        self,
        timestamp: Timestamp,
        action_type: LedgerActionType,
        location: Location,
        amount: AssetAmount,
        asset: Asset,
        rate: Optional[Price],
        rate_asset: Optional[Asset],
        link: Optional[str],
        notes: Optional[str],
    ) -> Response:
        action = LedgerAction(
            identifier=0,  # whatever -- is not used at insertion
            timestamp=timestamp,
            action_type=action_type,
            location=location,
            amount=amount,
            asset=asset,
            rate=rate,
            rate_asset=rate_asset,
            link=link,
            notes=notes,
        )
        return self.rest_api.add_ledger_action(action)

    @use_kwargs(patch_schema, location='json')
    def patch(self, action: LedgerAction) -> Response:
        return self.rest_api.edit_ledger_action(action=action)

    @use_kwargs(delete_schema, location='json')
    def delete(self, identifier: int) -> Response:
        return self.rest_api.delete_ledger_action(identifier=identifier)
Exemplo n.º 2
0
class LedgerActionsResource(BaseResource):

    get_schema = TimerangeLocationQuerySchema()
    put_schema = LedgerActionSchema()
    patch_schema = LedgerActionEditSchema()
    delete_schema = LedgerActionIdentifierSchema()

    @use_kwargs(get_schema, location='json_and_query')  # type: ignore
    def get(
        self,
        from_timestamp: Timestamp,
        to_timestamp: Timestamp,
        location: Optional[Location],
        async_query: bool,
    ) -> Response:
        return self.rest_api.get_ledger_actions(
            from_ts=from_timestamp,
            to_ts=to_timestamp,
            location=location,
            async_query=async_query,
        )

    @use_kwargs(put_schema, location='json')  # type: ignore
    def put(
        self,
        timestamp: Timestamp,
        action_type: LedgerActionType,
        location: Location,
        amount: AssetAmount,
        asset: Asset,
        link: str,
        notes: str,
    ) -> Response:
        return self.rest_api.add_ledger_action(
            timestamp=timestamp,
            action_type=action_type,
            location=location,
            amount=amount,
            asset=asset,
            link=link,
            notes=notes,
        )

    @use_kwargs(patch_schema, location='json')  # type: ignore
    def patch(self, action: LedgerAction) -> Response:
        return self.rest_api.edit_ledger_action(action=action)

    @use_kwargs(delete_schema, location='json')  # type: ignore
    def delete(self, identifier: int) -> Response:
        return self.rest_api.delete_ledger_action(identifier=identifier)
Exemplo n.º 3
0
class AssetMovementsResource(BaseResource):

    get_schema = TimerangeLocationQuerySchema()

    @use_kwargs(get_schema, location='json_and_query')  # type: ignore
    def get(
            self,
            from_timestamp: Timestamp,
            to_timestamp: Timestamp,
            location: Optional[Location],
            async_query: bool,
    ) -> Response:
        return self.rest_api.get_asset_movements(
            from_timestamp=from_timestamp,
            to_timestamp=to_timestamp,
            location=location,
            async_query=async_query,
        )
Exemplo n.º 4
0
class TradesResource(BaseResource):

    get_schema = TimerangeLocationQuerySchema()
    put_schema = TradeSchema()
    patch_schema = TradePatchSchema()
    delete_schema = TradeDeleteSchema()

    @use_kwargs(get_schema, location='json_and_query')  # type: ignore
    def get(
            self,
            from_timestamp: Timestamp,
            to_timestamp: Timestamp,
            location: Optional[Location],
            async_query: bool,
    ) -> Response:
        return self.rest_api.get_trades(
            from_ts=from_timestamp,
            to_ts=to_timestamp,
            location=location,
            async_query=async_query,
        )

    @use_kwargs(put_schema, location='json')  # type: ignore
    def put(
            self,
            timestamp: Timestamp,
            location: Location,
            pair: TradePair,
            trade_type: TradeType,
            amount: AssetAmount,
            rate: Price,
            fee: Fee,
            fee_currency: Asset,
            link: str,
            notes: str,
    ) -> Response:
        return self.rest_api.add_trade(
            timestamp=timestamp,
            location=location,
            pair=pair,
            trade_type=trade_type,
            amount=amount,
            rate=rate,
            fee=fee,
            fee_currency=fee_currency,
            link=link,
            notes=notes,
        )

    @use_kwargs(patch_schema, location='json')  # type: ignore
    def patch(
            self,
            trade_id: str,
            timestamp: Timestamp,
            location: Location,
            pair: TradePair,
            trade_type: TradeType,
            amount: AssetAmount,
            rate: Price,
            fee: Fee,
            fee_currency: Asset,
            link: str,
            notes: str,
    ) -> Response:
        return self.rest_api.edit_trade(
            trade_id=trade_id,
            timestamp=timestamp,
            location=location,
            pair=pair,
            trade_type=trade_type,
            amount=amount,
            rate=rate,
            fee=fee,
            fee_currency=fee_currency,
            link=link,
            notes=notes,
        )

    @use_kwargs(delete_schema, location='json')  # type: ignore
    def delete(self, trade_id: str) -> Response:
        return self.rest_api.delete_trade(trade_id=trade_id)