Beispiel #1
0
        /// <summary>
        /// Implements call to Twofish method StoreBulkGet
        /// Retreive Twofish Store offers
        /// </summary>
        /// <param name="storeInfo">StoreName, IpAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML response document containing the Twofish CSV file listing all store offers</returns>
        public XmlDocument StoreBulkGet(StoreInfo storeInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("name", storeInfo.StoreName);
            keyValues.Add("ipAddress", storeInfo.IpAddress);

            DebugLog("StoreBulkGet", keyValues);

            string storeData = rest.GetStringRequest("store/bulk", keyValues);

            return(rest.WrapDataXML("Store", "StoreBulkGet", storeInfo.StoreName, storeData));
        }
Beispiel #2
0
        /// <summary>
        /// Implements call to Twofish method StoreBulkLoad
        /// Loads a store catalog
        /// </summary>
        /// <param name="storeInfo">IpAddress</param>
        /// <param name="fileData">Twofish store csv file</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>Twofish store bulk load XML response document</returns>
        public XmlDocument StoreBulkLoad(StoreInfo storeInfo, PostFile fileData, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("ipAddress", storeInfo.IpAddress);
            keyValues.Add("submit", "User Bulk Load (pretty format)");
            DebugLog("StoreBulkLoad", keyValues);

            return(rest.MultiPartFormXMLPost("store/bulk", keyValues, fileData.FileData));
        }
Beispiel #3
0
        /// <summary>
        /// Implements call to Twofish method item to find an item.
        /// </summary>
        /// <param name="itemsInfo">ItemName</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>Twofish XML response document containing detailed information about the Item</returns>
        public XmlDocument FindItem(ItemsInfo itemsInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("name", itemsInfo.ItemName);

            DebugLog("Item", keyValues);

            return(rest.GetXMLRequest("item", keyValues));
        }
Beispiel #4
0
        /// <summary>
        /// Implements call to Twofish method item/update to update an item
        /// </summary>
        /// <param name="itemsInfo">ItemName, ItemTypeName, ButtonName, Description, SmallImageUrl, MediumImageUrl, LargeImageUrl, Available, IPAddress</param>
        /// <param name="appName">The name of the application to contain the item</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>Twofish XML response document containing Update Item response</returns>
        public XmlDocument UpdateItem(ItemsInfo itemsInfo, string appName, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("item.name", itemsInfo.ItemName);
            keyValues.Add("item.appName", appName);
            keyValues.Add("item.itemTypeName", itemsInfo.ItemTypeName);
            keyValues.Add("item.buttonName", itemsInfo.ButtonName);
            keyValues.Add("item.description", itemsInfo.Description);
            keyValues.Add("item.smallImageUrl", itemsInfo.SmallImageUrl);
            keyValues.Add("item.mediumImageUrl", itemsInfo.MediumImageUrl);
            keyValues.Add("item.largeImageUrl", itemsInfo.LargeImageUrl);
            keyValues.Add("item.available", itemsInfo.Available);
            keyValues.Add("ipAddress", itemsInfo.IPAddress);
            //   keyValues.Add("p.color", "Blue");  // Test for additional properties.

            DebugLog("UpdateItem", keyValues);

            return(rest.PostXMLRequest("item/update", keyValues));
        }
Beispiel #5
0
        /// <summary>
        /// Implements call to Twofish method itemInstances to retrieve the item instance information for a user and item
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="itemsInfo">ItemName, ItemTypeName, IPAddress</param>
        /// <param name="filter">Filter</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>Twofish XML response document containing item instances information for a user and item</returns>
        public XmlDocument ItemInstance(UserId userId, ItemsInfo itemsInfo, ResultFilter filter, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("userId", userId.ToString());
            keyValues.Add("itemName", itemsInfo.ItemName);
            keyValues.Add("itemTypeName", itemsInfo.ItemTypeName);
            keyValues.Add("ipAddress", itemsInfo.IPAddress);
            keyValues.Add("filter", filter.Filter);
            keyValues.Add("fetchRequest.startIndex", filter.StartIndex);
            keyValues.Add("fetchRequest.blockSize", filter.BlockSize);

            DebugLog("ItemInstance", keyValues);

            return(rest.GetXMLRequest("itemInstances", keyValues));
        }
Beispiel #6
0
        /// <summary>
        /// Implements call to Twofish method ItemTypes to retrieve the item type information for a given store
        /// </summary>
        /// <param name="storeName"></param>
        /// <param name="commmonKeyValue"></param>
        /// <param name="baseAddress"></param>
        /// <returns>Twofish XML response document containing item type information for a given store</returns>
        public XmlDocument ItemTypes(string storeName, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("storeName", storeName);

            DebugLog("ItemTypes", keyValues);

            return(rest.GetXMLRequest("itemTypes", keyValues));
        }
Beispiel #7
0
        /// <summary>
        /// Implements call to user/secureKey method to generate a new secure key for the user.
        /// </summary>
        /// <param name="userId">userId, IPAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML response document containing user new secure key</returns>
        public XmlDocument SecureKey(UserId userId, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("userId", userId.ToString());
            keyValues.Add("ipAddress", userId.IPAddress);

            DebugLog("SecureKey", keyValues);

            return(rest.PostXMLRequest("user/secureKey", keyValues));
        }
Beispiel #8
0
        /// <summary>
        /// Does a tranfer of funds from one account to another account of the same currency.
        /// </summary>
        /// <param name="transferInfo">Amount, DebitAccountId, CreditAccountId, TransferType, ExternalTxnId, IpAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML document containing results of the transfer</returns>
        public XmlDocument CreateTransfer(TransferInfo transferInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);
            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("amount", transferInfo.Amount);
            keyValues.Add("debitAccountId", transferInfo.DebitAccountId);
            keyValues.Add("creditAccountId", transferInfo.CreditAccountId);
            keyValues.Add("transferType", transferInfo.TransferType);
            keyValues.Add("externalTxnId", transferInfo.ExternalTxnId);
            keyValues.Add("ipAddress", transferInfo.IpAddress);

            DebugLog("CreateTransfer", keyValues);

            return(rest.PostXMLRequest("transfer", keyValues));
        }
Beispiel #9
0
        /// <summary>
        /// Implements call to user/widget method to retreive user foreign exchange offers and payment methods
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="virtualCurrencyId">virtualCurrencyId</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML response document containing user foreign exchange offers and payment methods</returns>
        public XmlDocument UserWidget(UserId userId, String virtualCurrencyId, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false, "DefaultPaymentGateway");

            keyValues.Add("userId", userId.ToString());
            keyValues.Add("virtualCurrencyId", virtualCurrencyId);

            DebugLog("UserWidget", keyValues);

            return(rest.GetXMLRequest("user/widget", keyValues));
        }
Beispiel #10
0
        public XmlDocument PaymentOptions(UserId userId, string PaymentGatewayName, PaymentInfo paymentInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false, PaymentGatewayName);

            keyValues.Add("userId", userId.ToString());
            keyValues.Add("countryCode", paymentInfo.CountryCode);
            keyValues.Add("currencyCode", paymentInfo.CurrencyCode);
            keyValues.Add("virtualCurrencyIds", paymentInfo.VirtualCurrencyIds);

            DebugLog("PaymentOptions", keyValues);

            return(rest.GetXMLRequest("user/paymentOptions", keyValues));
        }
Beispiel #11
0
        /// <summary>
        /// Implements call to Twofish method CreateCatalog
        /// </summary>
        /// <param name="itemsInfo">IPAddress</param>
        /// <param name="fileData">Twofish catalog csv file</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>Twofish CreateCatalog XML response document</returns>
        public XmlDocument CreateCatalog(ItemsInfo itemsInfo, PostFile fileData, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("ipAddress", itemsInfo.IPAddress);

            DebugLog("CreateCatalog", keyValues);

            return(rest.MultiPartFormXMLPost("catalog", keyValues, fileData.FileData));
        }
Beispiel #12
0
        /// <summary>
        /// Implements call to Twofish method FindCatalog
        /// Retreive Twofish items catalog
        /// </summary>
        /// <param name="itemsInfo">ItemTypeNames, IPAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML response document containing the Twofish CSV file listing the Items Catalog</returns>
        public XmlDocument FindCatalog(ItemsInfo itemsInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("appName", GetAppName());
            keyValues.Add("itemTypeNames", itemsInfo.ItemTypeNames);
            keyValues.Add("ipAddress", itemsInfo.IPAddress);

            DebugLog("FindCatalog", keyValues);

            string catalogData = rest.GetStringRequest("catalog", keyValues);

            return(rest.WrapDataXML("Catalog", "FindCatalog", "Catalog", catalogData));
        }
Beispiel #13
0
        /// <summary>
        /// Parse CSV file that is a Catalog File, a Store File or a combination of Catalog and Store File.
        /// Upload created Catalog and Store Files to Twofish returning the XML results form Twofish.
        /// </summary>
        /// <param name="itemInfo">ItemsInfo, used for the for the the IP Address.</param>
        /// <param name="fileData">PostFile The CSV file</param>
        /// <param name="commmonKeyValue">CommmonKeyValues</param>
        /// <param name="baseAddress">BaseAddress</param>
        /// <returns>An XML document containing the response from Catalog and or Store uploads as returned by Twofish.</returns>
        public XmlDocument UploadCatalogStore(ItemsInfo itemInfo, PostFile fileData, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            XmlDocument response = null;

            try
            {
                response = new XmlDocument();
                response.LoadXml("<response></response>");

                fileData.RemoveLeadingSpacesAndLines();

                PostFile catalogFile = CreateCatalogUpload(fileData);
                if (catalogFile.FileData != null)
                {
                    Catalog     catalogCommand  = new Catalog();
                    XmlDocument catalogResponse = catalogCommand.CreateCatalog(itemInfo, catalogFile, commmonKeyValue, baseAddress);
                    AddToResponse(response, "/response", "Catalog", catalogResponse);
                }

                StoreInfo storeInfo = new StoreInfo();
                storeInfo.IpAddress = itemInfo.IPAddress;

                string[] storeNameArray = FindStoreNames(fileData);

                if (storeNameArray != null)
                {
                    foreach (string storeName in storeNameArray)
                    {
                        Store       storeCommand  = new Store();
                        PostFile    storeFile     = CreateStoreUpload(fileData, storeName);
                        XmlDocument storeResponse = storeCommand.StoreBulkLoad(storeInfo, storeFile, commmonKeyValue, baseAddress);
                        AddToResponse(response, "/response", storeName, storeResponse);
                    }
                }
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("UploadCatalogStore", ex);
            }

            return(response);
        }
Beispiel #14
0
        /// <summary>
        /// Retrieve all of the store offer for a given store
        /// </summary>
        /// <param name="storeName">storeName<storeName/param>
        /// <param name="filter">ItemTypeNames, MaxRemaining, LatestEndDate, OrderBy, Descending, StartIndex, BlockSize</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML doucment containing stores offers</returns>
        public XmlDocument FindStore(String storeName, ResultFilter filter, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(true);

            keyValues.Add("name", storeName);
            keyValues.Add("itemTypeNames", filter.ItemTypeNames);
            keyValues.Add("maxRemaining", filter.MaxRemaining);
            keyValues.Add("latestEndDate", filter.LatestEndDate);
            keyValues.Add("orderBy", filter.OrderBy);
            keyValues.Add("descending", filter.Descending);
            keyValues.Add("fetchRequest.startIndex", filter.StartIndex);
            keyValues.Add("fetchRequest.blockSize", filter.BlockSize);

            DebugLog("Store", keyValues);

            return(rest.GetXMLRequest("store", keyValues));
        }
Beispiel #15
0
        /// <summary>
        /// Implements call to user/update method to update a Twofish user account
        /// </summary>
        /// <param name="userInfo">UserId, CountryCode, ExternalKey, Gender, DateOfBirth, EmailAddress, Tags, IPAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML response document containing user information</returns>
        public XmlDocument UpdateUser(UserInfo userInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("user.id", userInfo.UserId);
            keyValues.Add("user.countryCode", userInfo.CountryCode);
            keyValues.Add("user.externalKey", userInfo.ExternalKey);
            keyValues.Add("user.gender", userInfo.Gender);
            keyValues.Add("user.dateOfBirth", userInfo.DateOfBirth);
            keyValues.Add("user.emailAddress", userInfo.EmailAddress);
            keyValues.Add("user.tags", userInfo.Tags);
            keyValues.Add("ipAddress", userInfo.IPAddress);

            DebugLog("UpdateUser", keyValues);

            return(rest.PostXMLRequest("user/update", keyValues));
        }
Beispiel #16
0
        /// <summary>
        /// Purchase an item as a gift from a store.
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="purchaseInfo">RecipientUserId, NoteToRecipient AccountId, OfferIds, ExternalTxnId, IPAddress</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XML document containing purchase gift results</returns>
        public XmlDocument PurchaseGift(UserId userId, PurchaseInfo purchaseInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);

            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            keyValues.Add("userId", userId.ToString());
            keyValues.Add("recipientUserId", purchaseInfo.RecipientUserId);
            keyValues.Add("note", purchaseInfo.NoteToRecipient);
            keyValues.Add("accountId", purchaseInfo.AccountId);
            keyValues.Add("offerId", purchaseInfo.OfferId);
            keyValues.Add("externalTxnId", purchaseInfo.ExternalTxnId);
            keyValues.Add("ipAddress", userId.IPAddress);

            DebugLog("PurchaseGift", keyValues);

            return(rest.PostXMLRequest("store/purchaseGift", keyValues));
        }
Beispiel #17
0
        /// <summary>
        /// Implements call to Twofish method FindCurrency
        /// </summary>
        /// <param name="currencyInfo">id, appId</param>
        /// <param name="commmonKeyValue">Twofish REST service common values</param>
        /// <param name="baseAddress">Twofish REST service base address</param>
        /// <returns>XmlDocument document containing the list of currency's for the application</returns>
        public XmlDocument FindCurrency(CurrencyInfo currencyInfo, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            ServiceHandler rest = new ServiceHandler(baseAddress.BaseAddressValue);
            Dictionary <string, string> keyValues = commmonKeyValue.GetCommmonInfo(false);

            if (currencyInfo != null)
            {
                keyValues.Add("currency.id", currencyInfo.CurrencyId);
                keyValues.Add("currency.appId", currencyInfo.CurrencyAppId);
            }

            DebugLog("FindCurrency", keyValues);

            return(rest.GetXMLRequest("currency", keyValues));
        }