Giter Site home page Giter Site logo

cityscan's Introduction

CityScan addresses API

PHP client for CityScan. Allow you to activate or deactivate addresses.

Install

composer require ayctor/cityscan

Instanciate

Instanciate a new CityScan API with API key (required), client key (required for report) and an environment (optional), prod by default or preprod.

Be carefull, the function signature has changed with the client key added after api key.

$cs = new \CityScan\CityScan('api_key', 'client_key', 'preprod');

Errors

Throws an exception on error. Error message is filled with the message returned by the API. If needed, the error code is also present.

Activate an address

By road

function activateAddressByRoad($road, $postal_code, $city, $external_id = null){}

$address = $cs->activateAddressByRoad('23, rue sébastien mercier', 75015, 'Paris', 'ayctor');

Returns:

{
    "source": "IGN",
    "lat": 48.8445,
    "lon": 2.2786,
    "address": {
        "id": 74752,
        "geoloc_id": 69849,
        "route": "23, rue Sébastien Mercier",
        "postal_code": "75015",
        "city": "Paris"
    },
    "externalAddressId": "ayctor"
}

By GPS

function activateAddressByGPS($latitude, $longitude, $external_id = null){}

$address = $cs->activateAddressByGPS(48.8445, 2.2786);

Returns:

{
    "source": "IGN",
    "lat": "48.8445",
    "lon": "2.2786",
    "address": {
        "id": 74728,
        "geoloc_id": 69849,
        "route": "28 rue sebastien mercier",
        "postal_code": "75015",
        "city": "Paris"
    },
    "externalAddressId": null
}

Deactivate an address

function deactivateAddress($id, $isExternal = false)

$res_road = $cs->deactivateAddress('ayctor', true);

$res_gps = $cs->deactivateAddress(74728);

Returns:

{
    "deactivation": "true"
}

Reactivate addresses

function reactivateAddresses($ids, $isExternal = false){}

$cs->reactivateAddresses(['ayctor', 'digibox'], true);

$cs->reactivateAddresses(['ayctor', 'digibox'], true);

$cs->reactivateAddresses([74728, 74729]);

Returns:

{
  "status": 0,
  "content": {
    "addresses": [
      {
          "id": 74728,
          "route": "23, rue Sébastien Mericer",
          "postalCode": "75015",
          "city": "Paris",
          "externalAddressId": "ayctor",
          "active": true,
          "activation": "2020-01-03 18:42:47",
          "deactivation": null,
          "lastSeen": null,
          "lat": 48.8445, 
          "lon": 2.2786
      },
      {
          "id": 74729,
          "route": "23, rue Sébastien Mericer",
          "postalCode": "75015",
          "city": "Paris",
          "externalAddressId": "digibox",
          "active": true,
          "activation": "2020-01-03 18:42:47",
          "deactivation": null,
          "lastSeen": null,
          "lat": 48.8445, 
          "lon": 2.2786
      }
    ]
  }
}

Get adresses

Get active adresses

function getActives()

$adresses = $cs->getActives();

Returns:

{
  "status": 0,
  "content": {
    "count": 12,
    "addresses": [
      {
        "id": 68401,
        "route": "73 rue lecourbe",
        "postalCode": "75015",
        "city": "Paris",
        "externalAddressId": null,
        "active": true,
        "activation": "2019-01-02 09:43:48",
        "deactivation": null,
        "lat": 48.843331,
        "lon": 7.230364
      }, ...
    ]
  }
}

Get all adresses

function getAll()

$adresses = $cs->getAll();

Returns:

{
  "status": 0,
  "content": {
    "count": 12,
    "addresses": [
      {
        "id": 68401,
        "route": "73 rue lecourbe",
        "postalCode": "75015",
        "city": "Paris",
        "externalAddressId": null,
        "active": true,
        "activation": "2019-01-02 09:43:48",
        "deactivation": null,
        "lat": 48.843331,
        "lon": 7.230364
      }, ...
    ]
  }
}

Get activated

Get the adresses activated between two dates. If null is sent for one of the dates, no limit is applied.

function getActivated($start = null, $end = null)

$adresses = $cs->getActivated('2018-01-01','2018-02-01');

Returns:

{
  "status": 0,
  "content": {
    "count": 12,
    "addresses": [
      {
        "id": 68401,
        "route": "73 rue lecourbe",
        "postalCode": "75015",
        "city": "Paris",
        "externalAddressId": null,
        "active": true,
        "activation": "2019-01-02 09:43:48",
        "deactivation": null,
        "lat": 48.843331,
        "lon": 7.230364
      }, ...
    ]
  }
}

Get billed

Get the adresses billed between two dates. If null is sent for one of the dates, no limit is applied.

function getActivated($start = null, $end = null)

$adresses = $cs->getActivated('2018-01-01','2018-02-01');

Returns:

{
  "status": 0,
  "content": {
    "count": 12,
    "addresses": [
      {
        "id": 68401,
        "route": "73 rue lecourbe",
        "postalCode": "75015",
        "city": "Paris",
        "externalAddressId": null,
        "active": true,
        "activation": "2019-01-02 09:43:48",
        "deactivation": null,
        "lat": 48.843331,
        "lon": 7.230364
      }, ...
    ]
  }
}

Get deactivated

Get the adresses deactivated between two dates. If null is sent for one of the dates, no limit is applied.

function getDeactivated($start = null, $end = null)

$adresses = $cs->getDeactivated('2018-01-01','2018-02-01');

Returns:

{
  "status": 0,
  "content": {
    "count": 12,
    "addresses": [
      {
        "id": 68401,
        "route": "73 rue lecourbe",
        "postalCode": "75015",
        "city": "Paris",
        "externalAddressId": null,
        "active": true,
        "activation": "2019-01-02 09:43:48",
        "deactivation": null,
        "lat": 48.843331,
        "lon": 7.230364
      }, ...
    ]
  }
}

Get report

function report($id, $isExternal = false)

$report = $cs->report('ayctor', true);

Returns:

{
    "reportId": "51EA1BE0-6D13-1234-4E78-3A24BAEED2F0",
    "filename": "Rapport CityScan -  23 rue Sébastien Mercier - 75015 Paris.pdf"
}

cityscan's People

Contributors

damien-couteillou avatar

Stargazers

jb veron avatar Dionysios Mavrotas avatar Julien DELASSAUX avatar

Watchers

Erwan Guillon avatar James Cloos avatar  avatar Dionysios Mavrotas avatar jb veron avatar

cityscan's Issues

"Invalid API key" response

Hi there,

When tried to activate an address with your extension the Cityscan WS says "Invalid API key". Tested with CityScan live and same Api key and it works.

Screenshot_2019-10-25 Exception

image001

Thank you for your feedback.

Michael

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.