Pecuario.Backend

<back to all web services

GetProfile

Requires Authentication
The following routes are available for this service:
GET/api/v1/profile
import Foundation
import ServiceStack

public class GetProfile : IGet, Codable
{
    required public init(){}
}

public class GetProfileResponse : BaseResponse
{
    public var firstName:String
    public var lastName:String
    public var userType:String
    public var phoneNumber:String
    public var country:String

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

    private enum CodingKeys : String, CodingKey {
        case firstName
        case lastName
        case userType
        case phoneNumber
        case country
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        firstName = try container.decodeIfPresent(String.self, forKey: .firstName)
        lastName = try container.decodeIfPresent(String.self, forKey: .lastName)
        userType = try container.decodeIfPresent(String.self, forKey: .userType)
        phoneNumber = try container.decodeIfPresent(String.self, forKey: .phoneNumber)
        country = try container.decodeIfPresent(String.self, forKey: .country)
    }

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

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(){}
}


Swift GetProfile 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/profile HTTP/1.1 
Host: pecuario-backend.develsystems.com 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"firstName":"String","lastName":"String","userType":"String","phoneNumber":"String","country":"String"}