<?php
$service = happyforms_get_integrations()->get_service( 'constant-contact' );
$credentials = $service->get_credentials();
?>
<div id="happyforms-service-<?php echo $service->id; ?>" class="happyforms-service-integration">
	<div class="widget-content <?php if ( $service->is_connected() ) : ?>authenticated<?php endif; ?>">
		<?php
		happyforms_credentials_input(
			$service->id,
			'client_id',
			__( 'API key', 'happyforms' ),
			$credentials['client_id']
		);
		?>
		<?php
		happyforms_credentials_input(
			$service->id,
			'client_secret',
			__( 'API secret', 'happyforms' ),
			$credentials['client_secret']
		);
		?>
		<p>
			<input type="text" value="<?php echo $service->redirect_uri; ?>" id="constant-contact-redirect-url" style="position: absolute; left: -9999px;">
			<script type="text/javascript" charset="utf-8">
			function happyFormsConstantContactCopyRedirectURI() {
				document.getElementById( 'constant-contact-redirect-url' ).trigger( 'select' );
				try { document.execCommand( 'copy' ); } catch( e ) {};
			}
			</script>
			<?php printf(
				__( 'Not sure what your "Redirect URI" should be? We\'ve gone ahead and prepared one for you (<a href="%s" onclick="%s">copy to clipboard</a>).', 'happyforms' ),
				'javascript:void(0);',
				'happyFormsConstantContactCopyRedirectURI()'
			); ?>
		</p>
	</div>
</div>
