2022-01-02 01:34:23 +03:00
|
|
|
from rest_framework import serializers
|
2022-06-21 22:29:07 +03:00
|
|
|
from .models import MarketTick, Order
|
2022-01-02 01:34:23 +03:00
|
|
|
|
2022-02-17 22:50:10 +03:00
|
|
|
|
2022-01-05 03:13:08 +03:00
|
|
|
class ListOrderSerializer(serializers.ModelSerializer):
|
2022-02-17 22:50:10 +03:00
|
|
|
|
2022-01-02 01:34:23 +03:00
|
|
|
class Meta:
|
|
|
|
model = Order
|
2022-02-17 22:50:10 +03:00
|
|
|
fields = (
|
|
|
|
"id",
|
|
|
|
"status",
|
|
|
|
"created_at",
|
|
|
|
"expires_at",
|
|
|
|
"type",
|
|
|
|
"currency",
|
|
|
|
"amount",
|
2022-03-22 02:27:36 +03:00
|
|
|
"has_range",
|
|
|
|
"min_amount",
|
|
|
|
"max_amount",
|
2022-02-17 22:50:10 +03:00
|
|
|
"payment_method",
|
|
|
|
"is_explicit",
|
|
|
|
"premium",
|
|
|
|
"satoshis",
|
2022-03-22 20:49:57 +03:00
|
|
|
"bondless_taker",
|
2022-02-17 22:50:10 +03:00
|
|
|
"maker",
|
|
|
|
"taker",
|
2022-04-29 21:54:20 +03:00
|
|
|
"escrow_duration",
|
2022-02-17 22:50:10 +03:00
|
|
|
)
|
|
|
|
|
2022-01-02 01:34:23 +03:00
|
|
|
|
|
|
|
class MakeOrderSerializer(serializers.ModelSerializer):
|
2022-02-17 22:50:10 +03:00
|
|
|
|
2022-01-02 01:34:23 +03:00
|
|
|
class Meta:
|
|
|
|
model = Order
|
2022-02-17 22:50:10 +03:00
|
|
|
fields = (
|
|
|
|
"type",
|
|
|
|
"currency",
|
|
|
|
"amount",
|
2022-03-22 02:27:36 +03:00
|
|
|
"has_range",
|
|
|
|
"min_amount",
|
|
|
|
"max_amount",
|
2022-02-17 22:50:10 +03:00
|
|
|
"payment_method",
|
|
|
|
"is_explicit",
|
|
|
|
"premium",
|
|
|
|
"satoshis",
|
2022-03-19 00:21:13 +03:00
|
|
|
"public_duration",
|
2022-04-29 21:54:20 +03:00
|
|
|
"escrow_duration",
|
2022-03-19 01:09:38 +03:00
|
|
|
"bond_size",
|
2022-03-22 02:27:36 +03:00
|
|
|
"bondless_taker",
|
2022-02-17 22:50:10 +03:00
|
|
|
)
|
|
|
|
|
2022-01-06 23:33:40 +03:00
|
|
|
class UpdateOrderSerializer(serializers.Serializer):
|
2022-02-17 22:50:10 +03:00
|
|
|
invoice = serializers.CharField(max_length=2000,
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
|
|
|
default=None)
|
2022-06-06 23:37:51 +03:00
|
|
|
address = serializers.CharField(max_length=100,
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
|
|
|
default=None)
|
2022-02-17 22:50:10 +03:00
|
|
|
statement = serializers.CharField(max_length=10000,
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
|
|
|
default=None)
|
|
|
|
action = serializers.ChoiceField(
|
|
|
|
choices=(
|
2022-04-29 21:54:20 +03:00
|
|
|
"pause",
|
2022-02-17 22:50:10 +03:00
|
|
|
"take",
|
|
|
|
"update_invoice",
|
2022-06-06 23:37:51 +03:00
|
|
|
"update_address",
|
2022-02-17 22:50:10 +03:00
|
|
|
"submit_statement",
|
|
|
|
"dispute",
|
|
|
|
"cancel",
|
|
|
|
"confirm",
|
|
|
|
"rate_user",
|
|
|
|
"rate_platform",
|
|
|
|
),
|
|
|
|
allow_null=False,
|
|
|
|
)
|
|
|
|
rating = serializers.ChoiceField(
|
|
|
|
choices=("1", "2", "3", "4", "5"),
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
2022-03-22 20:49:57 +03:00
|
|
|
amount = serializers.DecimalField(max_digits=18, decimal_places=8, allow_null=True, required=False, default=None)
|
2022-06-06 23:37:51 +03:00
|
|
|
mining_fee_rate = serializers.DecimalField(max_digits=6, decimal_places=3, allow_null=True, required=False, default=None)
|
2022-03-06 19:08:28 +03:00
|
|
|
|
2022-05-23 14:21:01 +03:00
|
|
|
class UserGenSerializer(serializers.Serializer):
|
|
|
|
# Mandatory fields
|
2022-05-30 17:08:32 +03:00
|
|
|
token_sha256 = serializers.CharField(
|
|
|
|
min_length=64,
|
|
|
|
max_length=64,
|
2022-05-23 14:21:01 +03:00
|
|
|
allow_null=False,
|
|
|
|
allow_blank=False,
|
|
|
|
required=True,
|
|
|
|
help_text="SHA256 of user secret")
|
2022-05-30 17:08:32 +03:00
|
|
|
public_key = serializers.CharField(max_length=2000,
|
2022-05-23 14:21:01 +03:00
|
|
|
allow_null=False,
|
|
|
|
allow_blank=False,
|
|
|
|
required=True,
|
|
|
|
help_text="Armored ASCII PGP public key block")
|
2022-05-30 17:08:32 +03:00
|
|
|
encrypted_private_key = serializers.CharField(max_length=2000,
|
2022-05-23 14:21:01 +03:00
|
|
|
allow_null=False,
|
|
|
|
allow_blank=False,
|
|
|
|
required=True,
|
|
|
|
help_text="Armored ASCII PGP encrypted private key block")
|
|
|
|
|
|
|
|
# Optional fields
|
|
|
|
ref_code = serializers.CharField(max_length=30,
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
|
|
|
required=False,
|
|
|
|
default=None)
|
|
|
|
counts = serializers.ListField(child=serializers.IntegerField(),
|
|
|
|
allow_null=True,
|
|
|
|
required=False,
|
|
|
|
default=None)
|
|
|
|
length = serializers.IntegerField(allow_null=True,
|
|
|
|
default=None,
|
|
|
|
required=False,
|
|
|
|
min_value=1)
|
|
|
|
unique_values = serializers.IntegerField(allow_null=True,
|
|
|
|
default=None,
|
|
|
|
required=False,
|
|
|
|
min_value=1)
|
|
|
|
|
2022-03-06 19:08:28 +03:00
|
|
|
class ClaimRewardSerializer(serializers.Serializer):
|
|
|
|
invoice = serializers.CharField(max_length=2000,
|
|
|
|
allow_null=True,
|
|
|
|
allow_blank=True,
|
2022-03-12 14:24:11 +03:00
|
|
|
default=None)
|
|
|
|
|
|
|
|
class PriceSerializer(serializers.Serializer):
|
2022-06-21 22:29:07 +03:00
|
|
|
pass
|
|
|
|
|
|
|
|
class TickSerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = MarketTick
|
|
|
|
fields = (
|
|
|
|
"timestamp",
|
|
|
|
"currency",
|
|
|
|
"volume",
|
|
|
|
"price",
|
|
|
|
"premium",
|
|
|
|
"fee",
|
|
|
|
)
|
2022-08-12 20:41:06 +03:00
|
|
|
depth = 1
|
|
|
|
|
|
|
|
class StealthSerializer(serializers.Serializer):
|
|
|
|
wantsStealth = serializers.BooleanField()
|