Skip to content

Commit

Permalink
update(27062): SNA URL request updated to POST (#7)
Browse files Browse the repository at this point in the history
* update(27062): SNA URL request changed to POST

* update(27062): UI updated to show SDK version on sample app

* update(27062): Method name updated

* update(27062): Tests updated
  • Loading branch information
mejiagarcia committed Sep 22, 2022
1 parent 104a18e commit 60bbb56
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions SNASources/CellularSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ @implementation CellularSession
@param url The URL to be requested
@return A string response from the request to the URL
*/
- (CellularSessionResult * _Nonnull)performGetRequest:(NSURL * _Nonnull)url {
- (CellularSessionResult * _Nonnull)performRequest:(NSURL * _Nonnull)url {
// Prepare a class to return results.
CellularSessionResult *sessionResult = [[CellularSessionResult alloc] init];
sessionResult.result = nil;
Expand Down Expand Up @@ -180,7 +180,7 @@ - (CellularSessionResult * _Nonnull)performGetRequest:(NSURL * _Nonnull)url {

// Create the HTTP request string
NSString *requestString = [NSString
stringWithFormat:@"GET %@%@ HTTP/1.2\r\nHost: %@%@\r\n",
stringWithFormat:@"POST %@%@ HTTP/1.2\r\nHost: %@%@\r\nAccept: */*\r\nContent-Type: application/json\r\nContent-Length: 0\r\n",
[url path],
[url query] ? [@"?" stringByAppendingString:[url query]] : @"",
[url host],
Expand Down
2 changes: 1 addition & 1 deletion SNASources/include/CellularSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "CellularSessionProtocol.h"

@interface CellularSession : NSObject <CellularSessionProtocol>
- (CellularSessionResult * _Nonnull)performGetRequest:(NSURL * _Nonnull)url;
- (CellularSessionResult * _Nonnull)performRequest:(NSURL * _Nonnull)url;
@end

#endif /* HTTPRequester_h */
2 changes: 1 addition & 1 deletion SNASources/include/CellularSessionProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

@protocol CellularSessionProtocol
@required
- (CellularSessionResult * _Nonnull)performGetRequest:(NSURL * _Nonnull)url;
- (CellularSessionResult * _Nonnull)performRequest:(NSURL * _Nonnull)url;
@end
2 changes: 1 addition & 1 deletion Sources/Networking/NetworkRequestProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension NetworkRequestProvider: NetworkRequestProviderProtocol {
onComplete: @escaping NetworkRequestResult
) {
networkRequestQueue.async {
let networkOperationOnCellularData = self.cellularSession.performGetRequest(url)
let networkOperationOnCellularData = self.cellularSession.performRequest(url)

guard case .success = networkOperationOnCellularData.status else {
onComplete(
Expand Down
2 changes: 1 addition & 1 deletion Tests/Domain/Mocks/MockCellularSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MockCellularSession: CellularSessionProtocol {
self.status = status
}

func performGetRequest(_ url: URL) -> CellularSessionResult {
func performRequest(_ url: URL) -> CellularSessionResult {
let result = CellularSessionResult()
result.status = status
result.result = String(describing: status)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Domain/Mocks/MockNetworkRequestProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct MockNetworkRequestProvider: NetworkRequestProviderProtocol {
}

func performRequest(url: URL, onComplete: @escaping NetworkRequestResult) {
let request = session.performGetRequest(url)
let request = session.performRequest(url)

guard let result = request.result else {
return onComplete(.failure(.requestFinishedWithNoResult))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class PhoneNumberViewController: UIViewController {

// MARK: - IBOutlets

@IBOutlet private var appVersionLabel: UILabel!
@IBOutlet private var backendUrlTextField: UITextField!
@IBOutlet private var phoneNumberTextField: UITextField!
@IBOutlet private var phoneCountryCodeTextField: UITextField!
Expand Down Expand Up @@ -347,6 +348,9 @@ extension PhoneNumberViewController {
)
$0?.layer.borderColor = borderColor.cgColor
}

/// Only used for reference
appVersionLabel.text = "\(appVersionLabel.text ?? "") \(TwilioVerifySNAConfig.version)"
}

/// Not required for the SDK implementation.
Expand Down

0 comments on commit 60bbb56

Please sign in to comment.