Esempio n. 1
0
        public static ApiCallResponse Insert <TEntity>(TEntity entity, ParaCredentials paraCredentials) where TEntity : ParaEntity, new()
        {
            var doc = XmlGenerator.GenerateXml(entity);
            var ar  = ApiCallFactory.ObjectCreateUpdate <TEntity>(paraCredentials, doc, 0);

            entity.Id = ar.Id;
            return(ar);
        }
Esempio n. 2
0
        public static ApiCallResponse Insert(TFolder folder, ParaCredentials creds)
        {
            var doc = XmlGenerator.GenerateXml(folder);
            var ar  = ApiCallFactory.ObjectCreateUpdate <TFolder>(creds, doc, 0);

            folder.Id = ar.Id;
            return(ar);
        }
        public static TEntity Schema(ParaCredentials pc)
        {
            var entity = new TEntity();
            var ar     = ApiCallFactory.ObjectGetSchema <TEntity>(pc);

            if (ar.HasException == false)
            {
                var purgedSchema = ApiUtils.RemoveStaticFieldsNodes(ar.XmlReceived);
                entity = ParaEntityParser.EntityFill <TEntity>(purgedSchema);
            }

            entity.ApiCallResponse = ar;
            return(entity);
        }
Esempio n. 4
0
        /// <summary>
        /// Fills an Download list object.
        /// </summary>
        private static ParaEntityList <TFolder> FillList(ParaCredentials creds, TQuery query)
        {
            var folderList = new ParaEntityList <TFolder>();
            var ar         = ApiCallFactory.ObjectGetList <TFolder>(creds, query.BuildQueryArguments());

            if (ar.HasException == false)
            {
                folderList = ParaEntityParser.FillList <TFolder>(ar.XmlReceived);
            }
            folderList.ApiCallResponse = ar;

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                bool continueCalling = true;
                while (continueCalling)
                {
                    if (folderList.TotalItems > folderList.Data.Count)
                    {
                        // We still need to pull data

                        // Getting next page's data
                        query.PageNumber = query.PageNumber + 1;

                        ar = ApiCallFactory.ObjectGetList <TFolder>(creds, query.BuildQueryArguments());

                        var objectlist = ParaEntityParser.FillList <TFolder>(ar.XmlReceived);

                        if (objectlist.Data.Count == 0)
                        {
                            continueCalling = false;
                        }

                        folderList.Data.AddRange(objectlist.Data);
                        folderList.ResultsReturned = folderList.Data.Count;
                        folderList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        // That is it, pulled all the items.
                        continueCalling            = false;
                        folderList.ApiCallResponse = ar;
                    }
                }
            }

            return(folderList);
        }
Esempio n. 5
0
        private static ParaEntityList <ParaObjects.Chat> RetrieveAllEntitites(ParaCredentials creds, ChatQuery query)
        {
            var chatList = new ParaEntityList <ParaObjects.Chat>();
            var ar       = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());

            if (ar.HasException == false)
            {
                chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived);
            }
            chatList.ApiCallResponse = ar;

            bool continueCalling = true;

            while (continueCalling)
            {
                if (chatList.TotalItems > chatList.Data.Count)
                {
                    // We still need to pull data

                    // Getting next page's data
                    query.PageNumber = query.PageNumber + 1;

                    ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());
                    if (ar.HasException == false)
                    {
                        chatList.Data.AddRange(ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived).Data);
                        chatList.ResultsReturned = chatList.Data.Count;
                        chatList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        continueCalling          = false;
                        chatList.ApiCallResponse = ar;
                        break;
                    }
                }
                else
                {
                    // That is it, pulled all the items.
                    continueCalling          = false;
                    chatList.ApiCallResponse = ar;
                }
            }

            return(chatList);
        }
Esempio n. 6
0
        private static TFolder FillDetails(Int64 folderId, ParaCredentials creds)
        {
            var folder = new TFolder();
            var ar     = ApiCallFactory.ObjectGetDetail <TFolder>(creds, folderId);

            if (ar.HasException == false)
            {
                folder             = ParaEntityParser.EntityFill <TFolder>(ar.XmlReceived);
                folder.FullyLoaded = true;
            }
            else
            {
                folder.FullyLoaded = false;
                folder.Id          = 0;
            }

            folder.ApiCallResponse = ar;
            return(folder);
        }
Esempio n. 7
0
        private static ParaObjects.Chat FillTranscriptDetails(Int64 chatid, ParaCredentials paraCredentials)
        {
            //Because chat transcripts return a Chat object with just a list messages, we'll deserialize the transcript into a chat object
            var chat = new ParaObjects.Chat();

            var ar = ApiCallFactory.ChatTranscriptGetDetail(paraCredentials, chatid);

            if (ar.HasException == false)
            {
                chat             = ParaEntityParser.EntityFill <ParaObjects.Chat>(ar.XmlReceived);
                chat.FullyLoaded = true;
            }
            else
            {
                chat.FullyLoaded = false;
                chat.Id          = 0;
            }
            chat.ApiCallResponse = ar;
            chat.IsDirty         = false;
            return(chat);
        }
Esempio n. 8
0
        private static ParaEntityList <ParaObjects.Chat> FillList(ParaCredentials creds, Boolean includeTranscripts,
                                                                  ChatQuery query)
        {
            if (query == null)
            {
                query = new ChatQuery();
            }
            var chatList = new ParaEntityList <ParaObjects.Chat>();

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                chatList = RetrieveAllEntitites(creds, query);
            }
            else
            {
                var ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());
                if (ar.HasException == false)
                {
                    chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived);
                }
                chatList.ApiCallResponse = ar;
            }

            if (includeTranscripts)
            {
                var service = new ParaService(creds);
                //Fetch transcripts for each chat. Each request is another API call...
                foreach (var chat in chatList)
                {
                    chat.Transcript = service.GetChatTranscript(chat.Id);
                }
            }

            return(chatList);
        }
Esempio n. 9
0
        public static ApiCallResponse Update(TFolder folder, ParaCredentials creds)
        {
            var ar = ApiCallFactory.ObjectCreateUpdate <TFolder>(creds, XmlGenerator.GenerateXml(folder), folder.Id);

            return(ar);
        }
Esempio n. 10
0
 public static ApiCallResponse Delete(Int64 folderId, ParaCredentials creds)
 {
     return(ApiCallFactory.ObjectDelete <TFolder>(creds, folderId, true));
 }
Esempio n. 11
0
 public static ApiCallResponse Delete(Int64 entityId, ParaCredentials pc)
 {
     return(ApiCallFactory.ObjectDelete <TEntity>(pc, entityId, false));
 }
Esempio n. 12
0
        public static ApiCallResponse Update <TEntity>(TEntity entity, ParaCredentials paraCredentials) where TEntity : ParaEntity, new()
        {
            var ar = ApiCallFactory.ObjectCreateUpdate <TEntity>(paraCredentials, XmlGenerator.GenerateXml(entity), entity.Id);

            return(ar);
        }