INESCloud Parking Hub - Provider (v1)

https://parkinghub.kiunsys.com/provider/v1

API Provider

Il INESCloud Parking Hub è la piattaforma per la registrazione e il controllo delle soste vendute dagli operatori (dealer).

Il provider è il gestore della piattaforma.

  • espone i servizi per la registrazione delle soste vendute dai dealer;
  • effettua la verifica e la sincronizzazione interrogando i servizi esposti dal dealer.

Il dealer vende, con i propri sistemi/app, le soste.

  • registra le soste vendute al sistema del provider;
  • espone i servizi per la verifica e la sincronizzazione delle soste vendute.

Ogni sosta (parking) viene identificata dal dealer con un identificatore unico (uid).

Non devono esistere soste con la stessa combinazione di targa, inizio sosta, zona tariffaria e dealer.

Parkings (registrazione sosta)

Per ogni sosta venduta, il dealer invoca il servizio di registrazione sosta.

Le soste possono seguire uno dei due modelli (il campo mode determina il modello seguito):

  1. Sosta Aperta (sosta con termine non prefissato) - caratterizzata da due eventi distinti: inizio e termine.

    In questo modello il campo mode può assume i seguenti valori:

    • start (inizio) - il servizio verrà invocato per registrare l'inizio della sosta
    • end (fine) - il servizio verrà invocato per registrare il termine della sosta

    parking mode

  2. Sosta Delimitata (sosta con inizio e termine prefissati) - caratterizzata da un unico evento. Questo secondo tipo di soste possono essere prolungate oppure terminate anticipatamente (ottenendo eventualmente un rimborso).

    In questo modello il campo mode può assume i seguenti valori:

    • bound (delimitata) - registra l'inizio e il termine della sosta
    • extend (prolungamento) - solo se l'utente decide di prolungare il termine della sosta, il servizio verrà invocato riportando i campi identificativi della sosta originaria e con importo e fine sosta opportunamente aggiornati (NOTA: intera sosta valida).
    • refund (termine anticipato) - solo se l'utente decide di terminare la sosta in anticipo, il servizio verrà invocato riportando i campi identificativi della sosta originaria e con importo e fine sosta opportunamente aggiornati (NOTA: intera sosta valida).

    parking mode

/parkings

post

Registra una nuova sosta.

Viene invocato dal dealer per registrare l'acquisto di una sosta da parte di un utente, limitatamente alle modalità start e bound.

Nel caso start sono obbligatori: uid, mode, fare, plate, start, created

Nel caso bound sono obbligatori: uid, mode, fare, plate, start, created, end, amount


Registrazione Standard

Quando è il Dealer che determina in autonomia l'importo della sosta.

NOTA: è a discrezione del dealer consentire o negare la sosta all'utente nel caso che il provider non dà risposta (timeout, internal-server-error). le API esposte dal dealer permettono di sincronizzare i sistemi in un secondo momento.


Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "provider": {
      "type": "string", "required": true,
      "description" : "Identificativo del gestore"
    },
    "token": {
      "type": "string", "required": true,
      "description" : "Token di autenticazione"
    },
    "invoked": {
      "type": "string", "required": true, "format": "date-time",
      "description" : "Timestamp della richiesta"
    },
    "parking": {
      "$ref" : "parking.schema.json", "required": true,
      "description" : "Informazioni della sosta da registrare o aggiornare"
    }
  }
}

Example:

{
  "provider": "providerCode",
  "token":    "token",
  "invoked":  "2016-08-26T08:00:01",
  "parking": {
    "dealer":  "dealerCode",
    "uid":     "parking-uid-1",
    "plate":   "SLW287R",
    "fare":    "fare-1",
    "amount":  2.0,
    "mode":    "bound",
    "start":   "2016-08-26T08:00:00",
    "end":     "2016-08-26T12:00:00",
    "created": "2016-08-26T08:00:00"
  }
}

HTTP status code 201

Created

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "dealer": {
      "type": "string", "required": true,
      "description" : "Identificativo del dealer"
    },
    "uid": {
      "type": "string", "required": true,
      "description" : "Identificativo unico della sosta sul sistema del dealer"
    },
    "mode": {
      "type": "string", "required": true,
      "enum": [ "start", "end", "bound", "extend", "refund" ],
      "description" : "Modalità di registrazione della sosta"
    },
    "plate": {
      "type": "string", "required": true
    },
    "fare": {
      "type": "string", "required": true
    },
    "amount": {
      "type": "number", "required": false
    },
    "start": {
      "type": "string", "required": true, "format": "date-time"
    },
    "end": {
      "type": "string", "required": false, "format": "date-time"
    },
    "created": {
      "type": "string", "required": true, "format": "date-time"
    }
  }
}

HTTP status code 401

Non autorizzato. Il richiedente non è un partner registrato o utilizza secrets non aggiornati (contattare l'amministratore della piattaforma)

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "401",
  "code": "401",
  "message": "Non autorizzato",
  "description": "Il richiedente non è un partner registrato o\\nutilizza secrets non aggiornati\\n(contattare l'amministratore della piattaforma)",
  "link": "http://hub.kiunsys.com/provider/v1/errors/401"
}

HTTP status code 403

Accesso negato. Il richiedente ha inviato una richiesta il cui invoked (timestamp richiesta) si scosta di più di 5 minuti (prima o dopo) rispetto al momento effettivo della chiamata al servizio. Le richieste fuori range sarranno rigettate.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "403",
  "code": "403-request-timestamp-overdue",
  "message": "Accesso negato, requestTimestamp non valido",
  "description": "Il richiedente ha inviato una richiesta il cui\\n_requestTimestamp_ si scosta di più di 5 minuti\\nrispetto al momento effettivo della chiamata al servizio.\\nLe richieste fuori range sono rigettate",
  "link": "http://hub.kiunsys.com/provider/v1/errors/403"
}

HTTP status code 422

Richiesta non valida. Il richiedente ha inviato una richiesta con dati mancanti o incoerenti.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "422",
  "code": "422-invalid-request",
  "message": "Richiesta non valida",
  "description": "Il richiedente ha inviato una richiesta\\nmancante di alcuni dati obbligatori",
  "link": "http://hub.kiunsys.com/provider/v1/errors/422"
}
put

Aggiorna una sosta.

Viene invocato dal dealer per

  • registrare il completamento della sosta, mode end (modello Sosta Aperta)
  • registrare l'aggiornamento di una sosta da parte di un utente, mode extend o refund (modello Sosta Delimitata).

Nel caso end, extend e refund sono obbligatori: uid, mode, fare, plate, start, end, amount, created


Aggiornamento Standard

Quando è il Dealer che determina in autonomia l'importo della sosta.


Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "provider": {
      "type": "string", "required": true,
      "description" : "Identificativo del gestore"
    },
    "token": {
      "type": "string", "required": true,
      "description" : "Token di autenticazione"
    },
    "invoked": {
      "type": "string", "required": true, "format": "date-time",
      "description" : "Timestamp della richiesta"
    },
    "parking": {
      "$ref" : "parking.schema.json", "required": true,
      "description" : "Informazioni della sosta da registrare o aggiornare"
    }
  }
}

Example:

{
  "provider": "provider",
  "token":    "token",
  "invoked":  "2016-08-26T12:00:01",
  "parking": {
    "dealer":  "dealerCode",
    "uid":     "parking-uid-1",
    "plate":   "SLW287R",
    "fare":    "fare-1",
    "amount":  2.0,
    "mode":    "end",
    "start":   "2016-08-26T08:00:00",
    "end":     "2016-08-26T12:00:00",
    "created": "2016-08-26T08:00:00"
  }
}

HTTP status code 200

Updated

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "dealer": {
      "type": "string", "required": true,
      "description" : "Identificativo del dealer"
    },
    "uid": {
      "type": "string", "required": true,
      "description" : "Identificativo unico della sosta sul sistema del dealer"
    },
    "mode": {
      "type": "string", "required": true,
      "enum": [ "start", "end", "bound", "extend", "refund" ],
      "description" : "Modalità di registrazione della sosta"
    },
    "plate": {
      "type": "string", "required": true
    },
    "fare": {
      "type": "string", "required": true
    },
    "amount": {
      "type": "number", "required": false
    },
    "start": {
      "type": "string", "required": true, "format": "date-time"
    },
    "end": {
      "type": "string", "required": false, "format": "date-time"
    },
    "created": {
      "type": "string", "required": true, "format": "date-time"
    }
  }
}

HTTP status code 401

Non autorizzato. Il richiedente non è un partner registrato o utilizza secrets non aggiornati (contattare l'amministratore della piattaforma)

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "401",
  "code": "401",
  "message": "Non autorizzato",
  "description": "Il richiedente non è un partner registrato o\\nutilizza secrets non aggiornati\\n(contattare l'amministratore della piattaforma)",
  "link": "http://hub.kiunsys.com/provider/v1/errors/401"
}

HTTP status code 403

Accesso negato. Il richiedente ha inviato una richiesta il cui invoked (timestamp richiesta) si scosta di più di 5 minuti (prima o dopo) rispetto al momento effettivo della chiamata al servizio. Le richieste fuori range sarranno rigettate.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "403",
  "code": "403-request-timestamp-overdue",
  "message": "Accesso negato, requestTimestamp non valido",
  "description": "Il richiedente ha inviato una richiesta il cui\\n_requestTimestamp_ si scosta di più di 5 minuti\\nrispetto al momento effettivo della chiamata al servizio.\\nLe richieste fuori range sono rigettate",
  "link": "http://hub.kiunsys.com/provider/v1/errors/403"
}

HTTP status code 422

Richiesta non valida. Il richiedente ha inviato una richiesta con dati mancanti o incoerenti.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "422",
  "code": "422-invalid-request",
  "message": "Richiesta non valida",
  "description": "Il richiedente ha inviato una richiesta\\nmancante di alcuni dati obbligatori",
  "link": "http://hub.kiunsys.com/provider/v1/errors/422"
}

Invoices (registrazione fattura)

servizio di registrazione delle fatture.

Le fatture possono essere di due tipi:

  1. Fatture NON elettroniche - il file trasmesso sarà un .pdf

    L'attributo status può essere omesso o assumere solo il valore:

    • paper (fattura non elettronica)


    L'attributo rejectedInvoice non è necessario.

  2. Fatture elettroniche - il file trasmesso sarà un .xml

    L'attributo status deve assumere un valore tra:

    • e_accepted (fattura accettata dallo SDI)
    • e_rejected (fattura scartata dallo SDI)
    • e_undelivered (fattura non recapitata all'utente finale).


    L'attributo rejectedInvoice specifica l'eventuale riferimento alla fattura scartata in caso di riemissione

Esempio (frammento):

// NON-elettronica      |   // elettronica             |   // elettronica (riemessa a fronte di uno scarto)
{                       |   {                          |   {
  ... ,                 |     ... ,                    |     ... ,
  "number": 2,          |     "number": 2,             |     "number": 2,
  "sectional": "MAG",   |     "sectional": "MAG",      |     "sectional": "MAG",
  "year": 2018,         |     "year": 2018,            |     "year": 2018,
  "status": "paper"     |     "status": "e_accepted"   |     "status": "e_accepted",
}                       |   }                          |     "rejectedInvoice": {
                        |                              |       "number": 1,
                        |                              |       "sectional": "MAG",
                        |                              |       "year": 2018
                        |                              |     }
                        |                              |   }

/invoices

post

Registra una fattura. Viene invocato dal dealer per registrare una fattura.

Body

Type: multipart/form-data

Form Parameters
  • file: required (file)

    il file della fattura da registrare

  • invoiceRegister: required (string)

    descrittore della registrazione fattura (json)

    Example:

    {
      "provider": "KIUNSYS",
      "token":    "token",
      "invoked":  "2017-12-04T10:00:00",
      "invoice": {
        "dealer":    "DEALER_CODE",
        "providerFiscalCode": "IT01656550702",
        "number":    "2",
        "sectional": "TEST",
        "year":      "2017",
        "date":      "2017-12-04T10:00:00",
        "subtotal":  4.67,
        "vatRate":   22,
        "vatAmount": 1.03,
        "total":     5.70,
        "billTo":    "Nome o RagioneSociale del destinatario",
        "billFiscalCode": "CodiceFiscale o PartitaIVA del destinatario",
        "billingAddress": {
          "street":     "via Umberto Forti",
          "number":     "6",
          "city":       "Pisa",
          "country":    "Italia",
          "province":   "PI",
          "postalCode": "56121"
        },
        "status": "accepted",
        "rejectedInvoice": {
          "number":    "1",
          "sectional": "TEST",
          "year":      "2017"
        },
        "items": [
          {"parkingUid": "121", "price": 1.20, "description": "sosta in ZCS-1 a rotazione veloce, ore 01:00"},
          {"parkingUid": "122", "price": 1.80, "description": "sosta in ZCS-1 a rotazione veloce, ore 01:30"},
          {"parkingUid": "123", "price": 2.70, "description": "sosta in ZCS-1 a rotazione veloce, ore 02:15"}
        ]
      }
    }
    

HTTP status code 201

Created

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "dealer": {
      "type": "string", "required": true,
      "description": "Identificativo del dealer (emittente)"
    },
    "providerFiscalCode": {
      "type": "string", "required": true,
      "description": "CodiceFiscale o PartitaIVA del destinatario"
    },
    "billTo": {
      "type": "string", "required": true,
      "description": "RagioneSociale o Nominativo del destinatario"
    },
    "billFiscalCode": {
      "type": "string", "required": true,
      "description": "CodiceFiscale o PartitaIVA del destinatario"
    },
    "billingAddress": {
      "$ref": "address.schema.json", "required": true,
      "description": "Indirizzo del destinatario"
    },
    "number": {
      "type": "string", "required": true,
      "description": "Numero fattura"
    },
    "sectional": {
      "type": "string", "required": false,
      "description": "Sezionale fattura"
    },
    "year": {
      "type": "string", "required": true,
      "description": "Anno fattura"
    },
    "date": {
      "type": "string", "required": true,  "format": "date",
      "description": "Data fattura"
    },
    "subtotal": {
      "type": "number", "required": true,
      "description": "Imponibile fattura"
    },
    "vatRate": {
      "type": "number", "required": true,
      "description": "IVA %"
    },
    "vatAmount": {
      "type": "number", "required": true,
      "description": "Importo IVA"
    },
    "total": {
      "type": "number", "required": true,
      "description": "Totale fattura"
    },
    "status": {
      "type": "string", "required": false,
      "enum": [ "paper", "e_accepted", "e_rejected", "e_undelivered" ], "default": "paper",
      "description" : "Stato della fattura elettronica"
    },
    "rejectedInvoice": {
      "$ref": "invoiceReference.schema.json", "required": false,
      "description": "Dati della eventuale relativa fattura scartata"
    },
    "items": {
      "$ref": "invoiceItems.schema.json", "required": false,
      "description": "Soste"
    }
  }
}

HTTP status code 401

Non autorizzato. Il richiedente non è un partner registrato o utilizza secrets non aggiornati (contattare l'amministratore della piattaforma)

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "401",
  "code": "401",
  "message": "Non autorizzato",
  "description": "Il richiedente non è un partner registrato o\\nutilizza secrets non aggiornati\\n(contattare l'amministratore della piattaforma)",
  "link": "http://hub.kiunsys.com/provider/v1/errors/401"
}

HTTP status code 403

Accesso negato. Il richiedente ha inviato una richiesta il cui invoked (timestamp richiesta) si scosta di più di 5 minuti (prima o dopo) rispetto al momento effettivo della chiamata al servizio. Le richieste fuori range sarranno rigettate.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "403",
  "code": "403-request-timestamp-overdue",
  "message": "Accesso negato, requestTimestamp non valido",
  "description": "Il richiedente ha inviato una richiesta il cui\\n_requestTimestamp_ si scosta di più di 5 minuti\\nrispetto al momento effettivo della chiamata al servizio.\\nLe richieste fuori range sono rigettate",
  "link": "http://hub.kiunsys.com/provider/v1/errors/403"
}

HTTP status code 422

Richiesta non valida. Il richiedente ha inviato una richiesta con dati mancanti o incoerenti.

Body

Type: application/json

Schema:

{
  "$schema": "http://json-schema.org/draft-03/schema",
  "type": "object",
  "properties": {
    "status": {"type": "string", "required": true},
    "code": {
      "enum": [
        "401",
        "403-request-timestamp-overdue",
        "403-parking-created-overdue",
        "422-invalid-request",
        "422-amount-required",
        "422-start-required"
      ],
      "required": true
    },
    "message":     {"type": "string", "required": true},
    "description": {"type": "string", "required": false},
    "link":        {"type": "string", "required": false}
  }
}

Example:

{
  "status": "422",
  "code": "422-invalid-request",
  "message": "Richiesta non valida",
  "description": "Il richiedente ha inviato una richiesta\\nmancante di alcuni dati obbligatori",
  "link": "http://hub.kiunsys.com/provider/v1/errors/422"
}