Skip to content

Commit 87a250e

Browse files
committed
chore: ♻️ make urlPrefix protected getter
1 parent c2ca919 commit 87a250e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/models/Order.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ export class Order {
133133
* @throws { PrintOneError } If the order could not be refreshed.
134134
*/
135135
public async refresh(): Promise<void> {
136-
const urlPrefix = this.batchId ? `batches/${this.batchId}/` : "";
137136
this._data = await this._protected.client.GET<IOrder>(
138-
`${urlPrefix}orders/${this.id}`,
137+
`${this.urlPrefix}orders/${this.id}`,
139138
);
140139
}
141140

@@ -179,10 +178,13 @@ export class Order {
179178
time++;
180179
}
181180

182-
const urlPrefix = this.batchId ? `batches/${this.batchId}/` : "";
183181
this._data = await this._protected.client.POST<IOrder>(
184-
`${urlPrefix}orders/${this.id}/cancel`,
182+
`${this.urlPrefix}orders/${this.id}/cancel`,
185183
{},
186184
);
187185
}
186+
187+
protected get urlPrefix(): string {
188+
return this.batchId ? `batches/${this.batchId}/` : "";;
189+
}
188190
}

0 commit comments

Comments
 (0)