Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
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
12 changes: 10 additions & 2 deletions lib/http-client-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
CreatedItemToken,
ProxyApprovedResponse,
IssueProxyResponse,
UserRequestStatus,
} from "./response";

import {
Expand Down Expand Up @@ -485,7 +486,7 @@ export class HttpClient {
contractId: string,
tokenType: string,
tokenIndex: string,
): Promise<GenericResponse<Array<NonFungibleId>>> {
): Promise<GenericResponse<NonFungibleId>> {
const path = `/v1/item-tokens/${contractId}/non-fungibles/${tokenType}/${tokenIndex}/parent`;
return this.instance.get(path);
}
Expand All @@ -495,7 +496,7 @@ export class HttpClient {
tokenType: string,
tokenIndex: string,
request: NonFungibleTokenAttachRequest,
): Promise<GenericResponse<TxHashResponse>> {
): Promise<GenericResponse<NonFungibleId>> {
const path = `/v1/item-tokens/${contractId}/non-fungibles/${tokenType}/${tokenIndex}/parent`;
return this.instance.post(path, request);
}
Expand Down Expand Up @@ -1082,6 +1083,13 @@ export class HttpClient {
return this.instance.get(path);
}

public userRequestStatus(
requestSessionToken: string,
): Promise<GenericResponse<UserRequestStatus>> {
const path = `/v1/user-requests/${requestSessionToken}`;
return this.instance.get(path);
}

private requestTypeParam(requestType: RequestType): AxiosRequestConfig {
return {
params: {
Expand Down
27 changes: 27 additions & 0 deletions test/http-client-base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,33 @@ describe("http-client-base test", () => {
expect(response["statusCode"]).to.equal(1000);
expect(response["responseData"]["isApproved"]).to.equal(true);
});

it("query user-request api test", async () => {
const testRequestSessionToken = "J4EDHA_oyCyXrtREGS4MpyoGeus";

const receivedData = {
responseTime: 1585467711877,
statusCode: 1000,
statusMessage: "Success",
responseData: {
status: "Authorized"
},
};

stub = new MockAdapter(httpClient.getAxiosInstance());

const path = `/v1/user-requests/${testRequestSessionToken}`;
stub.onGet(path).reply(config => {
assertHeaders(config.headers);
return [200, receivedData];
});

const response = await httpClient.userRequestStatus(
testRequestSessionToken,
);
expect(response["statusCode"]).to.equal(1000);
expect(response["responseData"]["status"]).to.equal("Authorized");
});
});

function assertHeaders(headers: any) {
Expand Down