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

Class "App\Repositories\MessageRepository not found... #45

Open
ablyanant opened this issue Jul 3, 2024 · 0 comments
Open

Class "App\Repositories\MessageRepository not found... #45

ablyanant opened this issue Jul 3, 2024 · 0 comments

Comments

@ablyanant
Copy link

I am trying to implement it via PHP way:

Steps to reproduce:

a) composer require tiamo/phpas2

b) Now create an index.php file with below code:

<?php 
require_once 'vendor/autoload.php';

$manager = new \AS2\Management();
        

//loading conf files
$partners          = require 'config/partners.php';

/** @var /AS2/MessageRepositoryInterface $messageRepository */
$messageRepository = new App\Repositories\MessageRepository(['path' => $storagePath . DIRECTORY_SEPARATOR . 'sent']);

/** @var /AS2/PartnerRepositoryInterface $partnerRepository */
$partnerRepository = new App\Repositories\PartnerRepository($partners);

// Init partners
$sender = $partnerRepository->findPartnerById('A');
$receiver = $partnerRepository->findPartnerById('B');

// Generate new message ID
$messageId = \AS2\Utils::generateMessageID($sender);
$rawMessage = '
Content-type: Application/EDI-X12
Content-disposition: attachment; filename=payload
Content-id: <[email protected]>

ISA*00~';

// Init new Message
$message = $messageRepository->createMessage();
$message->setMessageId($messageId);
$message->setSender($sender);
$message->setReceiver($receiver);

$payload = $manager->buildMessage($message, $rawMessage);
if ($response = $manager->sendMessage($message, $payload)) {
	echo "OK \n";
}

$messageRepository->saveMessage($message);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant