Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2025-07-17 16:56:02 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
32d9af8e621ef3347f8dd6817969fed8af227d6e
32d9af8e
1 parent
e46b41a6
added getProfile implementation
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
4 deletions
NETWORK_TESTING_AUTHORIZATION.md
SwiftWarplyFramework/SwiftWarplyFramework/Core/WarplySDK.swift
SwiftWarplyFramework/SwiftWarplyFramework/Network/Endpoints.swift
SwiftWarplyFramework/SwiftWarplyFramework/Network/NetworkService.swift
SwiftWarplyFramework/SwiftWarplyFramework/models/ProfileModel.swift
NETWORK_TESTING_AUTHORIZATION.md
View file @
32d9af8
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/Core/WarplySDK.swift
View file @
32d9af8
...
...
@@ -2177,6 +2177,65 @@ public final class WarplySDK {
}
}
// MARK: - Profile
/// Get user profile details
/// - Parameters:
/// - completion: Completion handler with profile model
/// - failureCallback: Failure callback with error code
public
func
getProfile
(
completion
:
@escaping
(
ProfileModel
?)
->
Void
,
failureCallback
:
@escaping
(
Int
)
->
Void
)
{
Task
{
do
{
let
endpoint
=
Endpoint
.
getProfile
let
response
=
try
await
networkService
.
requestRaw
(
endpoint
)
await
MainActor
.
run
{
if
response
[
"status"
]
as?
Int
==
1
{
let
dynatraceEvent
=
LoyaltySDKDynatraceEventModel
()
dynatraceEvent
.
_eventName
=
"custom_success_get_profile_loyalty"
dynatraceEvent
.
_parameters
=
nil
self
.
postFrameworkEvent
(
"dynatrace"
,
sender
:
dynatraceEvent
)
if
let
responseDataResult
=
response
[
"result"
]
as?
[
String
:
Any
]
{
let
profileModel
=
ProfileModel
(
dictionary
:
responseDataResult
)
completion
(
profileModel
)
}
else
{
completion
(
nil
)
}
}
else
{
let
dynatraceEvent
=
LoyaltySDKDynatraceEventModel
()
dynatraceEvent
.
_eventName
=
"custom_error_get_profile_loyalty"
dynatraceEvent
.
_parameters
=
nil
self
.
postFrameworkEvent
(
"dynatrace"
,
sender
:
dynatraceEvent
)
failureCallback
(
-
1
)
}
}
}
catch
{
await
MainActor
.
run
{
self
.
handleError
(
error
,
context
:
"getProfile"
,
endpoint
:
"getProfile"
,
failureCallback
:
failureCallback
)
}
}
}
}
/// Get user profile details (async/await variant)
/// - Returns: Profile model
/// - Throws: WarplyError if the request fails
public
func
getProfile
()
async
throws
->
ProfileModel
{
return
try
await
withCheckedThrowingContinuation
{
continuation
in
getProfile
(
completion
:
{
profile
in
if
let
profile
=
profile
{
continuation
.
resume
(
returning
:
profile
)
}
else
{
continuation
.
resume
(
throwing
:
WarplyError
.
networkError
)
}
},
failureCallback
:
{
errorCode
in
continuation
.
resume
(
throwing
:
WarplyError
.
unknownError
(
errorCode
))
})
}
}
// MARK: - Market
/// Get market pass details
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Network/Endpoints.swift
View file @
32d9af8
...
...
@@ -85,6 +85,9 @@ public enum Endpoint {
case
validateCoupon
(
coupon
:
[
String
:
Any
])
case
redeemCoupon
(
productId
:
String
,
productUuid
:
String
,
merchantId
:
String
)
// Profile
case
getProfile
// Events
case
sendEvent
(
eventName
:
String
,
priority
:
Bool
)
...
...
@@ -127,7 +130,7 @@ public enum Endpoint {
return
"/api/mobile/v2/{appUUID}/context/"
// Authenticated Context endpoints - /oauth/{appUUID}/context
case
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
case
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
getProfile
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
return
"/oauth/{appUUID}/context"
// Session endpoints - /api/session/{sessionUuid}
...
...
@@ -156,7 +159,7 @@ public enum Endpoint {
switch
self
{
case
.
register
,
.
changePassword
,
.
resetPassword
,
.
requestOtp
,
.
verifyTicket
,
.
refreshToken
,
.
logout
,
.
getCampaigns
,
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getCouponSets
,
.
getAvailableCoupons
,
.
getMarketPassDetails
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
,
.
getMerchants
,
.
sendEvent
,
.
sendDeviceInfo
,
.
getCosmoteUser
:
.
getMarketPassDetails
,
.
getProfile
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
,
.
getMerchants
,
.
sendEvent
,
.
sendDeviceInfo
,
.
getCosmoteUser
:
return
.
POST
case
.
getSingleCampaign
,
.
getNetworkStatus
:
return
.
GET
...
...
@@ -295,6 +298,14 @@ public enum Endpoint {
]
]
case
.
getProfile
:
return
[
"consumer_data"
:
[
"action"
:
"handle_user_details"
,
"process"
:
"get"
]
]
// Card Management endpoints - nested structure with cards wrapper
case
.
addCard
(
let
cardNumber
,
let
cardIssuer
,
let
cardHolder
,
let
expirationMonth
,
let
expirationYear
):
return
[
...
...
@@ -433,7 +444,7 @@ public enum Endpoint {
return
.
standardContext
// Authenticated Context - /oauth/{appUUID}/context
case
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
case
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
getProfile
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
return
.
authenticatedContext
// Authentication - /oauth/{appUUID}/login, /oauth/{appUUID}/token
...
...
@@ -475,7 +486,7 @@ public enum Endpoint {
return
.
standard
// Bearer Token Authentication (loyalty headers + Authorization: Bearer)
case
.
changePassword
,
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
case
.
changePassword
,
.
getCampaignsPersonalized
,
.
getCoupons
,
.
getMarketPassDetails
,
.
getProfile
,
.
addCard
,
.
getCards
,
.
deleteCard
,
.
getTransactionHistory
,
.
getPointsHistory
,
.
validateCoupon
,
.
redeemCoupon
:
return
.
bearerToken
// Basic Authentication (loyalty headers + Authorization: Basic)
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Network/NetworkService.swift
View file @
32d9af8
...
...
@@ -950,6 +950,21 @@ extension NetworkService {
return
response
}
// MARK: - Profile Methods
/// Get user profile details
/// - Returns: Response dictionary containing user profile information
/// - Throws: NetworkError if request fails
public
func
getProfile
()
async
throws
->
[
String
:
Any
]
{
print
(
"🔄 [NetworkService] Getting user profile..."
)
let
endpoint
=
Endpoint
.
getProfile
let
response
=
try
await
requestRaw
(
endpoint
)
print
(
"✅ [NetworkService] Get profile request completed"
)
return
response
}
// MARK: - Coupon Operations Methods
/// Validate a coupon for the user
...
...
SwiftWarplyFramework/SwiftWarplyFramework/models/ProfileModel.swift
0 → 100644
View file @
32d9af8
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment