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. 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

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 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.
 8
 9  Dim sQuotesUrl As String = SDK_SERVICE_URI & "/api/quotes"
10  Dim oInsertRequest As New QuoteInsertRequest With {
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 House 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  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
25  Dim sQuoteInsertRequestBody As String = jss.Serialize(oInsertRequest)
26
27  Dim sQuoteInsertResponse As String
28  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
29    With oWebclient.Headers
30      .Add("AuthenticationKey", AUTHENTICATION_KEY)
31      .Add("DatabaseName", DATABASE)
32      .Add("Content-type", "application/json")
33    End With
34    Dim aQuoteInsertResponse As Byte() = oWebclient.UploadData(sQuotesUrl, "POST", Encoding.ASCII.GetBytes(sQuoteInsertRequestBody))
35    sQuoteInsertResponse = oWebclient.Encoding.GetString(aQuoteInsertResponse)
36  End Using
37  Dim oQuoteInsertResponse As QuoteInsertResponse = jss.Deserialize(Of QuoteInsertResponse)(sQuoteInsertResponse)
38  Console.WriteLine("Quote Guid: " & oQuoteInsertResponse.quote_guid)
39  Console.WriteLine("Quote relative Uri used for Patch: " & oQuoteInsertResponse.quote_uri)
40
41Catch ex As WebException
42  Dim sStatusCode As String = ex.Status.ToString
43  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
44  Console.WriteLine($"Status Code: {sStatusCode}, Error: {sError}")
45Catch ex As Exception
46  Console.WriteLine(ex.Message)
47End 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

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
 9  Dim sQuoteDefinitionURL As String = SDK_SERVICE_URI & "/api/quotes/definition/" & sQuoteGuid
10  Dim sQuoteDefinitionResponse As String
11  Using oWebclient As New WebClient With {.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    sQuoteDefinitionResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
18  End Using
19  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
20  Dim oQuoteGetDefinitionResponse As RiskDefinition = jss.Deserialize(Of RiskDefinition)(sQuoteDefinitionResponse)
21
22  Console.WriteLine("Application Type: " & oQuoteGetDefinitionResponse.application_type)
23  Console.WriteLine("Application Type Version: " & oQuoteGetDefinitionResponse.application_type_version)
24  'These risk question items are not contained in a repeating group/scheduled item.
25  For Each oRiskItem As RiskItem In oQuoteGetDefinitionResponse.risk_items.fields
26    Console.WriteLine("Question ID: " & oRiskItem.question_id)
27    Console.WriteLine("Text: " & oRiskItem.text)
28    Console.WriteLine("Type: " & oRiskItem.type)
29    Console.WriteLine("Max Length: " & oRiskItem.max_length)
30  Next
31  'These risk question items are contained in a repeating group/scheduled item.
32  For Each kvpRepeatingGroup As KeyValuePair(Of String, List(Of RiskItem)) In oQuoteGetDefinitionResponse.risk_items.repeating_group_items
33    Console.WriteLine("Repeating Group Name: " & kvpRepeatingGroup.Value.First.repeating_group_name)
34    Console.WriteLine("Parent Group Name: " & kvpRepeatingGroup.Value.First.parent_repeatinggroup_name)
35    For Each oRiskItem As RiskItem In kvpRepeatingGroup.Value
36      Console.WriteLine("Question ID: " & oRiskItem.question_id)
37      Console.WriteLine("Text: " & oRiskItem.text)
38      Console.WriteLine("Type: " & oRiskItem.type)
39      Console.WriteLine("Max Length: " & oRiskItem.max_length)
40    Next
41  Next
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
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

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 oNumberOfSeatsRiskItem As New RiskItem With {
 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  'This risk item will update the first repeating item or create one if one doesn't exist (0 index).
 27  Dim oSecurityDeviceRiskItem As New RiskItem With {
 28    .question_id = "MO020", 'This is the question id for the field with description "Security device" for a UK Motor risk.
 29    .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".
 30    .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.
 31    .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.
 32  }
 33
 34  '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.
 35  Dim oDriverAutoIncrementRiskItem As New RiskItem With {
 36    .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.
 37    .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".
 38    .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.
 39    .value = "1" 'The type for this question in the quote definition is Autoincrement. Only integers are accepted. The first repeating group would start at 1. 
 40  }
 41
 42  'Certain questions require a person to be entered. Inorder for those questions to be unsed the corresponding person question must be entered first.
 43  'Valid Person guid can be obtained with the SDK Person Search functionality (Get /api/person_search). 
 44  'SDK only supports entering persons using the methods Insert_Contact and Insert_Client.
 45  Dim sPersonGuid As String = "5131c162-c7d4-49e5-b58d-9f724e690785"
 46  Dim oDriverPersonRiskItem As New RiskItem With {
 47    .question_id = "MO255", 'This is a hidden question not displayed in Epic UI.
 48    .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".
 49    .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.
 50    .value = sPersonGuid 'Although, the type for this question is FreeText, hidden person questions will only accept valid person guids.
 51  }
 52  Dim oDriverFirstNameRiskItem As New RiskItem With {
 53    .question_id = "MO069", 'This is the question id for the field with description "Forename" for a UK Motor risk.
 54    .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".
 55    .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.
 56    .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.
 57  }
 58
 59  'Certain questions related to claim require hidden claim questions to be entered first.
 60  'This is also an example where a repeating group is contained by a repeating group. 
 61  'The parent index of 0 would specify that this claim corresponds to the first driver created above.
 62  Dim oClaimIdRiskItem As New RiskItem With {
 63    .question_id = "MO415", 'This question is for a claim id. This is a hidden question not displayed in Epic UI.
 64    .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".
 65    .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".
 66    .value = "s" 'Although, the type for this question is FreeText, the claim Id needs to contain a value of "s".
 67  }
 68  Dim oClaimPersonIdRiskItem As New RiskItem With {
 69    .question_id = "MO416", 'This question is for a claim person id. This is a hidden question not displayed in Epic UI.
 70    .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".
 71    .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".
 72    .value = sPersonGuid 'Although, the type for this question is FreeText, hidden person questions will only accept valid person guids.
 73  }
 74  Dim oClaimCustomerCoverIdRiskItem As New RiskItem With {
 75    .question_id = "MO417", 'This question is for a claim customer cover id. This is a hidden question not displayed in Epic UI.
 76    .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".
 77    .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".
 78    .value = "s" 'Although, the type for this question is FreeText, the claim customer cover Id needs to contain a value of "s".
 79  }
 80  Dim oClaimTypeRiskItem As New RiskItem With {
 81    .question_id = "MO111", 'This is the question id for the field with description "Type of claim" for a UK Motor risk.
 82    .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".
 83    .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".
 84    .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.
 85  }
 86
 87  Dim lstRiskItems As New List(Of RiskItem) From {oNumberOfSeatsRiskItem, oSecurityDeviceRiskItem, oDriverAutoIncrementRiskItem,
 88    oDriverPersonRiskItem, oDriverFirstNameRiskItem, oClaimIdRiskItem, oClaimPersonIdRiskItem, oClaimCustomerCoverIdRiskItem, oClaimTypeRiskItem}
 89  Dim oQuotePatchRequestBody As New QuoteUpdateRequest With {
 90    .client_guid = sClientGuid,
 91    .risk_items = lstRiskItems
 92  }
 93  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
 94  Dim sQuoteUpdateRequestBody As String = jss.Serialize(oQuotePatchRequestBody)
 95  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
 96    With oWebclient.Headers
 97      .Add("AuthenticationKey", AUTHENTICATION_KEY)
 98      .Add("DatabaseName", DATABASE)
 99      .Add("Content-type", "application/json")
100    End With
101    Dim aQuoteUpdateResponse As Byte() = oWebclient.UploadData(sQuoteURL, "PATCH", Encoding.ASCII.GetBytes(sQuoteUpdateRequestBody))
102  End Using
103
104Catch ex As WebException
105  Dim sStatusCode As String = ex.Status.ToString
106  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
107  Console.WriteLine($"Status Code: {sStatusCode}, Error: {sError}")
108Catch ex As Exception
109  Console.WriteLine(ex.Message)
110End 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

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 With {.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    sQuoteDefinitionResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
18  End Using
19  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
20  Dim oQuoteGetDefinitionResponse As RiskDefinition = jss.Deserialize(Of RiskDefinition)(sQuoteDefinitionResponse)
21
22  Console.WriteLine("Application Type: " & oQuoteGetDefinitionResponse.application_type)
23  Console.WriteLine("Application Type Version: " & oQuoteGetDefinitionResponse.application_type_version)
24  'These risk question items are not contained in a repeating group/scheduled item.
25  For Each oRiskItem As RiskItem In oQuoteGetDefinitionResponse.risk_items.fields
26    Console.WriteLine("Question ID: " & oRiskItem.question_id)
27    Console.WriteLine("Text: " & oRiskItem.text)
28    Console.WriteLine("Type: " & oRiskItem.type)
29    Console.WriteLine("Max Length: " & oRiskItem.max_length)
30  Next
31  'These risk question items are contained in a repeating group/scheduled item.
32  For Each kvpRepeatingGroup As KeyValuePair(Of String, List(Of RiskItem)) In oQuoteGetDefinitionResponse.risk_items.repeating_group_items
33    Console.WriteLine("Repeating Group Name: " & kvpRepeatingGroup.Value.First.repeating_group_name)
34    Console.WriteLine("Parent Group Name: " & kvpRepeatingGroup.Value.First.parent_repeatinggroup_name)
35    For Each oRiskItem As RiskItem In kvpRepeatingGroup.Value
36      Console.WriteLine("Question ID: " & oRiskItem.question_id)
37      Console.WriteLine("Text: " & oRiskItem.text)
38      Console.WriteLine("Type: " & oRiskItem.type)
39      Console.WriteLine("Max Length: " & oRiskItem.max_length)
40    Next
41  Next
42
43  'Retrieve the option sets for a quote for the corresponding UK House policy.
44  Dim sOptionSetsURL As String = SDK_SERVICE_URI & $"/api/option_sets/{oQuoteGetDefinitionResponse.application_type}/{oQuoteGetDefinitionResponse.application_type_version}"
45  Dim sOptionSetsResponse As String
46  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
47    With oWebclient.Headers
48      .Add("AuthenticationKey", AUTHENTICATION_KEY)
49      .Add("DatabaseName", DATABASE)
50    End With
51    Dim aOptionSetsResponse As Byte() = oWebclient.DownloadData(sOptionSetsURL)
52    sOptionSetsResponse = oWebclient.Encoding.GetString(aOptionSetsResponse)
53  End Using
54  Dim dictOptionSets As Dictionary(Of String, Dictionary(Of String, [Option])) = jss.Deserialize(Of Dictionary(Of String, Dictionary(Of String, [Option])))(sOptionSetsResponse)
55
56  For Each dictOptionSet As KeyValuePair(Of String, Dictionary(Of String, [Option])) In dictOptionSets
57    Console.WriteLine("Option Set: " & dictOptionSet.Key)
58    For Each oOption As KeyValuePair(Of String, [Option]) In dictOptionSet.Value
59      Console.WriteLine("Option ID: " & oOption.Value.value)
60      Console.WriteLine("Option Description: " & oOption.Value.description)
61    Next
62  Next
63
64Catch ex As WebException
65  Dim sStatusCode As String = ex.Status.ToString
66  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
67  Console.WriteLine($"Status Code: {sStatusCode}, Error: {sError}")
68Catch ex As Exception
69  Console.WriteLine(ex.Message)
70End 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

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 for a UK House policy and update some risk information of that quote.
 6Try
 7  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.
 8
 9  'Insert a new quote for a UK House policy.
10  Dim sQuotesUrl As String = SDK_SERVICE_URI & "/api/quotes"
11  Dim oInsertRequest As New QuoteInsertRequest With {
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 = "B01", 'A valid branch code can be obtained using the SDK method Get_Lookup and passing the BranchForClientID enumerator. 
22                .department_code = "D01", 'A valid department code can be obtained using the SDK method Get_Lookup and passing the Department enumerator.
23                .profit_center_code = "P01" 'A profit center code can be obtained using the SDK method Get_Lookup and passing the ProfitCenter enumerator.
24              }
25  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
26  Dim sQuoteInsertRequestBody As String = jss.Serialize(oInsertRequest)
27
28  Dim sQuoteInsertResponse As String
29  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
30    With oWebclient.Headers
31      .Add("AuthenticationKey", AUTHENTICATION_KEY)
32      .Add("DatabaseName", DATABASE)
33      .Add("Content-type", "application/json")
34    End With
35    Dim aQuoteInsertResponse As Byte() = oWebclient.UploadData(sQuotesUrl, "POST", Encoding.ASCII.GetBytes(sQuoteInsertRequestBody))
36    sQuoteInsertResponse = oWebclient.Encoding.GetString(aQuoteInsertResponse)
37  End Using
38  Dim oQuoteInsertResponse As QuoteInsertResponse = jss.Deserialize(Of QuoteInsertResponse)(sQuoteInsertResponse)
39
40  'Check the latest quote definition version obtained matches the version the integration was written for
41  Dim sQuoteDefinitionURL As String = SDK_SERVICE_URI & "/api/quotes/definition/" & oQuoteInsertResponse.quote_guid
42  Dim sQuoteDefinitionResponse As String
43  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
44    With oWebclient.Headers
45      .Add("AuthenticationKey", AUTHENTICATION_KEY)
46      .Add("DatabaseName", DATABASE)
47    End With
48    Dim aQuoteDefinitionResponse As Byte() = oWebclient.DownloadData(sQuoteDefinitionURL)
49    sQuoteDefinitionResponse = oWebclient.Encoding.GetString(aQuoteDefinitionResponse)
50  End Using
51  Dim oQuoteGetDefinitionResponse As RiskDefinition = jss.Deserialize(Of RiskDefinition)(sQuoteDefinitionResponse)
52  Dim sLatestVersion As String = oQuoteGetDefinitionResponse.application_type_version
53  If sLatestVersion <> "2.0.3" Then Exit Sub 'Value obtained from application_type_version in Phase 1.
54
55  'Now update a desired field using the quote definition information obtained in the previous step.
56  Dim sQuoteURL As String = SDK_SERVICE_URI & oQuoteInsertResponse.quote_uri
57  Dim oPreviousPolicyExpiredDate As New RiskItem With {
58    .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})
59    .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.
60    .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.
61    .value = "2020-03-04" 'The type for this question in the quote definition is Date. This would signify that only date values are accepted.
62  }
63  Dim lstRiskItems As New List(Of RiskItem) From {oPreviousPolicyExpiredDate}
64  Dim oQuotePatchRequestBody As New QuoteUpdateRequest With {
65    .client_guid = sClientGuid,
66    .risk_items = lstRiskItems
67  }
68
69  Dim sQuoteUpdateRequestBody As String = jss.Serialize(oInsertRequest)
70  Using oWebclient As New WebClient With {.Encoding = Encoding.UTF8}
71    With oWebclient.Headers
72      .Add("AuthenticationKey", AUTHENTICATION_KEY)
73      .Add("DatabaseName", DATABASE)
74      .Add("Content-type", "application/json")
75    End With
76    Dim aQuoteUpdateResponse As Byte() = oWebclient.UploadData(sQuoteURL, "PATCH", Encoding.ASCII.GetBytes(sQuoteUpdateRequestBody))
77  End Using
78
79Catch ex As WebException
80  Dim sStatusCode As String = ex.Status.ToString
81  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
82  Console.WriteLine($"Status Code: {sStatusCode}, Error: {sError}")
83Catch ex As Exception
84  Console.WriteLine(ex.Message)
85End Try
See Also

Reference

Other Resources