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
dab0c90a
Commit
dab0c90a
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Refactor UdMultiLookupCallback.Result
parent
bcf22fb3
No related branches found
No related tags found
2 merge requests
!102
Release 1.0.0
,
!93
Lookup, Multi-Lookup and Search API improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
+34
-15
34 additions, 15 deletions
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
with
34 additions
and
15 deletions
Sources/XXClient/Callbacks/UdMultiLookupCallback.swift
+
34
−
15
View file @
dab0c90a
...
...
@@ -2,9 +2,20 @@ import Bindings
import
XCTestDynamicOverlay
public
struct
UdMultiLookupCallback
{
public
enum
Result
:
Equatable
{
case
success
([
Contact
])
case
failure
(
error
:
NSError
,
failedIDs
:
[
Data
])
public
struct
Result
:
Equatable
{
public
init
(
contacts
:
[
Contact
],
failedIds
:
[
Data
],
errors
:
[
NSError
]
)
{
self
.
contacts
=
contacts
self
.
failedIds
=
failedIds
self
.
errors
=
errors
}
public
var
contacts
:
[
Contact
]
public
var
failedIds
:
[
Data
]
public
var
errors
:
[
NSError
]
}
public
init
(
handle
:
@escaping
(
Result
)
->
Void
)
{
...
...
@@ -30,23 +41,31 @@ extension UdMultiLookupCallback {
let
callback
:
UdMultiLookupCallback
func
callback
(
_
contactListJSON
:
Data
?,
failedIDs
:
Data
?,
err
:
Error
?)
{
var
result
=
UdMultiLookupCallback
.
Result
(
contacts
:
[],
failedIds
:
[],
errors
:
[]
)
if
let
err
=
err
{
callback
.
handle
(
.
failure
(
error
:
err
as
NSError
,
failedIDs
:
failedIDs
.
map
{
(
try
?
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
$0
))
??
[]
}
??
[]
))
}
else
if
let
contactListJSON
=
contactListJSON
{
result
.
errors
.
append
(
err
as
NSError
)
}
if
let
contactListJSON
=
contactListJSON
{
do
{
result
.
contacts
=
try
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
contactListJSON
)
.
map
{
Contact
.
live
(
$0
)
}
}
catch
{
result
.
errors
.
append
(
error
as
NSError
)
}
}
if
let
failedIDs
=
failedIDs
{
do
{
let
contactsData
=
try
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
contactListJSON
)
let
contacts
:
[
Contact
]
=
contactsData
.
map
{
Contact
.
live
(
$0
)
}
callback
.
handle
(
.
success
(
contacts
))
result
.
failedIds
=
try
JSONDecoder
()
.
decode
([
Data
]
.
self
,
from
:
failedIDs
)
}
catch
{
callback
.
handle
(
.
failure
(
error
:
error
as
NSError
,
failedIDs
:
[])
)
result
.
errors
.
append
(
error
as
NSError
)
}
}
else
{
fatalError
(
"BindingsUdMultiLookupCallbackProtocol received `nil` contactListJSON and `nil` error"
)
}
callback
.
handle
(
result
)
}
}
...
...
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