Skip to content

Dev #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: base64
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6992a6b
Initial codable support
carson-katri Jul 21, 2019
ad74a62
Make generic
carson-katri Jul 21, 2019
f41d271
Codable support in RequestView
carson-katri Jul 21, 2019
f71cb6c
Improved Codable support for RequestView
carson-katri Jul 21, 2019
a3c8b0e
RequestView updates on State change
carson-katri Jul 22, 2019
8a80ce3
Merge with dev
carson-katri Jul 22, 2019
2e577f2
RequestImage
carson-katri Jul 28, 2019
ad9592d
Initial `Codable` support (#4)
carson-katri Jul 28, 2019
e29b404
Merge branch 'RequestImage' into dev
carson-katri Jul 29, 2019
d322b8d
Resolve merge conflict
carson-katri Jul 29, 2019
dd88227
v1.1.0
carson-katri Jul 29, 2019
96e0986
.gitignore fix
carson-katri Aug 3, 2019
8aa6735
codecov
carson-katri Aug 3, 2019
7854262
Improved `Json` Implementation (#9)
carson-katri Aug 9, 2019
da92b38
Fix documentation
carson-katri Aug 9, 2019
9d56334
Base64 encode Auth.basic value (#11)
carson-katri Sep 25, 2019
e7a4ab0
Fix Travis build config
carson-katri Sep 25, 2019
14128f5
Add buildIf realization
EgorKolyshkin Oct 18, 2019
46a7390
Add test for new case
EgorKolyshkin Oct 18, 2019
0aa8873
Resolve merge conflicts
carson-katri Oct 21, 2019
b0ced45
Merge travis
carson-katri Oct 21, 2019
8832cfb
Resolve merge conflict
carson-katri Oct 21, 2019
d57d6ea
Delete useless config files
carson-katri Oct 21, 2019
bd7004c
Merge pull request #13 from EgorKolyshkin/buildIfRealization
carson-katri Oct 21, 2019
a51721c
v1.2.0
carson-katri Oct 21, 2019
79a1151
Hotfix EXC_BAD_ACCESS with struct workaround.
carson-katri Nov 7, 2019
8d297a4
Better error handling coverage
carson-katri Feb 14, 2020
f8d1dd7
Improve test coverage
ezraberch May 1, 2020
b015d25
Remove superfluous second call of builder closure
ezraberch May 1, 2020
db1db61
Merge pull request #22 from ezraberch/improve-test-coverage
carson-katri May 6, 2020
0db9e72
Add 'update' methods, which allow for repeated calls to Requests.
ezraberch May 26, 2020
678327f
Merge pull request #24 from ezraberch/repeated-calls
carson-katri Jun 3, 2020
67407de
Timeout support
carson-katri Jun 23, 2020
c667934
Add missing file (which just happened to contain the entire new feature
carson-katri Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@ DerivedData/
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xcuserstate
*.xcscmblueprint
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
Expand Down
67 changes: 0 additions & 67 deletions .swiftpm/xcode/xcshareddata/xcschemes/Json.xcscheme

This file was deleted.

106 changes: 0 additions & 106 deletions .swiftpm/xcode/xcshareddata/xcschemes/Request-Package.xcscheme

This file was deleted.

67 changes: 0 additions & 67 deletions .swiftpm/xcode/xcshareddata/xcschemes/Request.xcscheme

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ language:
- swift
script:
- swift package generate-xcodeproj
- xcodebuild clean test -project Request.xcodeproj -scheme "Request-Package" -destination "OS=13.0,name=iPhone XS" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet -enableCodeCoverage YES -derivedDataPath .build/derivedData
- xcodebuild clean test -project Request.xcodeproj -scheme "Request-Package" -destination "OS=13.0,name=iPhone 11" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet -enableCodeCoverage YES -derivedDataPath .build/derivedData
after_success:
- bash <(curl -s https://codecov.io/bash) -D .build/derivedData
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ Body(["key": "value"])
Body("myBodyContent")
Body(myJson)
```
- `Timeout`

Sets the timeout for a request or resource:
```swift
Timeout(60)
Timeout(60, for: .request)
Timeout(30, for: .resource)
```
- `RequestParam`

Add a param directly
Expand Down Expand Up @@ -196,6 +204,17 @@ RequestChain {
}
```

## Repeated Calls
`.update` is used to run additional calls after the initial one. You can pass it either a number or a custom `Publisher`. You can also chain together multiple `.update`s. The two `.update`s in the following example are equivalent, so the end result is that the `Request` will be called once immediately and twice every 10 seconds thereafter.
```swift
Request {
Url("https://jsonplaceholder.typicode.com/todo")
}
.update(every: 10)
.update(publisher: Timer.publish(every: 10, on: .main, in: .common).autoconnect())
.call()
```

## Json
`swift-request` includes support for `Json`.
`Json` is used as the response type in the `onJson` callback on a `Request` object.
Expand Down
1 change: 1 addition & 0 deletions Sources/Json/Json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public struct Json {
newSubs.remove(at: 0)
var json = self[subs.first!]
json[newSubs] = newValue
self[subs.first!] = json
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/Json/Literals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ extension Json: ExpressibleByArrayLiteral {

extension Json: ExpressibleByDictionaryLiteral {
public init(dictionaryLiteral elements: (String, Any)...) {
self.init { elements }
jsonData = Dictionary(elements, uniquingKeysWith: { (value1, value2) -> Any in
return value1
})
}
}
2 changes: 1 addition & 1 deletion Sources/Request/Helpers/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public struct Auth {
extension Auth {
/// Authenticates using `username` and `password` directly
public static func basic(username: String, password: String) -> Auth {
return Auth(type: .basic, key: "\(username):\(password)")
return Auth(type: .basic, key: Data("\(username):\(password)".utf8).base64EncodedString())
}

/// Authenticates using a `token`
Expand Down
Loading