Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# OS2Forms Digital Post

Send Digital Post to danish citizens from a webform.

## Installation

Require it with composer:

```shell
composer require "itk-dev/os2forms-digital-post"
```

Enable it with drush:

```shell
drush pm:enable os2forms_digital_post
```

Add the following configuration:

```php
$config['os2forms_digital_post'] = [
'path_to_templates' => '',

'digital_post_system_id' => '',
'digital_post_afsender_system' => '',

'digital_post_materiale_id' => '',

'digital_post_forsendelses_type' => '',

'azure_tenant_id' => '',
'azure_application_id' => '',
'azure_client_secret' => '',

'azure_key_vault_name' => '',
'azure_key_vault_secret' => '',
'azure_key_vault_secret_version' => '',

'service_agreement_uuid' => '',
'user_system_uuid' => '',
'user_uuid' => '',

'service_uuid' => 'fd885b8b-4a3f-46cb-b367-6c9dda1c78f6',
'service_endpoint' => 'https://prod.serviceplatformen.dk/service/Print/Print/2',
'service_contract' => dirname(DRUPAL_ROOT) . '/web/modules/contrib/os2forms-digital-post/resources/contracts/PrintService/wsdl/context/PrintService.wsdl',
];

```

## Templating / Styling the PDF
You'll need to provide a PDF template, that will be rendered when sending letters via digital post.
The template has to be in the twig format and accessible by this module. Configure the path to your templates
in the settings mentioned above.

The following variables is present in the twig-template:
* logo - Path to the logo in your template.
* recipient - Which holds information about the recipient of the letter.
* elements - The elements submitted in the form.

### Structure of template
Your template folder structure has to be as following:
```shell
/templates-root # Set this folder as "path_to_templates" in the settings.
/name-of-template
index.html.twig # The actual twig template.
logo.png # Logo
styles.css # The styles. Be aware that this module uses DomPDF to render the PDF, and therefore are submitted to the CSS rules defined in DomPDF.
```

## Usage

This module provides functionality for sending digital post to danish citizens.
A WebformHandler is provided that you can add to your webform, and if configured
it will send the submitted data as digital post.

This module provides functionality for querying the danish CPR register and
showing the result in webforms.

## Coding standards

Check coding standards (run `composer install` to install the required tools):

```shell
composer coding-standards-check
```

Apply coding standards:

```shell
composer coding-standards-apply
```
36 changes: 34 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,45 @@
"email": "[email protected]"
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"ext-soap": "*",
"itk-dev/serviceplatformen": "^1.0",
"itk-dev/serviceplatformen": "^1.1",
"php-http/guzzle6-adapter": "^2.0.1",
"http-interop/http-factory-guzzle": "^1.0.0",
"symfony/property-access": "^4.4"
"symfony/property-access": "^4.4",
"wsdltophp/packagebase": "^5.0",
"dompdf/dompdf": "~0.8.0",
"os2forms/os2forms": "^2.5",
"itk-dev/os2forms-cpr-lookup": "^1.2"
},
"autoload": {
"Drupal\\os2forms_digital_post\\": "src/"
},
"require-dev": {
"wsdltophp/packagegenerator": "^4.0",
"drupal/coder": "^8.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
},
"scripts": {
"coding-standards-check/phpcs": [
"phpcs --standard=phpcs.xml.dist"
],
"coding-standards-check": [
"@coding-standards-check/phpcs"
],
"coding-standards-apply/phpcs": [
"phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-apply": [
"@coding-standards-apply/phpcs"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace ItkDev\OS2Forms_Digital_Post\PrintService;

/**
* Class which returns the class map definition
*/
class ClassMap
{
/**
* Returns the mapping between the WSDL Structs and generated Structs' classes
* This array is sent to the \SoapClient when calling the WS
* @return string[]
*/
final public static function get(): array
{
return [
'InvocationContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\InvocationContextType',
'AuthorityContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\AuthorityContextType',
'CallContextType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\CallContextType',
'MeddelelsesFormatObjektType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\MeddelelsesFormatObjektType',
'DokumentParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\DokumentParametreType',
'CountryIdentificationCodeType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\CountryIdentificationCodeType',
'KontaktOplysningType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\KontaktOplysningType',
'ForsendelseAfsenderType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseAfsenderType',
'KanalUafhaengigeParametreIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\KanalUafhaengigeParametreIType',
'MeddelelseFESDmetadataType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\MeddelelseFESDmetadataType',
'DigitalPostParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\DigitalPostParametreType',
'PostParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PostParametreType',
'TransaktionsParametreIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\TransaktionsParametreIType',
'PrintParametreType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintParametreType',
'SlutbrugerIdentitetType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\SlutbrugerIdentitetType',
'ForsendelseModtagerType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseModtagerType',
'BilagType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BilagType',
'BilagSamlingType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BilagSamlingType',
'ForsendelseIType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ForsendelseIType',
'BrevSPBodyType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\BrevSPBodyType',
'TilmeldingRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\TilmeldingRequestType',
'PrintAfsendBrevRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintAfsendBrevRequestType',
'PrintAfsendBrevResponseType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintAfsendBrevResponseType',
'PrintSpoergTilmeldingRequestType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintSpoergTilmeldingRequestType',
'PrintSpoergTilmeldingResponseType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\PrintSpoergTilmeldingResponseType',
'FejlType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\FejlType',
'ServiceplatformFaultType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ServiceplatformFaultType',
'ErrorListType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ErrorListType',
'ErrorType' => '\\ItkDev\\OS2Forms_Digital_Post\\PrintService\\StructType\\ErrorType',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;

use WsdlToPhp\PackageBase\AbstractStructEnumBase;

/**
* This class stands for FarveSHKodeType EnumType
* @subpackage Enumerations
*/
class FarveSHKodeType extends AbstractStructEnumBase
{
/**
* Constant for value 'SH'
* @return string 'SH'
*/
const VALUE_SH = 'SH';
/**
* Constant for value 'Farve'
* @return string 'Farve'
*/
const VALUE_FARVE = 'Farve';
/**
* Return allowed values
* @uses self::VALUE_SH
* @uses self::VALUE_FARVE
* @return string[]
*/
public static function getValidValues(): array
{
return [
self::VALUE_SH,
self::VALUE_FARVE,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;

use WsdlToPhp\PackageBase\AbstractStructEnumBase;

/**
* This class stands for KanalKodeType EnumType
* @subpackage Enumerations
*/
class KanalKodeType extends AbstractStructEnumBase
{
/**
* Constant for value 'Digital Post'
* @return string 'Digital Post'
*/
const VALUE_DIGITAL_POST = 'Digital Post';
/**
* Constant for value 'Fysisk Post'
* @return string 'Fysisk Post'
*/
const VALUE_FYSISK_POST = 'Fysisk Post';
/**
* Return allowed values
* @uses self::VALUE_DIGITAL_POST
* @uses self::VALUE_FYSISK_POST
* @return string[]
*/
public static function getValidValues(): array
{
return [
self::VALUE_DIGITAL_POST,
self::VALUE_FYSISK_POST,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;

use WsdlToPhp\PackageBase\AbstractStructEnumBase;

/**
* This class stands for KanalvalgType EnumType
* @subpackage Enumerations
*/
class KanalvalgType extends AbstractStructEnumBase
{
/**
* Constant for value 'A'
* @return string 'A'
*/
const VALUE_A = 'A';
/**
* Constant for value 'D'
* @return string 'D'
*/
const VALUE_D = 'D';
/**
* Constant for value 'S'
* @return string 'S'
*/
const VALUE_S = 'S';
/**
* Constant for value 'F'
* @return string 'F'
*/
const VALUE_F = 'F';
/**
* Constant for value 'P'
* @return string 'P'
*/
const VALUE_P = 'P';
/**
* Return allowed values
* @uses self::VALUE_A
* @uses self::VALUE_D
* @uses self::VALUE_S
* @uses self::VALUE_F
* @uses self::VALUE_P
* @return string[]
*/
public static function getValidValues(): array
{
return [
self::VALUE_A,
self::VALUE_D,
self::VALUE_S,
self::VALUE_F,
self::VALUE_P,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace ItkDev\OS2Forms_Digital_Post\PrintService\EnumType;

use WsdlToPhp\PackageBase\AbstractStructEnumBase;

/**
* This class stands for KuvertTypeKodeType EnumType
* @subpackage Enumerations
*/
class KuvertTypeKodeType extends AbstractStructEnumBase
{
/**
* Constant for value 'C4'
* @return string 'C4'
*/
const VALUE_C_4 = 'C4';
/**
* Constant for value 'C5'
* @return string 'C5'
*/
const VALUE_C_5 = 'C5';
/**
* Constant for value 'MA'
* @return string 'MA'
*/
const VALUE_MA = 'MA';
/**
* Return allowed values
* @uses self::VALUE_C_4
* @uses self::VALUE_C_5
* @uses self::VALUE_MA
* @return string[]
*/
public static function getValidValues(): array
{
return [
self::VALUE_C_4,
self::VALUE_C_5,
self::VALUE_MA,
];
}
}
Loading