-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from tinkoff-mobile-tech/feature/response-header
headers added to response
- Loading branch information
Showing
7 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// HTTPBody.swift | ||
// TinkoffMockStrapping | ||
// | ||
// Created by Margarita Shishkina on 12.01.2023. | ||
// | ||
|
||
import Foundation | ||
import SwiftyJSON | ||
|
||
/// Тело запроса | ||
/// Http body | ||
public enum HttpBodyStub { | ||
|
||
/// В формате json | ||
/// JSON body | ||
case json(JSON) | ||
|
||
/// Тело запроса в любом формате | ||
/// Raw data | ||
case data(Data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// HTTPResponse.swift | ||
// TinkoffMockStrapping | ||
// | ||
// Created by Margarita Shishkina on 12.01.2023. | ||
// | ||
|
||
import Foundation | ||
import SwiftyJSON | ||
|
||
/// Http ответ | ||
/// Http response | ||
public struct HttpResponseStub: HttpResponseStubProtocol { | ||
|
||
/// Статус код | ||
/// Status code | ||
public let statusCode: Int | ||
|
||
/// Статус | ||
/// Reason phrase | ||
public let reasonPhrase: String | ||
|
||
/// Заголовки | ||
/// Headers | ||
public let headers: [String: String] | ||
|
||
/// Тело ответа | ||
/// Response body | ||
public let body: HttpBodyStub | ||
|
||
/// Инициализатор | ||
/// Initializer | ||
public init(statusCode: Int = 200, | ||
reasonPhrase: String = "OK", | ||
headers: [String: String] = [:], | ||
body: HttpBodyStub = .json(JSON())) { | ||
self.statusCode = statusCode | ||
self.reasonPhrase = reasonPhrase | ||
self.headers = headers | ||
self.body = body | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Development/Source/Core/Protocols/HttpResponseStubProtocol.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// IHTTPResponse.swift | ||
// TinkoffMockStrapping | ||
// | ||
// Created by Margarita Shishkina on 12.01.2023. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Протокол ответа сервера | ||
/// Http response protocol | ||
public protocol HttpResponseStubProtocol { | ||
|
||
/// Статус код | ||
/// Status code | ||
var statusCode: Int { get } | ||
|
||
/// Статус | ||
/// Reason phrase | ||
var reasonPhrase: String { get } | ||
|
||
/// Заголовки | ||
/// Headers | ||
var headers: [String: String] { get } | ||
|
||
/// Тело ответа | ||
/// Response body | ||
var body: HttpBodyStub { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters