Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Schultz Fasit handler #135

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before starting to add changes. Use example [placed in the end of the page](#exa
## [Unreleased]

- [OS-119] Keeping value of CPR clean, not adding address protection text
- Added `os2forms_fasit` module.
- Applied coding standards

## [3.16.0-beta1] 2024-08-27
Expand Down
62 changes: 62 additions & 0 deletions modules/os2forms_fasit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# OS2Forms Fasit

Adds [Fasit Schultz](https://schultz.dk/loesninger/schultz-fasit/)
handler for archiving purposes.

## Installation

```sh
drush pm:enable os2forms_fasit
```

## Settings

Configure Fasit API `base url` and a way of getting
certificate on `/admin/os2forms_fasit/settings`.

### Certificate

The certificate must be in `pem` or `cer` format and
must be whitelisted by Fasit Schultz.
For this the certificate thumbprint,
in lowercase and without colons, is needed.
To get the thumbprint in the correct format from the command line run

```sh
openssl x509 -in SOME_CERTIFICATE.pem -noout -fingerprint | cut -d= -f2 | sed 's/://g' | tr '[:upper:]' '[:lower:]'
```

Example output

```sh
6acb261f393172d87fa3997cec86569759a8528a
```

## Queue

Archiving is done via an
[Advanced Queue](https://www.drupal.org/project/advancedqueue)
called `fasit_queue`.

The queue should be processed with `drush`:

```sh
drush advancedqueue:queue:process fasit_queue
```

List the queue (and all other queues) with

```sh
drush advancedqueue:queue:list
```

or go to `/admin/config/system/queues/jobs/fasit_queue`
for a graphical overview of jobs in the queue.

### Cronjob

Consider running the queue via a cronjob.

```cron
*/5 * * * * /path/to/drush advancedqueue:queue:process fasit_queue
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
langcode: da
status: true
dependencies: { }
id: fasit_queue
label: 'Fasit Queue'
backend: database
backend_configuration:
lease_time: 300
processor: daemon
processing_time: 280
locked: false
threshold:
type: 0
limit: 0
state: all
10 changes: 10 additions & 0 deletions modules/os2forms_fasit/os2forms_fasit.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'OS2Forms Fasit'
type: module
description: 'Fasit integration'
package: OS2Forms
core_version_requirement: ^9 || ^10
dependencies:
- drupal:webform
- drupal:advancedqueue
- os2forms:os2forms_attachment
configure: os2forms_fasit.admin.settings
5 changes: 5 additions & 0 deletions modules/os2forms_fasit/os2forms_fasit.links.menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
os2forms_fasit.admin.settings:
title: OS2Forms Fasit
description: Configure the OS2Forms Fasit module
parent: system.admin_config_system
route_name: os2forms_fasit.admin.settings
7 changes: 7 additions & 0 deletions modules/os2forms_fasit/os2forms_fasit.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
os2forms_fasit.admin.settings:
path: '/admin/os2forms_fasit/settings'
defaults:
_form: '\Drupal\os2forms_fasit\Form\SettingsForm'
_title: 'Fasit settings'
requirements:
_permission: 'administer site configuration'
15 changes: 15 additions & 0 deletions modules/os2forms_fasit/os2forms_fasit.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
Drupal\os2forms_fasit\Helper\Settings:
arguments:
- "@keyvalue"

Drupal\os2forms_fasit\Helper\CertificateLocatorHelper:
arguments:
- "@Drupal\\os2forms_fasit\\Helper\\Settings"

Drupal\os2forms_fasit\Helper\FasitHelper:
arguments:
- '@http_client'
- '@entity_type.manager'
- "@Drupal\\os2forms_fasit\\Helper\\Settings"
- "@Drupal\\os2forms_fasit\\Helper\\CertificateLocatorHelper"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Certificate locator exception.
*/
class CertificateLocatorException extends Exception {

}
10 changes: 10 additions & 0 deletions modules/os2forms_fasit/src/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Certificate locator exception.
*/
class Exception extends \Exception {

}
10 changes: 10 additions & 0 deletions modules/os2forms_fasit/src/Exception/FasitResponseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Fasit response exception.
*/
class FasitResponseException extends Exception {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Fasit XML generation exception.
*/
class FasitXMLGenerationException extends Exception {

}
10 changes: 10 additions & 0 deletions modules/os2forms_fasit/src/Exception/FileTypeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* File type exception.
*/
class FileTypeException extends Exception {

}
10 changes: 10 additions & 0 deletions modules/os2forms_fasit/src/Exception/InvalidSettingException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Invalid setting exception.
*/
class InvalidSettingException extends Exception {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2forms_fasit\Exception;

/**
* Invalid submission exception.
*/
class InvalidSubmissionException extends Exception {

}
Loading
Loading