Skip to content

Commit

Permalink
feat(con-458): Add getAll PickJobs to PickJobService
Browse files Browse the repository at this point in the history
  • Loading branch information
saschaheinl-fft committed Aug 26, 2024
1 parent 83bbf73 commit 9400e36
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 6 deletions.
130 changes: 129 additions & 1 deletion src/fft-api/pickjob/fftPickJobService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import {
AbstractModificationAction,
PickJob,
PickJobAbortActionEnum,
PickjobDeliveryInformationForCreation,
PickJobObsoleteActionEnum,
PickJobResetActionEnum,
PickJobRestartActionEnum,
PickJobStatus,
StrippedPickJobs,
} from '../types';
import { FftApiClient } from '../common';
import { FftApiClient, MAX_ARRAY_SIZE } from '../common';
import { ResponseError } from 'superagent';
import { CustomLogger, QueryParams } from '../../common';
import { Logger } from 'tslog';
import ChannelEnum = PickjobDeliveryInformationForCreation.ChannelEnum;

export class FftPickJobService {
private readonly path = 'pickjobs';
private readonly logger: Logger<FftPickJobService> = new CustomLogger<FftPickJobService>();

constructor(private readonly apiClient: FftApiClient) {}

public async getByTenantOrderId(tenantOrderId: string): Promise<StrippedPickJobs> {
Expand Down Expand Up @@ -122,4 +126,128 @@ export class FftPickJobService {
throw err;
}
}

public async getAll(
searchTerm?: string,
carrierKeys?: string[],
startOrderDate?: string,
endOrderDate?: string,
orderRef?: string,
facilityRef?: string,
status?: PickJobStatus[],
zoneRefs?: string,
tenantOrderId?: string,
channel?: ChannelEnum,
consumerName?: string,
shortId?: string,
articleTitle?: string,
anonymized?: boolean,
startAfterId?: string,
size?: number,
orderBy?: string,
startTargetTime?: string,
endTargetTime?: string,
pickJobRefs?: string[],
modifiedByUsername?: string
): Promise<StrippedPickJobs> {
try {
const queryParams: QueryParams = {};

if (searchTerm) {
queryParams['searchTerm'] = searchTerm;
}

if (carrierKeys) {
carrierKeys = carrierKeys.slice(0, MAX_ARRAY_SIZE);
queryParams['carrierKeys'] = carrierKeys;
}

if (startOrderDate) {
queryParams['startOrderDate'] = startOrderDate;
}

if (endOrderDate) {
queryParams['endOrderDate'] = endOrderDate;
}

if (orderRef) {
queryParams['orderRef'] = orderRef;
}

if (facilityRef) {
queryParams['facilityRef'] = facilityRef;
}

if (status) {
queryParams['status'] = status;
}

if (zoneRefs) {
queryParams['zoneRefs'] = zoneRefs;
}

if (tenantOrderId) {
queryParams['tenantOrderId'] = tenantOrderId;
}

if (channel) {
queryParams['channel'] = channel;
}

if (consumerName) {
queryParams['consumerName'] = consumerName;
}

if (shortId) {
queryParams['shortId'] = shortId;
}

if (articleTitle) {
queryParams['articleTitle'] = articleTitle;
}

if (anonymized) {
queryParams['anonymized'] = anonymized.toString();
}

if (startAfterId) {
queryParams['startAfterId'] = startAfterId;
}

if (size) {
queryParams['size'] = size.toString();
}

if (orderBy) {
queryParams['orderBy'] = orderBy;
}

if (startTargetTime) {
queryParams['startTargetTime'] = startTargetTime;
}

if (endTargetTime) {
queryParams['endTargetTime'] = endTargetTime;
}

if (pickJobRefs) {
queryParams['pickJobRefs'] = pickJobRefs;
}

if (modifiedByUsername) {
queryParams['modifiedByUsername'] = modifiedByUsername;
}

return await this.apiClient.get<StrippedPickJobs>(this.path, queryParams);
} catch (error) {
const httpError = error as ResponseError;
this.logger.error(
`Fetching all pickjobs failed with status code ${httpError.status}, error: ${
httpError.response ? JSON.stringify(httpError.response.body) : ''
}`
);

throw error;
}
}
}
40 changes: 40 additions & 0 deletions src/fft-api/types/api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27340,6 +27340,8 @@ components:
minItems: 0
items:
$ref: '#/components/schemas/OperativeTransfer'
pickingTimes:
$ref: '#/components/schemas/PickJobPickingTimes'
required:
- orderDate
- facilityRef
Expand Down Expand Up @@ -27443,6 +27445,10 @@ components:
stockEmptied:
example: true
type: boolean
zoneRef:
type: string
zoneName:
type: string
required:
- tenantPartialStockId
type: object
Expand Down Expand Up @@ -30012,6 +30018,15 @@ components:
example: 42
type: integer
type: object
PickJobPickingTimes:
type: object
additionalProperties: false
properties:
startLatestAt:
description: The date this pickJob should be started at last.
example: '2024-02-03T09:45:51.525Z'
format: date-time
type: string
PickRunForCreation:
properties:
pickJobRefs:
Expand Down Expand Up @@ -33854,10 +33869,12 @@ components:
* `PICKABLE`- The stock is available for picking
* `ACCESSIBLE`- The stock is available for stock movements (stowing, inbound, etc)
* `KEEP_ON_ZERO`- The stock will not be deleted when emptied
* `OUTBOUND`- The stock is intended for outbound processes
enum:
- PICKABLE
- ACCESSIBLE
- KEEP_ON_ZERO
- OUTBOUND
xml:
name: StorageLocationTrait
StorageLocationSequenceType:
Expand Down Expand Up @@ -34386,6 +34403,13 @@ components:
mapping:
BLANK_LINK: '#/components/schemas/ExternalLinkActionDefinition'
FORM: '#/components/schemas/ExternalFormActionDefinition'
customAttributes:
nullable: true
description: >-
Attributes that can be added to this entity. These attributes
**cannot** be used within fulfillment processes, but enable you to
attach custom data from your systems to fulfillmenttools entities.
type: object
required:
- processRef
- nameLocalized
Expand Down Expand Up @@ -34419,6 +34443,13 @@ components:
mapping:
BLANK_LINK: '#/components/schemas/ExternalLinkActionDefinition'
FORM: '#/components/schemas/ExternalFormActionDefinition'
customAttributes:
nullable: true
description: >-
Attributes that can be added to this entity. These attributes
**cannot** be used within fulfillment processes, but enable you to
attach custom data from your systems to fulfillmenttools entities.
type: object
required:
- version
- nameLocalized
Expand Down Expand Up @@ -35125,9 +35156,12 @@ components:
- NONE
CustomServiceStatus:
type: string
description: 'Deprecated values: ENABLED and DISABLED, use INACTIVE and ACTIVE instead'
enum:
- ENABLED
- DISABLED
- INACTIVE
- ACTIVE
ServiceJobStatus:
type: string
enum:
Expand Down Expand Up @@ -36417,6 +36451,10 @@ components:
properties:
consumer:
properties:
consumerId:
description: The id of the consumer.
example: e4213a07-f563-46a3-b1ba-4dfeb6abe82a
type: string
addresses:
items:
$ref: '#/components/schemas/ConsumerAddress'
Expand Down Expand Up @@ -39562,6 +39600,7 @@ components:
- name
- version
OrderLineItemActionsParameter:
type: object
oneOf:
- $ref: '#/components/schemas/OrderLineItemCustomAttributesUpdateParameter'
AbstractOrderLineItemActionsParameter:
Expand Down Expand Up @@ -41672,6 +41711,7 @@ components:
- PICKABLE
- ACCESSIBLE
- KEEP_ON_ZERO
- OUTBOUND
scores:
type: array
items:
Expand Down
Loading

0 comments on commit 9400e36

Please sign in to comment.