text: #include "stdafx.h"
  #include <playfab/PFTrading.h>
  #include "Trading.h"
  #include "ApiAsyncProviders.h"
  #include "GlobalState.h"
  #include "Entity.h"
  
  using namespace PlayFab;
  using namespace PlayFab::Trading;
  
  HRESULT PFTradingClientAcceptTradeAsync(
      _In_ PFTitlePlayerHandle contextHandle,
      _In_ const PFTradingAcceptTradeRequest* request,
      _In_ XAsyncBlock* async
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(contextHandle);
      RETURN_HR_INVALIDARG_IF_NULL(request);
  
      auto provider = MakeProvider(async, __FUNCTION__, std::bind(&TradingAPI::ClientAcceptTrade, contextHandle->titlePlayer, *request, std::placeholders::_1));
      return Provider::Run(UniquePtr<Provider>(provider.release()));
  }
  
  HRESULT PFTradingClientAcceptTradeGetResultSize(
      _In_ XAsyncBlock* async,
      _Out_ size_t* bufferSize
  ) noexcept
  {
      return XAsyncGetResultSize(async, bufferSize);
  }
  
  HRESULT PFTradingClientAcceptTradeGetResult(
      _In_ XAsyncBlock* async,
      _In_ size_t bufferSize,
      _Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
      _Outptr_ PFTradingAcceptTradeResponse** result,
      _Out_opt_ size_t* bufferUsed
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(result);
  
      RETURN_IF_FAILED(XAsyncGetResult(async, nullptr, bufferSize, buffer, bufferUsed));
      *result = static_cast<PFTradingAcceptTradeResponse*>(buffer);
  
      return S_OK;
  }
  
  HRESULT PFTradingClientCancelTradeAsync(
      _In_ PFTitlePlayerHandle contextHandle,
      _In_ const PFTradingCancelTradeRequest* request,
      _In_ XAsyncBlock* async
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(contextHandle);
      RETURN_HR_INVALIDARG_IF_NULL(request);
  
      auto provider = MakeProvider(async, __FUNCTION__, std::bind(&TradingAPI::ClientCancelTrade, contextHandle->titlePlayer, *request, std::placeholders::_1));
      return Provider::Run(UniquePtr<Provider>(provider.release()));
  }
  
  HRESULT PFTradingClientCancelTradeGetResultSize(
      _In_ XAsyncBlock* async,
      _Out_ size_t* bufferSize
  ) noexcept
  {
      return XAsyncGetResultSize(async, bufferSize);
  }
  
  HRESULT PFTradingClientCancelTradeGetResult(
      _In_ XAsyncBlock* async,
      _In_ size_t bufferSize,
      _Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
      _Outptr_ PFTradingCancelTradeResponse** result,
      _Out_opt_ size_t* bufferUsed
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(result);
  
      RETURN_IF_FAILED(XAsyncGetResult(async, nullptr, bufferSize, buffer, bufferUsed));
      *result = static_cast<PFTradingCancelTradeResponse*>(buffer);
  
      return S_OK;
  }
  
  HRESULT PFTradingClientGetPlayerTradesAsync(
      _In_ PFTitlePlayerHandle contextHandle,
      _In_ const PFTradingGetPlayerTradesRequest* request,
      _In_ XAsyncBlock* async
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(contextHandle);
      RETURN_HR_INVALIDARG_IF_NULL(request);
  
      auto provider = MakeProvider(async, __FUNCTION__, std::bind(&TradingAPI::ClientGetPlayerTrades, contextHandle->titlePlayer, *request, std::placeholders::_1));
      return Provider::Run(UniquePtr<Provider>(provider.release()));
  }
  
  HRESULT PFTradingClientGetPlayerTradesGetResultSize(
      _In_ XAsyncBlock* async,
      _Out_ size_t* bufferSize
  ) noexcept
  {
      return XAsyncGetResultSize(async, bufferSize);
  }
  
  HRESULT PFTradingClientGetPlayerTradesGetResult(
      _In_ XAsyncBlock* async,
      _In_ size_t bufferSize,
      _Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
      _Outptr_ PFTradingGetPlayerTradesResponse** result,
      _Out_opt_ size_t* bufferUsed
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(result);
  
      RETURN_IF_FAILED(XAsyncGetResult(async, nullptr, bufferSize, buffer, bufferUsed));
      *result = static_cast<PFTradingGetPlayerTradesResponse*>(buffer);
  
      return S_OK;
  }
  
  HRESULT PFTradingClientGetTradeStatusAsync(
      _In_ PFTitlePlayerHandle contextHandle,
      _In_ const PFTradingGetTradeStatusRequest* request,
      _In_ XAsyncBlock* async
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(contextHandle);
      RETURN_HR_INVALIDARG_IF_NULL(request);
  
      auto provider = MakeProvider(async, __FUNCTION__, std::bind(&TradingAPI::ClientGetTradeStatus, contextHandle->titlePlayer, *request, std::placeholders::_1));
      return Provider::Run(UniquePtr<Provider>(provider.release()));
  }
  
  HRESULT PFTradingClientGetTradeStatusGetResultSize(
      _In_ XAsyncBlock* async,
      _Out_ size_t* bufferSize
  ) noexcept
  {
      return XAsyncGetResultSize(async, bufferSize);
  }
  
  HRESULT PFTradingClientGetTradeStatusGetResult(
      _In_ XAsyncBlock* async,
      _In_ size_t bufferSize,
      _Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
      _Outptr_ PFTradingGetTradeStatusResponse** result,
      _Out_opt_ size_t* bufferUsed
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(result);
  
      RETURN_IF_FAILED(XAsyncGetResult(async, nullptr, bufferSize, buffer, bufferUsed));
      *result = static_cast<PFTradingGetTradeStatusResponse*>(buffer);
  
      return S_OK;
  }
  
  HRESULT PFTradingClientOpenTradeAsync(
      _In_ PFTitlePlayerHandle contextHandle,
      _In_ const PFTradingOpenTradeRequest* request,
      _In_ XAsyncBlock* async
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(contextHandle);
      RETURN_HR_INVALIDARG_IF_NULL(request);
  
      auto provider = MakeProvider(async, __FUNCTION__, std::bind(&TradingAPI::ClientOpenTrade, contextHandle->titlePlayer, *request, std::placeholders::_1));
      return Provider::Run(UniquePtr<Provider>(provider.release()));
  }
  
  HRESULT PFTradingClientOpenTradeGetResultSize(
      _In_ XAsyncBlock* async,
      _Out_ size_t* bufferSize
  ) noexcept
  {
      return XAsyncGetResultSize(async, bufferSize);
  }
  
  HRESULT PFTradingClientOpenTradeGetResult(
      _In_ XAsyncBlock* async,
      _In_ size_t bufferSize,
      _Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
      _Outptr_ PFTradingOpenTradeResponse** result,
      _Out_opt_ size_t* bufferUsed
  ) noexcept
  {
      RETURN_HR_INVALIDARG_IF_NULL(result);
  
      RETURN_IF_FAILED(XAsyncGetResult(async, nullptr, bufferSize, buffer, bufferUsed));
      *result = static_cast<PFTradingOpenTradeResponse*>(buffer);
  
      return S_OK;
  }
  
  