Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
biwano committed Nov 28, 2023
1 parent 0a6ef73 commit 67ea18c
Show file tree
Hide file tree
Showing 14 changed files with 620 additions and 137 deletions.
25 changes: 25 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/clients/getActivities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { ResponseConfig } from "../client";
import client from "../client";
import type {
GetActivitiesQueryParams,
GetActivitiesQueryResponse,
} from "../types/GetActivities";

/**
* @description Retrieve an array of activities related to a carbon project
* @summary List project activities
* @link /activities
*/
export async function getActivities<TData = GetActivitiesQueryResponse>(
params?: GetActivitiesQueryParams,
options: Partial<Parameters<typeof client>[0]> = {}
): Promise<ResponseConfig<TData>["data"]> {
const { data: resData } = await client<TData>({
method: "get",
url: `/activities`,
params,
...options,
});

return resData;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { ResponseConfig } from "../client";
import client from "../client";
import type {
GetProjectsIdActivityPathParams,
GetProjectsIdActivityQueryParams,
GetProjectsIdActivityQueryResponse,
} from "../types/GetProjectsIdActivity";

/**
* @description Retrieve an array of activities related to a carbon project
* @summary List project activities
* @link /projects/:id/activity
*/
export async function getProjectsIdActivity<
TData = GetProjectsIdActivityQueryResponse,
>(
id: GetProjectsIdActivityPathParams["id"],
params?: GetProjectsIdActivityQueryParams,
options: Partial<Parameters<typeof client>[0]> = {}
): Promise<ResponseConfig<TData>["data"]> {
const { data: resData } = await client<TData>({
method: "get",
url: `/projects/${id}/activity`,
params,
...options,
});

return resData;
}
2 changes: 2 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/clients/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export * from "./getActivities";
export * from "./getCategories";
export * from "./getCountries";
export * from "./getProjects";
export * from "./getProjectsId";
export * from "./getProjectsIdActivity";
export * from "./getPurchasesId";
export * from "./getUsersWalletorhandle";
export * from "./getVintages";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
export const operations = {
get_activities: { path: "/activities", method: "get" },
get_categories: { path: "/categories", method: "get" },
get_projects: { path: "/projects", method: "get" },
get_countries: { path: "/countries", method: "get" },
get_projects: { path: "/projects", method: "get" },
"get_users-walletorhandle": { path: "/users/:walletOrHandle", method: "get" },
post_users: { path: "/users", method: "post" },
"put_users-wallet": { path: "/users/:wallet", method: "put" },
get_vintages: { path: "/vintages", method: "get" },
"get_projects-id": { path: "/projects/:id", method: "get" },
"get_purchases-id": { path: "/purchases/:id", method: "get" },
"post_users-login": { path: "/users/login", method: "post" },
"get_projects-id-activity": { path: "/projects/:id/activity", method: "get" },
"post_users-login-verify": { path: "/users/login/verify", method: "post" },
} as const;
2 changes: 2 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export * from "./useGetActivities";
export * from "./useGetCategories";
export * from "./useGetCountries";
export * from "./useGetProjects";
export * from "./useGetProjectsId";
export * from "./useGetProjectsIdActivity";
export * from "./useGetPurchasesId";
export * from "./useGetUsersWalletorhandle";
export * from "./useGetVintages";
Expand Down
60 changes: 60 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/hooks/useGetActivities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { SWRConfiguration, SWRResponse } from "swr";
import useSWR from "swr";
import client from "../../../lib/api/client";
import type {
GetActivitiesQueryParams,
GetActivitiesQueryResponse,
} from "../types/GetActivities";

export function getActivitiesQueryOptions<
TData = GetActivitiesQueryResponse,
TError = unknown,
>(
params?: GetActivitiesQueryParams,
options: Partial<Parameters<typeof client>[0]> = {}
): SWRConfiguration<TData, TError> {
return {
fetcher: () => {
return client<TData, TError>({
method: "get",
url: `/activities`,

params,

...options,
}).then((res) => res.data);
},
};
}

/**
* @description Retrieve an array of activities related to a carbon project
* @summary List project activities
* @link /activities
*/

export function useGetActivities<
TData = GetActivitiesQueryResponse,
TError = unknown,
>(
params?: GetActivitiesQueryParams,
options?: {
query?: SWRConfiguration<TData, TError>;
client?: Partial<Parameters<typeof client<TData, TError>>[0]>;
shouldFetch?: boolean;
}
): SWRResponse<TData, TError> {
const {
query: queryOptions,
client: clientOptions = {},
shouldFetch = true,
} = options ?? {};

const url = shouldFetch ? `/activities` : null;
const query = useSWR<TData, TError, string | null>(url, {
...getActivitiesQueryOptions<TData, TError>(params, clientOptions),
...queryOptions,
});

return query;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { SWRConfiguration, SWRResponse } from "swr";
import useSWR from "swr";
import client from "../../../lib/api/client";
import type {
GetProjectsIdActivityPathParams,
GetProjectsIdActivityQueryParams,
GetProjectsIdActivityQueryResponse,
} from "../types/GetProjectsIdActivity";

export function getProjectsIdActivityQueryOptions<
TData = GetProjectsIdActivityQueryResponse,
TError = unknown,
>(
id: GetProjectsIdActivityPathParams["id"],
params?: GetProjectsIdActivityQueryParams,
options: Partial<Parameters<typeof client>[0]> = {}
): SWRConfiguration<TData, TError> {
return {
fetcher: () => {
return client<TData, TError>({
method: "get",
url: `/projects/${id}/activity`,

params,

...options,
}).then((res) => res.data);
},
};
}

/**
* @description Retrieve an array of activities related to a carbon project
* @summary List project activities
* @link /projects/:id/activity
*/

export function useGetProjectsIdActivity<
TData = GetProjectsIdActivityQueryResponse,
TError = unknown,
>(
id: GetProjectsIdActivityPathParams["id"],
params?: GetProjectsIdActivityQueryParams,
options?: {
query?: SWRConfiguration<TData, TError>;
client?: Partial<Parameters<typeof client<TData, TError>>[0]>;
shouldFetch?: boolean;
}
): SWRResponse<TData, TError> {
const {
query: queryOptions,
client: clientOptions = {},
shouldFetch = true,
} = options ?? {};

const url = shouldFetch ? `/projects/${id}/activity` : null;
const query = useSWR<TData, TError, string | null>(url, {
...getProjectsIdActivityQueryOptions<TData, TError>(
id,
params,
clientOptions
),
...queryOptions,
});

return query;
}
51 changes: 51 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/GetActivities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { Def1 } from "./Def1";

/**
* @description List of project activities
*/
export type GetActivitiesQueryResponse = {
/**
* @type string
*/
id: string;
amount?: string | null;
previousAmount?: string | null;
price?: string | null;
previousPrice?: string | null;
timeStamp?: string | null;
activityType?: string | null;
seller?: {
/**
* @type string
*/
id: string;
handle?: string | null;
} | null;
buyer?: {
/**
* @type string
*/
id: string;
handle?: string | null;
} | null;
}[];

export type GetActivitiesQueryParams = {
network?: Def1;
/**
* @description Filter returned activities by project
* @type string | undefined
*/
projectId?: string;
/**
* @type array | undefined
*/
activityType?: (
| "CreatedListing"
| "DeletedListing"
| "Purchase"
| "Sold"
| "UpdatedPrice"
| "UpdatedQuantity"
)[];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { Def1 } from "./Def1";

export type GetProjectsIdActivityPathParams = {
/**
* @description Project id & vintage
* @type string
*/
id: string;
};

/**
* @description List of project activities
*/
export type GetProjectsIdActivityQueryResponse = {
/**
* @type string
*/
id: string;
amount?: string | null;
previousAmount?: string | null;
price?: string | null;
previousPrice?: string | null;
timeStamp?: string | null;
activityType?: string | null;
seller?: {
/**
* @type string
*/
id: string;
handle?: string | null;
} | null;
buyer?: {
/**
* @type string
*/
id: string;
handle?: string | null;
} | null;
}[];

export type GetProjectsIdActivityQueryParams = {
network?: Def1;
/**
* @description Filter returned activities by project
* @type string | undefined
*/
projectId?: string;
/**
* @type array | undefined
*/
activityType?: (
| "CreatedListing"
| "DeletedListing"
| "Purchase"
| "Sold"
| "UpdatedPrice"
| "UpdatedQuantity"
)[];
};
2 changes: 2 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export * from "./Country";
export * from "./Def0";
export * from "./Def1";
export * from "./DetailedProject";
export * from "./GetActivities";
export * from "./GetCategories";
export * from "./GetCountries";
export * from "./GetProjects";
export * from "./GetProjectsId";
export * from "./GetProjectsIdActivity";
export * from "./GetPurchasesId";
export * from "./GetUsersWalletorhandle";
export * from "./GetVintages";
Expand Down
Loading

0 comments on commit 67ea18c

Please sign in to comment.