The new SDK wraps all responses in a typed response object that includes both the API response and HTTP metadata:
// Old SDK
const { data, meta } = await crm.contactsAll();
console.log(data[0].id);
// New SDK
const result = await apideck.crm.contacts.list();
console.log(result.getContactsResponse.data[0].id);
// Access HTTP metadata
console.log(result.httpMeta.response.status);
console.log(result.httpMeta.response.headers);
Every response includes httpMeta which provides access to the raw HTTP request and response:
The
httpMeta
object is essential because it provides detailed information about the HTTP request and response, which can be crucial for debugging and logging purposes.
The new SDK uses RFC3339 format for all date and date-time fields. This ensures consistent date handling across all API operations. The SDK provides an
RFCDate
helper to make working with dates easier.
// Old SDK
const result = await crm.opportunitiesAll({
updated_since: "2020-09-30"
});
// New SDK - Using native Date
const result = await apideck.crm.opportunities.list({
serviceId: "salesforce",
filter: {
updatedSince: new Date("2020-09-30T07:43:32.000Z") // RFC3339 format
}
});
// New SDK - Using RFCDate helper
import { RFCDate } from "@apideck/unify";
const result = await apideck.crm.opportunities.list({
serviceId: "salesforce",
filter: {
// RFCDate for date-only fields (automatically handles timezone)
updatedSince: new RFCDate("2020-09-30")
}
});
// Example setting dates in create operations
const opportunity = await apideck.crm.opportunities.create({
serviceId: "salesforce",
opportunity: {
title: "New Deal",
// Use RFCDate for date-only fields
closeDate: new RFCDate("2024-12-31"),
}
});
The SDK will automatically validate that dates are in the correct format and will throw a
SDKValidationError
if an invalid date format is provided.
Additional features in the new SDK
The retry configuration allows you to specify how the SDK should handle retries for failed requests. You can configure the retry strategy, initial interval, maximum interval, exponent, and maximum elapsed time.