This file contains hidden or 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
| { | |
| "batch": { | |
| "uuid": "82c3cc53-a466-4e3f-8754-db3c3e779ebc", | |
| }, | |
| "results": [ | |
| { | |
| "status": "success", | |
| "createdAt": "2025-09-04T09:58:14.914Z", | |
| "finishedAt": "2025-09-04T10:00:40.541Z", | |
| "errorMessage": null, |
This file contains hidden or 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
| FROM ruby:2.4-alpine | |
| ENV PATH /root/.yarn/bin:$PATH | |
| RUN apk update && apk upgrade && \ | |
| apk add --no-cache bash git openssh build-base nodejs tzdata | |
| RUN apk update \ | |
| && apk add curl bash binutils tar gnupg \ | |
| && rm -rf /var/cache/apk/* \ |
This file contains hidden or 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
| // key keychain instance | |
| let keychain = MockedKeychain() | |
| // set some email | |
| try? KeychainAccessors.email | |
| .set(keychain: keychain, value: "[email protected]") | |
| // get stored email | |
| let storedEmail = try? KeychainAccessors.email | |
| .get(keychain: keychain) |
This file contains hidden or 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
| public class MockedKeychain: KeychainAccess { | |
| public var data: [String: Data] = [:] | |
| public func remove(_ key: String) throws { | |
| _ = data.removeValue(forKey: key) | |
| } | |
| public func set(_ value: Data, key: String) throws { | |
| data[key] = value | |
| } |
This file contains hidden or 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
| struct KeychainAccessors { | |
| /// User's email assign during sign-in | |
| static let email = KeychainAccessor<String>(name: "email", | |
| decoding: { $0.data(using: .utf8) }, | |
| encoding: { String(data: $0, encoding: .utf8) } | |
| ) | |
| } |
This file contains hidden or 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
| struct KeychainAccessor<T> { | |
| // key name | |
| let key: String | |
| // transformers | |
| let decoding: ((T) throws -> Data?) | |
| let encoding: ((Data) throws -> T?) | |
| // needs public accessor | |
| public init(name: String, decoding: @escaping ((T) throws -> Data?), encoding: @escaping ((Data) throws -> T?)) { |
This file contains hidden or 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
| enum Cipher { | |
| case root | |
| case generated(Data) | |
| func decrypt(data: Data) throws -> Data { | |
| /// In this case we use simple XOR decryption | |
| /// In real work implementation we should use AES here | |
| let _key = Array(key) | |
| var _data: Data = Data() | |
| for (offset, element) in data.enumerated() { |
This file contains hidden or 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
| public protocol KeychainAccess { | |
| func remove(_ key: String) throws | |
| func set(_ value: Data, key: String) throws | |
| func get(_ key: String) throws -> Data? | |
| } |
This file contains hidden or 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
| struct FakeAPI { | |
| static let api = API<FakeAPITarget>() | |
| static func allPosts() -> Observable<[Post]> { | |
| return api.provide(.posts) | |
| } | |
| } | |
| class PostsDataSource { | |
| func reloadData() { |
This file contains hidden or 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
| public struct API<T: TargetType> { | |
| fileprivate var provider: RxMoyaProvider<T> = RxMoyaProvider(plugins: [CachingPlugin()], trackInflights: true) | |
| private func request(_ endpoint: T) -> Observable<Response> { | |
| return provider.request(endpoint).asObservable() | |
| } | |
| public func request<O: JSONDecodable>(_ endpoint: T) -> Observable<O> { | |
| return provider.request(endpoint).asObservable().mapObject() |
NewerOlder