import DeviceInfo from 'react-native-device-info' import { Session } from './session' const brand = DeviceInfo.getBrand() const model = DeviceInfo.getModel() const systemName = DeviceInfo.getSystemName() const systemVersion = DeviceInfo.getSystemVersion() const readableVersion = DeviceInfo.getReadableVersion() const appName = DeviceInfo.getApplicationName() /** * This is for accessing https://github.com/planningcenter/upload */ export class UploadUri { session: Session app?: string constructor({ session }: { session: Session }) { this.session = session } get schema() { return 'https' } get host() { return `${this.subdomain}.${this.domain}.${this.tld}` } get subdomain() { switch (this.env) { case 'staging': return 'upload-staging' default: return 'upload' } } get domain(): 'pco' | 'planningcenteronline' { return this.env === 'development' ? 'pco' : 'planningcenteronline' } get tld() { switch (this.env) { case 'development': return 'test' default: return 'com' } } get env() { return this.session?.env || 'production' } get baseUrl() { return `${this.schema}://${this.host}` } get headers() { return { 'User-Agent': `${appName}/${readableVersion} (${brand}, ${model}, ${systemName}, ${systemVersion})`, Authorization: `Bearer ${this.session.token?.access_token}`, 'X-PCO-Moderate-Image': 'true', } } }