|
|
@ -9,7 +9,7 @@ class NextcloudClient { |
|
|
|
this.password, |
|
|
|
this.password, |
|
|
|
this.language, |
|
|
|
this.language, |
|
|
|
this.appType = AppType.unknown, |
|
|
|
this.appType = AppType.unknown, |
|
|
|
this.userAgentSuffix, |
|
|
|
this.userAgentOverride, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
final authentication = username != null && password != null |
|
|
|
final authentication = username != null && password != null |
|
|
|
? HttpBasicAuth(username: username!, password: password!) |
|
|
|
? HttpBasicAuth(username: username!, password: password!) |
|
|
@ -55,17 +55,13 @@ class NextcloudClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Headers that should be used for all requests |
|
|
|
/// Headers that should be used for all requests |
|
|
|
late final commonHeaders = () { |
|
|
|
late final commonHeaders = <String, String>{ |
|
|
|
// ignore: no_leading_underscores_for_local_identifiers |
|
|
|
'OCS-APIRequest': 'true', |
|
|
|
final _userAgent = userAgent; |
|
|
|
'Accept': 'application/json', |
|
|
|
return <String, String>{ |
|
|
|
if (userAgent != null) ...{ |
|
|
|
'OCS-APIRequest': 'true', |
|
|
|
'User-Agent': userAgent!, |
|
|
|
'Accept': 'application/json', |
|
|
|
}, |
|
|
|
if (_userAgent != null) ...{ |
|
|
|
}; |
|
|
|
'User-Agent': _userAgent, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
T _addCommonSettings<T extends BaseApiClient>(final T apiClient) { |
|
|
|
T _addCommonSettings<T extends BaseApiClient>(final T apiClient) { |
|
|
|
var newApiClient = apiClient; |
|
|
|
var newApiClient = apiClient; |
|
|
@ -91,17 +87,11 @@ class NextcloudClient { |
|
|
|
/// App type the client will register as. Only relevant for notifications. See [AppType] for explanations. |
|
|
|
/// App type the client will register as. Only relevant for notifications. See [AppType] for explanations. |
|
|
|
final AppType appType; |
|
|
|
final AppType appType; |
|
|
|
|
|
|
|
|
|
|
|
/// Will be appended to the user-agent from [appType] |
|
|
|
/// Overrides the user-agent set by [appType] |
|
|
|
final String? userAgentSuffix; |
|
|
|
final String? userAgentOverride; |
|
|
|
|
|
|
|
|
|
|
|
/// User-agent made up from the user-agent from [appType] and the [userAgentSuffix] |
|
|
|
/// User-agent made up from the user-agent from [userAgentOverride] and the [appType] |
|
|
|
String? get userAgent { |
|
|
|
late String? userAgent = userAgentOverride ?? appType.userAgent; |
|
|
|
if (appType.userAgent != null || userAgentSuffix != null) { |
|
|
|
|
|
|
|
return [appType.userAgent, userAgentSuffix].where((final a) => a != null).join(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NextcloudWebDAVClient? _webdav; |
|
|
|
NextcloudWebDAVClient? _webdav; |
|
|
|
|
|
|
|
|
|
|
|