Skip to content

Commit

Permalink
Merge pull request #3 from jasonnam/develop
Browse files Browse the repository at this point in the history
Release 0.1.3
  • Loading branch information
jasonnam authored Oct 15, 2019
2 parents cb6144b + 405b129 commit cb31647
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
14 changes: 14 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)

swift_library(
name = "XCallbackURL",
srcs = glob([
"Sources/XCallbackURL/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.3] - 2019-10-15
### Added
- `url` property to `XCallbackURL` returning `URL` value.
- [Bazel](https://bazel.build) support.

## [0.1.2] - 2019-08-04
### Changed
- SuccessCallback takes optional Parameters value.
Expand All @@ -21,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `XCallbackURL`
- `XCallbackURLHandler`

[0.1.3]: /~https://github.com/jasonnam/XCallbackURL/compare/0.1.2...0.1.3
[0.1.2]: /~https://github.com/jasonnam/XCallbackURL/compare/0.1.1...0.1.2
[0.1.1]: /~https://github.com/jasonnam/XCallbackURL/compare/0.1.0...0.1.1
[0.1.0]: /~https://github.com/jasonnam/XCallbackURL/releases/tag/0.1.0
48 changes: 48 additions & 0 deletions Sources/XCallbackURL/XCallbackURL+URL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// XCallbackURL+URL.swift
// XCallbackURL
//
// Copyright © 2019 Jason Nam (https://jasonnam.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

public extension XCallbackURL {

var url: URL? {
var urlComponents = URLComponents()
urlComponents.scheme = scheme
urlComponents.host = XCallbackURL.host
urlComponents.path = "/\(action)"
var queryItems = parameters.map { URLQueryItem(name: $0, value: $1) }
if let successCallbackURL = successCallbackURL {
queryItems.append(.init(name: Parameter.success, value: successCallbackURL.absoluteString))
}
if let errorCallbackURL = errorCallbackURL {
queryItems.append(.init(name: Parameter.error, value: errorCallbackURL.absoluteString))
}
if let cancelCallbackURL = cancelCallbackURL {
queryItems.append(.init(name: Parameter.cancel, value: cancelCallbackURL.absoluteString))
}
urlComponents.queryItems = queryItems
return urlComponents.url
}
}
14 changes: 14 additions & 0 deletions Sources/XCallbackURL/XCallbackURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ public struct XCallbackURL {
public let successCallbackURL: URL?
public let errorCallbackURL: URL?
public let cancelCallbackURL: URL?

public init(scheme: String,
action: String,
parameters: Parameters = [:],
successCallbackURL: URL? = nil,
errorCallbackURL: URL? = nil,
cancelCallbackURL: URL? = nil) {
self.scheme = scheme
self.action = action
self.parameters = parameters
self.successCallbackURL = successCallbackURL
self.errorCallbackURL = errorCallbackURL
self.cancelCallbackURL = cancelCallbackURL
}
}
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name = "XCallbackURL")
2 changes: 1 addition & 1 deletion XCallbackURL.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'XCallbackURL'
spec.version = '0.1.2'
spec.version = '0.1.3'
spec.authors = { 'Jason Nam' => 'contact@jasonnam.com' }
spec.license = 'MIT'
spec.homepage = '/~https://github.com/jasonnam/XCallbackURL'
Expand Down

0 comments on commit cb31647

Please sign in to comment.