Skip to content

Commit

Permalink
fix: fieldName path params for Case Classification valueCount and doc…
Browse files Browse the repository at this point in the history
…umentCount (#823)
  • Loading branch information
paulgerold authored May 24, 2024
1 parent 3b5e628 commit cc2f4d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export default class CaseClassificationConfiguration extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/machinelearning/configuration/caseclassif`;
static modelUrl = `${CaseClassificationConfiguration.baseUrl}/model`;
static fieldsUrl = `${CaseClassificationConfiguration.baseUrl}/fields`;
static fieldDocumentCountUrl = `${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/documentCount`;
static fieldValueCountUrl = `${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/valueCount`;

static previewUrl = `${CaseClassificationConfiguration.baseUrl}/preview`;

Expand Down Expand Up @@ -68,11 +66,17 @@ export default class CaseClassificationConfiguration extends Resource {
);
}

documentCount(params: CaseClassificationFieldCountParams) {
return this.api.post<FieldDocumentCount>(CaseClassificationConfiguration.fieldDocumentCountUrl, params);
documentCount(fieldName: string, params: CaseClassificationFieldCountParams) {
return this.api.post<FieldDocumentCount>(
`${CaseClassificationConfiguration.fieldsUrl}/${fieldName}/documentCount`,
params,
);
}

valueCount(params: CaseClassificationFieldCountParams) {
return this.api.post<FieldValueCount>(CaseClassificationConfiguration.fieldValueCountUrl, params);
valueCount(fieldName: string, params: CaseClassificationFieldCountParams) {
return this.api.post<FieldValueCount>(
`${CaseClassificationConfiguration.fieldsUrl}/${fieldName}/valueCount`,
params,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ describe('CaseClassificationConfiguration', () => {
it('should make a POST call to the specific Case Classification Configuration url with an advancedQuery', () => {
const params = {advancedQuery: "@source='some source'"};

ccConfig.documentCount(params);
ccConfig.documentCount('fieldTest', params);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(
`${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/documentCount`,
`${CaseClassificationConfiguration.baseUrl}/fields/fieldTest/documentCount`,
params,
);
});
Expand All @@ -187,11 +187,11 @@ describe('CaseClassificationConfiguration', () => {
caseExtractionPeriod: {exportPeriod: 'P6M', dateField: 'date'},
};

ccConfig.documentCount(params);
ccConfig.documentCount('fieldTest', params);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(
`${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/documentCount`,
`${CaseClassificationConfiguration.baseUrl}/fields/fieldTest/documentCount`,
params,
);
});
Expand All @@ -203,11 +203,11 @@ describe('CaseClassificationConfiguration', () => {
it('should make a POST call to the specific Case Classification Configuration url with an advancedQuery', () => {
const params = {advancedQuery: "@source='some source'"};

ccConfig.valueCount(params);
ccConfig.valueCount('fieldTest', params);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(
`${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/valueCount`,
`${CaseClassificationConfiguration.baseUrl}/fields/fieldTest/valueCount`,
params,
);
});
Expand All @@ -219,11 +219,11 @@ describe('CaseClassificationConfiguration', () => {
caseExtractionPeriod: {exportPeriod: 'P6M', dateField: 'date'},
};

ccConfig.valueCount(params);
ccConfig.valueCount('fieldTest', params);

expect(api.post).toHaveBeenCalledTimes(1);
expect(api.post).toHaveBeenCalledWith(
`${CaseClassificationConfiguration.baseUrl}/fields/{fieldName}/valueCount`,
`${CaseClassificationConfiguration.baseUrl}/fields/fieldTest/valueCount`,
params,
);
});
Expand Down

0 comments on commit cc2f4d5

Please sign in to comment.