-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
2,062 additions
and
155 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
struct ConnectApp { | ||
struct Server { | ||
static let baseUrl = "https://\(connectDomain):8443" | ||
} | ||
} | ||
|
||
struct NautaApp { | ||
struct Server { | ||
static let baseURL = "https://www.nauta.cu:5002" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,48 +1,47 @@ | ||
|
||
let connectDomain = "secure.etecsa.net" | ||
|
||
struct ConnectApp { | ||
struct Server { | ||
static let baseUrl = "https://\(connectDomain):8443" | ||
} | ||
enum HTTPHeaderField: String { | ||
case Authorization = "Authorization" | ||
case Accept = "Accept" | ||
case AcceptLanguage = "Accept-Language" | ||
case AcceptEncoding = "Accept-Encoding" | ||
case ContentType = "Content-Type" | ||
case Connection = "Connection" | ||
case Host = "Host" | ||
case IfNoneMatch = "If-None-Match" | ||
case Origin = "Origin" | ||
case Referer = "Referer" | ||
case SecFetchDest = "Sec-Fetch-Dest" | ||
case SecFetchMode = "Sec-Fetch-Mode" | ||
case SecFetchSite = "Sec-Fetch-Site" | ||
case TE = "TE" | ||
case UserAgent = "User-Agent" | ||
case secChUa = "sec-ch-ua" | ||
case secChUaMobile = "sec-ch-ua-mobile" | ||
case secChUaPlatform = "sec-ch-ua-platform" | ||
case usernameApp = "usernameApp" | ||
case passwordApp = "passwordApp" | ||
} | ||
|
||
let userPortalUrlBase = "https://www.portal.nauta.cu/" | ||
let connectPortalUrlBase = "https://\(connectDomain):8443/" | ||
|
||
let userPortalUrls: [Action : Any] = [ | ||
Action.Login: "user/login/es-es", | ||
Action.LoadUserInformation: "useraaa/user_info", | ||
Action.Recharge: "useraaa/recharge_account", | ||
Action.Transfer: "useraaa/transfer_balance", | ||
Action.PayNautaHome: "useraaa/transfer_nautahogarpaid", | ||
Action.ChangePassword: "useraaa/change_password", | ||
Action.ChangeEmailPassword: "mail/change_password", | ||
Action.GetConnections : [ | ||
"base": "useraaa/service_detail/", | ||
"summary": "useraaa/service_detail_summary/", | ||
"list": "useraaa/service_detail_list/" | ||
], | ||
Action.GetRecharges: [ | ||
"base": "useraaa/recharge_detail/", | ||
"summary": "useraaa/recharge_detail_summary/", | ||
"list": "useraaa/recharge_detail_list/" | ||
], | ||
Action.GetTransfers: [ | ||
"base": "useraaa/transfer_detail/", | ||
"summary": "useraaa/transfer_detail_summary/", | ||
"list": "useraaa/transfer_detail_list/" | ||
], | ||
Action.GetQuotesPaid: [ | ||
"base": "useraaa/nautahogarpaid_detail/", | ||
"summary": "useraaa/nautahogarpaid_detail_summary/", | ||
"list": "useraaa/nautahogarpaid_detail_list/" | ||
], | ||
Action.Logout: "user/logout" | ||
] | ||
|
||
let connectPortalUrls = [ | ||
Action.Logout: "LogoutServlet", | ||
Action.LoadUserInformation: "EtecsaQueryServlet", | ||
Action.CheckConnection: "http://www.cubadebate.cu/" | ||
] | ||
enum HTTPHeaderFieldValues: String { | ||
case Accept = "*/*" | ||
case AcceptLanguage = "es,es-US;q=0.9,es-419;q=0.8,en;q=0.7" | ||
case AcceptEncoding = "gzip, deflate, br" | ||
case ContentType = "application/json" | ||
case Connection = "keep-alive" | ||
case HostNauta = "www.nauta.cu:5002" | ||
case HostET = "www.tienda.etecsa.cu" | ||
case IfNoneMatch = "W/\"4573-cba3C56jjnn1stlozXGQSy4RngA\"" | ||
case OriginNauta = "https://www.nauta.cu" | ||
case OriginEtecsa = "https://www.tienda.etecsa.cu" | ||
case SecFetchDest = "empty" | ||
case SecFetchMode = "cors" | ||
case SecFetchSite = "same-site" | ||
case TE = "trailers" | ||
case UserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" | ||
case secChUa = "Not_A Brand\";v=\"99\", \"Google Chrome\";v=\"109\", \"Chromium\";v=\"109\"" | ||
case secChUaMobile = "?0" | ||
case secChUaPlatform = "\"Windows\"" | ||
case usernameApp = "portal" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
import Foundation | ||
|
||
public struct Promotion { | ||
public let backgroundUrl: String | ||
public let imageSvg: String | ||
public let url: String | ||
public var imageData: Data? | ||
} |
37 changes: 37 additions & 0 deletions
37
Sources/SuitEtecsaSdk/entity/nauta/auth/JSONSchemaSupport.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,37 @@ | ||
import Foundation | ||
|
||
// MARK: - Helper functions for creating encoders and decoders | ||
|
||
func newJSONDecoder() -> JSONDecoder { | ||
let decoder = JSONDecoder() | ||
decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in | ||
let container = try decoder.singleValueContainer() | ||
let dateStr = try container.decode(String.self) | ||
|
||
let formatter = DateFormatter() | ||
formatter.calendar = Calendar(identifier: .iso8601) | ||
formatter.locale = Locale(identifier: "en_US_POSIX") | ||
formatter.timeZone = TimeZone(secondsFromGMT: 0) | ||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" | ||
if let date = formatter.date(from: dateStr) { | ||
return date | ||
} | ||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX" | ||
if let date = formatter.date(from: dateStr) { | ||
return date | ||
} | ||
throw DecodingError.typeMismatch(Date.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not decode date")) | ||
}) | ||
return decoder | ||
} | ||
|
||
func newJSONEncoder() -> JSONEncoder { | ||
let encoder = JSONEncoder() | ||
let formatter = DateFormatter() | ||
formatter.calendar = Calendar(identifier: .iso8601) | ||
formatter.locale = Locale(identifier: "en_US_POSIX") | ||
formatter.timeZone = TimeZone(secondsFromGMT: 0) | ||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX" | ||
encoder.dateEncodingStrategy = .formatted(formatter) | ||
return encoder | ||
} |
26 changes: 26 additions & 0 deletions
26
Sources/SuitEtecsaSdk/entity/nauta/auth/captcha_response.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,26 @@ | ||
import Foundation | ||
|
||
// Define una estructura pública 'CaptchaResponse' que conforma al protocolo 'Codable'. | ||
public struct CaptchaResponse: Codable { | ||
// Propiedades públicas para almacenar la identificación de la solicitud y los datos de la respuesta. | ||
public let idRequest: String | ||
public let data: String | ||
|
||
// Enumeración interna para definir las claves de codificación personalizadas. | ||
enum CodingKeys: String, CodingKey { | ||
// Asigna la clave 'text' del JSON a la propiedad 'idRequest'. | ||
case idRequest = "text" | ||
// Asigna la clave 'data' del JSON a la propiedad 'data'. | ||
case data = "data" | ||
} | ||
|
||
// Inicializador personalizado para decodificar desde un tipo 'Decoder'. | ||
public init(from decoder: Decoder) throws { | ||
// Crea un contenedor de decodificación utilizando las claves definidas. | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
// Decodifica el valor asociado con la clave 'idRequest' (originalmente 'text' en JSON). | ||
idRequest = try container.decode(String.self, forKey: .idRequest) | ||
// Decodifica el valor asociado con la clave 'data'. | ||
data = try container.decode(String.self, forKey: .data) | ||
} | ||
} |
Oops, something went wrong.