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
ed9fc1f8
Commit
ed9fc1f8
authored
Jul 30, 2019
by
Jose Blaya
Browse files
referralLink and canInvite attributes for invites and account endpoints
parent
1518c9da
Changes
5
Hide whitespace changes
Inline
Side-by-side
PIALibrary/Sources/Core/WebServices/AccountInfo.swift
View file @
ed9fc1f8
...
...
@@ -31,6 +31,9 @@ public struct AccountInfo {
/// The date by when the account is due to expire.
public
let
expirationDate
:
Date
/// Returns `true` if the account can refer friends and get extra days
public
let
canInvite
:
Bool
/// Returns `true` if the account has expired.
public
var
isExpired
:
Bool
{
return
(
expirationDate
.
timeIntervalSinceNow
<
0
)
...
...
PIALibrary/Sources/Core/WebServices/InvitesInformation.swift
View file @
ed9fc1f8
...
...
@@ -17,6 +17,8 @@ public struct InvitesInformation {
public
let
totalFreeDaysGiven
:
Int
public
let
uniqueReferralLink
:
String
public
let
invites
:
[
Invites
]
}
PIALibrary/Sources/Library/WebServices/GlossAccountInfo.swift
View file @
ed9fc1f8
...
...
@@ -16,12 +16,15 @@ class GlossAccountInfo: GlossParser {
let
email
:
String
?
=
"email"
<~~
json
let
productId
:
String
?
=
"product_id"
<~~
json
let
plan
:
Plan
=
"plan"
<~~
json
??
.
other
let
canInvite
:
Bool
=
"can_invite"
<~~
json
??
false
guard
let
isRenewable
:
Bool
=
"renewable"
<~~
json
else
{
return
nil
}
guard
let
isRecurring
:
Bool
=
"recurring"
<~~
json
else
{
return
nil
}
guard
let
expirationTime
:
TimeInterval
=
"expiration_time"
<~~
json
else
{
return
nil
}
...
...
@@ -40,6 +43,7 @@ class GlossAccountInfo: GlossParser {
isRenewable
:
isRenewable
,
isRecurring
:
isRecurring
,
expirationDate
:
Date
(
timeIntervalSince1970
:
expirationTime
),
canInvite
:
canInvite
,
shouldPresentExpirationAlert
:
shouldPresentExpirationAlert
,
renewUrl
:
renewUrl
)
...
...
@@ -54,6 +58,7 @@ extension AccountInfo: JSONEncodable {
"product_id"
~~>
productId
,
"plan"
~~>
plan
.
rawValue
,
"renewable"
~~>
isRenewable
,
"can_invite"
~~>
canInvite
,
"recurring"
~~>
isRecurring
,
"expiration_time"
~~>
expirationDate
.
timeIntervalSince1970
,
"expire_alert"
~~>
shouldPresentExpirationAlert
,
...
...
PIALibrary/Sources/Library/WebServices/GlossInvitesInformation.swift
View file @
ed9fc1f8
...
...
@@ -18,6 +18,11 @@ class GlossInvitesInformation: GlossParser {
let
totalInvites
:
Int
=
"total_invites_sent"
<~~
json
??
0
let
totalRewarded
:
Int
=
"total_invites_rewarded"
<~~
json
??
0
let
totalDays
:
Int
=
"total_free_days_given"
<~~
json
??
0
guard
let
uniqueReferralLink
:
String
=
"unique_referral_link"
<~~
json
else
{
return
nil
}
var
invites
:
[
Invites
]
=
[]
if
let
inviteJSON
=
json
[
"invites"
]
as?
[
JSON
]
{
...
...
@@ -48,6 +53,7 @@ class GlossInvitesInformation: GlossParser {
parsed
=
InvitesInformation
(
totalInvitesSent
:
totalInvites
,
totalInvitesRewarded
:
totalRewarded
,
totalFreeDaysGiven
:
totalDays
,
uniqueReferralLink
:
uniqueReferralLink
,
invites
:
invites
)
}
...
...
PIALibrary/Sources/Mock/MockAccountProvider.swift
View file @
ed9fc1f8
...
...
@@ -44,6 +44,9 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
/// Fakes authentication outcome.
public
var
mockIsUnauthorized
=
false
/// Fakes can invite.
public
var
mockCanInvite
=
false
/// Fakes sign-up outcome.
public
var
mockSignupOutcome
:
SignupOutcome
=
.
success
...
...
@@ -95,6 +98,7 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
isRenewable
:
self
.
mockIsRenewable
,
isRecurring
:
self
.
mockIsRecurring
,
expirationDate
:
self
.
mockExpirationDate
,
canInvite
:
self
.
mockCanInvite
,
shouldPresentExpirationAlert
:
self
.
mockIsExpiring
,
renewUrl
:
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