Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Swift 2) IntakeQ: Send a QuestionnaireSee more IntakeQ ExamplesSend an intake package using the API. For more information, see https://support.intakeq.com/article/31-intakeq-api#send-questionnaire
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp() var success: Bool // Implements the following CURL command: // curl -H "Content-Type: application/json" \ // -H 'X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx' \ // -X POST \ // -d '{ // "QuestionnaireId": "00000000-0000-0000-0000-000000000000", // "ClientId": 123, // "ClientName": "Dexter Morgan", // "ClientEmail": "dexter@email.com", // "ClientPhone": "2222222222", // "PractitionerId": "00000000-0000-0000-0000-000000000000", // }' https://intakeq.com/api/v1/intakes/send // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "QuestionnaireId": "00000000-0000-0000-0000-000000000000", // "ClientId": 123, // "ClientName": "Dexter Morgan", // "ClientEmail": "dexter@email.com", // "ClientPhone": "2222222222", // "PractitionerId": "00000000-0000-0000-0000-000000000000" // } let json = CkoJsonObject() json.UpdateString("QuestionnaireId", value: "00000000-0000-0000-0000-000000000000") json.UpdateInt("ClientId", value: 123) json.UpdateString("ClientName", value: "Dexter Morgan") json.UpdateString("ClientEmail", value: "dexter@email.com") json.UpdateString("ClientPhone", value: "2222222222") json.UpdateString("PractitionerId", value: "00000000-0000-0000-0000-000000000000") http.SetRequestHeader("Content-Type", value: "application/json") http.SetRequestHeader("X-Auth-Key", value: "xxxxxxxxxxxxxxxxxxxxxxxxx") var resp: CkoHttpResponse? = http.PostJson3("https://intakeq.com/api/v1/intakes/send", contentType: "application/json", json: json) if http.LastMethodSuccess == false { print("\(http.LastErrorText)") return } let sbResponseBody = CkoStringBuilder() resp!.GetBodySb(sbResponseBody) let jResp = CkoJsonObject() jResp.LoadSb(sbResponseBody) jResp.EmitCompact = false print("Response Body:") print("\(jResp.Emit())") var respStatusCode: Int = resp!.StatusCode.intValue print("Response Status Code = \(respStatusCode)") if respStatusCode >= 400 { print("Response Header:") print("\(resp!.Header)") print("Failed.") resp = nil return } resp = nil // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "Id": "00000000-0000-0000-0000-000000000000", // "ClientName": "test", // "ClientEmail": "test@email.com", // "ClientId": 9999, // "Status": "Completed", // "DateCreated": 1458526480368, // "DateSubmitted": 1458526532654, // "QuestionnaireName": "test", // "Practitioner": "test@email.com", // "PractitionerName": "FirstName LastName", // "Questions": [ // { // "Id": "xxxx-1", // "Text": "Full name", // "Answer": "Dexter Morgan", // "QuestionType": "OpenQuestion", // "Rows": [ // ], // "ColumnNames": [ // ], // "OfficeUse": false, // "OfficeNote": "aaa" // }, // { // "Id": "xxxx-2", // "Text": "Full name", // "Answer": "Dexter Morgan", // "QuestionType": "OpenQuestion", // "Rows": [ // ], // "ColumnNames": [ // ], // "OfficeUse": false, // "OfficeNote": "aaa" // } // ], // "AppointmentId": "xxxxxxxx", // "ConsentForms": [ // { // "Id": "00000000-0000-0000-0000-000000000000", // "Name": "HIPAA Release Form", // "DocumentType": "Html", // "Signed": true, // "DateSubmitted": 1458526532654 // } // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON var Text: String? var Answer: String? var QuestionType: String? var OfficeUse: Bool var OfficeNote: String? var j: Int var count_j: Int var Name: String? var DocumentType: String? var Signed: Bool var Id: String? = jResp.StringOf("Id") var ClientName: String? = jResp.StringOf("ClientName") var ClientEmail: String? = jResp.StringOf("ClientEmail") var ClientId: Int = jResp.IntOf("ClientId").intValue var Status: String? = jResp.StringOf("Status") var DateCreated: Int = jResp.IntOf("DateCreated").intValue var DateSubmitted: Int = jResp.IntOf("DateSubmitted").intValue var QuestionnaireName: String? = jResp.StringOf("QuestionnaireName") var Practitioner: String? = jResp.StringOf("Practitioner") var PractitionerName: String? = jResp.StringOf("PractitionerName") var AppointmentId: String? = jResp.StringOf("AppointmentId") var i: Int = 0 var count_i: Int = jResp.SizeOfArray("Questions").intValue while i < count_i { jResp.I = i Id = jResp.StringOf("Questions[i].Id") Text = jResp.StringOf("Questions[i].Text") Answer = jResp.StringOf("Questions[i].Answer") QuestionType = jResp.StringOf("Questions[i].QuestionType") OfficeUse = jResp.BoolOf("Questions[i].OfficeUse") OfficeNote = jResp.StringOf("Questions[i].OfficeNote") j = 0 count_j = jResp.SizeOfArray("Questions[i].Rows").intValue while j < count_j { jResp.J = j j = j + 1 } j = 0 count_j = jResp.SizeOfArray("Questions[i].ColumnNames").intValue while j < count_j { jResp.J = j j = j + 1 } i = i + 1 } i = 0 count_i = jResp.SizeOfArray("ConsentForms").intValue while i < count_i { jResp.I = i Id = jResp.StringOf("ConsentForms[i].Id") Name = jResp.StringOf("ConsentForms[i].Name") DocumentType = jResp.StringOf("ConsentForms[i].DocumentType") Signed = jResp.BoolOf("ConsentForms[i].Signed") DateSubmitted = jResp.IntOf("ConsentForms[i].DateSubmitted").intValue i = i + 1 } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.