Example #1
0
        public static void Main(string[] args)
        {
            CATSApi catsApi = new CATSApi("catsone.com", "subdomain", "<Transaction Code>");

            // Add a joborder
            AddJoborderRequest addJoborderRequest = new AddJoborderRequest();
            addJoborderRequest.Title = "Marketing Specialist";
            addJoborderRequest.City = "Minneapolis";
            addJoborderRequest.State = "MN";
            AddJoborderResponse addJoborderResponse = catsApi.AddJoborder(addJoborderRequest);
            Console.WriteLine(addJoborderResponse.Id);

            // Update joborder
            UpdateJoborderRequest updateJoborderRequest = new UpdateJoborderRequest();
            updateJoborderRequest.Id = addJoborderResponse.Id;
            updateJoborderRequest.City = "Saint Paul";
            UpdateJoborderResponse updateJoborderResponse = catsApi.UpdateJoborder(updateJoborderRequest);
            Console.WriteLine(updateJoborderResponse.Id);

            // Get joborder
            GetJoborderResponse getJoborderResponse = catsApi.GetJoborder(addJoborderResponse.Id);
            Console.WriteLine(getJoborderResponse.City);

            // Delete joborder
            DeleteJoborderResponse deleteJoborderResponse = catsApi.DeleteJoborder(addJoborderResponse.Id);
            Console.WriteLine(deleteJoborderResponse.NumResults);

            // Error handling
            AddCompanyRequest addCompanyRequest = new AddCompanyRequest();
            addCompanyRequest.Address = "123 Imaginary Street";
            AddCompanyResponse addCompanyResponse = catsApi.AddCompany(addCompanyRequest);
            if (!addCompanyResponse.Success)
            {
                Console.WriteLine(addCompanyResponse.Error.Message);
            }
        }
Example #2
0
        public UpdateJoborderResponse UpdateJoborder(UpdateJoborderRequest request)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data["id"] = request.Id.ToString();
            if (request.Recruiter != -1)
            {
                data["recruiter"] = request.Recruiter.ToString();
            }
            if (request.Contact != -1)
            {
                data["contact"] = request.Contact.ToString();
            }
            if (request.Company != -1)
            {
                data["company"] = request.Company.ToString();
            }
            if (request.EnteredBy != -1)
            {
                data["entered_by"] = request.EnteredBy.ToString();
            }
            if (request.Owner != -1)
            {
                data["owner"] = request.Owner.ToString();
            }
            data["client_job_id"] = request.ClientJobId;
            data["title"] = request.Title;
            data["description"] = request.Description;
            data["notes"] = request.Notes;
            if (request.Type != null)
            {
                switch (request.Type)
                {
                    case JoborderType.Contract:
                        data["type"] = "C";
                        break;
                    case JoborderType.Hire:
                        data["type"] = "H";
                        break;
                    case JoborderType.ContractToHire:
                        data["type"] = "CH";
                        break;
                    case JoborderType.Freelance:
                        data["type"] = "FL";
                        break;
                }
            }
            data["duration"] = request.Duration;
            data["rate_max"] = request.RateMax;
            data["salary"] = request.Salary;
            data["status"] = request.Status;
            if (request.IsHot != null)
            {
                data["is_hot"] = request.IsHot.ToString().ToLower();
            }
            if (request.Openings != -1)
            {
                data["openings"] = request.Openings.ToString();
            }
            data["city"] = request.City;
            data["state"] = request.State;
            data["zip"] = request.Zip;
            if (request.StartDate != DateTime.MinValue)
            {
                data["start_date"] = DateTimeToUnixTimestamp(request.StartDate);
            }
            if (request.DateCreated != DateTime.MinValue)
            {
                data["date_created"] = DateTimeToUnixTimestamp(request.DateCreated);
            }
            if (request.DateModified != DateTime.MinValue)
            {
                data["date_modified"] = DateTimeToUnixTimestamp(request.DateModified);
            }
            if (request.Public != null)
            {
                data["public"] = request.Public.ToString().ToLower();
            }
            if (request.Department != -1)
            {
                data["department"] = request.Department.ToString();
            }
            if (request.Sourcer != -1)
            {
                data["sourcer"] = request.Sourcer.ToString();
            }
            if (request.OpeningsAvailable != -1)
            {
                data["openings_available"] = request.OpeningsAvailable.ToString();
            }
            if (request.Country != -1)
            {
                data["country"] = request.Country.ToString();
            }

            Dictionary<string, string> files = new Dictionary<string, string>();
            if (request.File != String.Empty)
            {
                files.Add("file", request.File);
            }

            UpdateJoborderResponse response = new UpdateJoborderResponse(
                MakeRequest("update_joborder", data, files)
            );
            return response;
        }