Pecuario.Backend

<back to all web services

GetMeasurementUnits

The following routes are available for this service:
GET/api/v1/utils/units
import 'package:servicestack/servicestack.dart';

class Status implements IConvertible
{
    String? message;
    int? statusCode;

    Status({this.message,this.statusCode});
    Status.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        message = json['message'];
        statusCode = json['statusCode'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'message': message,
        'statusCode': statusCode
    };

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

class BaseResponse implements IConvertible
{
    Status? status;

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

    fromMap(Map<String, dynamic> json) {
        status = JsonConverters.fromJson(json['status'],'Status',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'status': JsonConverters.toJson(status,'Status',context!)
    };

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

class MeasurementUnit implements IConvertible
{
    int? id;
    // @required()
    // @StringLength(10)
    String? code;

    // @required()
    // @StringLength(100)
    String? name;

    MeasurementUnit({this.id,this.code,this.name});
    MeasurementUnit.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        code = json['code'];
        name = json['name'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'code': code,
        'name': name
    };

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

class GetMeasurementUnitsResponse extends BaseResponse implements IConvertible
{
    List<MeasurementUnit>? units;

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

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        units = JsonConverters.fromJson(json['units'],'List<MeasurementUnit>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'units': JsonConverters.toJson(units,'List<MeasurementUnit>',context!)
    });

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

class GetMeasurementUnits implements IGet, IConvertible
{
    GetMeasurementUnits();
    GetMeasurementUnits.fromJson(Map<String, dynamic> json) : super();
    fromMap(Map<String, dynamic> json) {
        return this;
    }

    Map<String, dynamic> toJson() => {};
    getTypeName() => "GetMeasurementUnits";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'pecuario_backend.develsystems.com', types: <String, TypeInfo> {
    'Status': TypeInfo(TypeOf.Class, create:() => Status()),
    'BaseResponse': TypeInfo(TypeOf.Class, create:() => BaseResponse()),
    'MeasurementUnit': TypeInfo(TypeOf.Class, create:() => MeasurementUnit()),
    'GetMeasurementUnitsResponse': TypeInfo(TypeOf.Class, create:() => GetMeasurementUnitsResponse()),
    'List<MeasurementUnit>': TypeInfo(TypeOf.Class, create:() => <MeasurementUnit>[]),
    'GetMeasurementUnits': TypeInfo(TypeOf.Class, create:() => GetMeasurementUnits()),
});

Dart GetMeasurementUnits DTOs

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

HTTP + JSV

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

GET /api/v1/utils/units HTTP/1.1 
Host: pecuario-backend.develsystems.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	units: 
	[
		{
			id: 0,
			code: String,
			name: String
		}
	]
}