-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCRUD.swift
46 lines (38 loc) · 1.18 KB
/
CRUD.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// CRUD.swift
// TRON
//
// Created by Denys Telezhkin on 30.01.16.
// Copyright © 2016 Denys Telezhkin. All rights reserved.
//
import Foundation
import SwiftyJSON
import TRON
import TRONSwiftyJSON
class User: JSONDecodable {
required init(json: JSON) {
}
}
class UserRequestFactory
{
static let tron = TRON(baseURL: "https://api.myapp.com")
class func create() -> APIRequest<User,APIError> {
let request: APIRequest<User,APIError> = tron.swiftyJSON.request("users")
request.method = .post
return request
}
class func read(id: Int) -> APIRequest<User, APIError> {
return tron.swiftyJSON.request("users/\(id)")
}
class func update(id: Int, parameters: [String:AnyObject]) -> APIRequest<User, APIError> {
let request: APIRequest<User,APIError> = tron.swiftyJSON.request("users/\(id)")
request.method = .put
request.parameters = parameters
return request
}
class func delete(id: Int) -> APIRequest<User,APIError> {
let request: APIRequest<User,APIError> = tron.swiftyJSON.request("users/\(id)")
request.method = .delete
return request
}
}