BokaMera.API.Host

<back to all web services

ListWebhookMessages

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
GET/webhook/messagesList webhook message
import Foundation
import ServiceStack

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class ListWebhookMessages : ListMessagesRequestDto, ICompany
{
    /**
    * The company id, if empty will use the company id for the user you are logged in with.
    */
    // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.", IsRequired=true, ParameterType="query")
    public var companyId:String?

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

    private enum CodingKeys : String, CodingKey {
        case companyId
    }

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

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

public class ListMessagesRequestDto : ClientWebhookRequestBase
{
    public var before:Date?
    public var after:Date?
    public var channel:String
    public var iterator:String
    public var limit:Int?
    public var order:Ordering?
    public var eventTypes:[String] = []
    public var withContent:Bool?

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

    private enum CodingKeys : String, CodingKey {
        case before
        case after
        case channel
        case iterator
        case limit
        case order
        case eventTypes
        case withContent
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        before = try container.decodeIfPresent(Date.self, forKey: .before)
        after = try container.decodeIfPresent(Date.self, forKey: .after)
        channel = try container.decodeIfPresent(String.self, forKey: .channel)
        iterator = try container.decodeIfPresent(String.self, forKey: .iterator)
        limit = try container.decodeIfPresent(Int.self, forKey: .limit)
        order = try container.decodeIfPresent(Ordering.self, forKey: .order)
        eventTypes = try container.decodeIfPresent([String].self, forKey: .eventTypes) ?? []
        withContent = try container.decodeIfPresent(Bool.self, forKey: .withContent)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if before != nil { try container.encode(before, forKey: .before) }
        if after != nil { try container.encode(after, forKey: .after) }
        if channel != nil { try container.encode(channel, forKey: .channel) }
        if iterator != nil { try container.encode(iterator, forKey: .iterator) }
        if limit != nil { try container.encode(limit, forKey: .limit) }
        if order != nil { try container.encode(order, forKey: .order) }
        if eventTypes.count > 0 { try container.encode(eventTypes, forKey: .eventTypes) }
        if withContent != nil { try container.encode(withContent, forKey: .withContent) }
    }
}

public class ClientWebhookRequestBase : Codable
{
    public var clientId:String

    required public init(){}
}

public enum Ordering : Int, Codable
{
    case Ascending = 1
    case Descending = 2
}

public class ListMessagesResponseDto : Codable
{
    public var data:[GetMessageResponseDto] = []
    public var done:Bool
    public var iterator:String

    required public init(){}
}

public class GetMessageResponseDto : Codable
{
    public var id:String
    public var channels:[String] = []
    public var eventType:String
    public var metadata:[String:String] = [:]
    //payload:Object ignored. Type could not be extended in Swift
    public var eventId:String
    public var timestamp:Date

    required public init(){}
}


Swift ListWebhookMessages 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 /webhook/messages HTTP/1.1 
Host: api.bokamera.se 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Data":[{"Id":"String","Channels":["String"],"EventType":"String","Metadata":{"String":"String"},"Payload":{},"EventId":"String"}],"Done":false,"Iterator":"String"}