shlink-manager/lib/API/Classes/ShortURL/short_url.dart

46 lines
1.6 KiB
Dart
Raw Normal View History

2024-01-27 23:07:06 +01:00
import 'package:shlink_app/API/Classes/ShortURL/device_long_urls.dart';
import 'package:shlink_app/API/Classes/ShortURL/short_url_meta.dart';
import 'package:shlink_app/API/Classes/ShortURL/visits_summary.dart';
/// Data about a short URL
class ShortURL {
/// Slug of the short URL used in the URL
String shortCode;
/// Entire short URL
String shortUrl;
/// Long URL where the user gets redirected to
String longUrl;
/// Device-specific long URLs
DeviceLongUrls deviceLongUrls;
/// Creation date of the short URL
DateTime dateCreated;
/// Visitor data
VisitsSummary visitsSummary;
/// List of tags assigned to this short URL
List<dynamic> tags;
/// Metadata
ShortURLMeta meta;
/// Associated domain
String? domain;
/// Optional title
String? title;
/// Whether the short URL is crawlable by a web crawler
bool crawlable;
ShortURL(this.shortCode, this.shortUrl, this.longUrl, this.deviceLongUrls, this.dateCreated, this.visitsSummary, this.tags, this.meta, this.domain, this.title, this.crawlable);
/// Converts the JSON data from the API to an instance of [ShortURL]
ShortURL.fromJson(Map<String, dynamic> json):
shortCode = json["shortCode"],
shortUrl = json["shortUrl"],
longUrl = json["longUrl"],
deviceLongUrls = DeviceLongUrls.fromJson(json["deviceLongUrls"]),
dateCreated = DateTime.parse(json["dateCreated"]),
visitsSummary = VisitsSummary.fromJson(json["visitsSummary"]),
tags = json["tags"],
meta = ShortURLMeta.fromJson(json["meta"]),
domain = json["domain"],
title = json["title"],
crawlable = json["crawlable"];
}