| POST | /api/sendmessage | ||
|---|---|---|---|
| POST | /api/sendmessage/immediate | ||
| POST | /api/send | ||
| POST | /api/sms/send | ||
| POST | /api/send/immediate | ||
| POST | /api/sms/send/immediate |
import Foundation
import ServiceStack
/**
* Saves the specified SMS and sends it for background processing
*/
// @Api(Description="Saves the specified SMS and sends it for background processing")
public class SMSSend : Codable
{
public var smsModel:SMSModel
public var createCommunicationReferencesImmediately:Bool
required public init(){}
}
public class SMSModel : BaseLicenseeEnforcedServiceModel
{
public var from:SMSContact
public var to:[SMSContact]
public var messageBody:String
public var replyIsAllowed:Bool
public var replyIsRequired:Bool
public var notes:String
public var linkedObjectId:String
public var suiteId:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case from
case to
case messageBody
case replyIsAllowed
case replyIsRequired
case notes
case linkedObjectId
case suiteId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
from = try container.decodeIfPresent(SMSContact.self, forKey: .from)
to = try container.decodeIfPresent([SMSContact].self, forKey: .to) ?? []
messageBody = try container.decodeIfPresent(String.self, forKey: .messageBody)
replyIsAllowed = try container.decodeIfPresent(Bool.self, forKey: .replyIsAllowed)
replyIsRequired = try container.decodeIfPresent(Bool.self, forKey: .replyIsRequired)
notes = try container.decodeIfPresent(String.self, forKey: .notes)
linkedObjectId = try container.decodeIfPresent(String.self, forKey: .linkedObjectId)
suiteId = try container.decodeIfPresent(String.self, forKey: .suiteId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if from != nil { try container.encode(from, forKey: .from) }
if to != nil { try container.encode(to, forKey: .to) }
if messageBody != nil { try container.encode(messageBody, forKey: .messageBody) }
if replyIsAllowed != nil { try container.encode(replyIsAllowed, forKey: .replyIsAllowed) }
if replyIsRequired != nil { try container.encode(replyIsRequired, forKey: .replyIsRequired) }
if notes != nil { try container.encode(notes, forKey: .notes) }
if linkedObjectId != nil { try container.encode(linkedObjectId, forKey: .linkedObjectId) }
if suiteId != nil { try container.encode(suiteId, forKey: .suiteId) }
}
}
public class BaseLicenseeEnforcedServiceModel : Codable
{
public var licenseeId:String
required public init(){}
}
public class SMSContact : Codable
{
public var name:String
public var phoneNumber:String
public var contactId:String
required public init(){}
}
public class CommResponse : Codable
{
public var commId:String
public var reference:String
public var status:Bool
public var message:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/sendmessage HTTP/1.1
Host: production-eros-gateway-api-sms-wa.azurewebsites.net
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<SMSSend xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Dvaravartman.Common.Model.ServiceModel">
<CreateCommunicationReferencesImmediately>false</CreateCommunicationReferencesImmediately>
<SMSModel xmlns:d2p1="http://schemas.datacontract.org/2004/07/Eros.Subtle.Dvaravartman.Common.Model">
<LicenseeId xmlns="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.Library.ServiceModels">00000000-0000-0000-0000-000000000000</LicenseeId>
<d2p1:From>
<d2p1:ContactId>00000000-0000-0000-0000-000000000000</d2p1:ContactId>
<d2p1:Name>String</d2p1:Name>
<d2p1:PhoneNumber>String</d2p1:PhoneNumber>
</d2p1:From>
<d2p1:LinkedObjectId>00000000-0000-0000-0000-000000000000</d2p1:LinkedObjectId>
<d2p1:MessageBody>String</d2p1:MessageBody>
<d2p1:Notes>String</d2p1:Notes>
<d2p1:ReplyIsAllowed>false</d2p1:ReplyIsAllowed>
<d2p1:ReplyIsRequired>false</d2p1:ReplyIsRequired>
<d2p1:SuiteId>00000000-0000-0000-0000-000000000000</d2p1:SuiteId>
<d2p1:To>
<d2p1:SMSContact>
<d2p1:ContactId>00000000-0000-0000-0000-000000000000</d2p1:ContactId>
<d2p1:Name>String</d2p1:Name>
<d2p1:PhoneNumber>String</d2p1:PhoneNumber>
</d2p1:SMSContact>
</d2p1:To>
</SMSModel>
</SMSSend>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CommResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Dvaravartman.Common.Model"> <CommId>00000000-0000-0000-0000-000000000000</CommId> <Message>String</Message> <Reference>String</Reference> <Status>false</Status> </CommResponse>