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
10a3cf59
Commit
10a3cf59
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add RestlikeRequestSender
parent
4fef11e7
No related branches found
No related tags found
1 merge request
!2
Bindings API wrapper
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift
+44
-0
44 additions, 0 deletions
Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift
with
44 additions
and
0 deletions
Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift
0 → 100644
+
44
−
0
View file @
10a3cf59
import
Bindings
public
struct
RestlikeRequestSender
{
public
var
send
:
(
Int
,
Int
,
Data
)
throws
->
Data
public
func
callAsFunction
(
clientId
:
Int
,
connectionId
:
Int
,
request
:
Data
)
throws
->
Data
{
try
send
(
clientId
,
connectionId
,
request
)
}
}
extension
RestlikeRequestSender
{
public
static
func
live
(
authenticated
:
Bool
)
->
RestlikeRequestSender
{
RestlikeRequestSender
{
clientId
,
connectionId
,
request
in
var
error
:
NSError
?
let
response
:
Data
?
if
authenticated
{
response
=
BindingsRestlikeRequestAuth
(
clientId
,
connectionId
,
request
,
&
error
)
}
else
{
response
=
BindingsRestlikeRequest
(
clientId
,
connectionId
,
request
,
&
error
)
}
if
let
error
=
error
{
throw
error
}
guard
let
response
=
response
else
{
let
functionName
=
"BindingsRestlikeRequest
\(
authenticated
?
"Auth"
:
""
)
"
fatalError
(
"
\(
functionName
)
returned `nil` without providing error"
)
}
return
response
}
}
}
#if DEBUG
extension
RestlikeRequestSender
{
public
static
let
failing
=
RestlikeRequestSender
{
_
,
_
,
_
in
struct
NotImplemented
:
Error
{}
throw
NotImplemented
()
}
}
#endif
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