Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
liberty
tunnel
liberty-tunnel-client-library-apple
Commits
85e244a6
Commit
85e244a6
authored
Jul 31, 2019
by
Jose Blaya
Browse files
Add credentials object to request
parent
85f8e247
Changes
4
Hide whitespace changes
Inline
Side-by-side
PIALibrary/Sources/Core/WebServices/WebServices.swift
View file @
85e244a6
...
...
@@ -48,5 +48,5 @@ protocol WebServices: class {
func
invitesInformation
(
_
callback
:
LibraryCallback
<
InvitesInformation
>
?)
func
invite
(
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
func
invite
(
credentials
:
Credentials
,
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
}
PIALibrary/Sources/Library/Account/DefaultAccountProvider.swift
View file @
85e244a6
...
...
@@ -283,7 +283,12 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
}
func
invite
(
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
{
webServices
.
invite
(
name
:
name
,
email
:
email
,
{
result
in
guard
let
user
=
currentUser
else
{
preconditionFailure
()
}
webServices
.
invite
(
credentials
:
user
.
credentials
,
name
:
name
,
email
:
email
,
{
result
in
callback
?(
result
)
})
}
...
...
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
View file @
85e244a6
...
...
@@ -278,17 +278,18 @@ class PIAWebServices: WebServices, ConfigurationAccess {
}
func
invite
(
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
{
func
invite
(
credentials
:
Credentials
,
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
{
let
endpoint
=
ClientEndpoint
.
invites
let
status
=
[
200
,
400
]
let
status
=
[
200
,
400
,
401
]
let
errors
:
[
Int
:
ClientError
]
=
[
400
:
.
badReceipt
400
:
.
badReceipt
,
401
:
.
unauthorized
]
let
parameters
=
[
"invitee_name"
:
name
,
"invitee_email"
:
email
]
req
(
nil
,
.
post
,
endpoint
,
parameters
,
status
,
JSON
RequestExecutor
()
{
(
json
,
status
,
error
)
in
req
(
credentials
,
.
post
,
endpoint
,
parameters
,
status
,
Data
RequestExecutor
()
{
(
json
,
status
,
error
)
in
if
let
knownError
=
self
.
knownError
(
endpoint
,
status
,
errors
)
{
callback
?(
knownError
)
return
...
...
PIALibrary/Sources/Mock/MockWebServices.swift
View file @
85e244a6
...
...
@@ -77,7 +77,7 @@ class MockWebServices: WebServices {
callback
?(
result
,
error
)
}
func
invite
(
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
{
func
invite
(
credentials
:
Credentials
,
name
:
String
,
email
:
String
,
_
callback
:
SuccessLibraryCallback
?)
{
callback
?(
nil
)
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment