UseMuffin / Webservice

Bringing the power of the CakePHP ORM to your favourite webservices
MIT License
89 stars 43 forks source link

[cake 3.10, webservice 2.10] Wrong query result #103

Closed Edsol closed 2 years ago

Edsol commented 2 years ago

Cakephp 3.10 Webservice 2.10

I use webservice package to get remote data like this:

    {
        "id": 37744,
        "name": "A19-R35",
        "latitude": 40.427244444444,
        "timestamp": 1633612408,
        "longitude": 17.477786666667
    },
    {
        "id": 37776,
        "name": "A99-S440T",
        "latitude": 40.427088888889,
        "timestamp": 1633611825,
        "longitude": 17.47781
    },
    {
        "id": 37821,
        "name": "A134-S180",
        "latitude": 41.626684444444,
        "timestamp": 1627731959,
        "longitude": 13.319757777778
    },
    {
        "id": 38066,
        "name": "A139-S440T",
        "latitude": 38.055973333333,
        "timestamp": 1633562464,
        "longitude": 13.113187777778
    },
    {
        "id": 38353,
        "name": "A29-V380",
        "latitude": 40.4250433,
        "timestamp": 1633611852,
        "longitude": 17.4824466
    },
    {
        "id": 38696,
        "name": "A62-S190",
        "latitude": 40.94256,
        "timestamp": 1633601755,
        "longitude": 9.5173666
    },
    {
        "id": 38750,
        "name": "A40-VM90",
        "latitude": 40.7200366,
        "timestamp": 1633411097,
        "longitude": 8.6301933
    },
    {
        "id": 38751,
        "name": "A46-S190",
        "latitude": 40.6871316,
        "timestamp": 1633593958,
        "longitude": 8.62475
    },
    {
        "id": 38760,
        "name": "A96-l75",
        "latitude": 39.8879566,
        "timestamp": 1633593014,
        "longitude": 8.5964433
    },
    {
        "id": 38786,
        "name": "A137-ACM90",
        "latitude": 39.3558099,
        "timestamp": 1633604014,
        "longitude": 9.05761
    },
    {
        "id": 38787,
        "name": "A38-VM90",
        "latitude": 39.9739633,
        "timestamp": 1633429440,
        "longitude": 9.6387783
    },
    {
        "id": 38790,
        "name": "A134-S180",
        "latitude": 39.35592,
        "timestamp": 1633606331,
        "longitude": 9.0577099
    },
    {
        "id": 38791,
        "name": "A49-I90",
        "latitude": 39.3560433,
        "timestamp": 1633602699,
        "longitude": 9.057675
    },
    {
        "id": 38829,
        "name": "A25-R293",
        "latitude": 42.566625,
        "timestamp": 1633611572,
        "longitude": 12.9755516
    }
]

If I do a get:

$this->Vehicles->get(38751);

or a find with conditions:

$this->Vehicles->find()->where(['id' => 38751])->toArray()

return same the first element of list:

{
    "id": 37744,
    "name": "A19-R35",
    "latitude": 40.427244444444,
    "timestamp": 1633612675,
    "longitude": 17.477786666667
}
ADmad commented 2 years ago

You need to modify the request URL to the 3rdparty API based on value of id. The plugin itself won't do any filtering for you.

Here's an example https://github.com/CVO-Technologies/cakephp-github/blob/master/src/Webservice/GitHubWebservice.php#L49-L62.

Edsol commented 2 years ago

You need to modify the request URL to the 3rdparty API based on value of id. The plugin itself won't do any filtering for you.

Here's an example https://github.com/CVO-Technologies/cakephp-github/blob/master/src/Webservice/GitHubWebservice.php#L49-L62.

very fast,thank you!