goshippo / shippo-javascript-sdk

MIT License
7 stars 2 forks source link

How can i pass query param in shippo.orders.list(1,25,options) for getting only PAID orders? #76

Closed jigneshkmistry closed 4 months ago

jigneshkmistry commented 4 months ago

How can i pass query param in shippo.orders.list(1,25,options) for getting only PAID orders?

Currently I am passing as follow for get only PAID orders but didnt work.

const result = await shippo.orders.list(1,25,{ orderStatus: "PAID"});

vkkis93 commented 4 months ago

@jigneshkmistry it does not support filtering at all

shippo-lueders commented 4 months ago

the API does support filtering - https://docs.goshippo.com/docs/orders/orders/#filter-an-order-list

it's just missing from the SDK, should have an update by tomorrow

shippo-lueders commented 4 months ago

fixed in https://www.npmjs.com/package/shippo/v/2.6.1

example code

const response = await sdk.orders.list({
    page: 1,
    results: 25,
    orderStatus: [OrderStatusEnum.Paid]
});

order status along with the other available filters are documented here

jigneshkmistry commented 4 months ago

I appreciate your instant update to the library. The new OrderStatus constants are exactly what we needed. Thanks for the quick response!

jigneshkmistry commented 4 months ago

@shippo-lueders Recently its working fine as follow code : const result = await shippo.orders.list({ page: 1, results: 25, orderStatus: [orderStatusEnum.PAID] });

But now i am getting following exception :

Error in API :{"name":"SDKValidationError","cause":{"issues":[{"code":"invalid_type","expected":"string","received":"object","path":["results",3,"transactions",0],"message":"Expected string, received object"}],"name":"ZodError"},"rawValue":{"results":[{"object_id":"8d3066e841294f7c9fdb51b9e59ce759","order_number":"#1068","order_status":"PAID","placed_at":"2016-09-23T01:28:12Z","object_owner":"jigneshkmistry@gmail.com","to_address":{"object_created":"2024-07-03T05:42:00.068Z","object_updated":"2024-07-03T05:42:00.068Z","object_id":"c84003f7277249979bdc9eb4ec7663f0","is_complete":true,"validation_results":{},"object_owner":"jigneshkmistry@gmail.com","name":"Mr Hippo","company":"Shippo","street_no":"","street1":"965 Mission St.","street2":"#480","street3":"","city":"San Francisco","state":"CA","zip":"94103","country":"US","phone":"4151234567","email":"mrhippo@goshippo.com","metadata":"","test":true},"shop_app":"Shippo","weight":"0.40","weight_unit":"lb","transactions":[],"total_tax":"0.00","total_price":"24.93","subtotal_price":"12.10","currency":"USD","shipping_method":"USPS First Class Package International Service","shipping_cost":"12.83","shipping_cost_currency":"USD","line_items":[],"test":true},{"object_id":"4efd3a04a43a482f81e3005e817657a2","order_number":"#1068","order_status":"PAID","placed_at":"2016-09-23T01:28:12Z","object_owner":"jigneshkmistry@gmail.com","to_address":{"object_created":"2024-07-09T11:37:46.169Z","object_updated":"2024-07-09T11:37:46.169Z","object_id":"69dc54d103ab43018ff26ad127571b35","is_complete":true,"validation_results":{},"object_owner":"jigneshkmistry@gmail.com","name":"Mr Hippo","company":"Shippo","street_no":"","street1":"965 Mission St.","street2":"#480","street3":"","city":"San Francisco","state":"CA","zip":"94103","country":"US","phone":"4151234567","email":"mrhippo@goshippo.com","metadata":"","test":true},"shop_app":"Shippo","weight":"0.40","weight_unit":"lb","transactions":[],"total_tax":"0.00","total_price":"24.93","subtotal_price":"12.10","currency":"USD","shipping_method":"USPS First Class Package International Service","shipping_cost":"12.83","shipping_cost_currency":"USD","line_items":[],"test":true},{"object_id":"ecf00bfb0f444b27a6b0df7b6a5506e5","order_number":"#1068","order_status":"PAID","placed_at":"2016-09-23T01:28:12Z","object_owner":"jigneshkmistry@gmail.com","to_address":{"object_created":"2024-07-09T11:38:38.645Z","object_updated":"2024-07-09T11:38:38.645Z","object_id":"2ebb15b3fec3487ebc3e17b76f50ecb6","is_complete":true,"validation_results":{},"object_owner":"jigneshkmistry@gmail.com","name":"Mr Hippo","company":"Shippo","street_no":"","street1":"965 Mission St.","street2":"#480","street3":"","city":"San Francisco","state":"CA","zip":"94103","country":"US","phone":"4151234567","email":"mrhippo@goshippo.com","metadata":"","test":true},"from_address":{"object_created":"2024-07-09T11:38:38.653Z","object_updated":"2024-07-09T11:38:38.653Z","object_id":"448a4e9718704ee7a553bbebefc825e7","is_complete":true,"validation_results":{},"object_owner":"jigneshkmistry@gmail.com","name":"Mr Hippo","company":"Shippo","street_no":"","street1":"965 Mission St.","street2":"#480","street3":"","city":"San Francisco","state":"CA","zip":"94103","country":"US","phone":"4151234567","email":"mrhippo@goshippo.com","metadata":"","test":true},"shop_app":"Shippo","weight":"0.40","weight_unit":"lb","transactions":[],"total_tax":"0.00","total_price":"24.93","subtotal_price":"12.10","currency":"USD","shipping_method":"USPS First Class Package International Service","shipping_cost":"12.83","shipping_cost_currency":"USD","line_items":[],"test":true},{"object_id":"0257d7b2e6454807bb08705f4c9754e3","order_number":"#1111","order_status":"PAID","placed_at":"2016-09-23T01:28:12Z","object_owner":"jigneshkmistry@gmail.com","to_address":{"object_created":"2024-07-09T12:37:05.136Z","object_updated":"2024-07-09T12:37:05.136Z","object_id":"1aa53b46e7454d949d7734ecd167bc19","is_complete":true,"validation_results":{},"object_owner":"jigneshkmistry@gmail.com","name":"Mr Hippo","company":"Shippo","street_no":"","street1":"215 Clayton St.","street2":"","street3":"","city":"San Francisco","state":"CA","zip":"94117","country":"US","phone":"15553419393","email":"shippotle@shippo.com","metadata":"","test":true},"shop_app":"Shippo","weight":"0.40","weight_unit":"lb","transactions":[{"object_id":"acfe7f52f8834d198aadf375c1b1b979","object_status":"SUCCESS","label_url":"https://deliver.goshippo.com/acfe7f52f8834d198aadf375c1b1b979.pdf?Expires=1752064910&Signature=CWKEneKQ943XyT7uifjgqHtDN97OuB1Mp2u4N7hJamEyA--tFKkk5sDMeA4bbv29sbaC6XG7vSUNC7GgOW7CTe9-Lj9s5RESdWoFe5J4jqd4NF1NM~0aDDYQHQkqyhcNgvEd8MxCxFBtnVeXt5DPEVqANiEx9hBfzoKJGftxGbhRPMa7rrmf50LrtYT9fs7x4pk6NJAht5lTL97UrAb~Wjnl-KlTPZcDVGvIonPWu9ZB7T8wqa8g7IA~7hDt7Z~Mor9ZkUitw2lOq3ngBUFm7VLOOMj81Z9udVfJbZUWJC2bWTjZP71yRck5N2ydfgEyutxhAxGJxoc7cXja-1LiSw__&Key-Pair-Id=APKAJRICFXQ2S4YUQRSQ","tracking_number":"92055903470167000000000011","test":true}],"total_tax":"0.00","total_price":"24.93","subtotal_price":"12.10","currency":"USD","shipping_method":"USPS First Class Package","shipping_cost":"12.83","shipping_cost_currency":"USD","line_items":[{"object_id":"07ce0935b1f34fbc9d812cd91f134925","title":"Hippo Magazines","sku":"HM-123","quantity":1,"total_price":"12.10","currency":"USD","weight":"0.4000","weight_unit":"lb"}],"test":true}]}}

jfriedr commented 4 months ago

@jigneshkmistry I've gone ahead and created a new issue for this new exception and will close this one. Will share updates in the new issue:

https://github.com/goshippo/shippo-javascript-sdk/issues/80