Skip to content

Commit

Permalink
fix: do the same for 'mailaddress', which does not have a shortID either
Browse files Browse the repository at this point in the history
  • Loading branch information
tillwestpfahl committed Aug 28, 2024
1 parent 2310072 commit 1ef429b
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/lib/resources/mail/flags.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
import { makeProjectFlagSet } from "../project/flags.js";
import { assertStatus } from "@mittwald/api-client-commons";
import { validate as validateUuid } from "uuid";
import FlagSetBuilder from "../../context/FlagSetBuilder.js";

export const {
flags: mailAddressFlags,
args: mailAddressArgs,
withId: withMailAddressId,
} = makeProjectFlagSet("mailaddress", "m", {
normalize: async (apiClient, projectId, id): Promise<string> => {
if (validateUuid(id)) {
return id;
}

const response = await apiClient.mail.listMailAddresses({ projectId });
assertStatus(response, 200);

const address = response.data.find((address) => address.address === id);
if (!address) {
throw new Error(`mail address with id "${id}" not found`);
}

return address.id;
},
shortIDName: "mail address",
});
} = new FlagSetBuilder("mailaddress", "m", {
retrieveFromContext: false,
}).build();

export const {
flags: mailDeliveryBoxFlags,
Expand Down

0 comments on commit 1ef429b

Please sign in to comment.