Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getTranslatedSolutionCategory and getTranslatedSolutionFolder methods #252

Merged
merged 1 commit into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dist/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ declare class Freshdesk {
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getSolutionCategory(id: number, cb: Freshdesk.requestCallback): void;
/**
* View a translated solution Category
*
* @category Solutions
*
* @see {@link https://developer.freshdesk.com/api/#view_solution_category}
*
* @param {Number} id Solution category ID
* @param {String} language_code Language code for the translated solution category
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getTranslatedSolutionCategory(id: number, language_code: string, cb: Freshdesk.requestCallback): void;
/**
* List all Solution Categories
*
Expand Down Expand Up @@ -697,6 +709,18 @@ declare class Freshdesk {
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getSolutionFolder(id: number, cb: Freshdesk.requestCallback): void;
/**
* View a translated solution Folder
*
* @category Solutions
*
* @see {@link https://developer.freshdesk.com/api/#view_solution_folder}
*
* @param {Number} id Solution folder ID
* @param {String} language_code Language code for the translated solution folder
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getTranslatedSolutionFolder(id: number, language_code: string, cb: Freshdesk.requestCallback): void;
/**
* List all Solution Folders in a Category
*
Expand Down
44 changes: 44 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,28 @@ class Freshdesk {
);
}

/**
* View a translated solution Category
*
* @category Solutions
*
* @see {@link https://developer.freshdesk.com/api/#view_solution_category}
*
* @param {Number} id Solution category ID
* @param {String} language_code Language code for the translated solution category
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getTranslatedSolutionCategory(id, language_code, cb) {
makeRequest(
"GET",
this._auth,
`${this.baseUrl}/api/v2/solutions/categories/${id}/${language_code}`,
null,
null,
cb
);
}

/**
* List all Solution Categories
*
Expand Down Expand Up @@ -1370,6 +1392,28 @@ class Freshdesk {
);
}

/**
* View a translated solution Folder
*
* @category Solutions
*
* @see {@link https://developer.freshdesk.com/api/#view_solution_folder}
*
* @param {Number} id Solution folder ID
* @param {String} language_code Language code for the translated solution folder
* @param {Freshdesk.requestCallback} cb Callback function {@link Freshdesk.requestCallback}
*/
getTranslatedSolutionFolder(id, language_code, cb) {
makeRequest(
"GET",
this._auth,
`${this.baseUrl}/api/v2/solutions/folders/${id}/${language_code}`,
null,
null,
cb
);
}

/**
* List all Solution Folders in a Category
*
Expand Down
54 changes: 54 additions & 0 deletions test/api.solutions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,32 @@ describe("api.solutions", function () {
});
});

describe("get a translated category", () => {
it("should send GET request to /api/v2/solutions/categories/NNNN/SSSS", (done) => {
const res = {
id: 3,
name: "la categoría de la muestra",
description: "este es creado para fines de demostración",
created_at: "2016-09-08T07:04:07Z",
updated_at: "2016-09-08T07:04:07Z",
};
const id = 3;
const language_code = 'es';

// SET UP expected request

nock("https://test.freshdesk.com")
.get(`/api/v2/solutions/categories/3/es`)
.reply(200, res);

freshdesk.getTranslatedSolutionCategory(id, language_code, (err, data) => {
expect(err).is.null;
expect(data).to.deep.equal(res);
done();
});
});
});

describe("list all solution categories", () => {
it("should send GET request to /api/v2/solutions/categories", (done) => {
const res = [
Expand Down Expand Up @@ -380,6 +406,34 @@ describe("api.solutions", function () {
});
});

describe("get a translated solution folder", () => {
it("should send GET request to /api/v2/solutions/folders/NNNN/SSSS", (done) => {
const res = {
id: 4,
name: "carpeta de la muestra",
description: "este es creado para fines de demostración",
visibility: 1,
category_id: 3,
created_at: "2016-09-08T12:04:49Z",
updated_at: "2016-09-08T12:04:49Z",
};
const id = 4;
const language_code = "es";

// SET UP expected request

nock("https://test.freshdesk.com")
.get(`/api/v2/solutions/folders/4/es`)
.reply(200, res);

freshdesk.getTranslatedSolutionFolder(id, language_code, (err, data) => {
expect(err).is.null;
expect(data).to.deep.equal(res);
done();
});
});
});

describe("list all solution category folders", () => {
it("should send GET request to /api/v2/solutions/categories/NNNN/folders", (done) => {
const res = [
Expand Down