| PUT | /tabelle/comuni/ | ||
|---|---|---|---|
| PUT,GET | /tabelle/comuni/{Id} | ||
| PUT,GET | /tabelle/comuni/codiceexport/{CodiceExport} |
import Foundation
import ServiceStack
public class Comune : Codable
{
public var codiceExport:String?
public var id:Int?
public var denominazione:String?
public var cap:String?
public var provincia:String?
public var zona:FK_Zona?
public var isEsclusoDaListe:Bool?
public var codiceISTAT:String?
public var durezzaTotaleAcqua:OptionalNullableDouble?
public var tipoRCEE:OptionalNullableInteger?
required public init(){}
}
public class FK_Zona : FK, IUniqueSigla, IUniqueDescrizione
{
public var sigla:String?
public var descrizione:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case sigla
case descrizione
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
sigla = try container.decodeIfPresent(String.self, forKey: .sigla)
descrizione = try container.decodeIfPresent(String.self, forKey: .descrizione)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if sigla != nil { try container.encode(sigla, forKey: .sigla) }
if descrizione != nil { try container.encode(descrizione, forKey: .descrizione) }
}
}
public class FK : Codable
{
public var id:Int?
required public init(){}
}
public class OptionalNullableDouble : Optional<Double>
{
required public init(){ super.init() }
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}
}
public class Optional<T : Codable> : Codable
{
public var value:String?
required public init(){}
}
public class OptionalNullableInteger : Optional<Int>
{
required public init(){ super.init() }
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /tabelle/comuni/ HTTP/1.1
Host: unico3.link.api
Accept: application/json
Content-Type: application/json
Content-Length: length
{"CodiceExport":"String","Id":0,"Denominazione":"String","CAP":"String","Provincia":"String","Zona":{"Sigla":"String","Descrizione":"String","Id":0},"IsEsclusoDaListe":false,"CodiceISTAT":"String","DurezzaTotaleAcqua":{"Value":0},"TipoRCEE":{"Value":0}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"CodiceExport":"String","Id":0,"Denominazione":"String","CAP":"String","Provincia":"String","Zona":{"Sigla":"String","Descrizione":"String","Id":0},"IsEsclusoDaListe":false,"CodiceISTAT":"String","DurezzaTotaleAcqua":{"Value":0},"TipoRCEE":{"Value":0}}