import 'package:json_annotation/json_annotation.dart';

part 'file_sharing_api_params.g.dart';

// includeIfNull:false so the optional sharing fields below are only sent when
// set — otherwise the OCS query would carry `permissions=null` etc. and be
// rejected.
@JsonSerializable(includeIfNull: false)
class FileSharingApiParams {
  int shareType;
  String shareWith;
  String path;
  String? referenceId;
  String? talkMetaData;

  /// Permission bitmask (see `share_permissions.dart`).
  int? permissions;

  /// Public link password.
  String? password;

  /// Expiry as `YYYY-MM-DD`.
  String? expireDate;

  FileSharingApiParams({
    required this.shareType,
    required this.shareWith,
    required this.path,
    this.referenceId,
    this.talkMetaData,
    this.permissions,
    this.password,
    this.expireDate,
  });

  factory FileSharingApiParams.fromJson(Map<String, dynamic> json) =>
      _$FileSharingApiParamsFromJson(json);
  Map<String, dynamic> toJson() => _$FileSharingApiParamsToJson(this);
}
