Skip to content

Commit

Permalink
Merge pull request #90 from olgadanylova/master
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
Olha Danylova authored Jun 25, 2019
2 parents 618771a + bbd9999 commit 56925e1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 44 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# RELEASE HISTORY

### 0.0.14 / ?, 2019
### 0.0.14 / June 25, 2019
* the sendEmails functions renamed into the sendEmailFromTemplate:
```
func sendEmailFromTemplate(templateName: String, envelope: EmailEnvelope, responseHandler: ((MessageStatus) -> Void)!, errorHandler: ((Fault) -> Void)!)
func sendEmailFromTemplate(templateName: String, templateValues: [String : String], envelope: EmailEnvelope, responseHandler: ((MessageStatus) -> Void)!, errorHandler: ((Fault) -> Void)!)
```
* added custom serialization/deserialization for class BackendlessGeoQuery

### 0.0.13 / June, 21 2019
* the EmailEnvelope signatures changed
Expand Down
36 changes: 36 additions & 0 deletions Sources/SwiftSDK/Geo/BackendlessGeoQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,46 @@
case rectangle
case pageSize
case offset
case relativeFindMetadata
case relativeFindPercentThreshold
case degreePerPixel
case clusterGridSize
}

required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
geoPoint = try container.decodeIfPresent(GeoPoint.self, forKey: .geoPoint)
_radius = try container.decodeIfPresent(Double.self, forKey: ._radius)
categories = try container.decodeIfPresent([String].self, forKey: .categories)
includemetadata = try container.decodeIfPresent(Bool.self, forKey: .includemetadata) ?? false
_metadata = try container.decodeIfPresent(JSON.self, forKey: ._metadata)
whereClause = try container.decodeIfPresent(String.self, forKey: .whereClause)
rectangle = try container.decodeIfPresent(GeoQueryRectangle.self, forKey: .rectangle)
pageSize = try container.decodeIfPresent(Int.self, forKey: .pageSize) ?? 10
offset = try container.decodeIfPresent(Int.self, forKey: .offset) ?? 0
relativeFindMetadata = try container.decodeIfPresent([String: String].self, forKey: .relativeFindMetadata)
relativeFindPercentThreshold = try container.decodeIfPresent(Double.self, forKey: .relativeFindPercentThreshold) ?? 0.0
degreePerPixel = try container.decodeIfPresent(Double.self, forKey: .degreePerPixel) ?? 0.0
clusterGridSize = try container.decodeIfPresent(Double.self, forKey: .clusterGridSize) ?? 100.0
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(geoPoint, forKey: .geoPoint)
try container.encodeIfPresent(_radius, forKey: ._radius)
try container.encodeIfPresent(categories, forKey: .categories)
try container.encode(includemetadata, forKey: .includemetadata)
try container.encodeIfPresent(_metadata, forKey: ._metadata)
try container.encodeIfPresent(whereClause, forKey: .whereClause)
try container.encodeIfPresent(rectangle, forKey: .rectangle)
try container.encode(pageSize, forKey: .pageSize)
try container.encode(offset, forKey: .offset)
try container.encodeIfPresent(relativeFindMetadata, forKey: .relativeFindMetadata)
try container.encode(relativeFindPercentThreshold, forKey: .relativeFindPercentThreshold)
try container.encode(degreePerPixel, forKey: .degreePerPixel)
try container.encode(clusterGridSize, forKey: .clusterGridSize)
}

open func setUnits(units: Int) {
self.units = units
}
Expand Down
55 changes: 16 additions & 39 deletions Sources/SwiftSDK/Messaging/EmailEnvelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,29 @@

@objcMembers open class EmailEnvelope: NSObject {

private var to = [String]()
private var cc = [String]()
private var bcc = [String]()
private var recipientsQuery: String?
open var to: [String]?
open var cc: [String]?
open var bcc: [String]?
open var query: String?

open func addTo(to: [String]) {
self.to.append(contentsOf: to)
}

open func setTo(to: [String]) {
self.to = to
}

open func getTo() -> [String] {
return self.to
if self.to == nil {
self.to = [String]()
}
self.to!.append(contentsOf: to)
}

open func addCc(cc: [String]) {
self.cc.append(contentsOf: cc)
}

open func setCc(cc: [String]) {
self.cc = cc
}

open func getCc() -> [String] {
return self.cc
if self.cc == nil {
self.cc = [String]()
}
self.cc!.append(contentsOf: cc)
}

open func addBcc(bcc: [String]) {
self.bcc.append(contentsOf: bcc)
}

open func setBcc(bcc: [String]) {
self.bcc = bcc
}

open func getBcc() -> [String] {
return self.bcc
}

open func setRecipientsQuery(recipientsQuery: String) {
self.recipientsQuery = recipientsQuery
}

open func getRecipientsQuery() -> String? {
return self.recipientsQuery
if self.bcc == nil {
self.bcc = [String]()
}
self.bcc!.append(contentsOf: bcc)
}
}
8 changes: 4 additions & 4 deletions Sources/SwiftSDK/Messaging/MessagingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@
let headers = ["Content-Type": "application/json"]
var parameters = [String : Any]()
parameters["template-name"] = templateName
parameters["addresses"] = envelope.getTo()
parameters["cc-addresses"] = envelope.getCc()
parameters["bcc-addresses"] = envelope.getBcc()
parameters["criteria"] = envelope.getRecipientsQuery()
parameters["addresses"] = envelope.to
parameters["cc-addresses"] = envelope.cc
parameters["bcc-addresses"] = envelope.bcc
parameters["criteria"] = envelope.query
if let templateValues = templateValues {
parameters["template-values"] = templateValues
}
Expand Down
Binary file not shown.

0 comments on commit 56925e1

Please sign in to comment.