Enhance deployment script and update package dependencies
- Added detailed labels to the deployment script for IndeedHub, including title, version, description, license, icon, and repository URL. - Updated package dependencies in package.json and package-lock.json, including upgrading 'nostr-tools' to version 2.23.0 and adding 'axios' and '@tanstack/vue-query'. - Improved README with a modern description of the platform and updated project structure details. This commit enhances the clarity of the deployment process and ensures the project is using the latest dependencies for better performance and features.
This commit is contained in:
114
src/services/subscription.service.ts
Normal file
114
src/services/subscription.service.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import { apiService } from './api.service'
|
||||
import type { ApiSubscription } from '../types/api'
|
||||
|
||||
/**
|
||||
* Subscription Service
|
||||
* Handles user subscriptions
|
||||
*/
|
||||
class SubscriptionService {
|
||||
/**
|
||||
* Get user's subscriptions
|
||||
*/
|
||||
async getSubscriptions(): Promise<ApiSubscription[]> {
|
||||
return apiService.get<ApiSubscription[]>('/subscriptions')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active subscription
|
||||
*/
|
||||
async getActiveSubscription(): Promise<ApiSubscription | null> {
|
||||
const subscriptions = await this.getSubscriptions()
|
||||
return subscriptions.find((sub) => sub.status === 'active') || null
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to a tier
|
||||
*/
|
||||
async subscribe(data: {
|
||||
tier: 'enthusiast' | 'film-buff' | 'cinephile'
|
||||
period: 'monthly' | 'annual'
|
||||
paymentMethodId?: string
|
||||
}): Promise<ApiSubscription> {
|
||||
return apiService.post<ApiSubscription>('/subscriptions', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel subscription
|
||||
*/
|
||||
async cancelSubscription(subscriptionId: string): Promise<void> {
|
||||
await apiService.delete(`/subscriptions/${subscriptionId}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume cancelled subscription
|
||||
*/
|
||||
async resumeSubscription(subscriptionId: string): Promise<ApiSubscription> {
|
||||
return apiService.post<ApiSubscription>(`/subscriptions/${subscriptionId}/resume`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update payment method
|
||||
*/
|
||||
async updatePaymentMethod(subscriptionId: string, paymentMethodId: string): Promise<void> {
|
||||
await apiService.patch(`/subscriptions/${subscriptionId}/payment-method`, {
|
||||
paymentMethodId,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subscription tiers with pricing
|
||||
*/
|
||||
async getSubscriptionTiers(): Promise<Array<{
|
||||
tier: string
|
||||
name: string
|
||||
monthlyPrice: number
|
||||
annualPrice: number
|
||||
features: string[]
|
||||
}>> {
|
||||
// This might be a static endpoint or hardcoded
|
||||
// Adjust based on actual API
|
||||
return [
|
||||
{
|
||||
tier: 'enthusiast',
|
||||
name: 'Enthusiast',
|
||||
monthlyPrice: 9.99,
|
||||
annualPrice: 99.99,
|
||||
features: [
|
||||
'Access to all films and series',
|
||||
'HD streaming',
|
||||
'Watch on 2 devices',
|
||||
'Cancel anytime',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 'film-buff',
|
||||
name: 'Film Buff',
|
||||
monthlyPrice: 19.99,
|
||||
annualPrice: 199.99,
|
||||
features: [
|
||||
'Everything in Enthusiast',
|
||||
'4K streaming',
|
||||
'Watch on 4 devices',
|
||||
'Exclusive behind-the-scenes content',
|
||||
'Early access to new releases',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 'cinephile',
|
||||
name: 'Cinephile',
|
||||
monthlyPrice: 29.99,
|
||||
annualPrice: 299.99,
|
||||
features: [
|
||||
'Everything in Film Buff',
|
||||
'Watch on unlimited devices',
|
||||
'Offline downloads',
|
||||
'Director commentary tracks',
|
||||
'Virtual festival access',
|
||||
'Support independent filmmakers',
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export const subscriptionService = new SubscriptionService()
|
||||
Reference in New Issue
Block a user