Cochrane+ App API

<back to all web services

SubmitThunderBoltAction

Requires Authentication
The following routes are available for this service:
POST/thunderbolt/submit
import Foundation
import ServiceStack

public class SubmitThunderBoltAction : ApiServiceRequest
{
    public var actionId:Int
    public var platform:ContactInteractionPlatform
    public var number:String
    public var email:String
    public var notes:String
    public var dateTime:Date
    public var contactId:Int

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

    private enum CodingKeys : String, CodingKey {
        case actionId
        case platform
        case number
        case email
        case notes
        case dateTime
        case contactId
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        actionId = try container.decodeIfPresent(Int.self, forKey: .actionId)
        platform = try container.decodeIfPresent(ContactInteractionPlatform.self, forKey: .platform)
        number = try container.decodeIfPresent(String.self, forKey: .number)
        email = try container.decodeIfPresent(String.self, forKey: .email)
        notes = try container.decodeIfPresent(String.self, forKey: .notes)
        dateTime = try container.decodeIfPresent(Date.self, forKey: .dateTime)
        contactId = try container.decodeIfPresent(Int.self, forKey: .contactId)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if actionId != nil { try container.encode(actionId, forKey: .actionId) }
        if platform != nil { try container.encode(platform, forKey: .platform) }
        if number != nil { try container.encode(number, forKey: .number) }
        if email != nil { try container.encode(email, forKey: .email) }
        if notes != nil { try container.encode(notes, forKey: .notes) }
        if dateTime != nil { try container.encode(dateTime, forKey: .dateTime) }
        if contactId != nil { try container.encode(contactId, forKey: .contactId) }
    }
}

public class ApiServiceRequest : IServiceRequest, IHasApiKey, IHasDeviceInfo, Codable
{
    /**
    * The API Key required for authentication
    */
    // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
    public var apiKey:String

    /**
    * Latitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Latitude of the user making this request")
    public var latitude:Double

    /**
    * Longitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Longitude of the user making this request")
    public var longitude:Double

    required public init(){}
}

public enum ContactInteractionPlatform : Int, Codable
{
    case None = 0
    case Whatsapp = 1
    case Linkus = 2
    case Mobile = 3
    case Outlook = 4
    case LinkedIn = 5
    case Telegram = 6
    case Signal = 7
    case Sms = 8
}

public class SubmitThunderBoltActionResponse : GetThunderBoltActionsResponse
{
    public var thunderboltActionEventId:Int

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

    private enum CodingKeys : String, CodingKey {
        case thunderboltActionEventId
    }

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

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

public class GetThunderBoltActionsResponse : ApiServiceResponse
{
    public var dailyActionsNumber:Int
    public var supportingDocumentProbability:Int
    public var thunderBoltActions:[ThunderBoltActionData] = []
    public var thunderBoltActionEvents:[ThunderBoltActionEventData] = []
    public var contacts:[ContactData] = []

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

    private enum CodingKeys : String, CodingKey {
        case dailyActionsNumber
        case supportingDocumentProbability
        case thunderBoltActions
        case thunderBoltActionEvents
        case contacts
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        dailyActionsNumber = try container.decodeIfPresent(Int.self, forKey: .dailyActionsNumber)
        supportingDocumentProbability = try container.decodeIfPresent(Int.self, forKey: .supportingDocumentProbability)
        thunderBoltActions = try container.decodeIfPresent([ThunderBoltActionData].self, forKey: .thunderBoltActions) ?? []
        thunderBoltActionEvents = try container.decodeIfPresent([ThunderBoltActionEventData].self, forKey: .thunderBoltActionEvents) ?? []
        contacts = try container.decodeIfPresent([ContactData].self, forKey: .contacts) ?? []
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if dailyActionsNumber != nil { try container.encode(dailyActionsNumber, forKey: .dailyActionsNumber) }
        if supportingDocumentProbability != nil { try container.encode(supportingDocumentProbability, forKey: .supportingDocumentProbability) }
        if thunderBoltActions.count > 0 { try container.encode(thunderBoltActions, forKey: .thunderBoltActions) }
        if thunderBoltActionEvents.count > 0 { try container.encode(thunderBoltActionEvents, forKey: .thunderBoltActionEvents) }
        if contacts.count > 0 { try container.encode(contacts, forKey: .contacts) }
    }
}

public class ApiServiceResponse : IServiceResponse, Codable
{
    public var Description:String
    public var heading:String
    public var wasSuccessful:Bool
    //modelState:Object ignored. Type could not be extended in Swift

    required public init(){}
}

public class ThunderBoltActionData : Codable
{
    public var id:Int
    public var actionName:String
    public var color:String
    public var dailyActionCount:Int
    public var showNumberInput:Bool
    public var showEmailInput:Bool
    public var showPlatformInput:Bool
    public var showDateTimeInput:Bool
    public var contactInteractionPlatforms:[EnumOption] = []

    required public init(){}
}

public class EnumOption : Codable
{
    public var value:Int
    public var label:String

    required public init(){}
}

public class ThunderBoltActionEventData : Codable
{
    public var id:Int
    public var createdDate:String
    public var actionId:Int
    public var actionName:String
    public var color:String
    public var notes:String

    required public init(){}
}

public class ContactData : Codable
{
    public var contactId:Int
    public var contactName:String
    public var email:String
    public var phoneNumber:String

    required public init(){}
}


Swift SubmitThunderBoltAction 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.

POST /thunderbolt/submit HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	actionId: 0,
	platform: 0,
	number: String,
	email: String,
	notes: String,
	dateTime: 0001-01-01,
	contactId: 0,
	apiKey: String,
	latitude: 0,
	longitude: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	thunderboltActionEventId: 0,
	dailyActionsNumber: 0,
	supportingDocumentProbability: 0,
	thunderBoltActions: 
	[
		{
			id: 0,
			actionName: String,
			color: String,
			dailyActionCount: 0,
			showNumberInput: False,
			showEmailInput: False,
			showPlatformInput: False,
			showDateTimeInput: False,
			contactInteractionPlatforms: 
			[
				{
					value: 0,
					label: String
				}
			]
		}
	],
	thunderBoltActionEvents: 
	[
		{
			id: 0,
			createdDate: String,
			actionId: 0,
			actionName: String,
			color: String,
			notes: String
		}
	],
	contacts: 
	[
		{
			
		}
	],
	description: String,
	heading: String,
	wasSuccessful: False,
	modelState: {}
}