This repository has been archived by the owner on Nov 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from facebook/nlutsenko.graph.apiVersion
Change type GraphRequestProtocol.apiVersion from String to concrete GraphAPIVersion.
- Loading branch information
Showing
6 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) 2016-present, Facebook, Inc. All rights reserved. | ||
// | ||
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use, | ||
// copy, modify, and distribute this software in source code or binary form for use | ||
// in connection with the web services and APIs provided by Facebook. | ||
// | ||
// As with any software that integrates with the Facebook platform, your use of | ||
// this software is subject to the Facebook Developer Principles and Policies | ||
// [http://developers.facebook.com/policy/]. This copyright 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 | ||
|
||
import FBSDKCoreKit | ||
|
||
/** | ||
Represents version of the Facebook Graph API. | ||
To find out the current latest version - refer to https://developers.facebook.com/docs/graph-api/overview | ||
*/ | ||
public struct GraphAPIVersion { | ||
/// String representation of an api version. | ||
public let stringValue: String | ||
} | ||
|
||
extension GraphAPIVersion { | ||
|
||
/** | ||
Represents the default Graph API version. | ||
Note: This value may change between versions of the SDK. | ||
*/ | ||
public static let Default: GraphAPIVersion = { | ||
var version = FBSDK_TARGET_PLATFORM_VERSION | ||
// ObjC SDK has a prefix of `v` on this constant | ||
if version.hasPrefix("v") { | ||
version = String(version.characters.dropFirst()) | ||
} | ||
return GraphAPIVersion(stringLiteral: version) | ||
}() | ||
} | ||
|
||
extension GraphAPIVersion: StringLiteralConvertible { | ||
|
||
/** | ||
Create a `GraphAPIVersion` from a string literal. | ||
- parameter value: The string literal to create from. | ||
*/ | ||
public init(stringLiteral value: StringLiteralType) { | ||
stringValue = value | ||
} | ||
|
||
/** | ||
Create a `GraphAPIVersion` from a unicode scalar literal. | ||
- parameter value: The string literal to create from. | ||
*/ | ||
public init(unicodeScalarLiteral value: String) { | ||
self.init(stringLiteral: value) | ||
} | ||
|
||
/** | ||
Create a `GraphAPIVersion` from an extended grapheme cluster. | ||
- parameter value: The string literal to create from. | ||
*/ | ||
public init(extendedGraphemeClusterLiteral value: String) { | ||
self.init(stringLiteral: value) | ||
} | ||
} | ||
|
||
extension GraphAPIVersion: FloatLiteralConvertible { | ||
|
||
/** | ||
Create a `GraphAPIVersion` from a float literal. | ||
- parameter value: The float literal to create from. | ||
*/ | ||
public init(floatLiteral value: FloatLiteralType) { | ||
stringValue = String(format: "%.1f", value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters