Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Commit badf834

Browse files
authored
Dev - Release prep 3.1.0 (#177)
* add page and limit params * fix unit tests * convert let to var * codable conformance + tests * default `unpublished` to false if the key is missing * update to 3.1.0 * update CHANGELOG.md
1 parent fee425f commit badf834

22 files changed

+326
-362
lines changed

BLOCKv.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Pod::Spec.new do |s|
77
s.name = 'BLOCKv'
8-
s.version = '3.0.1'
8+
s.version = '3.1.0'
99
s.summary = 'The BLOCKv SDK allows you to easily integrate your apps into the BLOCKv Platform.'
1010
s.homepage = 'https://blockv.io'
1111
s.license = { :type => 'BLOCKv AG', :file => 'LICENSE' }

BlockV/Core/Network/Models/Activity/MessageListModel.swift

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ public struct MessageListModel: Equatable {
2020
*/
2121

2222
// Inner model
23-
struct InnerModel: Decodable {
23+
struct InnerModel: Codable {
2424
let message: MessageModel
2525
// let whenModified: Date
2626

2727
enum CodingKeys: String, CodingKey {
2828
case message
29-
case whenModified = "when_modified"
29+
// case whenModified = "when_modified"
3030
}
3131

32+
init(message: MessageModel) {
33+
self.message = message
34+
}
35+
36+
// MARK: - Codable
37+
3238
init(from decoder: Decoder) throws {
3339
let container = try decoder.container(keyedBy: CodingKeys.self)
3440
self.message = try container.decode(MessageModel.self, forKey: .message)
@@ -37,12 +43,17 @@ public struct MessageListModel: Equatable {
3743
// whenModified = Date(timeIntervalSince1970: _whenModified / 1000)
3844
}
3945

46+
func encode(to encoder: Encoder) throws {
47+
var container = encoder.container(keyedBy: CodingKeys.self)
48+
try container.encode(message, forKey: .message)
49+
}
50+
4051
}
4152

4253
/// Filters out all threads more recent than the cursor (useful for paging).
43-
public let cursor: String
54+
public var cursor: String
4455
/// Array of messages for the specifed thread.
45-
public let messages: [MessageModel]
56+
public var messages: [MessageModel]
4657

4758
enum CodingKeys: String, CodingKey {
4859
case cursor
@@ -51,16 +62,21 @@ public struct MessageListModel: Equatable {
5162

5263
}
5364

54-
extension MessageListModel: Decodable {
65+
extension MessageListModel: Codable {
5566

5667
public init(from decoder: Decoder) throws {
5768
let container = try decoder.container(keyedBy: CodingKeys.self)
5869
self.cursor = try container.decode(String.self, forKey: .cursor)
59-
//print(self.cursor)
6070
let inner = container.decodeSafelyArray(of: InnerModel.self, forKey: .messages)
61-
//print(inner)
6271
self.messages = inner.map { $0.message }
6372
print(self.messages)
6473
}
6574

75+
public func encode(to encoder: Encoder) throws {
76+
var container = encoder.container(keyedBy: CodingKeys.self)
77+
try container.encode(cursor, forKey: .cursor)
78+
let innerWrapper = messages.map { InnerModel(message: $0) }
79+
try container.encode(innerWrapper, forKey: .messages)
80+
}
81+
6682
}

BlockV/Core/Network/Models/Activity/ThreadListModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import Foundation
1515
public struct ThreadListModel: Equatable {
1616

1717
/// Filters out all threads more recent than the cursor (useful for paging).
18-
public let cursor: String
18+
public var cursor: String
1919
/// Array of threads
20-
public let threads: [ThreadModel]
20+
public var threads: [ThreadModel]
2121

2222
enum CodingKeys: String, CodingKey {
2323
case cursor

BlockV/Core/Network/Models/Package/VatomModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ extension VatomModel: Codable {
6969
let items = try decoder.container(keyedBy: CodingKeys.self)
7070
id = try items.decode(String.self, forKey: .id)
7171
version = try items.decode(String.self, forKey: .version)
72-
isUnpublished = try items.decode(Bool.self, forKey: .isUnpublished)
7372
whenCreated = try items.decode(Date.self, forKey: .whenCreated)
7473
whenModified = try items.decode(Date.self, forKey: .whenModified)
7574
props = try items.decode(RootProperties.self, forKey: .props)
76-
75+
76+
isUnpublished = try items.decodeIfPresent(Bool.self, forKey: .isUnpublished) ?? false
7777
`private` = try items.decodeIfPresent(JSON.self, forKey: .private)
7878
eos = try items.decodeIfPresent(JSON.self, forKey: .eos)
7979
eth = try items.decodeIfPresent(JSON.self, forKey: .eth)

BlockV/Core/Network/Params/DiscoverQueryBuilder.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ public class DiscoverQueryBuilder {
3737

3838
// - Public
3939

40-
/*
41-
Page and limit are not yet documented by the backend.
42-
They will be added in a later release.
43-
*/
44-
4540
/// The page to return.
4641
///
4742
/// Note: This property should only be use in conjunction with a non-zero `limit`
@@ -53,15 +48,15 @@ public class DiscoverQueryBuilder {
5348
/// "page": 1,
5449
/// "limit" : 10
5550
/// ```
56-
// public var page: Int = 0
51+
public var page: Int = 0
5752

5853
/// Limits the number of vAtoms returned in the response.
5954
///
6055
/// Defaults to zero - which enusres *all* results are returned.
6156
///
6257
/// Note that the API will return a maximum of 1000 vAtoms. The `page`
6358
/// property should be used to traverse the colleciton further.
64-
// public var limit: Int = 0
59+
public var limit: Int = 0
6560

6661
// - Private
6762

@@ -173,6 +168,8 @@ extension DiscoverQueryBuilder: DictionaryCodable {
173168
payload["filters"] = [["filter_elems": filterElems]] // filters is an array, the first element is
174169
}
175170
payload["return"] = self.resultStructure
171+
payload["limit"] = self.limit
172+
payload["page"] = self.page
176173

177174
return payload
178175

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
All notable changes to this project will be documented in this file.
33

44
#### 3.x Release (API v1)
5+
- `3.1.x` Releases - [3.1.0](#310)
56
- `3.0.x` Releases - [3.0.0](#300)
67

78
#### 2.x Releases (API v1)
@@ -19,6 +20,24 @@ All notable changes to this project will be documented in this file.
1920

2021
---
2122

23+
## [3.1.0](https://github.com/BLOCKvIO/ios-sdk/releases/tag/3.1.0)
24+
25+
### Updated
26+
27+
- Add `Codable` conformance to `MessageListModel`.
28+
- Convert `cursor` and `messages` properties on `MessageListModel` from `let` to `var` .
29+
- Convert `cursor` and `threads` properties on `MessageListModel` from `let` to `var`.
30+
- Pull Request [#175](https://github.com/BLOCKvIO/ios-sdk/pull/175)
31+
32+
- Add `page` and `limit` properties to `DiscoverQueryBuilder` to allow for paging.
33+
- Pull Request [#173](https://github.com/BLOCKvIO/ios-sdk/pull/173/files)
34+
35+
### Fixed
36+
37+
- Default `isPublished` is `false`. This allows vAtoms with a missing `unpublished` JSON key to be decoded.
38+
- Pull Request [#176](https://github.com/BLOCKvIO/ios-sdk/pull/176)
39+
40+
2241
## [3.0.0](https://github.com/BLOCKvIO/ios-sdk/releases/tag/3.0.0)
2342

2443
### Added

Example/BLOCKv Unit Tests/Face Selection Procedure/FaceSelectionProcedure_Tests.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,78 +13,78 @@ import XCTest
1313
@testable import BLOCKv
1414

1515
class FaceSelectionProcedure_Tests: XCTestCase {
16-
16+
1717
//TODO: Replace with official blockv decoder
1818
lazy private var decoder: JSONDecoder = {
1919
let decoder = JSONDecoder()
2020
decoder.dateDecodingStrategy = .iso8601
2121
return decoder
2222
}()
23-
23+
2424
override func setUp() {
2525
super.setUp()
2626
// Put setup code here. This method is called before the invocation of each test method in the class.
2727
}
28-
28+
2929
override func tearDown() {
3030
// Put teardown code here. This method is called after the invocation of each test method in the class.
3131
super.tearDown()
3232
}
33-
33+
3434
// MARK: - Tests
35-
35+
3636
///TODO: This does not yet test whether the native face is installed.
3737
func testEmbeddedIconSelectionProcedure() {
38-
38+
3939
do {
40-
40+
4141
// decode json into face models
4242
let faceModels = try decoder.decode([FaceModel].self, from: MockModelFaces.genericIconAnd3D)
4343
XCTAssertEqual(faceModels.count, 2)
44-
44+
4545
// decode json into a vatom model
4646
var vatomModel = try decoder.decode(VatomModel.self, from: MockModel.VatomModel.basicVatom)
4747
vatomModel.faceModels = faceModels
48-
48+
4949
let possibleBestFaceForIcon = EmbeddedProcedure.icon.procedure(vatomModel,
5050
["native://image", "native://generic-3d"])
51-
51+
5252
let bestFaceForIcon = try self.require(possibleBestFaceForIcon)
5353
XCTAssertEqual(bestFaceForIcon.id, "bbbb")
54-
54+
5555
} catch {
5656
XCTFail(error.localizedDescription)
5757
}
58-
58+
5959
}
60-
60+
6161
func testEmbeddedCardSelectionProcedure() {
62-
62+
6363
do {
6464
// decode json into pack model
6565
let faceModels = try decoder.decode([FaceModel].self, from: MockModelFaces.genericIconAnd3D)
6666
XCTAssertEqual(faceModels.count, 2)
67-
67+
6868
// decode json into a vatom model
6969
var vatomModel = try decoder.decode(VatomModel.self, from: MockModel.VatomModel.basicVatom)
7070
vatomModel.faceModels = faceModels
71-
71+
7272
let possibleBestFaceForCard = EmbeddedProcedure.card.procedure(vatomModel,
7373
["native://image", "native://generic-3d"])
7474
let bestFaceForCard = try self.require(possibleBestFaceForCard)
7575
XCTAssertEqual(bestFaceForCard.id, "aaaa")
76-
76+
7777
} catch {
7878
XCTFail(error.localizedDescription)
7979
}
80-
80+
8181
}
82-
82+
8383
func testPerformanceExample() {
8484
// This is an example of a performance test case.
8585
self.measure {
8686
// Put the code you want to measure the time of here.
8787
}
8888
}
89-
89+
9090
}

0 commit comments

Comments
 (0)