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

Disable api calls #851

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Disable api calls #851

wants to merge 11 commits into from

Conversation

DordeDimitrijev
Copy link
Contributor

@DordeDimitrijev DordeDimitrijev commented Nov 14, 2024

Description

Implemented feature for stopping api calls from being sent after unsuccessful response. This behavior is aligned with other appcenter SDKs. Disabling of api calls occurs only per session after first failed request.

Related PRs or issues

AB#107980

src/test/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/test/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
@DordeDimitrijev DordeDimitrijev marked this pull request as ready for review November 19, 2024 08:39
@DordeDimitrijev DordeDimitrijev requested a review from a team as a code owner November 19, 2024 08:39
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/test/acquisition-sdk.ts Show resolved Hide resolved
src/test/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Show resolved Hide resolved
src/test/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/test/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/test/acquisition-sdk.ts Show resolved Hide resolved

constructor(expectedStatusCode?: number) {
this.expectedStatusCode = expectedStatusCode;
}
public request(verb: acquisitionSdk.Http.Verb, url: string, requestBodyOrCallback: string | acquisitionSdk.Callback<acquisitionSdk.Http.Response>, callback?: acquisitionSdk.Callback<acquisitionSdk.Http.Response>): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line

reportStatusDownloadUrl = serverUrl + publicPrefixUrl + "/report_status/download";
updateCheckUrl = serverUrl + publicPrefixUrl + "/update_check?";
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove one empty line

public request(verb: acquisitionSdk.Http.Verb, url: string, requestBodyOrCallback: string | acquisitionSdk.Callback<acquisitionSdk.Http.Response>, callback?: acquisitionSdk.Callback<acquisitionSdk.Http.Response>): void {
if (!callback && typeof requestBodyOrCallback === "function") {
callback = <acquisitionSdk.Callback<acquisitionSdk.Http.Response>>requestBodyOrCallback;
}

if (verb === acquisitionSdk.Http.Verb.GET && url.indexOf(updateCheckUrl) === 0) {
var params = querystring.parse(url.substring(updateCheckUrl.length));
Server.onUpdateCheck(params, callback);
Server.onUpdateCheck(params, callback,this.expectedStatusCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between parameters

@@ -226,6 +229,67 @@ describe("Acquisition SDK", () => {
done();
}));
});
it("disables api calls on unsuccessful response", (done: Mocha.Done): void => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line

assert.strictEqual(returnPackage, null);
acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.HttpRequester(404), configuration);
(acquisitionSdk.AcquisitionManager as any)._apiCallsDisabled = false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line


done();
})
it("doesn't disable api calls on successful response", (done: Mocha.Done): void => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line

@IlyaBausovAkvelon
Copy link

I've built and tested this PR on my machine. Everything seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants