Click or drag to resize

Quotes

SDK provides functionality to insert a partial quote and update the risk data. In other words it exposes similar functionality of inserting an incomplete quote and updating the risk data using the Epic UI except through an api.

Post /api/quotes

This method is used to insert a quote header. This returns the quote guid and quote URI. The quote guid is a unique identifier of the quote. It can be used to retrieve the quote definition. The quote URI provides the URI of the inserted quote resource. The URI can be used for the Patch functionality. There can be a delay before the quote is fully inserted into the system. Before using other methods that use the recently inserted quote, we recommend first checking if the quote was successfully inserted. This is explained in the workflow below in Phase 2. We recommend waiting before calling other methods that use that quote. In other words, this method mimics the Epic behaviour of the following screens:

Epic Insert Quote

Can be accessed via the URI [Your_SDK_Service]/api/quotes.

Request Body

Response

Examples

Insert a quote.

VB
 1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
 2' Constant DATABASE preset to current database name
 3' Constant AUTHENTICATION_KEY set to current authentication key
 4
 5'Here we will insert a new quote for a UK Motor policy.
 6Try
 7  Dim sQuotesUrl As String = SDK_SERVICE_URI & "/api/quotes"
 8
 9  Dim sClientGuid As String = "0fcc2cd6-4dfa-4ca6-a31b-3b15bd0f2424" 'A client guid can be obtained from the ClientGuid property from a client. Clients can be obtained using the SDK method Get_Client.
10  Dim diCtRequest As New Dictionary(Of String, Object) From {
11        {"client_guid", sClientGuid},
12        {"policy_type_code", "UKMT"}, 'UK policy types can be found using the SDK method Get_Policy_PolicyLineType. This code must also be configured for new business in Epic under Configure > Quotes > Automatic Transactions.
13        {"description", "UK Motor Policy"},
14        {"effective_date", Date.Today},
15        {"policy_source_code", "101"}, 'A valid policy source code can be obtained using the SDK method Get_Lookup and passing the PolicySource enumerator.
16        {"broker_code", "BROKERA-01"}, 'A valid broker code can be obtained using the SDK method Get_Broker.
17        {"employee_code", "EMPLOY"}, 'A valid employee code can be obtained using the SDK method Get_Employee.
18        {"duty_of_disclosure", False},
19        {"agency_code", "A01"}, 'A valid agency code can be obtained using the SDK method Get_Lookup and passing the AgencyForClientID enumerator.
20        {"branch_code", "BRC"}, 'A valid branch code can be obtained using the SDK method Get_Lookup and passing the BranchForClientID enumerator.
21        {"department_code", "DPT"}, 'A valid department code can be obtained using the SDK method Get_Lookup and passing the Department enumerator.
22        {"profit_center_code", "PFC"} 'A profit center code can be obtained using the SDK method Get_Lookup and passing the ProfitCenter enumerator.
23  }
24
25  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
26  Dim sQuoteInsertRequestBody As String = jss.Serialize(diCtRequest)
27
28  Dim sQuoteInsertResponse As String
29  Using oWebclient As New WebClient
30    oWebclient.Encoding = Encoding.UTF8
31    With oWebclient.Headers
32      .Add("AuthenticationKey", AUTHENTICATION_KEY)
33      .Add("DatabaseName", DATABASE)
34      .Add("Content-type", "application/json")
35    End With
36    Dim aQuoteInsertResponse As Byte() = oWebclient.UploadData(sQuotesUrl, "POST", Encoding.ASCII.GetBytes(sQuoteInsertRequestBody))
37    sQuoteInsertResponse = oWebclient.Encoding.GetString(aQuoteInsertResponse)
38  End Using
39  Dim oQuoteInsertResponse As QuoteInsertResponse = jss.Deserialize(Of QuoteInsertResponse)(sQuoteInsertResponse)
40  Console.WriteLine("Quote Guid: " & oQuoteInsertResponse.quote_guid)
41  Console.WriteLine("Quote relative Uri used for Patch: " & oQuoteInsertResponse.quote_uri)
42
43Catch ex As WebException
44  Dim sStatusCode As String = ex.Status.ToString
45  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
46  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
47Catch ex As Exception
48  Console.WriteLine(ex.Message)
49End Try
Get /api/quotes/definition/{quote_guid}

This method is used to get a quote definition. A quote definition contains information about the type of data that can be entered into the quote. This information is necessary to consume the Patch functionality. In other words, this method mimics the Epic behaviour of the following screen:

Epic Quote Risk

Can be accessed via the URI [Your_SDK_Service]/api/quotes/definition/{quote_guid}.

Request Parameters

quote_guid

  • Type: System.String

    A unique indentifier specifing the Quote for which to obtain the corresponding definition.

Response

Examples

Get the definition for a particular quote.

VB
 1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
 2' Constant DATABASE preset to current database name
 3' Constant AUTHENTICATION_KEY set to current authentication key
 4
 5'Here we will get the quote definition. It contains information required to update risk data of a quote.
 6Try
 7  Dim sQuoteGuid As String = "a2d6e989-17af-4163-a1e4-2029497c562c" 'This is the unique identifier of quote of the desired policy type. It can be obtained from the response of quote header post. (POST /api/quotes)
 8  Dim sQuoteDefinitionURL As String = SDK_SERVICE_URI & "/api/quotes/definition/" & sQuoteGuid
 9  Dim sResponse As String
10  Using oWebclient As New WebClient
11    oWebclient.Encoding = Encoding.UTF8
12    With oWebclient.Headers
13      .Add("AuthenticationKey", AUTHENTICATION_KEY)
14      .Add("DatabaseName", DATABASE)
15    End With
16    Dim aQuoteDefinitionResponse As Byte() = oWebclient.DownloadData(sQuoteDefinitionURL)
17    sResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
18  End Using
19  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
20
21  Dim dictRiskDefinition As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sResponse)
22  Console.WriteLine("Application Type: " & dictRiskDefinition("application_type").ToString)
23  Console.WriteLine("Application Type Version: " & dictRiskDefinition("application_type_version").ToString)
24
25  Dim dictRiskItems As Dictionary(Of String, Object) = CType(dictRiskDefinition("risk_items"), Dictionary(Of String, Object))
26  'These risk question items are not contained in a repeating group/scheduled item.
27  Dim lstNonScheduledRiskItems As ArrayList = CType(dictRiskItems("fields"), ArrayList)
28  For Each dictRiskItem As Dictionary(Of String, Object) In lstNonScheduledRiskItems
29    Console.WriteLine("Question ID: " & dictRiskItem("question_id").ToString)
30    Console.WriteLine("Text: " & dictRiskItem("text").ToString)
31    Console.WriteLine("Type: " & dictRiskItem("type").ToString)
32    Console.WriteLine("Max Length: " & dictRiskItem("max_length").ToString)
33    Console.WriteLine()
34  Next
35
36  'These risk question items are contained in a repeating group/scheduled item.
37  Dim dictScheduledItems As Dictionary(Of String, Object) = CType(dictRiskItems("repeating_group_items"), Dictionary(Of String, Object))
38  For Each kvpRepeatingGroup As KeyValuePair(Of String, Object) In dictScheduledItems
39    Dim lstRiskItems As ArrayList = CType(kvpRepeatingGroup.Value, ArrayList)
40    Dim dictFirstRepeatingGroup As Dictionary(Of String, Object) = CType(lstRiskItems(0), Dictionary(Of String, Object))
41    Console.WriteLine("Repeating Group Name: " & dictFirstRepeatingGroup("repeating_group_name").ToString)
42    Console.WriteLine("Parent Group Name: " & CType(dictFirstRepeatingGroup("parent_repeatinggroup_name"), String))
43    For Each dictRiskItem As Dictionary(Of String, Object) In lstRiskItems
44      Console.WriteLine("Question ID: " & dictRiskItem("question_id").ToString)
45      Console.WriteLine("Text: " & dictRiskItem("text").ToString)
46      Console.WriteLine("Type: " & dictRiskItem("type").ToString)
47      Console.WriteLine("Max Length: " & dictRiskItem("max_length").ToString)
48      Console.WriteLine()
49    Next
50  Next
51
52Catch ex As WebException
53  Dim sStatusCode As String = ex.Status.ToString
54  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
55  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
56Catch ex As Exception
57  Console.WriteLine(ex.Message)
58End Try
Patch /api/quotes/{quote_guid}

This method provides write access to the risk data of a partial quote. In other words, this method mimics the Epic behaviour of the following screen:

Epic Quote Risk Save

Can be accessed via the URI [Your_SDK_Service]/api/quotes/{quote_guid}.

Request Parameters

quote_guid

  • Type: System.String

    A unique indentifier specifing the Quote for which to update the risk data.

Request Body

Response

  • Status Code: 204

Examples

Update a quote detail.

VB
  1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
  2' Constant DATABASE preset to current database name
  3' Constant AUTHENTICATION_KEY set to current authentication key
  4
  5'Here we will update the risk data of a quote for a UK Motor policy.
  6Try
  7  'In this example, the quote guid corresponds to a UK Motor Policy. The client guid corresponds to a client that contains the specified quote.
  8  Dim sQuoteGuid As String = "db3e6f10-98c7-474e-b5e6-094b2a36dbbc" 'A quote guid can be obtained from the insert quote response (Post /api/quotes).
  9  Dim sQuoteURL As String = SDK_SERVICE_URI & "/api/quotes/" & sQuoteGuid
 10  Dim sClientGuid As String = "e76cabdd-8345-44d6-80d7-97dbf0195acf" 'A client guid can be obtained from the ClientGuid property from a client. Clients can be obtained using the SDK method Get_Client.
 11
 12  'Here we provide an example of how to write various values to a UKMotor quote
 13  'The quote definition (Get /api/quotes/definition/{quote_guid}) should be used to obtain information on how to populate the risk items. 
 14  'Most importantly, the question id to specify the risk question and the type to determine what kind of values can be entered.
 15
 16  'Note that the quote definition is likely to change over time as industry standards change. Questions can be added and removed. 
 17  'It is recommended that seperate code to update risk question data be written for each quote definition version. Refer, to the workflow Phase 2 for an example.
 18
 19  Dim dictNumberOfSeatsRiskItem As New Dictionary(Of String, Object) From {
 20    {"question_id", "MO018"}, 'This is the question id for the field with description "Number of seats" for a UK Motor risk.
 21    {"instance_index", Nothing}, 'This question is not on a scheduled/repeating item. This is shown in the quote definition by instance_index being null. Also, by the repeating_group_name being null.
 22    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 23    {"value", "2"} 'The type for this question in the quote definition is IntegerText. This would signify that only integer values are accepted.
 24  }
 25
 26  Dim dictSecurityDeviceRiskItem As New Dictionary(Of String, Object) From {
 27    {"question_id", "MO020"}, 'This is the question id for the field with description "Security device" for a UK Motor risk.
 28    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Security Devices".
 29    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 30    {"value", "410"} 'The type for this question in the quote definition is ComboBox. This would signify that only values obtained from the corresponding option set (PLSecurityMakeModel) are accepted.
 31  }
 32
 33  'This risk item will update the first repeating item or create one if one doesn't exist (0 index).
 34  Dim dictDriverAutoIncrementRiskItem As New Dictionary(Of String, Object) From {
 35    {"question_id", "MO159"}, 'This is the question id for the field with description "prn" for a UK Motor risk. It is a hidden question not displayed in Epic UI.
 36    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Drivers".
 37    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 38    {"value", "410"} 'The type for this question in the quote definition is Autoincrement. Only integers are accepted. The first repeating group would start at 1. 
 39  }
 40
 41  'Certain questions require a person to be entered. Inorder for those questions to be unsed the corresponding person question must be entered first.
 42  'Valid Person guid can be obtained with the SDK Person Search functionality (Get /api/person_search). 
 43  'SDK only supports entering persons using the methods Insert_Contact and Insert_Client.
 44  Dim sPersonGuid As String = "5131c162-c7d4-49e5-b58d-9f724e690785"
 45  Dim dictDriverPersonRiskItem As New Dictionary(Of String, Object) From {
 46    {"question_id", "MO255"}, 'This is a hidden question not displayed in Epic UI.
 47    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Drivers".
 48    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 49    {"value", sPersonGuid} 'Although, the type for this question is FreeText, hidden person questions will only accept valid person guids.
 50  }
 51
 52  'Certain repeating groups have risk questions with the AutoIncrement type. Inorder to add questions for these repeating groups, the AutoIncrement question needs to be added first.
 53  Dim dictDriverFirstNameRiskItem As New Dictionary(Of String, Object) From {
 54    {"question_id", "MO069"}, 'This is the question id for the field with description "Forename" for a UK Motor risk.
 55    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Drivers".
 56    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 57    {"value", "John"} 'The type for this question in the quote definition is FreeText and max_length is 40. This would signify almost any string 40 or less characters is accepted.
 58  }
 59
 60  'Certain questions related to claim require hidden claim questions to be entered first.
 61  'This is also an example where a repeating group is contained by a repeating group. 
 62  'The parent index of 0 would specify that this claim corresponds to the first driver created above.
 63  Dim dictClaimIdRiskItem As New Dictionary(Of String, Object) From {
 64    {"question_id", "MO415"}, 'This question is for a claim id. This is a hidden question not displayed in Epic UI.
 65    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Claims".
 66    {"parent_index", "0"},'This question is contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being 0. Also, by the parent_repeatinggroup_name being "Drivers".
 67    {"value", "s"} 'Although, the type for this question is FreeText, the claim Id needs to contain a value of "s".
 68  }
 69
 70  Dim dictClaimPersonIdRiskItem As New Dictionary(Of String, Object) From {
 71    {"question_id", "MO416"}, 'This question is for a claim person id. This is a hidden question not displayed in Epic UI.
 72    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Claims".
 73    {"parent_index", "0"},'This question is contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being 0. Also, by the parent_repeatinggroup_name being "Drivers".
 74    {"value", sPersonGuid} 'Although, the type for this question is FreeText, hidden person questions will only accept valid person guids.
 75  }
 76
 77  Dim dictClaimCustomerCoverIdRiskItem As New Dictionary(Of String, Object) From {
 78    {"question_id", "MO417"}, 'This question is for a claim customer cover id. This is a hidden question not displayed in Epic UI.
 79    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Claims".
 80    {"parent_index", "0"},'This question is contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being 0. Also, by the parent_repeatinggroup_name being "Drivers".
 81    {"value", "s"} 'Although, the type for this question is FreeText, the claim customer cover Id needs to contain a value of "s".
 82  }
 83
 84  Dim dictClaimTypeRiskItem As New Dictionary(Of String, Object) From {
 85    {"question_id", "MO111"}, 'This is the question id for the field with description "Type of claim" for a UK Motor risk.
 86    {"instance_index", "0"}, 'This question is on a scheduled/repeating item. This is shown in the quote definition by instance_index being 0. Also, by the repeating_group_name being "Claims".
 87    {"parent_index", "0"},'This question is contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being 0. Also, by the parent_repeatinggroup_name being "Drivers".
 88    {"value", "L"} 'The type for this question in the quote definition is ComboBox. This would signify that only values obtained from the corresponding option set (PLClaimType) are accepted.
 89  }
 90
 91  Dim lstRiskItems As New List(Of Object) From {dictNumberOfSeatsRiskItem, dictSecurityDeviceRiskItem, dictDriverAutoIncrementRiskItem,
 92          dictDriverPersonRiskItem, dictDriverFirstNameRiskItem, dictClaimIdRiskItem, dictClaimPersonIdRiskItem, dictClaimCustomerCoverIdRiskItem, dictClaimTypeRiskItem}
 93  Dim oQuotePatchRequestBody As New Dictionary(Of String, Object) From {
 94    {"client_guid", sClientGuid},
 95    {"risk_items", lstRiskItems}
 96  }
 97
 98  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
 99  Dim sQuoteUpdateRequestBody As String = jss.Serialize(oQuotePatchRequestBody)
100  Using oWebclient As New WebClient
101    oWebclient.Encoding = Encoding.UTF8
102    With oWebclient.Headers
103      .Add("AuthenticationKey", AUTHENTICATION_KEY)
104      .Add("DatabaseName", DATABASE)
105      .Add("Content-type", "application/json")
106    End With
107    Dim aQuoteUpdateResponse As Byte() = oWebclient.UploadData(sQuoteURL, "PATCH", Encoding.ASCII.GetBytes(sQuoteUpdateRequestBody))
108  End Using
109
110Catch ex As WebException
111  Dim sStatusCode As String = ex.Status.ToString
112  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
113  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
114Catch ex As Exception
115  Console.WriteLine(ex.Message)
116End Try

After running the patch sample code, opening the updated quote in the Epic UI would appear as follows:

Epic Vehicle After Patch
Epic Driver After Patch

Workflow to Insert a Partial Quote and Modify the Risk Data

This section is to demonstate the steps that could be taken to code a typical integration. It is possible to code a dynamic application that reads from the quote definition and displays a UI. Such an applicaiton would not need to keep track of the meaning of questions. This is the case with the Epic UI. However, often information known before runtime will need to be entered programatically. The steps for this type of application are illustarated in the below 2 phases, gathering information and writing the integration.

Keep in mind that the quote definition is likely to change over time as industry standards change. Risk questions can be added and removed. It is recommended that seperate code to update risk question data be written for each quote definition version. So when new quote definitions are introduced, phases 1 and 2 may need to be repeated.

It is recommended to run the sample code below on a test integration to become familiar with the code required to utilize the SDK quoting functionality.

Phase 1: Gather information before writing the integration.

1.   The quote definition for the desired policy type should be retrieved (Get /api/quotes/definition/{quote_guid}). The quote guid will need to be obtained from an existing quote of the desired policy type or from the result of inserting a dummy quote header using SDK (Post /api/quotes).

2.   The option sets for the desired policy type should be retrieved (Get /api/option_sets). This call can be expensive.

3.   The quote definition can be analysed. Information from the desired questions can be obtained. For questions related to option sets the definition will display the related option set key. The key would be used to access the desired option set values for the question from the entire set of the policy.

Examples

Retrieving a quote definition.

VB
 1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
 2' Constant DATABASE preset to current database name
 3' Constant AUTHENTICATION_KEY set to current authentication key
 4
 5'Here we will get the quote definition and option sets. It contains information required to update risk data of a quote.
 6Try
 7  Dim sQuoteGuid As String = "a2d6e989-17af-4163-a1e4-2029497c562c" 'This is the unique identifier of quote of the desired policy type. It can be obtained from the response of quote header post. (POST /api/quotes)
 8
 9  Dim sQuoteDefinitionURL As String = SDK_SERVICE_URI & "/api/quotes/definition/" & sQuoteGuid
10  Dim sQuoteDefinitionResponse As String
11  Using oWebclient As New WebClient
12    oWebclient.Encoding = Encoding.UTF8
13    With oWebclient.Headers
14      .Add("AuthenticationKey", AUTHENTICATION_KEY)
15      .Add("DatabaseName", DATABASE)
16    End With
17    Dim aQuoteDefinitionResponse As Byte() = oWebclient.DownloadData(sQuoteDefinitionURL)
18    sQuoteDefinitionResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
19  End Using
20  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
21
22  Dim dictRiskDefinition As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sQuoteDefinitionResponse)
23  Console.WriteLine("Application Type: " & dictRiskDefinition("application_type").ToString)
24  Console.WriteLine("Application Type Version: " & dictRiskDefinition("application_type_version").ToString)
25
26  Dim dictRiskItems As Dictionary(Of String, Object) = CType(dictRiskDefinition("risk_items"), Dictionary(Of String, Object))
27  'These risk question items are not contained in a repeating group/scheduled item.
28  Dim lstNonScheduledRiskItems As ArrayList = CType(dictRiskItems("fields"), ArrayList)
29  For Each dictRiskItem As Dictionary(Of String, Object) In lstNonScheduledRiskItems
30    Console.WriteLine("Question ID: " & dictRiskItem("question_id").ToString)
31    Console.WriteLine("Text: " & dictRiskItem("text").ToString)
32    Console.WriteLine("Type: " & dictRiskItem("type").ToString)
33    Console.WriteLine("Max Length: " & dictRiskItem("max_length").ToString)
34    Console.WriteLine()
35  Next
36
37  'These risk question items are contained in a repeating group/scheduled item.
38  Dim dictScheduledItems As Dictionary(Of String, Object) = CType(dictRiskItems("repeating_group_items"), Dictionary(Of String, Object))
39  For Each kvpRepeatingGroup As KeyValuePair(Of String, Object) In dictScheduledItems
40    Dim lstRiskItems As ArrayList = CType(kvpRepeatingGroup.Value, ArrayList)
41    Dim dictFirstRepeatingGroup As Dictionary(Of String, Object) = CType(lstRiskItems(0), Dictionary(Of String, Object))
42    Console.WriteLine("Repeating Group Name: " & dictFirstRepeatingGroup("repeating_group_name").ToString)
43    Console.WriteLine("Parent Group Name: " & CType(dictFirstRepeatingGroup("parent_repeatinggroup_name"), String))
44    For Each dictRiskItem As Dictionary(Of String, Object) In lstRiskItems
45      Console.WriteLine("Question ID: " & dictRiskItem("question_id").ToString)
46      Console.WriteLine("Text: " & dictRiskItem("text").ToString)
47      Console.WriteLine("Type: " & dictRiskItem("type").ToString)
48      Console.WriteLine("Max Length: " & dictRiskItem("max_length").ToString)
49      Console.WriteLine()
50    Next
51  Next
52
53  'Retrieve the option sets for a quote for the corresponding UK House policy.
54  Dim sOptionSetsURL As String = SDK_SERVICE_URI & "/api/option_sets/" & dictRiskDefinition("application_type").ToString & "/" & dictRiskDefinition("application_type_version").ToString
55  Dim sOptionSetsResponse As String
56  Using oWebclient As New WebClient
57    oWebclient.Encoding = Encoding.UTF8
58    With oWebclient.Headers
59      .Add("AuthenticationKey", AUTHENTICATION_KEY)
60      .Add("DatabaseName", DATABASE)
61    End With
62    Dim aOptionSetsResponse As Byte() = oWebclient.DownloadData(sOptionSetsURL)
63    sOptionSetsResponse = oWebclient.Encoding.GetString(aOptionSetsResponse)
64  End Using
65  Dim dictOptionSets As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sOptionSetsResponse)
66
67  For Each kvpOptionSet As KeyValuePair(Of String, Object) In dictOptionSets
68    Dim dictOptionSet As Dictionary(Of String, Object) = CType(kvpOptionSet.Value, Dictionary(Of String, Object))
69
70    Console.WriteLine("Option Set: " & kvpOptionSet.Key)
71    For Each dictOption As Dictionary(Of String, Object) In dictOptionSet.Values
72      Console.WriteLine("Option ID: " & dictOption("value").ToString)
73      Console.WriteLine("Option Description: " & dictOption("description").ToString)
74    Next
75  Next
76
77Catch ex As WebException
78  Dim sStatusCode As String = ex.Status.ToString
79  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
80  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
81Catch ex As Exception
82  Console.WriteLine(ex.Message)
83End Try

Phase 2: Write the integration

1.   Insert a quote header (Post /api/quotes).

2.   Update the risk data of the inserted quote (Patch /api/quotes/{quote_guid}).

Examples

Insert quote and update risk data.

VB
  1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
  2' Constant DATABASE preset to current database name
  3' Constant AUTHENTICATION_KEY set to current authentication key
  4
  5'Here we will insert a quote and update some risk information of that quote.
  6Try
  7  Dim sQuotesUrl As String = SDK_SERVICE_URI & "/api/quotes"
  8
  9  Dim sClientGuid As String = "DE5F8ACB-2FC9-449F-8516-AFC0613F57FD" 'A client guid can be obtained from the ClientGuid property from a client. Clients can be obtained using the SDK method Get_Client.
 10  'Insert a new quote for a UK House policy.
 11  Dim dictInsertRequest As New Dictionary(Of String, Object) From {
 12        {"client_guid", sClientGuid},
 13        {"policy_type_code", "UKHM"}, 'UK policy types can be found using the SDK method Get_Policy_PolicyLineType. This code must also be configured for new business in Epic under Configure > Quotes > Automatic Transactions.
 14        {"description", "UK House Policy"},
 15        {"effective_date", Date.Today},
 16        {"policy_source_code", "101"}, 'A valid policy source code can be obtained using the SDK method Get_Lookup and passing the PolicySource enumerator.
 17        {"broker_code", "BROKERA-01"}, 'A valid broker code can be obtained using the SDK method Get_Broker.
 18        {"employee_code", "EMPLOY"}, 'A valid employee code can be obtained using the SDK method Get_Employee.
 19        {"duty_of_disclosure", False},
 20        {"agency_code", "A01"}, 'A valid agency code can be obtained using the SDK method Get_Lookup and passing the AgencyForClientID enumerator.
 21        {"branch_code", "BRC"}, 'A valid branch code can be obtained using the SDK method Get_Lookup and passing the BranchForClientID enumerator.
 22        {"department_code", "DPT"}, 'A valid department code can be obtained using the SDK method Get_Lookup and passing the Department enumerator.
 23        {"profit_center_code", "PFC"} 'A profit center code can be obtained using the SDK method Get_Lookup and passing the ProfitCenter enumerator.
 24  }
 25
 26  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
 27  Dim sQuoteInsertRequestBody As String = jss.Serialize(dictInsertRequest)
 28
 29  Dim sQuoteInsertResponse As String
 30  Using oWebclient As New WebClient
 31    oWebclient.Encoding = Encoding.UTF8
 32    With oWebclient.Headers
 33      .Add("AuthenticationKey", AUTHENTICATION_KEY)
 34      .Add("DatabaseName", DATABASE)
 35      .Add("Content-type", "application/json")
 36    End With
 37    Dim aQuoteInsertResponse As Byte() = oWebclient.UploadData(sQuotesUrl, "POST", Encoding.ASCII.GetBytes(sQuoteInsertRequestBody))
 38    sQuoteInsertResponse = oWebclient.Encoding.GetString(aQuoteInsertResponse)
 39  End Using
 40  Dim dictQuoteInsertResponse As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sQuoteInsertResponse)
 41
 42  'Check the latest quote definition version obtained matches the version the integration was written for
 43  Dim sQuoteDefinitionURL As String = SDK_SERVICE_URI & "/api/quotes/definition/" & dictQuoteInsertResponse("quote_guid").ToString
 44  Dim sQuoteDefinitionResponse As String
 45  Using oWebclient As New WebClient
 46    oWebclient.Encoding = Encoding.UTF8
 47    With oWebclient.Headers
 48      .Add("AuthenticationKey", AUTHENTICATION_KEY)
 49      .Add("DatabaseName", DATABASE)
 50    End With
 51    Dim aQuoteDefinitionResponse As Byte() = Nothing
 52
 53    'There is a delay when the quote header is inserted to the system. The quote Id will be considered invalid until then. 
 54    'Here is an example of how we can wait and retry until the quote is fully inserted into the system.
 55    Const MAX_ATTEMPTS As Integer = 3
 56    For iAttemptCount As Integer = 1 To MAX_ATTEMPTS
 57      System.Threading.Thread.Sleep(500) 'Wait times can be adjusted based on network performance.
 58      Try
 59        aQuoteDefinitionResponse = oWebclient.DownloadData(sQuoteDefinitionURL)
 60        Exit For
 61      Catch ex As WebException
 62        If iAttemptCount = MAX_ATTEMPTS Then Throw 'Assume the call didn't work after a few attempts
 63      End Try
 64    Next
 65
 66    sQuoteDefinitionResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
 67  End Using
 68  Dim dictQuoteGetDefinitionResponse As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sQuoteDefinitionResponse)
 69  Dim sLatestVersion As String = dictQuoteGetDefinitionResponse("application_type_version").ToString
 70  If sLatestVersion <> "2.0.5" Then Exit Sub 'Value obtained from application_type_version in Phase 1.
 71
 72  'Now update a desired field using the quote definition information obtained in the previous step.
 73  Dim sQuoteURL As String = SDK_SERVICE_URI & dictQuoteInsertResponse("quote_uri").ToString
 74
 75  Dim dictPreviousPolicyExpiredDate As New Dictionary(Of String, Object) From {
 76    {"question_id", "HO041"}, 'This is the question id for the field "Previous policy expiry date" of a UK House risk. It can be obtained from the quote definition. (GET /api/quotes/definition/{quote_guid})
 77    {"instance_index", Nothing}, 'This question is not on a scheduled/repeating item. This is shown in the quote definition by instance_index being null. Also, by the repeating_group_name being null.
 78    {"parent_index", Nothing}, 'This question is not contained under a parent scheduled/repeating item. This is shown in the quote definition by parent_index being null. Also, by the parent_repeatinggroup_name being null.
 79    {"value", "2020-03-04"}  'The type field for this question in the quote definition is Date. This would signify that only date values are accepted.
 80  }
 81
 82  Dim lstRiskItems As New List(Of Object) From {dictPreviousPolicyExpiredDate}
 83  Dim dictQuotePatchRequestBody As New Dictionary(Of String, Object) From {
 84    {"client_guid", sClientGuid},
 85    {"risk_items", lstRiskItems}
 86  }
 87
 88  Dim sQuoteUpdateRequestBody As String = jss.Serialize(dictQuotePatchRequestBody)
 89  Using oWebclient As New WebClient
 90    oWebclient.Encoding = Encoding.UTF8
 91    With oWebclient.Headers
 92      .Add("AuthenticationKey", AUTHENTICATION_KEY)
 93      .Add("DatabaseName", DATABASE)
 94      .Add("Content-type", "application/json")
 95    End With
 96    Dim aQuoteUpdateResponse As Byte() = oWebclient.UploadData(sQuoteURL, "PATCH", Encoding.ASCII.GetBytes(sQuoteUpdateRequestBody))
 97  End Using
 98
 99Catch ex As WebException
100  Dim sStatusCode As String = ex.Status.ToString
101  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
102  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
103Catch ex As Exception
104  Console.WriteLine(ex.Message)
105End Try
See Also