コード例 #1
0
ファイル: Main.cs プロジェクト: cognizo/cats-api-dotnet
        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);
            }
        }
コード例 #2
0
ファイル: CATSApi.cs プロジェクト: cognizo/cats-api-dotnet
        public AddJoborderResponse AddJoborder(AddJoborderRequest request)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            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;
            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;
            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.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();
            }
            data["on_duplicate"] = CamelCaseToUnderscore(Enum.GetName(typeof(OnDuplicateAction), request.OnDuplicate));

            AddJoborderResponse response = new AddJoborderResponse(MakeRequest("add_joborder", data));
            return response;
        }