Create the Staff for TASQ.
URL:
https://jobapi.tasq.com.au/api/Q6/CreateStaff
Supports:
POST.
Attribute Details:
Post Internal User Data
Company Validate Info Company Staff View
Company Validate Info | (object) | must |
Login Name | String | |
Client IP | String | |
Password | String | |
Mobile Device Token | String | |
Web Api TOKEN | (Guid) | |
Company Staff View | (Object) | |
Company ID | (String) (200) | Optional |
User ID | (Guid) | Must |
User Name | (String) | Optional |
First Name | (String)(256) | Optional |
Last Name | (String)(256) | Optional |
Mobile | (String)(50) | Optional |
Login Email | (String)(256) | Optional |
Password | (String)(50) | Optional |
Old Password | (String)(50) | Optional |
Password | (Boolean) | Optional |
Is Main | (Date Time) | Must |
Create Date | (Guid) | Must |
User Role ID | (String)(256) | Optional |
User Role Name | (Boolean) | Optional |
Shown In Dispatch Job | Optional | |
Staff Photo | (byte[]) | Must |
Rounding By | (String)(50 | Optional |
Shift Status | (String) (50) | Optional |
JSON Sample Code
{
"CompanyValidateInfo": {
"ClientIP": null,
"LoginName": "testapi@tasq.com.au",
"MobileDeviceToken": null,
"Password": "test123.",
"WebApiTOKEN": "b3b777b0-c7af-458d-be64-b3d6d760177f"
},
"InternalUser": {
"CompanyID": null,
"UserID": "00000000-0000-0000-0000-000000000000",
"UserName": null,
"FirstName": "test",
"LastName": "Name",
"Mobile": "1233445511",
"LoginEmail": "test181120@uniware.com.au",
"Password": null,
"OldPassword": null,
"NewPassword": "richman58.",
"IsMain": false,
"CreateDate": "0001-01-01T00:00:00",
"UserRoleID": "f436c08d-1393-482d-818f-2dbcead0b324",
"UserRoleName": null,
"ShownInDispatchJob": true,
"StaffPhoto": null,
"RoundingBy": "None",
"ShiftStatus": null
}
}
Return Value:
{
"ActionCode": "Create",
"IsSuccessed": "YES",
"ErrorMessage": "Save successfully!",
"ReturnData": "126fffbe-cbca-491a-83e9-a4a06cfa6dd0"
}
C# Sample Code
public static string CreateStaff (string Url ,string content)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
req.Method = "POST";
req.ContentType = "application/json";
#region Add Post Param
byte[] data = Encoding.UTF8.GetBytes(content);
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
#endregion
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
JavaScript Sample Code
function CreateStaff () {
$.ajax({
type: "Post",
url: "https://jobapi.tasq.com.au/api/Q6/CreateStaff",
data: {
…
},
dataType: "json",
success: function (data) {
console.dir(data)
},
error: function (e) {
console.dir(e)
}
});
}
Java Sample Code
private static void CreateStaff(String json){
try {
URL url = new URL("https://jobapi.tasq.com.au/api/Q6/CreateStaff");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Accept", "application/json");
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Connection", "Keep-Alive");
if (json != null){
byte[] writeBytes = json.getBytes("utf-8");
OutputStream outputStream = con.getOutputStream();
outputStream.write(writeBytes,0, writeBytes.length);
outputStream.flush();
outputStream.close();
}
if (con.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStreamReader in = new InputStreamReader(con.getInputStream());
BufferedReader br = new BufferedReader(in);
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null){
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
} catch (IOException e) {
e.printStackTrace();
}
}
Swift Sample Code
func CreateStaff ()
{
let staff: Staff = Staff()
let UrlString = TASQSampleCommonLibrary.TASQApiUrl + "Q6/CreateStaff"
let loginDetail: LoginDetail = LoginDetail()
var parameters = [String:AnyObject]()
var arrayData = [String:AnyObject]()
arrayData ["WebApiTOKEN"] = TASQSampleCommonLibrary.TASQApiTOKEN as AnyObject?
arrayData ["LoginName"] = loginDetail.LoginEmail! as AnyObject?
arrayData ["Password"] = loginDetail.LoginPassword! as AnyObject?
arrayData ["ClientIP"] = TASQSampleCommonLibrary.getIPAddresses() as AnyObject?
arrayData ["MobileDeviceToken"] = TASQSampleCommonLibrary.getMobileDeviceToken() as AnyObject?
parameters["CompanyValidateInfo"] = arrayData as AnyObject?
var StaffData = [String:AnyObject]()
StaffData["UserID"] = "" as AnyObject
StaffData["CreateDate"] = staff.CreateDate! as AnyObject?
StaffData["IsMain"] = staff.IsMain! as AnyObject?
StaffData["StaffPhoto"] = staff.StaffPhoto! as AnyObject?
parameters["InternalUser"] = StaffData as AnyObject
let request = NSMutableURLRequest(url: NSURL(string: UrlString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 300)
let jsonString = TASQSampleCommonLibrary.convertDictionaryToJSONData(dicData: parameters)
print(jsonString)
request.httpBody = jsonString.data(using: String.Encoding.utf8, allowLossyConversion: true)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
do {
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let task = session.dataTask(with: request as URLRequest, completionHandler: {
(data, response, error) in
})
task.resume()
}
}