Exemplo n.º 1
0
from purplship.server.manager.serializers import (
    reset_related_shipment_rates,
    create_shipment_tracker,
    ShipmentSerializer,
    ShipmentRateData,
    ShipmentPurchaseData,
    ShipmentPurchaseSerializer,
    ShipmentCancelSerializer,
    RateSerializer,
    ParcelSerializer,
)
import purplship.server.manager.models as models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$$$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Shipments = PaginatedResult("ShipmentList", Shipment)


class ShipmentFilters(filters.FilterSet):
    created_start = filters.DateFilter(field_name="created_at",
                                       lookup_expr="gte")
    created_end = filters.DateFilter(field_name="created_at",
                                     lookup_expr="lte")
    carrier_id = filters.CharFilter(
        field_name="selected_rate_carrier__carrier_id")
    service = filters.CharFilter(field_name="selected_rate__service")
    reference = filters.CharFilter(field_name="reference",
                                   lookup_expr="iregex")

    parameters = [
        openapi.Parameter("test_mode",
Exemplo n.º 2
0
from rest_framework.request import Request
from rest_framework import status, serializers
from drf_yasg.utils import swagger_auto_schema
from django.urls import path

from purplship.server.core.views.api import GenericAPIView, APIView
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.core.serializers import ErrorResponse, Operation, FlagField, PlainDictField
from purplship.server.events.serializers import WebhookData, Webhook, WebhookSerializer
from purplship.server.events.tasks.webhook import notify_subscribers
from purplship.server.events.router import router
from purplship.server.events import models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$$$$$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Webhooks = PaginatedResult('WebhookList', Webhook)


class WebhookTestRequest(serializers.Serializer):
    payload = PlainDictField(required=True)


class WebhookFilters(serializers.Serializer):
    test_mode = FlagField(
        required=False,
        allow_null=True,
        default=None,
        help_text="This flag filter out webhooks created in test or live mode")


class WebhookList(GenericAPIView):
Exemplo n.º 3
0
from rest_framework.request import Request
from rest_framework import status
from drf_yasg.utils import swagger_auto_schema
from django.urls import path

from purplship.server.core.views.api import GenericAPIView, APIView
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.core.exceptions import PurplShipApiException
from purplship.server.core.serializers import ShipmentStatus, ErrorResponse, AddressData, Address, Operation
from purplship.server.manager.serializers import AddressSerializer, reset_related_shipment_rates
from purplship.server.manager.router import router
from purplship.server.manager import models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Addresses = PaginatedResult('AddressList', Address)


class AddressList(GenericAPIView):
    queryset = models.Address.objects
    pagination_class = type('CustomPagination', (LimitOffsetPagination, ),
                            dict(default_limit=20))

    @swagger_auto_schema(tags=['Addresses'],
                         operation_id=f"{ENDPOINT_ID}list",
                         operation_summary="List all addresses",
                         responses={
                             200: Addresses(),
                             400: ErrorResponse()
                         },
                         code_examples=[{
Exemplo n.º 4
0
from purplship.server.core.serializers import (
    MODELS,
    TrackingStatus,
    ErrorResponse,
    TestFilters,
    Operation,
    TrackerStatus,
)
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.manager.router import router
from purplship.server.manager.serializers import TrackingSerializer
import purplship.server.manager.models as models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$$$$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Trackers = PaginatedResult("TrackerList", TrackingStatus)
CARRIER_NAMES = list(MODELS.keys())


class TrackerFilters(filters.FilterSet):
    carrier_id = filters.CharFilter(field_name="tracking_carrier__carrier_id")

    parameters = [
        openapi.Parameter(
            "carrier_name",
            in_=openapi.IN_QUERY,
            type=openapi.TYPE_STRING,
            enum=CARRIER_NAMES,
        ),
        openapi.Parameter("carrier_id",
                          in_=openapi.IN_QUERY,
Exemplo n.º 5
0
from rest_framework.request import Request
from rest_framework import status
from drf_yasg.utils import swagger_auto_schema
from django.urls import path

from purplship.server.core.views.api import GenericAPIView, APIView
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.core.exceptions import PurplShipApiException
from purplship.server.core.serializers import ShipmentStatus, ErrorResponse, ParcelData, Parcel, Operation
from purplship.server.manager.serializers import ParcelSerializer, reset_related_shipment_rates
from purplship.server.manager.router import router
import purplship.server.manager.models as models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Parcels = PaginatedResult('ParcelList', Parcel)


class ParcelList(GenericAPIView):
    queryset = models.Parcel.objects
    pagination_class = type('CustomPagination', (LimitOffsetPagination, ),
                            dict(default_limit=20))

    @swagger_auto_schema(tags=['Parcels'],
                         operation_id=f"{ENDPOINT_ID}list",
                         operation_summary="List all parcels",
                         responses={
                             200: Parcels(),
                             400: ErrorResponse()
                         },
                         code_examples=[{
Exemplo n.º 6
0
from purplship.server.core.views.api import GenericAPIView, APIView
from purplship.server.core.serializers import (
    FlagField,
    Pickup,
    ErrorResponse,
    OperationConfirmation,
    TestFilters,
)
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.manager.router import router
from purplship.server.manager.serializers import PickupData, PickupUpdateData, PickupCancelData
import purplship.server.manager.models as models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
Pickups = PaginatedResult('PickupList', Pickup)


class PickupFilters(filters.FilterSet):
    parameters = [
        openapi.Parameter('test_mode',
                          in_=openapi.IN_QUERY,
                          type=openapi.TYPE_BOOLEAN),
    ]

    class Meta:
        model = models.Pickup
        fields = ['test_mode']


class PickupList(GenericAPIView):
Exemplo n.º 7
0
from django.urls import path

from purplship.server.core.views.api import GenericAPIView, APIView
from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.core.exceptions import PurplShipApiException
from purplship.server.core.serializers import ShipmentStatus, ErrorResponse, CustomsData, Customs, Operation
from purplship.server.manager.serializers import (CustomsSerializer,
                                                  CommodityData,
                                                  CommoditySerializer,
                                                  reset_related_shipment_rates)
from purplship.server.manager.router import router
import purplship.server.manager.models as models

logger = logging.getLogger(__name__)
ENDPOINT_ID = "$$"  # This endpoint id is used to make operation ids unique make sure not to duplicate
CustomsInfoList = PaginatedResult('CustomsList', Customs)


class CustomsList(GenericAPIView):
    queryset = models.Customs.objects
    pagination_class = type('CustomPagination', (LimitOffsetPagination, ),
                            dict(default_limit=20))

    @swagger_auto_schema(tags=['Customs'],
                         operation_id=f"{ENDPOINT_ID}list",
                         operation_summary="List all customs info",
                         responses={
                             200: CustomsInfoList(),
                             400: ErrorResponse()
                         },
                         code_examples=[{
Exemplo n.º 8
0
from django.urls import path
from purplship.server import serializers
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.request import Request
from drf_yasg.utils import swagger_auto_schema

from purplship.server.serializers import SerializerDecorator, PaginatedResult
from purplship.server.core.views.api import GenericAPIView
from purplship.server.core.gateway import Carriers
from purplship.server.core.serializers import CarrierSettings, ErrorResponse, FlagField, FlagsSerializer, CARRIERS
from purplship.server.providers.router import router

logger = logging.getLogger(__name__)
ENDPOINT_ID = "&&"  # This endpoint id is used to make operation ids unique make sure not to duplicate
CarriersSettingsList = PaginatedResult('CarrierList', CarrierSettings)


class CarrierFilters(FlagsSerializer):

    carrier_name = serializers.ChoiceField(
        choices=CARRIERS,
        required=False,
        help_text="Indicates a carrier (type)")
    test = FlagField(
        required=False,
        allow_null=True,
        default=None,
        help_text="This flag filter out carriers in test or prod mode")
    active = FlagField(
        required=False,