Pecuario.Backend

<back to all web services

GetFarms

Requires Authentication
The following routes are available for this service:
GET/api/v1/farms
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 Farm implements IConvertible
{
    int? id;
    // @References(typeof(AppUser))
    int? userId;

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

    // @References(typeof(Region))
    int? regionId;

    // @References(typeof(MeasurementUnit))
    int? measurementUnitId;

    double? area;

    Farm({this.id,this.userId,this.name,this.regionId,this.measurementUnitId,this.area});
    Farm.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        userId = json['userId'];
        name = json['name'];
        regionId = json['regionId'];
        measurementUnitId = json['measurementUnitId'];
        area = JsonConverters.toDouble(json['area']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'userId': userId,
        'name': name,
        'regionId': regionId,
        'measurementUnitId': measurementUnitId,
        'area': area
    };

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

class GetFarmsResponse extends BaseResponse implements IConvertible
{
    List<Farm>? farms;

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

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

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

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

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

    Map<String, dynamic> toJson() => {};
    getTypeName() => "GetFarms";
    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()),
    'Farm': TypeInfo(TypeOf.Class, create:() => Farm()),
    'GetFarmsResponse': TypeInfo(TypeOf.Class, create:() => GetFarmsResponse()),
    'List<Farm>': TypeInfo(TypeOf.Class, create:() => <Farm>[]),
    'GetFarms': TypeInfo(TypeOf.Class, create:() => GetFarms()),
});

Dart GetFarms 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.

GET /api/v1/farms HTTP/1.1 
Host: pecuario-backend.develsystems.com 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"farms":[{"id":0,"userId":0,"name":"String","regionId":0,"measurementUnitId":0,"area":0}]}