managarten/manadeck/apps/mobile/services/creditService.ts
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
Projects included:
- maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing)
- manacore (Expo mobile + SvelteKit web + Astro landing)
- manadeck (NestJS backend + Expo mobile + SvelteKit web)
- memoro (Expo mobile + SvelteKit web + Astro landing)

This commit preserves the current state before monorepo restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:38:24 +01:00

38 lines
1 KiB
TypeScript

import { get } from '../utils/apiClient';
import type { CreditBalance } from '../types/credits';
const BASE_API_URL = process.env.EXPO_PUBLIC_API_URL || 'https://manadeck-backend-111768794939.europe-west3.run.app';
/**
* Credit Service
* Handles all credit-related API operations
*/
export const creditService = {
/**
* Get user's current credit balance
*/
async getBalance(): Promise<number> {
try {
const response = await get<CreditBalance>(`${BASE_API_URL}/v1/api/credits/balance`);
return response.balance || 0;
} catch (error) {
console.error('Error fetching credit balance:', error);
throw error;
}
},
/**
* Get user profile including credit balance
*/
async getProfile(): Promise<{ user: any; credits: number }> {
try {
const response = await get<{ user: any; credits: number }>(`${BASE_API_URL}/v1/api/profile`);
return response;
} catch (error) {
console.error('Error fetching profile:', error);
throw error;
}
},
};
export default creditService;