Skip to content

Commit

Permalink
fix TorrentSort params use snake case #23
Browse files Browse the repository at this point in the history
  • Loading branch information
yosemiteyss committed Sep 9, 2024
1 parent 54ca10c commit 1e80836
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 79 deletions.
60 changes: 30 additions & 30 deletions lib/src/v2/torrents/dto/torrent_list_options.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 92 additions & 49 deletions lib/src/v2/torrents/dto/torrent_sort.dart
Original file line number Diff line number Diff line change
@@ -1,51 +1,94 @@
enum TorrentSort {
addedOn('added_on'),
amountLeft('amount_left'),
autoTmm('auto_tmm'),
availability('availability'),
category('category'),
completed('completed'),
completionOn('completion_on'),
contentPath('content_path'),
dlLimit('dl_limit'),
dlSpeed('dlspeed'),
downloaded('downloaded'),
downloadedSession('downloaded_session'),
eta('eta'),
fLPiecePrio('f_l_piece_prio'),
forceStart('force_start'),
hash('hash'),
lastActivity('last_activity'),
magnetUri('magnet_uri'),
maxRatio('max_ratio'),
maxSeedingTime('max_seeding_time'),
name('name'),
numComplete('num_complete'),
numIncomplete('num_incomplete'),
numLeechs('num_leechs'),
numSeeds('num_seeds'),
priority('priority'),
progress('progress'),
ratio('ratio'),
ratioLimit('ratio_limit'),
savePath('save_path'),
seedingTime('seeding_time'),
seedingTimeLimit('seeding_time_limit'),
seenComplete('seen_complete'),
seqDl('seq_dl'),
size('size'),
state('state'),
superSeeding('super_seeding'),
tags('tags'),
timeActive('time_active'),
totalSize('total_size'),
tracker('tracker'),
upLimit('up_limit'),
uploaded('uploaded'),
uploadedSession('uploaded_session'),
upSpeed('upspeed');

const TorrentSort(this.value);
import 'package:json_annotation/json_annotation.dart';

final String value;
enum TorrentSort {
@JsonValue('added_on')
addedOn,
@JsonValue('amount_left')
amountLeft,
@JsonValue('auto_tmm')
autoTmm,
@JsonValue('availability')
availability,
@JsonValue('category')
category,
@JsonValue('completed')
completed,
@JsonValue('completion_on')
completionOn,
@JsonValue('content_path')
contentPath,
@JsonValue('dl_limit')
dlLimit,
@JsonValue('dlspeed')
dlSpeed,
@JsonValue('downloaded')
downloaded,
@JsonValue('downloaded_session')
downloadedSession,
@JsonValue('eta')
eta,
@JsonValue('f_l_piece_prio')
fLPiecePrio,
@JsonValue('force_start')
forceStart,
@JsonValue('hash')
hash,
@JsonValue('last_activity')
lastActivity,
@JsonValue('magnet_uri')
magnetUri,
@JsonValue('max_ratio')
maxRatio,
@JsonValue('max_seeding_time')
maxSeedingTime,
@JsonValue('name')
name,
@JsonValue('num_complete')
numComplete,
@JsonValue('num_incomplete')
numIncomplete,
@JsonValue('num_leechs')
numLeechs,
@JsonValue('num_seeds')
numSeeds,
@JsonValue('priority')
priority,
@JsonValue('progress')
progress,
@JsonValue('ratio')
ratio,
@JsonValue('ratio_limit')
ratioLimit,
@JsonValue('save_path')
savePath,
@JsonValue('seeding_time')
seedingTime,
@JsonValue('seeding_time_limit')
seedingTimeLimit,
@JsonValue('seen_complete')
seenComplete,
@JsonValue('seq_dl')
seqDl,
@JsonValue('size')
size,
@JsonValue('state')
state,
@JsonValue('super_seeding')
superSeeding,
@JsonValue('tags')
tags,
@JsonValue('time_active')
timeActive,
@JsonValue('total_size')
totalSize,
@JsonValue('tracker')
tracker,
@JsonValue('up_limit')
upLimit,
@JsonValue('uploaded')
uploaded,
@JsonValue('uploaded_session')
uploadedSession,
@JsonValue('upspeed')
upSpeed
}
12 changes: 12 additions & 0 deletions test/v2/torrents/dto/torrent_list_options_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:qbittorrent_api/qbittorrent_api.dart';
import 'package:test/test.dart';

void main() {
group('test TorrentSort', () {
test('should TorrentSort request parameters converted to snake case', () {
const listOptions = TorrentListOptions(sort: TorrentSort.addedOn);
final json = listOptions.toJson();
expect(json['sort'], 'added_on');
});
});
}

0 comments on commit 1e80836

Please sign in to comment.