voucherifyio / voucherify-dotNET-sdk

.Net SDK for Voucherify - coupons, vouchers, promo codes http://www.voucherify.io
http://www.voucherify.io
MIT License
12 stars 16 forks source link

Empty Redemption ID is handled incorrectly #60

Closed a-martynovich closed 4 years ago

a-martynovich commented 4 years ago

Simple code snippet:

using Queries = Voucherify.DataModel.Queries;
using Contexts = Voucherify.DataModel.Contexts;
// ...
var _api = new Voucherify.Api(applicationId, secretKey).WithSSL();
await _api.Redemptions.Rollback("", new Queries.RedemptionRollback(), new Contexts.RedemptionRollback());

This throws VoucherifyError[code=404, key=', message='API endpoint does not exist.', details='']

The reason for that is because the empty string is inserted into the URL as-is, resulting in such URL: https://api.voucherify.io/v1/redemptions//rollback which effectively means https://api.voucherify.io/v1/redemptions/rollback to Voucherify API hence the error.

I suggest checking for non-empty strings in all methods which insert them into URLs.

bandraszyk commented 4 years ago

Thank you a lot for reporting the issue. I will take a closer look and we will release a fix today. I will keep you posted.

bandraszyk commented 4 years ago

@a-martynovich the PR is ready. From now on the ArgmentNullException will be thrown to avoid unneeded calls. The v7.4.0 will be released today once all checks are done