Giter Club home page Giter Club logo

Comments (3)

JasperAlgra avatar JasperAlgra commented on July 20, 2024

Hi, I was looking for the same.. and created this based on some stuf I've seen in the API itself.
maybe this helps you as wel.

try {
            $request = (new MyParcelRequest());

            $userAgent = $request->getUserAgentFromComposer();
            $request
                ->setUserAgent($userAgent)
                ->setRequestParameters(
                    APIKEY,
                    "?q={$query}",
                    MyParcelRequest::REQUEST_HEADER_RETRIEVE_SHIPMENT
                )
                ->sendRequest('GET');


            if ($request->getResult() === null) {
                self::echoError("error", 'Unable to connect to MyParcel.');
            }

            $results = $request->getResult();


        } catch (\Exception $exception) {
            self::echoError("error", $exception->getMessage());
        }
	}

from sdk.

RichardPerdaan avatar RichardPerdaan commented on July 20, 2024

Hi @badbitnl,

Can You indicate if the example of @JasperAlgra works for you?

from sdk.

reindert-vetter avatar reindert-vetter commented on July 20, 2024

@badbitnl @JasperAlgra a nice solution is made in https://github.com/myparcelnl/sdk/releases/tag/v4.1.0

Query consignments

You can search and filter consignments by certain values:

$consignments = MyParcelCollection::query(
            'api_key_from_MyParcel_backoffice',
            [
                'q'                    => 'Niels',
                'reference_identifier' => 'order-1234',
                'status'               => 2,
                'from'                 => '2020-01-01 00:00:00',
                'to'                   => '2020-02-01 00:00:00',
                'page'                 => 1,
                'size'                 => 200,
                'order'                => 'DESC',
                'package_type'         => 1,
                'region'               => 'NL;EU',
                'dropoff_today'        => 1,
            ]
        )

For q and reference identifier you can use * to search smarter.

If the 2nd parameter is an object, then public properties will be used. If you query in many ways, creating a separate class can provide a clean solution.

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.