Esempio n. 1
0
        public override async Task <OrdersResponse> GetClosedOrders(OrdersRequest request, ServerCallContext context)
        {
            var result = await _validationService.ValidateOrdersRequestAsync(request.AssetPairId, request.Offset, request.Take);

            if (result != null)
            {
                return(new OrdersResponse
                {
                    Error = new Error
                    {
                        Code = (int)result.Code,
                        Message = result.Message
                    }
                });
            }

            var orders = await _historyClient.GetOrdersByWalletAsync(context.GetHttpContext().User.GetWalletId(), request.AssetPairId,
                                                                     new [] { OrderStatus.Matched, OrderStatus.Cancelled }, null, false, request.Offset, request.Take);

            var res = new OrdersResponse();

            res.Payload.AddRange(_mapper.Map <List <Order> >(orders));

            return(res);
        }
        public async Task <IActionResult> GetCloasedOrders(
            [FromQuery] string assetPairId = null,
            [FromQuery] int?offset         = 0,
            [FromQuery] int?take           = 100
            )
        {
            var result = await _validationService.ValidateOrdersRequestAsync(assetPairId, offset, take);

            if (result != null)
            {
                throw HftApiException.Create(result.Code, result.Message).AddField(result.FieldName);
            }

            var orders = await _historyClient.GetOrdersByWalletAsync(User.GetWalletId(), assetPairId,
                                                                     new [] { OrderStatus.Matched, OrderStatus.Cancelled }, null, false, offset, take);

            var ordersModel = _mapper.Map <IReadOnlyCollection <OrderModel> >(orders);

            return(Ok(ResponseModel <IReadOnlyCollection <OrderModel> > .Ok(_mapper.Map <IReadOnlyCollection <OrderModel> >(ordersModel))));
        }