ContentType
public struct ContentType : CustomStringConvertible, Equatable
The ContentType struct represents the common types of Content Types used
when sending through the SendGrid API.
-
The first part of the content type, for example
textintext/html.Declaration
Swift
public let type: String -
The second part of the content type, for example
htmlintext/html.Declaration
Swift
public let subtype: String -
The full value of the content type.
Declaration
Swift
public var description: String { get }
-
Initializes the struct with a type and subtype. These two parameters will be combined with a
/between to create the value of the Content-Type header.Declaration
Swift
public init(type: String, subtype: String)Parameters
typeThe first part of the content type, for example
textintext/html.subtypeThe second part of the content type, for example
htmlintext/html. -
Initializes the struct with a raw value. The raw value should be a string containing a type and subtype separated by a
/character, such astext/html
. If the provided value is invalid,nilis returned.Declaration
Swift
public init?(rawValue: String)Parameters
rawValueA
Stringrepresenting the value of the content type.
-
Validates that the content-type has no CLRF characters.
Declaration
Swift
public func validate() throws
-
Represents
application/x-www-form-urlencoded
encodings.Declaration
Swift
static let formUrlEncoded: ContentType -
The
application/json
content type.Declaration
Swift
static let json: ContentType -
The
text/plain
content type, used for the plain text portion of an email.Declaration
Swift
static let plainText: ContentType -
The
text/html
content type, used for the HTML portion of an email.Declaration
Swift
static let htmlText: ContentType -
The
application/csv
content type, used for CSV attachments.Declaration
Swift
static let csv: ContentType -
The
application/pdf
content type, used for PDF attachments.Declaration
Swift
static let pdf: ContentType -
The
application/zip
content type, used for Zip file attachments.Declaration
Swift
static let zip: ContentType -
The
image/png
content type, used for PNG images.Declaration
Swift
static let png: ContentType -
The
image/jpeg
content type, used for JPEG images.Declaration
Swift
static let jpeg: ContentType -
The
text/x-amp-html
content type, used for Google AMP support.Declaration
Swift
static let amp: ContentType
View on GitHub
ContentType Structure Reference