From 9375d993e7b15bfcd4ee74be8ef04f43bd0eeae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ce=C4=BEuch?= Date: Mon, 18 Nov 2024 13:26:32 +0100 Subject: [PATCH] use new build-signature endpoint on avm service --- app/models/document.rb | 8 +++++--- lib/avm_api.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/document.rb b/app/models/document.rb index 79639d6..1925743 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -76,12 +76,14 @@ def datatosign(signing_certificate) def sign(key, data_to_sign, signed_data) response = avm_service.sign(self, data_to_sign, signed_data) - document = response['documentResponse'] - encrypt_file(key, document.dig('filename'), document['mimeType'], document['content']) + encrypt_file(key, response.dig('filename'), response['mimeType'], response['content']) self.last_signed_at = Time.current save! - response['signer'] + { + 'signedBy': response['signedBy'], + 'issuedBy': response['issuedBy'] + } end private diff --git a/lib/avm_api.rb b/lib/avm_api.rb index a48f766..6ea4842 100644 --- a/lib/avm_api.rb +++ b/lib/avm_api.rb @@ -62,7 +62,7 @@ def datatosign(document, signing_certificate) end def sign(document, datatosign_structure, signed_data) - response = Faraday.post(url('/sign'), { + response = Faraday.post(url('/build-signature'), { "originalSignRequestBody": { document: { filename: document.encrypted_content.filename,