Pecuario.Backend

<back to all web services

GetFarm

Requires Authentication
The following routes are available for this service:
GET/api/v1/farms/{Id}
import Foundation
import ServiceStack

public class GetFarm : IGet, Codable
{
    public var id:Int

    required public init(){}
}

public class GetFarmResponse : BaseResponse
{
    public var farm:Farm

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case farm
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        farm = try container.decodeIfPresent(Farm.self, forKey: .farm)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if farm != nil { try container.encode(farm, forKey: .farm) }
    }
}

public class BaseResponse : Codable
{
    public var status:Status

    required public init(){}
}

public class Status : Codable
{
    public var message:String
    public var statusCode:Int

    required public init(){}
}

public class Farm : Codable
{
    public var id:Int
    // @References(typeof(AppUser))
    public var userId:Int

    // @Required()
    // @StringLength(100)
    public var name:String?

    // @References(typeof(Region))
    public var regionId:Int?

    // @References(typeof(MeasurementUnit))
    public var measurementUnitId:Int?

    public var area:Double?

    required public init(){}
}


Swift GetFarm 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/farms/{Id} HTTP/1.1 
Host: pecuario-backend.develsystems.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	farm: 
	{
		id: 0,
		userId: 0,
		name: String,
		regionId: 0,
		measurementUnitId: 0,
		area: 0
	}
}