BokaMera.API.Host

<back to all web services

GeoDataCitiesQuery

The following routes are available for this service:
GET/geodata/{CountryId}/cities/Get all cities for a specific countryGet all information stored on the customer
import Foundation
import ServiceStack

public class GeoDataCitiesQuery : QueryDb2<City, GeoDataCitiesQueryResponse>
{
    /**
    * Enter the country id you want to search cities. Example SE for Sweden.
    */
    // @ApiMember(Description="Enter the country id you want to search cities. Example SE for Sweden.", IsRequired=true, ParameterType="path")
    public var countryId:String

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case countryId
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        countryId = try container.decodeIfPresent(String.self, forKey: .countryId)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if countryId != nil { try container.encode(countryId, forKey: .countryId) }
    }
}

public class City : BaseModel
{
    // @Ignore()
    public var longitude:Double

    // @Ignore()
    public var latitude:Double

    // @Required()
    public var name:String?

    // @Required()
    public var country:String?

    public var iso2:String
    // @Required()
    public var admin:String?

    public var capital:String
    public var population:Int?
    public var populationProper:Int?
    public var modifiedDate:Date?
    // @Required()
    public var id:String?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case longitude
        case latitude
        case name
        case country
        case iso2
        case admin
        case capital
        case population
        case populationProper
        case modifiedDate
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        longitude = try container.decodeIfPresent(Double.self, forKey: .longitude)
        latitude = try container.decodeIfPresent(Double.self, forKey: .latitude)
        name = try container.decodeIfPresent(String.self, forKey: .name)
        country = try container.decodeIfPresent(String.self, forKey: .country)
        iso2 = try container.decodeIfPresent(String.self, forKey: .iso2)
        admin = try container.decodeIfPresent(String.self, forKey: .admin)
        capital = try container.decodeIfPresent(String.self, forKey: .capital)
        population = try container.decodeIfPresent(Int.self, forKey: .population)
        populationProper = try container.decodeIfPresent(Int.self, forKey: .populationProper)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        id = try container.decodeIfPresent(String.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if longitude != nil { try container.encode(longitude, forKey: .longitude) }
        if latitude != nil { try container.encode(latitude, forKey: .latitude) }
        if name != nil { try container.encode(name, forKey: .name) }
        if country != nil { try container.encode(country, forKey: .country) }
        if iso2 != nil { try container.encode(iso2, forKey: .iso2) }
        if admin != nil { try container.encode(admin, forKey: .admin) }
        if capital != nil { try container.encode(capital, forKey: .capital) }
        if population != nil { try container.encode(population, forKey: .population) }
        if populationProper != nil { try container.encode(populationProper, forKey: .populationProper) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

public class BaseModel : Codable
{
    required public init(){}
}

public class GeoDataCitiesQueryResponse : Codable
{
    public var id:String
    public var city:String
    public var longitude:String
    public var latitude:String
    public var country:String
    public var iso2:String
    public var admin:String
    public var capital:String
    public var population:Int?
    public var populationProper:Int?

    required public init(){}
}

public class AccessKeyTypeResponse : Codable
{
    public var id:Int
    public var keyType:String
    public var Description:String

    required public init(){}
}


Swift GeoDataCitiesQuery DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /geodata/{CountryId}/cities/ HTTP/1.1 
Host: api.bokamera.se 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfGeoDataCitiesQueryResponseWg5EthtI xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Offset>0</Offset>
  <Total>0</Total>
  <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
    <d2p1:GeoDataCitiesQueryResponse>
      <d2p1:Admin>String</d2p1:Admin>
      <d2p1:Capital>String</d2p1:Capital>
      <d2p1:City>String</d2p1:City>
      <d2p1:Country>String</d2p1:Country>
      <d2p1:Id>00000000-0000-0000-0000-000000000000</d2p1:Id>
      <d2p1:Iso2>String</d2p1:Iso2>
      <d2p1:Latitude>String</d2p1:Latitude>
      <d2p1:Longitude>String</d2p1:Longitude>
      <d2p1:Population>0</d2p1:Population>
      <d2p1:PopulationProper>0</d2p1:PopulationProper>
    </d2p1:GeoDataCitiesQueryResponse>
  </Results>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</QueryResponseOfGeoDataCitiesQueryResponseWg5EthtI>