Add public visibility for swift module
This commit is contained in:
parent
fec4299959
commit
b47d064fe9
|
|
@ -6,28 +6,28 @@
|
|||
import LeadKit
|
||||
import SwiftDate
|
||||
|
||||
enum ApiDateFormat: String, DateFormat {
|
||||
public enum ApiDateFormat: String, DateFormat {
|
||||
|
||||
{% for format in dateFormats -%}
|
||||
case {{ format.name }} = "{{ format.format }}"
|
||||
{% endfor %}
|
||||
var dateToStringFormat: DateToStringStyles {
|
||||
public var dateToStringFormat: DateToStringStyles {
|
||||
return .custom(rawValue)
|
||||
}
|
||||
|
||||
var stringToDateFormat: StringToDateStyles {
|
||||
public var stringToDateFormat: StringToDateStyles {
|
||||
return .custom(rawValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class ApiDateFormattingService: DateFormattingService, Singleton {
|
||||
public final class ApiDateFormattingService: DateFormattingService, Singleton {
|
||||
|
||||
typealias DateFormatType = ApiDateFormat
|
||||
public typealias DateFormatType = ApiDateFormat
|
||||
|
||||
var currentRegion: Region = .local
|
||||
public static let shared = ApiDateFormattingService()
|
||||
|
||||
static let shared = ApiDateFormattingService()
|
||||
public var currentRegion: Region = .local
|
||||
|
||||
private init() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
import LeadKit
|
||||
import Foundation
|
||||
|
||||
enum ApiNumberFormat: NumberFormat {
|
||||
public enum ApiNumberFormat: NumberFormat {
|
||||
|
||||
case decimal
|
||||
|
||||
var numberFormatter: NumberFormatter {
|
||||
public var numberFormatter: NumberFormatter {
|
||||
let numberFormatter = NumberFormatter()
|
||||
numberFormatter.decimalSeparator = "."
|
||||
numberFormatter.minimumIntegerDigits = 1
|
||||
|
|
@ -17,17 +17,17 @@ enum ApiNumberFormat: NumberFormat {
|
|||
}
|
||||
}
|
||||
|
||||
final class ApiNumberFormattingService: NumberFormattingService, Singleton {
|
||||
public final class ApiNumberFormattingService: NumberFormattingService, Singleton {
|
||||
|
||||
typealias NumberFormatType = ApiNumberFormat
|
||||
public typealias NumberFormatType = ApiNumberFormat
|
||||
|
||||
let formatters = computedFormatters
|
||||
public static let shared = ApiNumberFormattingService()
|
||||
|
||||
static let shared = ApiNumberFormattingService()
|
||||
public let formatters = computedFormatters
|
||||
|
||||
private init() {}
|
||||
|
||||
func decimalNumber(from string: String, format: ApiNumberFormat) -> NSDecimalNumber? {
|
||||
public func decimalNumber(from string: String, format: ApiNumberFormat) -> NSDecimalNumber? {
|
||||
guard let number = number(from: string, format: format) else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ final class ApiNumberFormattingService: NumberFormattingService, Singleton {
|
|||
|
||||
extension ApiNumberFormattingService {
|
||||
|
||||
static func decimalNumber(from string: String, format: ApiNumberFormat) -> NSDecimalNumber? {
|
||||
public static func decimalNumber(from string: String, format: ApiNumberFormat) -> NSDecimalNumber? {
|
||||
return shared.decimalNumber(from: string, format: format)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ import SwiftDate
|
|||
import LeadKit
|
||||
|
||||
/// {{ description }}
|
||||
{% if (not hasChilds) -%}final {% endif %}class {{ classType }}: {{ parentClassType }} {
|
||||
public {% if (not hasChilds) -%}final {% endif %}class {{ classType }}: {{ parentClassType }} {
|
||||
{% include 'blocks/class/coding-keys.twig' with { fields: fields } %}
|
||||
{% include 'blocks/class/fields.twig' with { fields: fields } %}
|
||||
// MARK: - Initializers
|
||||
|
||||
{% if (hasParent and (fields is empty)) %} override {% endif %}init({%- include 'blocks/class/init-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) {
|
||||
public {% if (hasParent and (fields is empty)) %} override {% endif %}init({%- include 'blocks/class/init-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) {
|
||||
{%- include 'blocks/class/fields-initialization.twig' with { fields: fields } -%}
|
||||
{% if hasParent %}
|
||||
super.init({%- include 'blocks/class/fields-super-initialization.twig' with { fields: superclassesFields } -%})
|
||||
|
|
@ -27,7 +27,7 @@ import LeadKit
|
|||
}
|
||||
|
||||
{% if hasParent or fields is not empty %}
|
||||
required init(from decoder: Decoder) throws {
|
||||
public required init(from decoder: Decoder) throws {
|
||||
{%- if fields is not empty %}
|
||||
{% include 'blocks/class/fields-initialization-from-decoder.twig' with { fields: fields} %}
|
||||
{%- endif -%}
|
||||
|
|
@ -37,7 +37,7 @@ import LeadKit
|
|||
}
|
||||
{% endif %}
|
||||
|
||||
{% if hasParent -%}override {% endif %}func encode(to encoder: Encoder) throws {
|
||||
public {% if hasParent -%}override {% endif %}func encode(to encoder: Encoder) throws {
|
||||
{%- if fields is not empty %}
|
||||
{% include 'blocks/class/fields-encode-to-encoder.twig' with { fields: fields} %}
|
||||
{%- endif -%}
|
||||
|
|
@ -47,7 +47,7 @@ import LeadKit
|
|||
}
|
||||
|
||||
{% if classAndFieldsHaveNotGenericsOrNonEqutableCollections -%}
|
||||
func isEqual(to other: {{ classType }}?) -> Bool {
|
||||
public func isEqual(to other: {{ classType }}?) -> Bool {
|
||||
{% if (fields is empty) and (not hasParent) %}
|
||||
return false
|
||||
{% else %}
|
||||
|
|
@ -64,7 +64,7 @@ import LeadKit
|
|||
{%- if (not hasChilds) and classAndFieldsHaveNotGenericsOrNonEqutableCollections -%}
|
||||
extension {{ type.baseTypeName }}: Equatable {
|
||||
|
||||
static func ==(lhs: {{ classType }}, rhs: {{ classType }}) -> Bool {
|
||||
public static func ==(lhs: {{ classType }}, rhs: {{ classType }}) -> Bool {
|
||||
return lhs.isEqual(to: rhs)
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ extension {{ type.baseTypeName }}: Equatable {
|
|||
{%- if classAndFieldsHaveNotGenericsOrNonEqutableCollections -%}
|
||||
extension {{ type.baseTypeName }} {
|
||||
|
||||
static let new{{ type.baseTypeName }} = {{ type.baseTypeName }}({%- include 'blocks/class/fields-initialization-default-values.twig' with { fields: allFieldsOrdered } -%})
|
||||
public static let new{{ type.baseTypeName }} = {{ type.baseTypeName }}({%- include 'blocks/class/fields-initialization-default-values.twig' with { fields: allFieldsOrdered } -%})
|
||||
|
||||
{% include 'blocks/class/copy-declaration.twig' with { hasChilds: hasChilds, type: type, fields: allFieldsOrdered } %}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
{% for value in values -%}
|
||||
/// - {{ utils.decapitalize(value.name) }}: {{ value.description }}
|
||||
{% endfor -%}
|
||||
enum {{ name }}: {{ enumutils.enumType(valuesTypes) }}, Codable, RawRepresentable, CaseIterable {
|
||||
public enum {{ name }}: {{ enumutils.enumType(valuesTypes) }}, Codable, RawRepresentable, CaseIterable {
|
||||
{% include 'blocks/enum/cases.twig' with { values: values } %}
|
||||
}
|
||||
{{ "\n" }}
|
||||
|
|
@ -5,7 +5,7 @@ import Alamofire
|
|||
{% set serviceName = concat(networkServiceName, "NetworkService") -%}
|
||||
{% set protocolName = concat(networkServiceName, "NetworkProtocol") -%}
|
||||
|
||||
protocol {{ protocolName }} {
|
||||
public protocol {{ protocolName }} {
|
||||
|
||||
func apiRequest<T: Decodable>(with parametersSingle: Single<ApiRequestParameters>, additionalValidStatusCodes: Set<Int>, decoder: JSONDecoder) -> Single<T>
|
||||
func deferredApiRequestParameters(relativeUrl: String,
|
||||
|
|
@ -19,25 +19,25 @@ protocol {{ protocolName }} {
|
|||
{% endfor %}
|
||||
}
|
||||
|
||||
class {{ serviceName }}: NetworkService, {{ protocolName }} {
|
||||
open class {{ serviceName }}: NetworkService, {{ protocolName }} {
|
||||
|
||||
static let apiBaseUrl = "{{ apiUrl }}"
|
||||
public static let apiBaseUrl = "{{ apiUrl }}"
|
||||
|
||||
convenience init() {
|
||||
public convenience init() {
|
||||
self.init(configuration: NetworkServiceConfiguration(baseUrl: {{ serviceName }}.apiBaseUrl))
|
||||
}
|
||||
|
||||
func apiRequest<T: Decodable>(with parametersSingle: Single<ApiRequestParameters>, additionalValidStatusCodes: Set<Int> = [], decoder: JSONDecoder = JSONDecoder()) -> Single<T> {
|
||||
open func apiRequest<T: Decodable>(with parametersSingle: Single<ApiRequestParameters>, additionalValidStatusCodes: Set<Int> = [], decoder: JSONDecoder = JSONDecoder()) -> Single<T> {
|
||||
return parametersSingle.flatMap {
|
||||
self.rxRequest(with: $0, additionalValidStatusCodes: additionalValidStatusCodes, decoder: decoder).map { $0.model }.asSingle()
|
||||
}
|
||||
}
|
||||
|
||||
func deferredApiRequestParameters(relativeUrl: String,
|
||||
method: HTTPMethod = .get,
|
||||
parameters: Parameters? = nil,
|
||||
requestEncoding: ParameterEncoding? = nil,
|
||||
requestHeaders: HTTPHeaders? = nil) -> Single<ApiRequestParameters> {
|
||||
open func deferredApiRequestParameters(relativeUrl: String,
|
||||
method: HTTPMethod = .get,
|
||||
parameters: Parameters? = nil,
|
||||
requestEncoding: ParameterEncoding? = nil,
|
||||
requestHeaders: HTTPHeaders? = nil) -> Single<ApiRequestParameters> {
|
||||
return .deferredJust {
|
||||
self.configuration.apiRequestParameters(relativeUrl: relativeUrl,
|
||||
method: method,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{%- import '../../macroses/common.utils.twig' as utils -%}
|
||||
|
||||
func copy{%- if hasChilds -%}{{ type.baseTypeName }}{%- endif -%}With({%- include '../class/nullable-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) -> {{ type.baseTypeName }} {
|
||||
public func copy{%- if hasChilds -%}{{ type.baseTypeName }}{%- endif -%}With({%- include '../class/nullable-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) -> {{ type.baseTypeName }} {
|
||||
return {{ type.baseTypeName }}({% include '../class/fields-optional-initialization.twig' with { fields: allFieldsOrdered } %})
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
{% if containsOptionalFields %}
|
||||
|
||||
func copy{%- if hasChilds -%}{{ type.baseTypeName }}{%- endif -%}Without({%- include '../class/bool-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) -> {{ type.baseTypeName }} {
|
||||
public func copy{%- if hasChilds -%}{{ type.baseTypeName }}{%- endif -%}Without({%- include '../class/bool-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) -> {{ type.baseTypeName }} {
|
||||
return {{ type.baseTypeName }}({%- include '../class/fields-without-initialization.twig' with { fields: allFieldsOrdered } -%})
|
||||
}
|
||||
{% endif %}
|
||||
|
|
@ -4,6 +4,6 @@
|
|||
// MARK: - Fields
|
||||
{% for field in fields %}
|
||||
/// {{ field.description }}
|
||||
let {{ field.name }}: {{ utils.formatNullableOrOptional(utils.formatValueType(field.type.type), field.nullable, field.optional) }}
|
||||
public let {{ field.name }}: {{ utils.formatNullableOrOptional(utils.formatValueType(field.type.type), field.nullable, field.optional) }}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
@ -9,4 +9,4 @@
|
|||
|
||||
{%- set funcName = utils.decapitalize(method.name) -%}
|
||||
|
||||
{{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ " " }}{%- endif -%}requestEncoding: ParameterEncoding?, requestHeaders: HTTPHeaders?, additionalValidStatusCodes: Set<Int>) -> Single<{{ method.responseType.type.typeName }}>
|
||||
public {{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ " " }}{%- endif -%}requestEncoding: ParameterEncoding?, requestHeaders: HTTPHeaders?, additionalValidStatusCodes: Set<Int>) -> Single<{{ method.responseType.type.typeName }}>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
{%- set funcName = utils.decapitalize(method.name) -%}
|
||||
|
||||
/// {{ method.description }}
|
||||
{{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%}
|
||||
public {{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%}
|
||||
requestEncoding: ParameterEncoding? = nil,
|
||||
requestHeaders: HTTPHeaders? = nil,
|
||||
additionalValidStatusCodes: Set<Int> = []) -> Single<{{ method.responseType.type.typeName }}> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue