Skip to content

Commit

Permalink
Merge pull request #5 from shopware/fix-helper-method
Browse files Browse the repository at this point in the history
fix: refactor getFlowId helper method
  • Loading branch information
pweyck authored May 23, 2024
2 parents d88b803 + b76e2cf commit 03f2e89
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/services/ShopwareDataHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,20 @@ export const getStateMachineStateId = async (stateMachineId: string, adminApiCon
return result.data[0].id;
};

export const getFlowId = async (eventName: string, adminApiContext: AdminApiContext): Promise<{ id: string }> => {
const resp = await adminApiContext.post('search-ids/flow', {
export const getFlowId = async (flowName: string, adminApiContext: AdminApiContext): Promise<string> => {
const resp = await adminApiContext.post('./search/flow', {
data: {
query: [{
query: {
type: 'contains',
field: 'flow.eventName',
value: eventName,
},
limit: 1,
filter: [{
type: 'equals',
field: 'name',
value: flowName,
}],
},
});

const result = (await resp.json()) as { data: { id: string }[]; total: number };

return result.data[0];
return result.data[0].id;
};

export const getOrderTransactionId = async (orderId: string, adminApiContext: AdminApiContext): Promise<{ id: string }> =>{
Expand Down

0 comments on commit 03f2e89

Please sign in to comment.