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
1ecd925e
Commit
1ecd925e
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add NotificationReport model
parent
a0cd9910
No related branches found
No related tags found
2 merge requests
!102
Release 1.0.0
,
!56
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/XXClient/Models/NotificationReport.swift
+47
-0
47 additions, 0 deletions
Sources/XXClient/Models/NotificationReport.swift
Tests/XXClientTests/Models/NotificationReportTests.swift
+31
-0
31 additions, 0 deletions
Tests/XXClientTests/Models/NotificationReportTests.swift
with
78 additions
and
0 deletions
Sources/XXClient/Models/NotificationReport.swift
0 → 100644
+
47
−
0
View file @
1ecd925e
import
Foundation
public
struct
NotificationReport
:
Equatable
{
public
enum
ReportType
:
String
,
Equatable
{
case
`
default
`
case
request
case
reset
case
confirm
case
silent
case
e2e
case
group
case
endFT
case
groupRQ
}
public
init
(
forMe
:
Bool
,
type
:
NotificationReport
.
ReportType
,
source
:
Data
)
{
self
.
forMe
=
forMe
self
.
type
=
type
self
.
source
=
source
}
public
var
forMe
:
Bool
public
var
type
:
ReportType
public
var
source
:
Data
}
extension
NotificationReport
.
ReportType
:
Codable
{}
extension
NotificationReport
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
forMe
=
"ForMe"
case
type
=
"Type"
case
source
=
"Source"
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Tests/XXClientTests/Models/NotificationReportTests.swift
0 → 100644
+
31
−
0
View file @
1ecd925e
import
CustomDump
import
XCTest
@testable
import
XXClient
final
class
NotificationReportTests
:
XCTestCase
{
func
testCoding
()
throws
{
let
forMe
=
true
let
type
=
NotificationReport
.
ReportType
.
default
let
sourceB64
=
"dGVzdGVyMTIzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
let
jsonString
=
"""
{
"
ForMe
": true,
"
Type
": "
\(
type
.
rawValue
)
",
"
Source
": "
\(
sourceB64
)
"
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
model
=
try
NotificationReport
.
decode
(
jsonData
)
XCTAssertNoDifference
(
model
,
NotificationReport
(
forMe
:
forMe
,
type
:
type
,
source
:
Data
(
base64Encoded
:
sourceB64
)
!
))
let
encodedModel
=
try
model
.
encode
()
let
decodedModel
=
try
NotificationReport
.
decode
(
encodedModel
)
XCTAssertNoDifference
(
decodedModel
,
model
)
}
}
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