﻿<?xml version="1.0" encoding="utf-8"?>
<ConnectionManager Name="KPA Flex" RuntimeVersion="" Help="http://www.cozyroc.com/ssis/kpa-flex-connection" xmlns="http://www.cozyroc.com/schema/rcm-config-1.0.xsd">
	<Service EndPoint="https://api.kpaehs.com/v1"/>

	<Authentication>
		<Documentation>https://https://api.kpaehs.com/</Documentation>

		<User>
			<Parameter Name="APIKey" Type="password">
				<Documentation>Required. Specify the subscription key that is obtained through the KPA Flex Portal.</Documentation>
			</Parameter>
		</User>

		<Test Url="/api.ping" Method="POST" />

		<Parameters>
			<Parameter Name="application/json" Value="{{=_.extend({ token: connection.user.APIKey }, JSON.parse(request.body.content))}}" Type="Body" />
		</Parameters>
	</Authentication>

	<Resources>
		<Template>
			<Field Name="ShortText" DataType="DT_WSTR" Length="255"/>
			<Field Name="LongText" DataType="DT_WSTR" Length="4000"/>
			<Field Name="DateTime" DataType="DT_DBTIMESTAMP"/>
			<Field Name="Boolean" DataType="DT_BOOL"/>

			<Resource Name="Base">
				<Read Method="POST">
					<Parameters>
						<Parameter Name="application/json" Value="{{={ page: parameters.iterator, limit: parameters.batchSize } }}" Type="Body"/>
					</Parameters>

					<Iterator>
						<Next Value="{{=parseInt(parameters.iterator || 1) + 1}}" />
					</Iterator>
				</Read>
			</Resource>
		</Template>
	</Resources>
	<Script>
		<Module Name="Main">
			<![CDATA[
require('underscore');
]]>
		</Module>
	</Script>
</ConnectionManager>