Skip to content

Commit a356cc6

Browse files
committed
feat: expose http methods
1 parent fa51d31 commit a356cc6

File tree

8 files changed

+17
-43
lines changed

8 files changed

+17
-43
lines changed

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Example/PutioAPI/ViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import UIKit
22
import PutioAPI
33
import AuthenticationServices
44

5-
@available(iOS 13.0, *)
65
class ViewController: UIViewController {
76
var api: PutioAPI?
87
var session: ASWebAuthenticationSession?
@@ -106,7 +105,6 @@ class ViewController: UIViewController {
106105
}
107106
}
108107

109-
@available(iOS 13.0, *)
110108
extension ViewController: ASWebAuthenticationPresentationContextProviding {
111109
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
112110
return view.window ?? ASPresentationAnchor()

PutioAPI.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'PutioAPI'
11-
s.version = '1.4.0'
11+
s.version = '1.5.0'
1212
s.swift_version = '4.2'
1313

14-
s.summary = 'Swift client for put.io API v2'
15-
s.description = 'Swift client for put.io API v2 [https://api.put.io]'
14+
s.summary = 'Swift client for put.io API.'
15+
s.description = 'Swift client for [put.io API](https://api.put.io).'
1616

1717
s.license = { :type => 'MIT', :file => 'LICENSE' }
18-
s.author = { 'put.io' => 'devs@put.io' }
18+
s.author = { 'put.io' => 'ui@put.io' }
1919

2020
s.homepage = 'https://github.com/putdotio/putio-swift'
2121
s.source = { :git => 'https://github.com/putdotio/putio-swift.git', :tag => s.version.to_s }

PutioAPI/Classes/PutioAPI.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public protocol PutioAPIDelegate: class {
77
}
88

99
public final class PutioAPI {
10-
typealias RequestCompletion = (Result<JSON, PutioAPIError>) -> Void
10+
public typealias RequestCompletion = (Result<JSON, PutioAPIError>) -> Void
1111

1212
weak var delegate: PutioAPIDelegate?
1313

@@ -27,22 +27,22 @@ public final class PutioAPI {
2727
self.config.token = ""
2828
}
2929

30-
func get(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], _ completion: @escaping RequestCompletion) {
30+
public func get(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], _ completion: @escaping RequestCompletion) {
3131
let requestConfig = PutioAPIRequestConfig(apiConfig: config, url: url, method: .get, headers: headers, query: query)
3232
self.send(requestConfig: requestConfig, completion)
3333
}
3434

35-
func post(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], body: Parameters = [:], _ completion: @escaping RequestCompletion) {
35+
public func post(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], body: Parameters = [:], _ completion: @escaping RequestCompletion) {
3636
let requestConfig = PutioAPIRequestConfig(apiConfig: config, url: url, method: .post, headers: headers, query: query, body: body)
3737
self.send(requestConfig: requestConfig, completion)
3838
}
3939

40-
func put(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], body: Parameters = [:], _ completion: @escaping RequestCompletion) {
40+
public func put(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], body: Parameters = [:], _ completion: @escaping RequestCompletion) {
4141
let requestConfig = PutioAPIRequestConfig(apiConfig: config, url: url, method: .put, headers: headers, query: query, body: body)
4242
self.send(requestConfig: requestConfig, completion)
4343
}
4444

45-
func delete(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], _ completion: @escaping RequestCompletion) {
45+
public func delete(_ url: String, headers: HTTPHeaders = [:], query: Parameters = [:], _ completion: @escaping RequestCompletion) {
4646
let requestConfig = PutioAPIRequestConfig(apiConfig: config, url: url, method: .delete, headers: headers, query: query)
4747
self.send(requestConfig: requestConfig, completion)
4848
}

PutioAPI/Classes/PutioAPITypes.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct PutioAPIConfig {
1010
public var clientName: String
1111
public var timeoutInterval: Double
1212

13-
public init(clientID: String, clientSecret: String = "", clientName: String = "", token: String = "", timeoutInterval: Double = 10.0) {
13+
public init(clientID: String, clientSecret: String = "", clientName: String = "", token: String = "", timeoutInterval: Double = 15.0) {
1414
self.baseURL = PutioAPI.apiURL
1515
self.clientID = clientID
1616
self.clientSecret = clientSecret
@@ -37,11 +37,7 @@ public struct PutioAPIRequestConfig {
3737

3838
self.method = method
3939

40-
// Header: Correlation ID
4140
var enhancedHeaders = headers
42-
enhancedHeaders.add(name: "X-Putio-Correlation-Id", value: UUID().uuidString)
43-
44-
// Header: Authorization
4541
if enhancedHeaders.value(for: "authorization") == nil {
4642
if apiConfig.token != "" {
4743
let authorizationHeader = HTTPHeader.authorization("token \(apiConfig.token)")

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ pod 'PutioAPI'
2525

2626
## Usage
2727

28-
See the [Example Project](./Example/PutioAPI/ViewController.swift) for a simple auth -> API call flow.
28+
- For authentication, check the [Example Project](./Example/PutioAPI/ViewController.swift) for a simple [`ASWebAuthenticationSession`](https://developer.apple.com/documentation/authenticationservices/authenticating_a_user_through_a_web_service) flow.
29+
- Check [the classes folder](./PutioAPI/Classes/) for available models and respective methods.
30+
- You can also use `get`, `post`, `put`, and `delete` methods with relative URLs to make requests to the API.
2931

30-
### Development
32+
## Contribution
3133

3234
Clone the repo.
3335

@@ -46,6 +48,7 @@ bundle install
4648
Install the dependencies then open the workspace.
4749

4850
```bash
49-
./scripts/setup.sh
50-
open ./Example/PutioAPI.xcworkspace
51+
cd ./Example
52+
bundle exec pod install
53+
open ./PutioAPI.xcworkspace
5154
```

scripts/deploy.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

scripts/setup.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)