generated from spatie/package-skeleton-laravel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP. Create basic node class, refactor from array to nodes.
- Loading branch information
Showing
12 changed files
with
258 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
class GetPendingDocumentsStatesList | ||
{ | ||
|
||
// TODO: implement. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes\Envelope; | ||
|
||
use Smartprax\Medidoc\Methods\AbstractMethod; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
class Action extends \Smartprax\Medidoc\XML\Nodes\Node | ||
{ | ||
|
||
public function __construct(private AbstractMethod $method) | ||
{} | ||
|
||
public function namespace(): ?XML_NS | ||
{ | ||
return XML_NS::addressing; | ||
} | ||
|
||
public function attributes(): array | ||
{ | ||
return [ | ||
XML_NS::envelope->attribute('mustUnderstand') => '1', | ||
]; | ||
} | ||
|
||
public function value(): string|array | ||
{ | ||
return 'http://tempuri.org/IMedidoc/' . $this->method->name(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes\Envelope; | ||
|
||
use Ramsey\Uuid\Uuid; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
class MessageID extends \Smartprax\Medidoc\XML\Nodes\Node | ||
{ | ||
|
||
public function namespace(): ?XML_NS | ||
{ | ||
return XML_NS::addressing; | ||
} | ||
|
||
public function attributes(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function value(): string|array | ||
{ | ||
return 'urn:uuid:' . Uuid::uuid4(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes\Envelope; | ||
|
||
use Smartprax\Medidoc\XML\Nodes\Node; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
class ReplyTo extends Node | ||
{ | ||
|
||
public function namespace(): ?XML_NS | ||
{ | ||
return XML_NS::addressing; | ||
} | ||
|
||
public function attributes(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function value(): string|array | ||
{ | ||
return [ | ||
'name' => XML_NS::addressing->node('Address'), | ||
'value' => 'http://www.w3.org/2005/08/addressing/anonymous' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes\Envelope; | ||
|
||
use Ramsey\Uuid\Uuid; | ||
use Smartprax\Medidoc\XML\Nodes\Node; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
class Security extends Node | ||
{ | ||
|
||
public function namespace(): ?XML_NS | ||
{ | ||
return XML_NS::wss_secext; | ||
} | ||
|
||
public function attributes(): array | ||
{ | ||
return [ | ||
XML_NS::envelope->attribute('mustUnderstand') => '1' | ||
]; | ||
} | ||
|
||
public function value(): array | ||
{ | ||
return [ | ||
|
||
// <u:Timestamp u:Id="_0"> | ||
// <u:Created>2023-03-21T08:35:52Z</u:Created> | ||
// <u:Expires>2023-03-21T08:40:52Z</u:Expires> | ||
// </u:Timestamp> | ||
|
||
[ | ||
'name' => XML_NS::wss_utility->node('Timestamp'), | ||
'attributes' => [ | ||
XML_NS::wss_utility->attribute('Id') => '_0', | ||
], | ||
'value' => [ | ||
[ | ||
'name' => XML_NS::wss_utility->node('Created'), | ||
'value' => \now()->subSeconds(50)->toIso8601String(), | ||
], | ||
|
||
[ | ||
'name' => XML_NS::wss_utility->node('Expires'), | ||
'value' => \now()->addSeconds(50)->toIso8601String(), | ||
] | ||
|
||
] | ||
], | ||
|
||
// <c:SecurityContextToken xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" | ||
// u:Id="uuid-126619d5-b159-4b44-bbdf-ed5e8a618d57-1491"> | ||
// <c:Identifier>urn:uuid:64ef4932-5c3f-4acd-bf81-183ebab4bef3</c:Identifier> | ||
// </c:SecurityContextToken> | ||
|
||
[ | ||
'name' => XML_NS::sc->node('SecurityContextToken'), | ||
'attributes' => [ | ||
XML_NS::wss_utility->attribute('Id') => 'uuid' . Uuid::uuid4(), | ||
], | ||
'value' => [ | ||
[ | ||
'name' => XML_NS::sc->node('Identifier'), | ||
'value' => 'urn:uuid:' . Uuid::uuid4(), | ||
], | ||
|
||
] | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes\Envelope; | ||
|
||
use Smartprax\Medidoc\XML\Nodes\Node; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
class To extends Node | ||
{ | ||
|
||
public function namespace(): ?XML_NS | ||
{ | ||
return XML_NS::addressing; | ||
} | ||
|
||
public function attributes(): array | ||
{ | ||
return [ | ||
XML_NS::envelope->attribute('mustUnderstand') => '1' | ||
]; | ||
} | ||
|
||
public function value(): string | ||
{ | ||
return 'https://test.medidoc.ch/WebServices/MedidocAccessV3.svc'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Smartprax\Medidoc\XML\Nodes; | ||
|
||
use Illuminate\Support\Str; | ||
use Sabre\Xml\Writer; | ||
use Sabre\Xml\XmlSerializable; | ||
use Smartprax\Medidoc\Methods\AbstractMethod; | ||
use Smartprax\Medidoc\XML\XML_NS; | ||
|
||
abstract class Node implements XmlSerializable | ||
{ | ||
abstract public function namespace() : ?XML_NS; | ||
abstract public function attributes() : array; | ||
abstract public function value() : string|array; | ||
|
||
public function name() : string | ||
{ | ||
return Str::of(get_class($this)) | ||
->replace('\\', '/') | ||
->basename(); | ||
} | ||
|
||
public function xmlSerialize(Writer $writer): void | ||
{ | ||
$writer->write([ | ||
'name' => $this->namespace() ? $this->namespace()->node($this->name()) : $this->name(), | ||
'attributes' => $this->attributes(), | ||
'value' => $this->value(), | ||
]); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters