Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Last active September 22, 2019 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertmryan/d34c8c5499aa94ee9db05a619219e08f to your computer and use it in GitHub Desktop.
Save robertmryan/d34c8c5499aa94ee9db05a619219e08f to your computer and use it in GitHub Desktop.
struct Industry: Encodable {
let industryTypeCode: String
}
struct Company: Encodable {
let companyName: String
let cinNumber: String
let isListed: Bool
let industryType: [Industry]
}
struct Address: Encodable {
let address: String
let countryCode: String
}
struct RequestPayload: Encodable {
let basicDetail: Company
let addressDetail: Address
}
func sendRequest() {
let industries = [Industry(industryTypeCode: "4AC0C192"), Industry(industryTypeCode: "2E128A3A")]
let basics = Company(companyName: "Abhishek", cinNumber: "1234565", isListed: false, industryType: industries)
let address = Address(address: "dfd\ndf", countryCode: "050822CF")
let requestPayload = RequestPayload(basicDetail: basics, addressDetail: address)
AF.request(url, method: .post, parameters: requestPayload, encoder: JSONParameterEncoder.default)
.responseJSON { response in
switch response.result {
case .success(let value):
print(value)
case .failure(let error):
print(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment