Example #1
0
        public ResultDataPaged <Contact> SearchContacts(string token, ContactFilter filter, int offset = -1, int limit = -1)
        {
            try
            {
                // Validate
                RequestValidator.ValidateToken(token);

                StringBuilder url = new StringBuilder(apiUrl).Append(ConfigurationReader.GetValue("SearchContact")).Replace("{limit}", limit.ToString()).Replace("{offset}", offset.ToString());;
                if (this.language != null)
                {
                    url.Append("&lang=").Append(this.language);
                }

                RESTResponse   response       = HttpHelper.SendPostRequest(url.ToString(), filter, token, this.appId);
                PaginationInfo paginationInfo = null;

                // create response
                List <Contact> contacts = new List <Contact>();
                contacts = (List <Contact>)HttpHelper.ConvertToSDKResponse(contacts, response, ref paginationInfo);
                ResultDataPaged <Contact> results = new ResultDataPaged <Contact> {
                    Data = contacts, PageInfo = paginationInfo
                };
                return(results);
            }
            catch (WebException webException)
            {
                throw new Exception(HttpHelper.HandleWebException(webException, "Error in Search Record Contacts :"));
            }
            catch (Exception exception)
            {
                throw new Exception(HttpHelper.HandleException(exception, "Error in Search Record Contacts :"));
            }
        }
Example #2
0
        private Record GetRecord(string recordCustomId)
        {
            var recordFilter = new RecordFilter
            {
                customId = recordCustomId
            };
            ResultDataPaged <Record> page = this.recApi.SearchRecords(null, recordFilter, null, -1, -1, null, null, "addresses");

            return(page.Data.First());
        }
Example #3
0
        public ResultDataPaged <Record> SearchRecords(string token, RecordFilter filter, string fields = null, int offset = -1, int limit = -1, string sortField = null, string sortOrder = null, string expand = null)
        {
            try
            {
                // validate
                RequestValidator.ValidateToken(token);

                // create url
                StringBuilder url = new StringBuilder(apiUrl);
                url = url.Append(ConfigurationReader.GetValue("SearchRecords")).Replace("{limit}", limit.ToString()).Replace("{offset}", offset.ToString());
                if (fields != null)
                {
                    url.Append("&fields=").Append(fields);
                }
                if (this.language != null)
                {
                    url.Append("&lang=").Append(this.language);
                }
                if (sortField != null)
                {
                    url.Append("&sort=").Append(sortField);
                }
                if (sortOrder != null)
                {
                    url.Append("&direction=").Append(sortOrder);
                }
                if (expand != null)
                {
                    url.Append("&expand=").Append(expand);
                }

                RESTResponse   response       = HttpHelper.SendPostRequest(url.ToString(), filter, token, this.appId);
                PaginationInfo paginationInfo = null;

                // create response
                List <Record> records = new List <Record>();
                records = (List <Record>)HttpHelper.ConvertToSDKResponse(records, response, ref paginationInfo);
                ResultDataPaged <Record> results = new ResultDataPaged <Record> {
                    Data = records, PageInfo = paginationInfo
                };
                return(results);
            }
            catch (WebException webException)
            {
                throw new Exception(HttpHelper.HandleWebException(webException, "Error in Search Records :"));
            }
            catch (Exception exception)
            {
                throw new Exception(HttpHelper.HandleException(exception, "Error in Search Records :"));
            }
        }
Example #4
0
        public ResultDataPaged <Contact> GetRecordContacts(string recordId, string token, string fields = null, int offset = -1, int limit = -1)
        {
            try
            {
                // Validate
                if (String.IsNullOrWhiteSpace(recordId))
                {
                    throw new Exception("Null Record Id provided");
                }
                RequestValidator.ValidateToken(token);

                // get contacts
                StringBuilder url = new StringBuilder(apiUrl + ConfigurationReader.GetValue("GetRecordContacts").Replace("{recordIds}", recordId).Replace("{limit}", limit.ToString()).Replace("{offset}", offset.ToString()));
                if (this.language != null || fields != null)
                {
                    url.Append("?");
                }
                if (this.language != null)
                {
                    url.Append("lang=").Append(this.language);
                }
                if (this.language != null && fields != null)
                {
                    url.Append("&");
                }
                if (fields != null)
                {
                    url.Append("fields=").Append(fields);
                }

                RESTResponse   response       = HttpHelper.SendGetRequest(url.ToString(), token, this.appId);
                PaginationInfo paginationInfo = null;

                // create response
                List <Contact> contacts = new List <Contact>();
                contacts = (List <Contact>)HttpHelper.ConvertToSDKResponse(contacts, response);
                ResultDataPaged <Contact> results = new ResultDataPaged <Contact> {
                    Data = contacts, PageInfo = paginationInfo
                };
                return(results);
            }
            catch (WebException webException)
            {
                throw new Exception(HttpHelper.HandleWebException(webException, "Error in Get Record Contacts :"));
            }
            catch (Exception exception)
            {
                throw new Exception(HttpHelper.HandleException(exception, "Error in Get Record Contacts :"));
            }
        }
Example #5
0
        public ResultDataPaged <Record> GetRecords(string token, string filter, int offset = -1, int limit = -1)
        {
            try
            {
                // validate
                RequestValidator.ValidateToken(token);

                // create url
                StringBuilder url = new StringBuilder(apiUrl);
                if (this.appType == ApplicationType.Agency)
                {
                    url = url.Append(ConfigurationReader.GetValue("GetRecords")).Replace("{limit}", limit.ToString()).Replace("{offset}", offset.ToString());
                }
                else if (this.appType == ApplicationType.Citizen)
                {
                    url = url.Append(ConfigurationReader.GetValue("GetMyRecords")).Replace("{limit}", limit.ToString()).Replace("{offset}", offset.ToString());
                }
                if (!string.IsNullOrEmpty(filter))
                {
                    url.Append("&").Append(filter);
                }
                if (this.language != null)
                {
                    url.Append("&lang=").Append(this.language);
                }

                // get records
                RESTResponse   response       = HttpHelper.SendGetRequest(url.ToString(), token, this.appId);
                PaginationInfo paginationInfo = new PaginationInfo {
                    hasmore = false, offset = offset, limit = limit
                };

                // create response
                //List<Record> records = new List<Record>();
                //records = (List<Record>)HttpHelper.ConvertToSDKResponse(records, response, ref paginationInfo);
                var records = HttpHelper.ConvertToSDKResponse <List <Record> >(response, ref paginationInfo);
                ResultDataPaged <Record> results = new ResultDataPaged <Record> {
                    Data = records, PageInfo = paginationInfo
                };
                return(results);
            }
            catch (WebException webException)
            {
                throw new Exception(HttpHelper.HandleWebException(webException, "Error in Get Records :"));
            }
            catch (Exception exception)
            {
                throw new Exception(HttpHelper.HandleException(exception, "Error in Get Records :"));
            }
        }
Example #6
0
        public List <Permit> SearchPermits(PermitFilter filter)
        {
            var recordFilter = new RecordFilter();

            if (filter.PermitNumber != null)
            {
                recordFilter.customId = filter.PermitNumber;
            }
            else if (filter.Address != null)
            {
                Address   address       = new Address();
                UsAddress parsedAddress = this.ParseAddress(filter.Address);
                int       strNo;
                int.TryParse(parsedAddress.AddressNumber, out strNo);
                address.streetStart = strNo;
                address.streetName  = parsedAddress.StreetName;

                // address.xCoordinate = -82.458328247070312;
                // address.yCoordinate = 27.938003540039063;
                recordFilter.address = address;
            }

            ResultDataPaged <Record> page = this.recApi.SearchRecords(null, recordFilter, null, 0, 1000, null, null, "addresses");

            var result = new List <Permit>();

            if (page.Data != null)
            {
                foreach (var record in page.Data)
                {
                    Permit permit = this.ToPermit(record);
                    result.Add(permit);
                }
            }

            return(result);
        }
Example #7
0
        // Licenses-Animal-Dog-License, Licenses-Animal-Dog-Application
        // DUB13-00000-00006, DUB13-00000-00005
        // Active-LIC_PET, Issued-LIC_PET

        static void Main(string[] args)
        {
            PaginationInfo p           = null;
            string         filter      = "module=Licenses";
            string         redirectUrl = "http://*****:*****@accela.com" });

            //// Agency
            Agency ag = a.GetAgency(token, "SOLNDEV-ENG");
            Stream sr = a.GetAgencyLogo(token, "SOLNDEV-ENG");

            using (FileStream fs = new FileStream(@"C:\Swapnali\TestPurposes\logo.png", FileMode.Create))
            {
                sr.CopyTo(fs);
            }

            // Record Contact
            //ResultDataPaged<Contact> contacts = rec.GetRecordContacts(recordId, token);
            //List<Contact> cs = new List<Contact> {
            //    new Contact { isPrimary = "N", businessName = "test",
            //        firstName = "Swapnali", lastName = "Dembla", email = "*****@*****.**",
            //        address = new ContactAddress { addressLine1 = "500 San Blvd", city = "San Ramon", state = new State { value = "CA" },
            //        postalCode = "94566" },
            //        type = new ContactType { value = "Pet Owner" } }};

            //rec.CreateRecordContact(cs, recordId, token);
            //contacts = rec.GetRecordContacts(recordId, token);
            //Contact c = ((List<Contact>)contacts.Data)[0];
            //c.type.text = null;
            //c.middleName = "test for Oscar";
            //c = rec.UpdateRecordContact(c, recordId, token);
            //contacts = rec.GetRecordContacts(recordId, token);
            ////rec.DeleteRecordContact(c.id, rId, token);
            //contacts = rec.GetRecordContacts(recordId, token);

            // Address
            //List<Country> cn = ad.GetCountries(token);
            //List<State> s = ad.GetStates(token);

            // Records
            //Record record = rec.GetRecord(recordId, token);
            //record.name = "Test Again & Again";

            //List<Dictionary<string, string>> cf = rec.GetRecordCustomFields(record.id, token);


            //record.description = "Test Again & Again";
            //record = rec.UpdateRecordDetail(record, token);
            //record = rec.GetRecord(recordId, token);
            //records = rec.SearchRecords(token, new RecordFilter { type = new RecordType { category = "Application" }, contact = new Contact { firstName = "Sam" } }, null);
            //records = rec.GetRecords(token, null);
            //Record record = new Record { type = new RecordType { id = "Licenses-Animal-Dog-Application" } };
            //List<Contact> contactList = new List<Contact> { new Contact { type = new ContactType { value = "Pet Owner" }, firstName = "Swapnali", lastName = "Dembla", email = "*****@*****.**" } };
            //Record r1 = rec.CreateRecordInitialize(new Record { type = new RecordType { id = "Licenses-Animal-Dog-Application" } }, token);
            ////Record r1 = record;
            //r1.name = "Test Renewal";
            //r1.description = "Test Renewal";
            //r1 = rec.UpdateRecordDetail(r1, token);
            //record = rec.GetRecord(r1.id, token);
            //rec.CreateRecordContact(contactList, r1.id, token);
            //ResultDataPaged<Contact> cons = rec.GetRecordContacts(r1.id, token);
            //Contact cn = ((Contact)cons.Data.First());
            //cn.lastName = "Dembla";
            //cn = rec.UpdateRecordContact(cn, r1.id, token);
            //List<Dictionary<string, string>> cf = rec.GetRecordCustomFields(r1.id, token);
            //Dictionary<string, string> temp = cf[1];
            //temp["Pet Name"] = "Goof";
            ////rec.UpdateRecordCustomFields(r1.id, cf, token);
            //cf = rec.GetRecordCustomFields(r1.id, token);
            //cons = rec.GetRecordContacts(r1.id, token);

            //FileInfo file = new FileInfo(@"C:\Swapnali\TestPurposes\Ducky.jpeg");
            //if (file != null)
            //{
            //    AttachmentInfo at = new AttachmentInfo { FileType = "image/jpeg", FileName = "Ducky.jpeg", ServiceProviderCode = "BPTMSTR", Description = "Test" };
            //    at.FileContent = new StreamContent(file.OpenRead());
            //    rec.CreateRecordDocument(at, r1.id, token, "ooo");
            //}
            //List<Document> docs = rec.GetRecordDocuments(r1.id, token);
            //record.contacts = new List<Contact> { new Contact { id = "1234", firstName = "Swapnali", lastName = "Dembla", email = "*****@*****.**", type = new ContactType { value = "Pet Owner" } } };
            //record = rec.CreateRecordFinalize(new Record { id = "BPTMSTR-14EST-00000-00257", type = new RecordType { id = "Licenses-Animal-Dog-Application" } }, token);
            //record = rec.CreateRecordFinalize(r1, token);
            //record = rec.GetRecord(record.id, token);
            //cons = rec.GetRecordContacts(record.id, token);
            //cf = rec.GetRecordCustomFields(record.id, token);
            ////docs = rec.GetRecordDocuments(record.id, token);

            // Documents
            //List<DocumentType> d = rec.GetRecordDocumentTypes(recordId, token);
            //List<Document> docs = rec.GetRecordDocuments(recordId, token);
            //Stream sr = doc.DownloadDocument("1132", token);
            //using (FileStream fs = new FileStream(@"C:\Swapnali\TestPurposes\photo.jpeg", FileMode.Create))
            //{
            //    sr.CopyTo(fs);
            //}

            //FileInfo file = new FileInfo(@"C:\Swapnali\TestPurposes\Ducky.jpeg");
            //if (file != null)
            //{
            //    AttachmentInfo at = new AttachmentInfo { FileType = "image/jpeg", FileName = "Ducky.jpeg", ServiceProviderCode = "BPTMSTR", Description = "Test" };
            //    at.FileContent = new StreamContent(file.OpenRead());
            //    rec.CreateRecordDocument(at, recordId, token, "ooo");
            //}
            //rec.DeleteRecordDocument("1012", recordId, token);
            //docs = rec.GetRecordDocuments(recordId, token);

            // Status
            //List<Status> s = rec.GetRecordStatuses("Licenses-Animal-Pig-Application", token);

            //// Workflow
            //List<WorkflowTask> w2 = rec.GetWorkflowTasks(record.id, token);
            //WorkflowTask w = rec.GetWorkflowTask(record.id, taskId, token);
            //UpdateWorkflowTaskRequest uw = new UpdateWorkflowTaskRequest { comment = "testing", status = new Status { value = "In Review" } };
            //w = rec.UpdateWorkflowTask("BPTMSTR-DUB14-00000-00059", taskId, uw, token);

            // Fees
            //List<RecordFees> fs = rec.GetRecordFees(recordId, token);

            // Custom Fields
            //cf = rec.GetRecordCustomFields(recordId, token);
            //temp = cf[0];
            //temp["Pet Name"] = "Toffy";
            ////List<Dictionary<string, string>> cfs = new List<Dictionary<string, string>>();
            ////Dictionary<string, string> val = new Dictionary<string,string>();
            ////val.Add("id", "LIC_DOG_LIC-GENERAL.cINFORMATION");
            ////val.Add("Name", "Woofy");
            ////cfs.Add(val);
            //rec.UpdateRecordCustomFields(recordId, cf, token);
            //cf = rec.GetRecordCustomFields(recordId, token);
        }