Skip to content

Instantly share code, notes, and snippets.

@PauloLeon
PauloLeon / BaseDeepLink1.swift
Last active August 17, 2017 15:30
the methods for object
init(originLocation : CLLocationCoordinate2D, destinationLocation:CLLocationCoordinate2D, originAddress: String, destinationAddress: String, urlProtocol: String){
self.originLocation = originLocation
self.destinationLocation = destinationLocation
self.destinationAddress = dropoffFormattedAddress
self.originAddress = originAddress
self.urlProtocol = urlProtocol
}
func deepLink() {
if let appURL = finalURL {
@PauloLeon
PauloLeon / BaseDeepLink.swift
Last active August 17, 2017 15:30
piece of code for my Medium post about DeepLinks
@PauloLeon
PauloLeon / .swiftlint.yml
Created September 18, 2017 20:54
the custom rules for swxftlint
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 250
@PauloLeon
PauloLeon / .swiftlint.yml
Created September 18, 2017 20:54
the custom rules for swxftlint
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 250
//
// BaseApiClient.swift
// Melhor Corrida
//
// Created by Paulo Rosa on 07/08/17.
// Copyright © 2017 Paulo Rosa. All rights reserved.
//
//swiftlint:disable empty_enum_arguments
import UIKit
import Alamofire
// MARK: - Paths
var hearders: String {
if path == "estimates" || path == "users"{
return "103260408667b5727f0bc10dc37240b2d38579051d9924b979ea2e4fe3a31635802b3b4ff8e25d31b39066957a8c3811c9f427e0d8a4c8c0bc58916fc3ea1be6"
}
return ""
}
func asURLRequest() throws -> URLRequest {
let url: URL
if path == "estimates" || path == "users"{
url = try Router.routeResults.asURL()
} else {
url = try Router.routeGoogle.asURL()
}
var urlRequest = URLRequest(url: url.appendingPathComponent(path))
urlRequest.httpMethod = method.rawValue
if hearders != ""{
static func signin(_ data: URLRequestParams, success: @escaping (User) -> Void, failure: @escaping (ApiError) -> Void ){
var data = URLRequestParams()
data["usuario"] = "nayanne.moritsuka+tcr6@terras.agr.br"
data["senha"] = "1234"
// da um break na linha abaixo, e ve se a variavel data ta populada
Alamofire.request(Router.login(data: data))
.validate()
.responseJSON { response in
switch response.result {
case .success:
init(fromJSON json: JSON) {
// tinha que alterar esse init:
let result = json["result"]
self.id = result["id"].stringValue
self.name = result["nome"].stringValue
self.token = result["token"].stringValue
self.email = result["usuario"].stringValue
self.cpf = result["cpf"].stringValue
self.password = result["senha"].stringValue