I am getting an error trying to fetch data using Square's customer API.
debugDescription: "No value associated with key CodingKeys(stringValue: \"customer\", intValue: nil) (\"customer\").", underlyingError: nil))
Here is an example of the returned data:
{
"customers": [
{
"id": "MJAG403GV96BX367R56N4FZJTG",
"created_at": "2021-11-07T04:18:21.42Z",
"updated_at": "2021-11-07T23:10:20Z",
"given_name": "Test",
"family_name": "Customer",
"email_address": "email@email.com",
"address": {
"address_line_1": "123 Any St",
"locality": "Somewhere",
"administrative_district_level_1": "CA",
"postal_code": "55555"
},
"phone_number": "+12025551234",
"preferences": {
"email_unsubscribed": false
},
"creation_source": "DIRECTORY",
"segment_ids": [
"MLPYEYRXNK0KW.REACHABLE"
],
"version": 1
}
]
}
And this is what I have for the model currently:
struct arrayOfCustomers: Codable {
var customer: [Customer]
}
struct Customer: Codable, Identifiable {
var id: String
var created_at: Date
var updated_at: Date
var given_name, family_name, email_address, phone_number: String?
struct address: Codable {
var address_line_1, locality, administrative_district_level_1, postalCode: String?
var country: String?
}
}