smartystreets / smartystreets-ios-sdk

The official client libraries for accessing SmartyStreets APIs from iOS
https://smartystreets.com/docs/sdk/ios
Apache License 2.0
7 stars 7 forks source link

USReverseGeoAddress state_abbreviation -> stateAbbreviation #30

Closed dpolkovnikov closed 1 year ago

dpolkovnikov commented 1 year ago

after the SmartyStreets API response transformation iOS mobile was not refactored in a proper way. While decoding JSON response, the result always has stateAbbreviation as nil

adding proper enum keys config, can easily fix this issue. Proper version is provided below

smartystreets-ios-sdk/Sources/SmartyStreets/USReverseGeo/USReverseGeoAddress.swift

import Foundation

@objcMembers public class USReverseGeoAddress: NSObject, Codable {
    public var street:String?
    public var city:String?
    public var stateAbbreviation:String?
    public var zipcode:String?

    enum CodingKeys: String, CodingKey {
        case street = "street"
        case city = "city"
        case stateAbbreviation = "state_abbreviation"
        case zipcode = "zipcode"
    }

    init(dictionary: NSDictionary) {
        self.street = dictionary["street"] as? String
        self.city = dictionary["city"] as? String
        self.stateAbbreviation = dictionary["state_abbreviation"] as? String
        self.zipcode = dictionary["zipcode"] as? String
    }
}
RyanLCox1 commented 1 year ago

Thank you! This is fixed in the latest commit.