Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
23dc50b2
Commit
23dc50b2
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Update BackupReport model
parent
38c2aa56
No related branches found
No related tags found
1 merge request
!102
Release 1.0.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Models/BackupReport.swift
+5
-19
5 additions, 19 deletions
Sources/ElixxirDAppsSDK/Models/BackupReport.swift
Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift
+4
-5
4 additions, 5 deletions
Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift
with
9 additions
and
24 deletions
Sources/ElixxirDAppsSDK/Models/BackupReport.swift
+
5
−
19
View file @
23dc50b2
...
@@ -2,21 +2,21 @@ import Foundation
...
@@ -2,21 +2,21 @@ import Foundation
public
struct
BackupReport
:
Equatable
{
public
struct
BackupReport
:
Equatable
{
public
init
(
public
init
(
id
s
:
[
Data
],
restoredContact
s
:
[
Data
],
params
:
Data
params
:
Data
)
{
)
{
self
.
ids
=
id
s
self
.
restoredContacts
=
restoredContact
s
self
.
params
=
params
self
.
params
=
params
}
}
public
var
id
s
:
[
Data
]
public
var
restoredContact
s
:
[
Data
]
public
var
params
:
Data
public
var
params
:
Data
}
}
extension
BackupReport
:
Codable
{
extension
BackupReport
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
enum
CodingKeys
:
String
,
CodingKey
{
case
ids
=
"BackupIdListJson
"
case
restoredContacts
=
"RestoredContacts
"
case
params
=
"
Backup
Params"
case
params
=
"Params"
}
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
...
@@ -26,18 +26,4 @@ extension BackupReport: Codable {
...
@@ -26,18 +26,4 @@ extension BackupReport: Codable {
public
func
encode
()
throws
->
Data
{
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
try
JSONEncoder
()
.
encode
(
self
)
}
}
public
init
(
from
decoder
:
Decoder
)
throws
{
let
container
=
try
decoder
.
container
(
keyedBy
:
CodingKeys
.
self
)
let
idsData
=
try
container
.
decode
(
Data
.
self
,
forKey
:
.
ids
)
ids
=
try
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
idsData
)
params
=
try
container
.
decode
(
Data
.
self
,
forKey
:
.
params
)
}
public
func
encode
(
to
encoder
:
Encoder
)
throws
{
var
container
=
encoder
.
container
(
keyedBy
:
CodingKeys
.
self
)
let
idsData
=
try
JSONEncoder
()
.
encode
(
ids
)
try
container
.
encode
(
idsData
,
forKey
:
.
ids
)
try
container
.
encode
(
params
,
forKey
:
.
params
)
}
}
}
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift
+
4
−
5
View file @
23dc50b2
...
@@ -4,24 +4,23 @@ import XCTest
...
@@ -4,24 +4,23 @@ import XCTest
final
class
BackupReportTests
:
XCTestCase
{
final
class
BackupReportTests
:
XCTestCase
{
func
testCoding
()
throws
{
func
testCoding
()
throws
{
let
id
s
:
[
Data
]
=
[
let
restoredContact
s
:
[
Data
]
=
[
"id1"
.
data
(
using
:
.
utf8
)
!
,
"id1"
.
data
(
using
:
.
utf8
)
!
,
"id2"
.
data
(
using
:
.
utf8
)
!
,
"id2"
.
data
(
using
:
.
utf8
)
!
,
"id3"
.
data
(
using
:
.
utf8
)
!
,
"id3"
.
data
(
using
:
.
utf8
)
!
,
]
]
let
idsB64
=
try
JSONEncoder
()
.
encode
(
ids
)
.
base64EncodedString
()
let
paramsB64
=
"cGFyYW1z"
let
paramsB64
=
"cGFyYW1z"
let
jsonString
=
"""
let
jsonString
=
"""
{
{
"
BackupIdListJson
":
"
\(
idsB64
)
"
,
"
RestoredContacts
":
[
\(
restoredContacts
.
map
{
"
\"\(
$0
.
base64EncodedString
()
)\"
"
}
.
joined
(
separator
:
", "
)
)
]
,
"
Backup
Params
": "
\(
paramsB64
)
"
"
Params
": "
\(
paramsB64
)
"
}
}
"""
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
model
=
try
BackupReport
.
decode
(
jsonData
)
let
model
=
try
BackupReport
.
decode
(
jsonData
)
XCTAssertNoDifference
(
model
,
BackupReport
(
XCTAssertNoDifference
(
model
,
BackupReport
(
ids
:
id
s
,
restoredContacts
:
restoredContact
s
,
params
:
Data
(
base64Encoded
:
paramsB64
)
!
params
:
Data
(
base64Encoded
:
paramsB64
)
!
))
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment