phpipam / phpipam

phpipam development repository
https://phpipam.net
2.23k stars 733 forks source link

[Enhancement] Location objects created via API doesn't get coordinates from address #979

Closed bardoup closed 7 years ago

bardoup commented 7 years ago

Hello,

When I create a location through the API (tools controller), specifying it's postal address, geo coordinates are not filled automagically as when created through the web interface.

phpipam commented 7 years ago

Hi, please try now.

bardoup commented 7 years ago

Nope, still not.

And I didn't tested on the wron platform this time :)

root@sv-t-vnl-phpipam:/var/www/html/phpipam# update_phpipam
remote: Counting objects: 55, done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 55 (delta 43), reused 41 (delta 31), pack-reused 0
Dépaquetage des objets: 100% (55/55), fait.
Depuis https://github.com/phpipam/phpipam
   022406e..5ef7e90  master     -> origin/master
Mise à jour 022406e..5ef7e90
Fast-forward
 api/controllers/Tools.php                       |  23 +++++++++++--
 app/admin/nameservers/edit-result.php           |  14 ++++++++
 app/admin/subnets/edit-folder-result.php        |   8 ++++-
 app/admin/subnets/edit-folder.php               |   2 +-
 app/admin/subnets/edit-result.php               |   7 +++-
 app/admin/subnets/edit.php                      |   2 +-
 app/admin/users/edit-result.php                 |   7 ++--
 app/subnets/addresses/address-modify-submit.php |   7 +++-
 app/subnets/addresses/address-modify.php        |   2 +-
 app/subnets/subnet-slaves.php                   |  17 ++++++++--
 app/tools/locations/single-location.php         |   2 +-
 app/tools/pstn-prefixes/edit-result.php         |  10 ++++--
 app/tools/pstn-prefixes/edit.php                |   3 +-
 functions/classes/class.Common.php              |  23 +++++++++++++
 functions/classes/class.Log.php                 | 257 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------
 misc/CHANGELOG                                  |   1 +
 16 files changed, 300 insertions(+), 85 deletions(-)
root@sv-t-vnl-phpipam:/var/www/html/phpipam# curl -s --insecure --header 'token: DZVwu.Bf6Kkkh0EQClBUwyVJ' --header "Content-Type: application/json" --data '{"name":"MipihBordeaux","description":null,"address":"184 quai de Brazza, 33000 BORDEAUX","nom_mipih":"Mipih Bordeaux (Maya)","nom_operateur":"33MIP Bordeaux","contacts":"PECHALI Luc;pechali.l@mipih.fr;05 56 32 57 97"}' -X POST https://localhost/phpipam/api/apphttps/tools/locations/
{"code":201,"success":true,"id":"32","data":"locations object created","time":0.69}
root@sv-t-vnl-phpipam:/var/www/html/phpipam# curl -s --insecure --header 'token: DZVwu.Bf6Kkkh0EQClBUwyVJ' --header "Content-Type: application/json" -X GET https://localhost/phpipam/api/apphttps/tools/locations/
{"code":200,"success":true,"data":[<... snipped ...>{"id":"33","name":"MipihBordeaux","description":null,"address":"184 quai de Brazza, 33000 BORDEAUX","lat":null,"long":null,"nom_mipih":"Mipih Bordeaux (Maya)","nom_operateur":"33MIP Bordeaux","contacts":"PECHALI Luc;pechali.l@mipih.fr;05 56 32 57 97"}],"time":0.104}
phpipam commented 7 years ago

Should be ok now, just needed to move code a bit higher :

curl -X POST http://devel.phpipam.net/1.3/api/apiclient/tools/locations/ --header 'token:u5D!bF7jEgF3M!xcq=vWa_5A'  --data 'name=api&address=Periceva 19, 1000 Ljubljana'
{"code":201,"success":true,"id":"27","data":"locations object created","time":0.201}%   

curl -X GET http://devel.phpipam.net/1.3/api/apiclient/tools/locations/27/ --header 'token:u5D!bF7jEgF3M!xcq=vWa_5A'            
{"code":200,"success":true,"data":{"id":"27","name":"api","description":null,"address":"Periceva 19, 1000 Ljubljana","lat":"46.0657633","long":"14.5115821","test":null},"time":0.008}                                                              
bardoup commented 7 years ago

Yes it works ! Many thanks, you fix bugs amazingly fast.

phpipam commented 7 years ago

Caught me in a good time :)