Method PostValidateContractor

Summary

Validate Contractor information

Remarks

This is used to validate the contractor information when linking to a customer account. You can link either Building Permit contractors or Occupational License contractors.

Input Parameters

NameTypeLengthDescription
contractorNumber numeric 7 [Required] Contractor Number
contractorType System.String 2 Contractor Type. B=Building Permit Contractor, O=Occupational License Contractor. Defaults to B. Forces to O for license and tax ID validations.
owner System.String 30 Owner Name
ownerDOB date 0 Owner Date Of Birth in MMDDYY format. Occupational licenses only.
requirement System.String 15 Contractor Requirement - This is the document number for a contractor license
reqmtNum numeric 1 Requirement number. If validating a requirement, indicates which license to validate. Either the 1st, 2nd, 3rd, 4th or 5th. license for the contractor. Defaults to 1.
phone numeric 10 Phone number. Digits only. I.e. 1112224444
address System.String 30 Address. This has to match the 1st address line. NOTE: If they put an ATTN: CONTACT NAME as the 1st address line, then it must match this and not the street address.
licenseYear System.String 2 License Year. Occupational licenses only.
licenseNum System.String 8 License Number. 8 digits. Occupational licenses only.
taxID System.String 9 Federal Tax ID. Occupational licenses only
applicationYear numeric 2 Permit Application Year. Permit contractors only.
applicationNumber numeric 8 Permit Application Number. Permit contractors only.

Example

POST http://localhost/FusionServices/v3/Naviline/Permit/Application/Contractor/Validate

Return Values

NameDescription
ContractorValid T = contractor is valid, F = not valid, N = not used
OwnerValid T = owner name is valid, F = not valid, N = not used
OwnerDOBValid T = owner DOB is valid, F = not valid, N = not used
ReqmtValid T = requirement is valid, F = not valid, N = not used
PhoneValid T = phone is valid, F = not valid, N = not used
AddressValid T = address is valid, F = not valid, N = not used
LicenseValid T = license is valid, F = not valid, N = not used
TaxIdValid T = tax ID is valid, F = not valid, N = not used
ApplicationNumValid T = application number is valid, F = not valid, N = not used

Sample Responses

Sample Code

using System.Net;
using Newtonsoft.Json.Linq;

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Permit/Application/Contractor/Validate";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("contractorNumber",System.Web.HttpUtility.UrlEncode("54"));
   postParms.Add("phone",System.Web.HttpUtility.UrlEncode("9366342435"));

   WebClient req = new WebClient();
   wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
   wc.Headers.Set("X-APPID", "YOURID");
   wc.Headers.Set("X-APPKEY", "YOURKEY");

   byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
   string stringResult = Encoding.UTF8.GetString(responseBytes); 
   JObject response = JObject.Parse(stringResult);
   string valid = response["OutputParms"]["ContractorValid"].ToString();
   if (valid == "T")
   {
         // TODO - YOUR CODE HERE
   }
}

C# Razor MVC Sample Code

using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;

// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
   public class PostValidateContractor
   {
       // Add property for each input param in order to map a field to it
       [Required(ErrorMessage = "Required")]
       [RegularExpression("[0-9]{0,7}", ErrorMessage = "Numeric values only. Must be 7 digits or less. ")]
       public string contractorNumber{get; set;}

       [RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
       public string contractorType{get; set;}

       [RegularExpression("^(?=.{0,30}$).*", ErrorMessage = "Must be 30 characters or less. ")]
       public string owner{get; set;}

       [RegularExpression("^\\d\\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$", ErrorMessage = "Date values only. Format: YYMMDD")]
       public string ownerDOB{get; set;}

       [RegularExpression("^(?=.{0,15}$).*", ErrorMessage = "Must be 15 characters or less. ")]
       public string requirement{get; set;}

       [RegularExpression("[0-9]{0,1}", ErrorMessage = "Numeric values only. Must be 1 digits or less. ")]
       public string reqmtNum{get; set;}

       [RegularExpression("[0-9]{0,10}", ErrorMessage = "Numeric values only. Must be 10 digits or less. ")]
       public string phone{get; set;}

       [RegularExpression("^(?=.{0,30}$).*", ErrorMessage = "Must be 30 characters or less. ")]
       public string address{get; set;}

       [RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
       public string licenseYear{get; set;}

       [RegularExpression("^(?=.{0,8}$).*", ErrorMessage = "Must be 8 characters or less. ")]
       public string licenseNum{get; set;}

       [RegularExpression("^(?=.{0,9}$).*", ErrorMessage = "Must be 9 characters or less. ")]
       public string taxID{get; set;}

       [RegularExpression("[0-9]{0,2}", ErrorMessage = "Numeric values only. Must be 2 digits or less. ")]
       public string applicationYear{get; set;}

       [RegularExpression("[0-9]{0,8}", ErrorMessage = "Numeric values only. Must be 8 digits or less. ")]
       public string applicationNumber{get; set;}

       public PostValidateContractor()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostValidateContractor class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top.  Replace the rest with the lines below.
@model FusionRazor.Models.PostValidateContractor

@{
   ViewBag.Title = "PostValidateContractor";
}

<h2>PostValidateContractor</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostValidateContractor</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.contractorNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.contractorNumber)
           @Html.ValidationMessageFor(model => model.contractorNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.contractorType)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.contractorType)
           @Html.ValidationMessageFor(model => model.contractorType)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.owner)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.owner)
           @Html.ValidationMessageFor(model => model.owner)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.ownerDOB)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.ownerDOB)
           @Html.ValidationMessageFor(model => model.ownerDOB)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.requirement)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.requirement)
           @Html.ValidationMessageFor(model => model.requirement)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.reqmtNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.reqmtNum)
           @Html.ValidationMessageFor(model => model.reqmtNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.phone)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.phone)
           @Html.ValidationMessageFor(model => model.phone)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.address)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.address)
           @Html.ValidationMessageFor(model => model.address)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.licenseYear)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.licenseYear)
           @Html.ValidationMessageFor(model => model.licenseYear)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.licenseNum)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.licenseNum)
           @Html.ValidationMessageFor(model => model.licenseNum)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.taxID)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.taxID)
           @Html.ValidationMessageFor(model => model.taxID)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.applicationYear)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.applicationYear)
           @Html.ValidationMessageFor(model => model.applicationYear)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.applicationNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.applicationNumber)
           @Html.ValidationMessageFor(model => model.applicationNumber)
       </div>
       <p>
       <input type="submit" value="Submit"/>
       </p>
   </fieldset>

}

@section Scripts {
   @Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;

// NOTE: Replace 'MyController' with the name of your controller.

// 
// GET: /MyController/PostValidateContractor
public ActionResult PostValidateContractor()
{
   // Create a new instance of the model to pick up any default values.
   PostValidateContractor model =  new PostValidateContractor();

   // pass model to set to default values
   // NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
   return View("~/Views/MyFolderPath/PostValidateContractor.cshtml", model);
}

// 
// POST: /MyController/PostValidateContractor
[HttpPost]
public ActionResult PostValidateContractor(FormCollection collection)
{
   string url = "v3/Naviline/Permit/Application/Contractor/Validate";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("contractorNumber", collection["contractorNumber"]);
   inputParms.Add("contractorType", collection["contractorType"]);
   inputParms.Add("owner", collection["owner"]);
   inputParms.Add("ownerDOB", collection["ownerDOB"]);
   inputParms.Add("requirement", collection["requirement"]);
   inputParms.Add("reqmtNum", collection["reqmtNum"]);
   inputParms.Add("phone", collection["phone"]);
   inputParms.Add("address", collection["address"]);
   inputParms.Add("licenseYear", collection["licenseYear"]);
   inputParms.Add("licenseNum", collection["licenseNum"]);
   inputParms.Add("taxID", collection["taxID"]);
   inputParms.Add("applicationYear", collection["applicationYear"]);
   inputParms.Add("applicationNumber", collection["applicationNumber"]);

   try
   {
       // Send the request
       FusionServiceRequest request = new FusionServiceRequest();
       FusionServiceResult result = request.Post(url, inputParms);

       return View("Result", result);
   }
   catch(Exception e)
   {
       HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostValidateContractor");
       return View("Error", info);
   }
}