Swift
You are reading an outdated document
Get the latest developer guides on Fynd Partners Help
How to install Swift FDK Client
- Add
pod 'FDKClient', :git => 'https://github.com/gofynd/fdk-client-swift'
- Do
pod install
- Add
import FDKClient
to the Swift files where you will be using the client - Start integrating
Sample Usage - PublicClient
let config = PublicConfig()
let publicClient = PublicClient(config: config)
publicClient.webhook.fetchAllWebhookEvents() { (webhookEvents, error) in
if let webhookEvents = webhookEvents {
print(webhookEvents.debugDescription)
} else if let error = error {
print(error.message)
}
}
Sample Usage - ApplicationClient
guard let config = ApplicationConfig(
applicationId: "YOUR_APPLICATION_ID",
applicationToken: "YOUR_APPLICATION_TOKEN"
) {
return
}
let applicationClient = ApplicationClient(config: config)
applicationClient.catalog.getProductDetailBySlug(slug: "product-slug") { (product, error) in
if let product = product {
print(product.name)
} else if let error = error {
print(error.message)
}
}
Sample Usage - PlatformClient
guard let config = PlatformConfig(
companyId: "COMPANY_ID",
apiKey: "API_KEY",
apiSecret: "API_SECRET"
) {
return
}
let platformClient = PlatformClient(config: config)
platformClient.catalog.getCompanyDetail { (response, error) in
if let companyDetail = response {
print("Name of the company \(companyDetail.name)")
} else if let error = error {
print(error.message)
}
}