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
2022-06-16 17:46:30 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cc8c1e683ba7cacab783677ade7ca0d4badd3d00
cc8c1e68
1 parent
a5c7c116
add consumerIntegrationAsync request
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
View file @
cc8c1e6
...
...
@@ -80,6 +80,7 @@
-
(
void
)
getInboxAsync
:(
void
(
^
)(
NSArray
*
list
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
verifyTicketAsync
:(
NSString
*
)
guid
:
(
NSString
*
)
ticket
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getProfileAsync
:(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
consumerIntegrationAsync
:(
NSNumber
*
)
nonTelco
:
(
NSNumber
*
)
acceptedConsent
:
(
NSArray
*
)
msisdnList
:
(
NSString
*
)
guid
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
@end
#endif
/* MyApi_h */
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
View file @
cc8c1e6
...
...
@@ -1321,4 +1321,18 @@ CMPedometer *pedometer;
failure
(
error
);
}];
}
-
(
void
)
consumerIntegrationAsync
:
(
NSNumber
*
)
nonTelco
:
(
NSNumber
*
)
acceptedConsent
:
(
NSArray
*
)
msisdnList
:
(
NSString
*
)
guid
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
consumerIntegrationWithSuccessBlock
:
nonTelco
:
acceptedConsent
:
msisdnList
:
guid
:^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
@end
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
View file @
cc8c1e6
...
...
@@ -328,6 +328,8 @@ WL_VERSION_INTERFACE()
andNickname
:(
NSString
*
)
nickname
andGender
:(
NSString
*
)
gender
andBirthday
:(
NSString
*
)
birthday
andNameDay
:(
NSString
*
)
nameday
andTaxID
:(
NSString
*
)
taxID
andProfileMetadata
:(
NSDictionary
*
)
profileMetadata
optin
:(
NSNumber
*
)
optin
newsLetter
:
(
NSNumber
*
)
newsletter
andSMS
:(
NSNumber
*
)
sms
andSegmentation
:(
NSNumber
*
)
segmentation
andSMSSegmentation
:(
NSNumber
*
)
smsSegmentation
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
consumerIntegrationWithSuccessBlock
:(
NSNumber
*
)
nonTelco
:
(
NSNumber
*
)
acceptedConsent
:
(
NSArray
*
)
msisdnList
:
(
NSString
*
)
guid
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
changeProfileImageWithSuccessBlock
:(
NSString
*
)
image
andUserId
:(
NSString
*
)
userId
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
View file @
cc8c1e6
...
...
@@ -994,6 +994,78 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
-
(
void
)
consumerIntegrationWithSuccessBlock
:
(
NSNumber
*
)
nonTelco
:
(
NSNumber
*
)
acceptedConsent
:
(
NSArray
*
)
msisdnList
:
(
NSString
*
)
guid
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
NSMutableDictionary
*
data
=
[[
NSMutableDictionary
alloc
]
init
];
if
(
nonTelco
&&
!
[
nonTelco
isEqual
:
@NO
])
{
[
data
setValue
:
nonTelco
forKey
:
@"nonTelco"
];
}
else
{
[
data
setValue
:
0
forKey
:
@"nonTelco"
];
}
if
(
acceptedConsent
&&
!
[
acceptedConsent
isEqual
:
@NO
])
{
[
data
setValue
:
acceptedConsent
forKey
:
@"acceptedConsent"
];
}
else
{
[
data
setValue
:
0
forKey
:
@"acceptedConsent"
];
}
if
(
msisdnList
&&
(
msisdnList
!=
nil
)
&&
([
msisdnList
count
]
!=
0
))
{
[
data
setValue
:
msisdnList
forKey
:
@"msisdnList"
];
}
else
{
[
data
setValue
:
nil
forKey
:
@"msisdnList"
];
}
if
(
guid
&&
!
[
guid
isEqual
:
@""
])
{
[
data
setValue
:
guid
forKey
:
@"guid"
];
}
else
{
[
data
setValue
:
@""
forKey
:
@"guid"
];
}
NSMutableDictionary
*
consumerData
=
[[
NSMutableDictionary
alloc
]
init
];
[
consumerData
setValue
:
@"integration"
forKey
:
@"action"
];
if
(
data
&&
!
[
data
isEqual
:@{}])
{
[
consumerData
setValue
:
data
forKey
:
@"data"
];
}
NSMutableDictionary
*
postDictionary
=
[[
NSMutableDictionary
alloc
]
init
];
[
postDictionary
setValue
:
consumerData
forKey
:
@"consumer_data"
];
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary
options
:
0
error
:
NULL
];
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
NSDictionary
*
dict
=
[
NSDictionary
alloc
];
dict
=
[
error
userInfo
];
NSString
*
errorCode
=
[
dict
objectForKey
:
@"NSLocalizedDescription"
];
if
([
errorCode
isEqual
:
@"Request failed: unauthorized (401)"
])
{
[
self
refreshToken
:
^
(
NSDictionary
*
response
)
{
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
failureBlock
:
^
(
NSError
*
error
)
{
if
(
failure
)
{
[
_db
executeUpdate
:
@"DROP TABLE requestVariables"
];
failure
(
error
);
}
NSLog
(
@"Error at token %@"
,
error
);
}];
}
NSLog
(
@"Error at consumer Integration %@"
,
error
);
}
}];
}
-
(
void
)
changeProfileImageWithSuccessBlock
:
(
NSString
*
)
image
andUserId
:
(
NSString
*
)
userId
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
NSDictionary
*
postDictionary
=
@{
@"action"
:
@"upload"
,
@"user_id"
:
userId
,
@"imageOnBase64"
:
image
};
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
cc8c1e6
...
...
@@ -1492,5 +1492,66 @@ public class swiftApi {
}
}
}
public
class
GenericResponseModel
{
private
var
result
:
Int
?
private
var
status
:
Int
?
private
var
msg
:
String
?
init
(
dictionary
:
[
String
:
Any
])
{
self
.
result
=
dictionary
[
"result"
]
as?
Int
?
??
-
1
self
.
status
=
dictionary
[
"status"
]
as?
Int
?
??
-
1
self
.
msg
=
dictionary
[
"msg"
]
as?
String
?
??
""
}
public
var
getResult
:
Int
{
get
{
// getter
return
self
.
result
??
-
1
}
}
public
var
getStatus
:
Int
{
get
{
// getter
return
self
.
status
??
-
1
}
}
public
var
getMsg
:
String
{
get
{
// getter
return
self
.
msg
??
""
}
}
}
public
func
consumerIntegrationAsync
(
nonTelco
:
Bool
,
acceptedConsent
:
Bool
,
msisdnList
:
Array
<
String
>
,
guid
:
String
,
_
consumerIntegrationCallback
:
@escaping
(
_
responseData
:
GenericResponseModel
?)
->
Void
)
->
Void
{
let
instanceOfMyApi
=
MyApi
()
instanceOfMyApi
.
consumerIntegrationAsync
(
nonTelco
as
NSNumber
,
acceptedConsent
as
NSNumber
,
msisdnList
,
guid
,
requestCallback
,
failureBlock
:
requestFailureCallback
)
func
requestCallback
(
_
responseData
:
[
AnyHashable
:
Any
]?)
->
Void
{
if
let
responseDataDictionary
=
responseData
as?
[
String
:
Any
]
{
let
tempResponse
=
GenericResponseModel
(
dictionary
:
responseDataDictionary
)
consumerIntegrationCallback
(
tempResponse
);
}
else
{
consumerIntegrationCallback
(
nil
)
}
}
func
requestFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"consumerIntegration error: "
)
print
(
error
)
print
(
"===================="
)
consumerIntegrationCallback
(
nil
)
}
}
}
...
...
Please
register
or
login
to post a comment