think.studio/laravel-myriad-soap

Unofficial web integration with Myriad 5.1

1.4.0 2023-07-11 05:43 UTC

This package is auto-updated.

Last update: 2024-12-11 08:53:46 UTC


README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

Unofficial web integration with Myriad 5.1

Installation

You can install the package via composer:

composer require think.studio/laravel-myriad-soap

php artisan vendor:publish --provider="MyriadSoap\ServiceProvider" --tag="config"

Usage

Direct call via facade:

$result = MyriadSoap::SOAP_getContactCommunications(['Contact_ID' => 1234]);
/*
    [
     "ContactCommunication" => [
       "123456;12;01234 567 890;Yes",
       "123457;14;me@test.co.uk;No",
     ],
    ]
*/

By default, Myriad lists responses has unexpected string lists responses, that why will be useful helper:

MyriadSoap::SOAP_getContactCommunications_List(['Contact_ID' => 1234], 3, 'ContactCommunication' /* Optional, as appropriate key, app will try guess itself */);

Or convert response to collection:

MyriadSoap::SOAP_getContactCommunications_Collection(['Contact_ID' => 1234], [
        'ContactCommunication_ID' => fn($i) => (int) $i,
        'DespatchType_ID' => fn($i) => (int) $i,
        'ContactCommunication',
        'PrimaryUse'              => fn($i) => $i == 'Yes',
    ], 'ContactCommunication' /* Optional, as appropriate key, app will try guess itself */);

To fetch not strings lists use AssocCollection call:

MyriadSoap::SOAP_getOrderPackageTypes_AssocCollection([], [
            'OrderPackageType_ID' => fn($i) => (int) tap($i, fn() => throw_if(! is_numeric($i), UnexpectedTypeException::class)),
            'OrderPackageType' => fn($i) => (string) $i,
            'OrderPackageCategory',
        ], 'OrderPackageType' /* Optional, as appropriate key, app will try guess itself */);

Using feature sets that allow you to wrap your own business logic (each class should extends FunctionsSet)

use MyriadSoap\Endpoints\FunctionsSet;

class MyContactFunctions extends FunctionsSet {

    public function getContactCommunications( int $customerNumber ) {
        return $this->api->call(
            'SOAP_getContactCommunications',
            [
                'Contact_ID' => $customerNumber,
            ]
        );
    }
}

$result =  MyriadSoap::functionsSet(MyContactFunctions::class)->getContactCommunications(1234);

Credits

  • Think Studio