prepareCartRequest method

dynamic prepareCartRequest(
  1. String? pogId,
  2. String? offerId,
  3. String? quantity
)

Implementation

prepareCartRequest(String? pogId, String? offerId, String? quantity) {
  var transactionType = storage.read("transactionType") ?? "SELL_IN";
  int buyerType = storage.read("LEVEL_ID");
  int sellerType = storage.read("seller_type_config") != null
      ? int.parse(storage.read("seller_type_config"))
      : 1;
  String regionName = storage.read("REGION_NAME") ?? "";
  String buyerTypeEntityId = storage.read("PARTNER_ID") ?? "1";
  String sellerTypeEntityId = stockOrderController.isDealerFlow
      ? storage.read("DISTRIBUTER_ID")
      : SecureStorageService.readSecureData(
            SecureStorageService.partnerIdLogin,
          ) ??
          "";
  String levelNameLogin = SecureStorageService.readSecureData(
        SecureStorageService.levelNameLogin,
      ) ??
      "";
  AddToCartRequest request = AddToCartRequest();
  List<RelatedParty> relatedPart = []; //1
  relatedPart.add(
    RelatedParty(
      name: SecureStorageService.readSecureData(
        SecureStorageService.userId,
      ),
      role: "CreatedBy",
    ),
  );
  relatedPart.add(RelatedParty(
    name: levelNameLogin,
    role: "DistributorType",
  ));
  relatedPart.add(
    RelatedParty(
      name: SecureStorageService.readSecureData(
        SecureStorageService.userId,
      ),
      role: "agentId",
    ),
  );
  List<SelectedCartoffers> selectedCartOffers = []; //2
  selectedCartOffers.add(SelectedCartoffers(
      id: offerId,
      autoRefill: false,
      isAttached: 'false',
      pog: pogId,
      quantity: quantity,
      recommended: false,
      assetId: "",
      startRange: "",
      endRange: ""));
  ContextParameters contextParameters = ContextParameters(
    currencyType: "USD",
    buyerType: buyerType.toString(),
    buyerTypeEntityId: stockOrderController.partnerId,
    sellerTypeEntityId: sellerTypeEntityId,
    sellerType: sellerType.toString(),
    region: regionName,
    transactionType: storage.read("transactionType") ?? "SELL_IN",
    creditLimitBalance: "",
  );
  request.category = transactionType;
  request.contextParameters = contextParameters;
  request.relatedParty = relatedPart;
  request.selectedCartoffers = selectedCartOffers;
  return request;
}