Skip to content

Commit

Permalink
feat: Add unsubscribe endpoints (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan authored Mar 5, 2024
1 parent efff757 commit 307a98c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,20 @@ export function registerRecoveryModule(
})
}

/**
* Delete email subscription for a single category
* @param query
*/
export function unsubscribeSingle(query: operations['unsubscribe_single']['parameters']['query']) {
return deleteEndpoint(baseUrl, '/v1/subscriptions', { query })
}

/**
* Delete email subscription for all categories
* @param query
*/
export function unsubscribeAll(query: operations['unsubscribe_all']['parameters']['query']) {
return deleteEndpoint(baseUrl, '/v1/subscriptions/all', { query })
}

/* eslint-enable @typescript-eslint/explicit-module-boundary-types */
48 changes: 47 additions & 1 deletion src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface Responses {

interface Endpoint {
parameters: {
path: Record<string, Primitive>
path: Record<string, Primitive> | null
} | null
}

Expand Down Expand Up @@ -409,6 +409,25 @@ export interface paths extends PathRegistry {
}
}
}
'/v1/subscriptions': {
delete: operations['unsubscribe_single']
parameters: {
path: null
query: {
category: string
token: string
}
}
}
'/v1/subscriptions/all': {
delete: operations['unsubscribe_all']
parameters: {
path: null
query: {
token: string
}
}
}
}

export interface operations {
Expand Down Expand Up @@ -1059,6 +1078,33 @@ export interface operations {
body: RegisterRecoveryModuleRequestBody
}

responses: {
200: {
schema: void
}
}
}
unsubscribe_single: {
parameters: {
query: {
category: string
token: string
}
}

responses: {
200: {
schema: void
}
}
}
unsubscribe_all: {
parameters: {
query: {
token: string
}
}

responses: {
200: {
schema: void
Expand Down

0 comments on commit 307a98c

Please sign in to comment.