WS-RESTRICTED_API Host [RESTRICTED_API] : D5290-staging

<back to all web services

url_shortener

URL Shortener
The following routes are available for this service:
GET,POST/url_shortener
import 'package:servicestack/servicestack.dart';

class url_shortenerResponse implements IConvertible
{
    String? tiny_url;
    String? original_url;
    DateTime? created_date;
    DateTime? expiry_date;
    int? collision;

    url_shortenerResponse({this.tiny_url,this.original_url,this.created_date,this.expiry_date,this.collision});
    url_shortenerResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        tiny_url = json['tiny_url'];
        original_url = json['original_url'];
        created_date = JsonConverters.fromJson(json['created_date'],'DateTime',context!);
        expiry_date = JsonConverters.fromJson(json['expiry_date'],'DateTime',context!);
        collision = json['collision'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'tiny_url': tiny_url,
        'original_url': original_url,
        'created_date': JsonConverters.toJson(created_date,'DateTime',context!),
        'expiry_date': JsonConverters.toJson(expiry_date,'DateTime',context!),
        'collision': collision
    };

    getTypeName() => "url_shortenerResponse";
    TypeContext? context = _ctx;
}

enum operationType
{
    NoOperation,
    ShortenUrl,
    GetOriginalUrl,
    RedirectUrl,
}

class url_shortener implements IConvertible
{
    /**
    * operation type
    */
    // @ApiMember(DataType="string", Description="operation type", IsRequired=true, Name="operation", ParameterType="body")
    operationType? operation;

    /**
    * url
    */
    // @ApiMember(DataType="string", Description="url", IsRequired=true, Name="url", ParameterType="body")
    String? url;

    /**
    * days to expire
    */
    // @ApiMember(DataType="string", Description="days to expire", Name="days", ParameterType="body")
    double? days;

    url_shortener({this.operation,this.url,this.days});
    url_shortener.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        operation = JsonConverters.fromJson(json['operation'],'operationType',context!);
        url = json['url'];
        days = JsonConverters.toDouble(json['days']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'operation': JsonConverters.toJson(operation,'operationType',context!),
        'url': url,
        'days': days
    };

    getTypeName() => "url_shortener";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'milliet.io', types: <String, TypeInfo> {
    'url_shortenerResponse': TypeInfo(TypeOf.Class, create:() => url_shortenerResponse()),
    'operationType': TypeInfo(TypeOf.Enum, enumValues:operationType.values),
    'url_shortener': TypeInfo(TypeOf.Class, create:() => url_shortener()),
});

Dart url_shortener DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /url_shortener HTTP/1.1 
Host: milliet.io 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"operation":"0x4E71","url":"String","days":0}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"tiny_url":"String","original_url":"String","created_date":"0001-01-01T00:00:00.0000000","expiry_date":"0001-01-01T00:00:00.0000000","collision":0}