Skip to content

Commit

Permalink
fix: Refactor over endpoints class
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Zarate committed May 15, 2024
1 parent 668a7ba commit aa0e772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions playwright/api/call-blockfrost/blockfrost.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function blockfrostApi(request: APIRequestContext) {
const getLatestBlockData = async () => {
return BaseApi.getData(
request,
Endpoint.BlockFrost.BLOCKS.Base + "/latest",
Endpoint.BlockFrost.Blocks.Latest,
{},
{
Accept: "*/*",
Expand All @@ -24,7 +24,7 @@ export function blockfrostApi(request: APIRequestContext) {
const getLastEpochData = async () => {
return BaseApi.getData(
request,
Endpoint.BlockFrost.EPOCHS.Base + "/latest",
Endpoint.BlockFrost.Epochs.Latest,
{},
{
Accept: "*/*",
Expand All @@ -39,7 +39,7 @@ export function blockfrostApi(request: APIRequestContext) {
const getEpochById = async (epochId: number) => {
return BaseApi.getData(
request,
Endpoint.BlockFrost.EPOCHS.Base + `/${epochId}`,
Endpoint.BlockFrost.Epochs.Base + `/${epochId}`,
{},
{
Accept: "*/*",
Expand All @@ -54,7 +54,7 @@ export function blockfrostApi(request: APIRequestContext) {
const getBlockByNumber = async (blockNumber: number) => {
return BaseApi.getData(
request,
Endpoint.BlockFrost.BLOCKS.Base + `/${blockNumber}`,
Endpoint.BlockFrost.Blocks.Base + `/${blockNumber}`,
{},
{
Accept: "*/*",
Expand Down
10 changes: 8 additions & 2 deletions playwright/helpers/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ export class CardanoFoundation {
export class BlockFrost {
static readonly BASE_MAIN_NET_URL = process.env.BLOCKFROST_API_URL;

static BLOCKS = class {
static Blocks = class {
public static get Base() {
return `${BlockFrost.BASE_MAIN_NET_URL}/blocks`;
}
public static get Latest() {
return `${BlockFrost.Blocks.Base}/latest`;
}
};
static EPOCHS = class {
static Epochs = class {
public static get Base() {
return `${BlockFrost.BASE_MAIN_NET_URL}/epochs`;
}
public static get Latest() {
return `${BlockFrost.Epochs.Base}/latest`;
}
};
}

Expand Down

0 comments on commit aa0e772

Please sign in to comment.