#Script Pages

<back to all web services

QueryGitHubRepos

import 'package:servicestack/servicestack.dart';

// @DataContract
abstract class QueryBase
{
    // @DataMember(Order=1)
    int? skip;

    // @DataMember(Order=2)
    int? take;

    // @DataMember(Order=3)
    String? orderBy;

    // @DataMember(Order=4)
    String? orderByDesc;

    // @DataMember(Order=5)
    String? include;

    // @DataMember(Order=6)
    String? fields;

    // @DataMember(Order=7)
    Map<String,String?>? meta;

    QueryBase({this.skip,this.take,this.orderBy,this.orderByDesc,this.include,this.fields,this.meta});
    QueryBase.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        skip = json['skip'];
        take = json['take'];
        orderBy = json['orderBy'];
        orderByDesc = json['orderByDesc'];
        include = json['include'];
        fields = json['fields'];
        meta = JsonConverters.toStringMap(json['meta']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'skip': skip,
        'take': take,
        'orderBy': orderBy,
        'orderByDesc': orderByDesc,
        'include': include,
        'fields': fields,
        'meta': meta
    };

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

abstract class QueryData<T> extends QueryBase
{
    QueryData();
    QueryData.fromJson(Map<String, dynamic> json) : super.fromJson(json);
    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson();
    getTypeName() => "QueryData<$T>";
    TypeContext? context = _ctx;
}

class GithubUser implements IConvertible
{
    int? id;
    String? login;
    String? avatar_Url;
    String? url;
    int? followers;
    int? following;
    String? type;
    int? public_Gists;
    String? location;
    String? company;
    String? html_Url;
    int? public_Repos;
    DateTime? created_At;
    String? blog;
    String? email;
    String? name;
    bool? hireable;
    String? gravatar_Id;
    String? bio;

    GithubUser({this.id,this.login,this.avatar_Url,this.url,this.followers,this.following,this.type,this.public_Gists,this.location,this.company,this.html_Url,this.public_Repos,this.created_At,this.blog,this.email,this.name,this.hireable,this.gravatar_Id,this.bio});
    GithubUser.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        login = json['login'];
        avatar_Url = json['avatar_Url'];
        url = json['url'];
        followers = json['followers'];
        following = json['following'];
        type = json['type'];
        public_Gists = json['public_Gists'];
        location = json['location'];
        company = json['company'];
        html_Url = json['html_Url'];
        public_Repos = json['public_Repos'];
        created_At = JsonConverters.fromJson(json['created_At'],'DateTime',context!);
        blog = json['blog'];
        email = json['email'];
        name = json['name'];
        hireable = json['hireable'];
        gravatar_Id = json['gravatar_Id'];
        bio = json['bio'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'login': login,
        'avatar_Url': avatar_Url,
        'url': url,
        'followers': followers,
        'following': following,
        'type': type,
        'public_Gists': public_Gists,
        'location': location,
        'company': company,
        'html_Url': html_Url,
        'public_Repos': public_Repos,
        'created_At': JsonConverters.toJson(created_At,'DateTime',context!),
        'blog': blog,
        'email': email,
        'name': name,
        'hireable': hireable,
        'gravatar_Id': gravatar_Id,
        'bio': bio
    };

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

class GithubRepo implements IConvertible
{
    int? id;
    String? name;
    String? description;
    String? homepage;
    String? language;
    int? watchers_Count;
    int? stargazes_Count;
    int? forks_Count;
    int? open_Issues_Count;
    int? size;
    String? full_Name;
    DateTime? created_at;
    DateTime? pushed_At;
    DateTime? updated_At;
    bool? has_issues;
    bool? has_Downloads;
    bool? has_Wiki;
    bool? has_Pages;
    bool? fork;
    GithubUser? owner;
    String? svn_Url;
    String? mirror_Url;
    String? url;
    String? ssh_Url;
    String? html_Url;
    String? clone_Url;
    String? git_Url;
    bool? private;

    GithubRepo({this.id,this.name,this.description,this.homepage,this.language,this.watchers_Count,this.stargazes_Count,this.forks_Count,this.open_Issues_Count,this.size,this.full_Name,this.created_at,this.pushed_At,this.updated_At,this.has_issues,this.has_Downloads,this.has_Wiki,this.has_Pages,this.fork,this.owner,this.svn_Url,this.mirror_Url,this.url,this.ssh_Url,this.html_Url,this.clone_Url,this.git_Url,this.private});
    GithubRepo.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        name = json['name'];
        description = json['description'];
        homepage = json['homepage'];
        language = json['language'];
        watchers_Count = json['watchers_Count'];
        stargazes_Count = json['stargazes_Count'];
        forks_Count = json['forks_Count'];
        open_Issues_Count = json['open_Issues_Count'];
        size = json['size'];
        full_Name = json['full_Name'];
        created_at = JsonConverters.fromJson(json['created_at'],'DateTime',context!);
        pushed_At = JsonConverters.fromJson(json['pushed_At'],'DateTime',context!);
        updated_At = JsonConverters.fromJson(json['updated_At'],'DateTime',context!);
        has_issues = json['has_issues'];
        has_Downloads = json['has_Downloads'];
        has_Wiki = json['has_Wiki'];
        has_Pages = json['has_Pages'];
        fork = json['fork'];
        owner = JsonConverters.fromJson(json['owner'],'GithubUser',context!);
        svn_Url = json['svn_Url'];
        mirror_Url = json['mirror_Url'];
        url = json['url'];
        ssh_Url = json['ssh_Url'];
        html_Url = json['html_Url'];
        clone_Url = json['clone_Url'];
        git_Url = json['git_Url'];
        private = json['private'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
        'description': description,
        'homepage': homepage,
        'language': language,
        'watchers_Count': watchers_Count,
        'stargazes_Count': stargazes_Count,
        'forks_Count': forks_Count,
        'open_Issues_Count': open_Issues_Count,
        'size': size,
        'full_Name': full_Name,
        'created_at': JsonConverters.toJson(created_at,'DateTime',context!),
        'pushed_At': JsonConverters.toJson(pushed_At,'DateTime',context!),
        'updated_At': JsonConverters.toJson(updated_At,'DateTime',context!),
        'has_issues': has_issues,
        'has_Downloads': has_Downloads,
        'has_Wiki': has_Wiki,
        'has_Pages': has_Pages,
        'fork': fork,
        'owner': JsonConverters.toJson(owner,'GithubUser',context!),
        'svn_Url': svn_Url,
        'mirror_Url': mirror_Url,
        'url': url,
        'ssh_Url': ssh_Url,
        'html_Url': html_Url,
        'clone_Url': clone_Url,
        'git_Url': git_Url,
        'private': private
    };

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

class QueryGitHubRepos extends QueryData<GithubRepo> implements IConvertible
{
    String? userName;

    QueryGitHubRepos({this.userName});
    QueryGitHubRepos.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        userName = json['userName'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'userName': userName
    });

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

class Order implements IConvertible
{
    int? orderId;
    String? customerId;
    DateTime? orderDate;
    double? total;

    Order({this.orderId,this.customerId,this.orderDate,this.total});
    Order.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        orderId = json['orderId'];
        customerId = json['customerId'];
        orderDate = JsonConverters.fromJson(json['orderDate'],'DateTime',context!);
        total = JsonConverters.toDouble(json['total']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'orderId': orderId,
        'customerId': customerId,
        'orderDate': JsonConverters.toJson(orderDate,'DateTime',context!),
        'total': total
    };

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

class Customer implements IConvertible
{
    String? customerId;
    String? companyName;
    String? address;
    String? city;
    String? region;
    String? postalCode;
    String? country;
    String? phone;
    String? fax;
    List<Order>? orders;

    Customer({this.customerId,this.companyName,this.address,this.city,this.region,this.postalCode,this.country,this.phone,this.fax,this.orders});
    Customer.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        customerId = json['customerId'];
        companyName = json['companyName'];
        address = json['address'];
        city = json['city'];
        region = json['region'];
        postalCode = json['postalCode'];
        country = json['country'];
        phone = json['phone'];
        fax = json['fax'];
        orders = JsonConverters.fromJson(json['orders'],'List<Order>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'customerId': customerId,
        'companyName': companyName,
        'address': address,
        'city': city,
        'region': region,
        'postalCode': postalCode,
        'country': country,
        'phone': phone,
        'fax': fax,
        'orders': JsonConverters.toJson(orders,'List<Order>',context!)
    };

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

// @DataContract
class QueryResponse<Customer> implements IConvertible
{
    // @DataMember(Order=1)
    int? offset;

    // @DataMember(Order=2)
    int? total;

    // @DataMember(Order=3)
    List<Customer>? results;

    // @DataMember(Order=4)
    Map<String,String?>? meta;

    // @DataMember(Order=5)
    ResponseStatus? responseStatus;

    QueryResponse({this.offset,this.total,this.results,this.meta,this.responseStatus});
    QueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        offset = json['offset'];
        total = json['total'];
        results = JsonConverters.fromJson(json['results'],'List<${runtimeGenericTypeDefs(this,[0]).join(",")}>',context!);
        meta = JsonConverters.toStringMap(json['meta']);
        responseStatus = JsonConverters.fromJson(json['responseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'offset': offset,
        'total': total,
        'results': JsonConverters.toJson(results,'List<Customer>',context!),
        'meta': meta,
        'responseStatus': JsonConverters.toJson(responseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "QueryResponse<$Customer>";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'sharpscript.net', types: <String, TypeInfo> {
    'GithubUser': TypeInfo(TypeOf.Class, create:() => GithubUser()),
    'GithubRepo': TypeInfo(TypeOf.Class, create:() => GithubRepo()),
    'QueryGitHubRepos': TypeInfo(TypeOf.Class, create:() => QueryGitHubRepos()),
    'List<GithubRepo>': TypeInfo(TypeOf.Class, create:() => <GithubRepo>[]),
    'Order': TypeInfo(TypeOf.Class, create:() => Order()),
    'Customer': TypeInfo(TypeOf.Class, create:() => Customer()),
    'List<Order>': TypeInfo(TypeOf.Class, create:() => <Order>[]),
    'QueryResponse<Customer>': TypeInfo(TypeOf.Class, create:() => QueryResponse<Customer>()),
});

Dart QueryGitHubRepos 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 /json/reply/QueryGitHubRepos HTTP/1.1 
Host: sharpscript.net 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"userName":"String","skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"offset":0,"total":0,"results":[{"id":0,"name":"String","description":"String","homepage":"String","language":"String","watchers_Count":0,"stargazes_Count":0,"forks_Count":0,"open_Issues_Count":0,"size":0,"full_Name":"String","created_at":"\/Date(-62135596800000-0000)\/","pushed_At":"\/Date(-62135596800000-0000)\/","updated_At":"\/Date(-62135596800000-0000)\/","has_issues":false,"has_Downloads":false,"has_Wiki":false,"has_Pages":false,"fork":false,"owner":{"id":0,"login":"String","avatar_Url":"String","url":"String","followers":0,"following":0,"type":"String","public_Gists":0,"location":"String","company":"String","html_Url":"String","public_Repos":0,"created_At":"\/Date(-62135596800000-0000)\/","blog":"String","email":"String","name":"String","hireable":false,"gravatar_Id":"String","bio":"String"},"svn_Url":"String","mirror_Url":"String","url":"String","ssh_Url":"String","html_Url":"String","clone_Url":"String","git_Url":"String","private":false}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}