This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added subscription dunning rules endpoint (#935)
- Loading branch information
1 parent
0de13d7
commit 695c1a0
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import CRUDExtend from '../extends/crud' | ||
|
||
class SubscriptionDunningRulesEndpoint extends CRUDExtend { | ||
constructor(endpoint) { | ||
super(endpoint) | ||
|
||
this.endpoint = 'subscriptions/dunning-rules' | ||
} | ||
|
||
Create(body) { | ||
return this.request.send(this.endpoint, 'POST', { | ||
...body | ||
}) | ||
} | ||
|
||
Update(id, body, token = null) { | ||
return this.request.send( | ||
`${this.endpoint}/${id}`, | ||
'PUT', | ||
{ | ||
...body | ||
}, | ||
token | ||
) | ||
} | ||
|
||
} | ||
|
||
export default SubscriptionDunningRulesEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Subscription Dunning Rules | ||
* Description: Subscription Dunning Rules. | ||
* DOCS: TODO: add docs when ready | ||
*/ | ||
import { | ||
Identifiable, | ||
CrudQueryableResource | ||
} from './core' | ||
|
||
/** | ||
* Core Subscription Dunning Rules Base Interface | ||
* For custom flows, extend this interface | ||
* DOCS: TODO: add docs when ready | ||
*/ | ||
export interface SubscriptionDunningRulesBase { | ||
type: 'subscription_dunning_rule' | ||
attributes: { | ||
payment_retry_type: 'fixed' | 'backoff' | 'tiered' | ||
payment_retry_interval?: number | ||
payment_retry_unit?: 'day' | 'week' | ||
payment_retry_multiplier?: number | ||
payment_retries_limit: number | ||
action: 'none' | 'pause' | 'close' | ||
default?: boolean | ||
} | ||
} | ||
|
||
export interface SubscriptionDunningRules extends Identifiable, SubscriptionDunningRulesBase { | ||
meta: { | ||
owner: 'store' | 'organization' | ||
timestamps: { | ||
updated_at: string | ||
created_at: string | ||
} | ||
} | ||
} | ||
|
||
export type SubscriptionDunningRulesCreate = SubscriptionDunningRulesBase | ||
export type SubscriptionDunningRulesUpdate = Identifiable & Omit<SubscriptionDunningRulesBase, 'attributes'> & {attributes: Partial<SubscriptionDunningRules['attributes']>} | ||
|
||
/** | ||
* Subscription Dunning Rules Endpoints | ||
* DOCS: TODO: add docs when ready | ||
*/ | ||
export interface SubscriptionDunningRulesEndpoint | ||
extends CrudQueryableResource< | ||
SubscriptionDunningRules, | ||
SubscriptionDunningRulesCreate, | ||
SubscriptionDunningRulesUpdate, | ||
never, | ||
never, | ||
never | ||
> { | ||
endpoint: 'dunning-rules' | ||
} |