@flexops/sdk 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -20
- package/dist/index.d.mts +40 -6
- package/dist/index.d.ts +40 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,27 +52,20 @@ await client.auth.login({
|
|
|
52
52
|
### Rate Shopping
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
+
const rateRequest = {
|
|
56
|
+
origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
|
|
57
|
+
destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
|
|
58
|
+
package: { weight: 16, weightUnit: 'oz' },
|
|
59
|
+
};
|
|
60
|
+
|
|
55
61
|
// Get all available rates
|
|
56
|
-
const rates = await client.shipping.getRates(
|
|
57
|
-
fromZip: '10001',
|
|
58
|
-
toZip: '90210',
|
|
59
|
-
weight: 16,
|
|
60
|
-
weightUnit: 'oz',
|
|
61
|
-
});
|
|
62
|
+
const rates = await client.shipping.getRates(rateRequest);
|
|
62
63
|
|
|
63
64
|
// Get the single cheapest rate
|
|
64
|
-
const cheapest = await client.shipping.getCheapestRate(
|
|
65
|
-
fromZip: '10001',
|
|
66
|
-
toZip: '90210',
|
|
67
|
-
weight: 16,
|
|
68
|
-
});
|
|
65
|
+
const cheapest = await client.shipping.getCheapestRate(rateRequest);
|
|
69
66
|
|
|
70
67
|
// Get the single fastest rate
|
|
71
|
-
const fastest = await client.shipping.getFastestRate(
|
|
72
|
-
fromZip: '10001',
|
|
73
|
-
toZip: '90210',
|
|
74
|
-
weight: 16,
|
|
75
|
-
});
|
|
68
|
+
const fastest = await client.shipping.getFastestRate(rateRequest);
|
|
76
69
|
```
|
|
77
70
|
|
|
78
71
|
### Create a Shipping Label
|
|
@@ -261,13 +254,13 @@ Every SDK method is a thin wrapper around the FlexOps REST API. If you want to v
|
|
|
261
254
|
|
|
262
255
|
```bash
|
|
263
256
|
# Shop rates across all connected carriers
|
|
264
|
-
curl -X POST https://gateway.flexops.io/api/
|
|
257
|
+
curl -X POST https://gateway.flexops.io/api/shipping/rates \
|
|
265
258
|
-H "X-API-Key: fxk_live_..." \
|
|
266
259
|
-H "Content-Type: application/json" \
|
|
267
260
|
-d '{
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"
|
|
261
|
+
"origin": {"addressLine1": "123 Main St", "city": "New York", "stateProvince": "NY", "postalCode": "10001", "countryCode": "US"},
|
|
262
|
+
"destination": {"addressLine1": "456 Oak Ave", "city": "Los Angeles", "stateProvince": "CA", "postalCode": "90210", "countryCode": "US"},
|
|
263
|
+
"package": {"weight": 16, "weightUnit": "oz"}
|
|
271
264
|
}'
|
|
272
265
|
|
|
273
266
|
# Create a label
|
package/dist/index.d.mts
CHANGED
|
@@ -76,7 +76,20 @@ interface WorkspaceMember {
|
|
|
76
76
|
role: 'Owner' | 'Admin' | 'Member' | 'Guest';
|
|
77
77
|
joinedAt: string;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
type RateRequest = CanonicalRateRequest | LegacyRateRequest;
|
|
80
|
+
interface CanonicalRateRequest {
|
|
81
|
+
origin: ShippingAddress;
|
|
82
|
+
destination: ShippingAddress;
|
|
83
|
+
package: ShippingPackage;
|
|
84
|
+
carriers?: string[];
|
|
85
|
+
serviceLevels?: string[];
|
|
86
|
+
shipDate?: string;
|
|
87
|
+
includeInsurance?: boolean;
|
|
88
|
+
declaredValue?: number;
|
|
89
|
+
currency?: string;
|
|
90
|
+
}
|
|
91
|
+
/** @deprecated Use CanonicalRateRequest. The legacy shape is retained for source compatibility. */
|
|
92
|
+
interface LegacyRateRequest {
|
|
80
93
|
fromZip: string;
|
|
81
94
|
toZip: string;
|
|
82
95
|
weight: number;
|
|
@@ -88,6 +101,28 @@ interface RateRequest {
|
|
|
88
101
|
packageType?: string;
|
|
89
102
|
carriers?: string[];
|
|
90
103
|
}
|
|
104
|
+
interface ShippingAddress {
|
|
105
|
+
name?: string;
|
|
106
|
+
company?: string;
|
|
107
|
+
addressLine1: string;
|
|
108
|
+
addressLine2?: string;
|
|
109
|
+
city: string;
|
|
110
|
+
stateProvince: string;
|
|
111
|
+
postalCode: string;
|
|
112
|
+
countryCode?: string;
|
|
113
|
+
phone?: string;
|
|
114
|
+
email?: string;
|
|
115
|
+
isResidential?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface ShippingPackage {
|
|
118
|
+
weight: number;
|
|
119
|
+
weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
120
|
+
length?: number;
|
|
121
|
+
width?: number;
|
|
122
|
+
height?: number;
|
|
123
|
+
dimensionUnit?: 'in' | 'cm';
|
|
124
|
+
predefinedPackage?: string;
|
|
125
|
+
}
|
|
91
126
|
interface ShippingRate {
|
|
92
127
|
carrierCode: string;
|
|
93
128
|
carrierName: string;
|
|
@@ -1160,10 +1195,9 @@ declare class ReportsResource {
|
|
|
1160
1195
|
*
|
|
1161
1196
|
* // Get shipping rates
|
|
1162
1197
|
* const rates = await client.shipping.getRates({
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* weight: 16,
|
|
1166
|
-
* weightUnit: 'oz',
|
|
1198
|
+
* origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
|
|
1199
|
+
* destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
|
|
1200
|
+
* package: { weight: 16, weightUnit: 'oz' },
|
|
1167
1201
|
* });
|
|
1168
1202
|
*
|
|
1169
1203
|
* // Create a label with the cheapest rate
|
|
@@ -1232,4 +1266,4 @@ declare class FlexOps {
|
|
|
1232
1266
|
setApiKey(key: string): void;
|
|
1233
1267
|
}
|
|
1234
1268
|
|
|
1235
|
-
export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
|
|
1269
|
+
export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingAddress, type ShippingPackage, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,7 +76,20 @@ interface WorkspaceMember {
|
|
|
76
76
|
role: 'Owner' | 'Admin' | 'Member' | 'Guest';
|
|
77
77
|
joinedAt: string;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
type RateRequest = CanonicalRateRequest | LegacyRateRequest;
|
|
80
|
+
interface CanonicalRateRequest {
|
|
81
|
+
origin: ShippingAddress;
|
|
82
|
+
destination: ShippingAddress;
|
|
83
|
+
package: ShippingPackage;
|
|
84
|
+
carriers?: string[];
|
|
85
|
+
serviceLevels?: string[];
|
|
86
|
+
shipDate?: string;
|
|
87
|
+
includeInsurance?: boolean;
|
|
88
|
+
declaredValue?: number;
|
|
89
|
+
currency?: string;
|
|
90
|
+
}
|
|
91
|
+
/** @deprecated Use CanonicalRateRequest. The legacy shape is retained for source compatibility. */
|
|
92
|
+
interface LegacyRateRequest {
|
|
80
93
|
fromZip: string;
|
|
81
94
|
toZip: string;
|
|
82
95
|
weight: number;
|
|
@@ -88,6 +101,28 @@ interface RateRequest {
|
|
|
88
101
|
packageType?: string;
|
|
89
102
|
carriers?: string[];
|
|
90
103
|
}
|
|
104
|
+
interface ShippingAddress {
|
|
105
|
+
name?: string;
|
|
106
|
+
company?: string;
|
|
107
|
+
addressLine1: string;
|
|
108
|
+
addressLine2?: string;
|
|
109
|
+
city: string;
|
|
110
|
+
stateProvince: string;
|
|
111
|
+
postalCode: string;
|
|
112
|
+
countryCode?: string;
|
|
113
|
+
phone?: string;
|
|
114
|
+
email?: string;
|
|
115
|
+
isResidential?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface ShippingPackage {
|
|
118
|
+
weight: number;
|
|
119
|
+
weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
|
|
120
|
+
length?: number;
|
|
121
|
+
width?: number;
|
|
122
|
+
height?: number;
|
|
123
|
+
dimensionUnit?: 'in' | 'cm';
|
|
124
|
+
predefinedPackage?: string;
|
|
125
|
+
}
|
|
91
126
|
interface ShippingRate {
|
|
92
127
|
carrierCode: string;
|
|
93
128
|
carrierName: string;
|
|
@@ -1160,10 +1195,9 @@ declare class ReportsResource {
|
|
|
1160
1195
|
*
|
|
1161
1196
|
* // Get shipping rates
|
|
1162
1197
|
* const rates = await client.shipping.getRates({
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* weight: 16,
|
|
1166
|
-
* weightUnit: 'oz',
|
|
1198
|
+
* origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
|
|
1199
|
+
* destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
|
|
1200
|
+
* package: { weight: 16, weightUnit: 'oz' },
|
|
1167
1201
|
* });
|
|
1168
1202
|
*
|
|
1169
1203
|
* // Create a label with the cheapest rate
|
|
@@ -1232,4 +1266,4 @@ declare class FlexOps {
|
|
|
1232
1266
|
setApiKey(key: string): void;
|
|
1233
1267
|
}
|
|
1234
1268
|
|
|
1235
|
-
export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
|
|
1269
|
+
export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingAddress, type ShippingPackage, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
|
package/package.json
CHANGED