Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #150 from vimeo/release/2.0.0
Browse files Browse the repository at this point in the history
Merging Release 2.0.0
  • Loading branch information
mikew-personal authored May 30, 2017
2 parents aff3bae + f48d675 commit dc65878
Show file tree
Hide file tree
Showing 57 changed files with 1,788 additions and 1,759 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3
3.1
8 changes: 0 additions & 8 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ target 'VimeoNetworkingExample-tvOS' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = "2.3"
end
end
end
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
VimeoNetworking: 17f8d451e4a168044f619315d0cd821669676e67

PODFILE CHECKSUM: 9f9867bb3720cc28bbfeab258d411b2ca6ee7bef
PODFILE CHECKSUM: a8a935f97d6d50906dbff286cd02db46fdd6f52c

COCOAPODS: 1.1.1
2 changes: 1 addition & 1 deletion Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,976 changes: 987 additions & 989 deletions Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions VimeoNetworking/Sources/AccountStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ final class AccountStore
enum AccountType
{
/// Client credentials accounts can access only public resources
case ClientCredentials
case clientCredentials

/// User accounts have an authenticated user and can act on the user's behalf
case User
case user

func keychainKey() -> String
{
switch self
{
case .ClientCredentials:
case .clientCredentials:

return "ClientCredentialsAccountKey"

case .User:
case .user:

return "UserAccountKey"
}
Expand All @@ -55,7 +55,10 @@ final class AccountStore

// MARK: -

private static let ErrorDomain = "AccountStoreErrorDomain"
private struct Constants
{
static let ErrorDomain = "AccountStoreErrorDomain"
}

// MARK: -

Expand Down Expand Up @@ -85,14 +88,14 @@ final class AccountStore

- throws: an error if the data could not be saved
*/
func saveAccount(account: VIMAccount, type: AccountType) throws
func save(_ account: VIMAccount, ofType type: AccountType) throws
{
let data = NSMutableData()
let archiver = NSKeyedArchiver(forWritingWithMutableData: data)
archiver.encodeObject(account)
let archiver = NSKeyedArchiver(forWritingWith: data)
archiver.encode(account)
archiver.finishEncoding()

try self.keychainStore.setData(data, forKey: type.keychainKey())
try self.keychainStore.set(data: data, forKey: type.keychainKey())
}

/**
Expand All @@ -104,17 +107,17 @@ final class AccountStore

- returns: an account of the specified type, if one was found
*/
func loadAccount(type: AccountType) throws -> VIMAccount?
func loadAccount(ofType type: AccountType) throws -> VIMAccount?
{
do
{
guard let data = try self.keychainStore.dataForKey(type.keychainKey())
guard let data = try self.keychainStore.data(for: type.keychainKey())
else
{
return nil
}

let unarchiver = NSKeyedUnarchiver(forReadingWithData: data)
let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
var decodedAccount: VIMAccount? = nil
try ExceptionCatcher.doUnsafe
{
Expand All @@ -125,21 +128,21 @@ final class AccountStore
else
{
let description = "Received corrupted VIMAccount data from keychain"
let error = NSError(domain: self.dynamicType.ErrorDomain, code: LocalErrorCode.AccountCorrupted.rawValue, userInfo: [NSLocalizedDescriptionKey: description])
let error = NSError(domain: Constants.ErrorDomain, code: LocalErrorCode.accountCorrupted.rawValue, userInfo: [NSLocalizedDescriptionKey: description])

throw error
}

if let userJSON = account.userJSON as? VimeoClient.ResponseDictionary
if let userJSON = account.userJSON
{
try account.user = VIMObjectMapper.mapObject(userJSON) as VIMUser
try account.user = VIMObjectMapper.mapObject(responseDictionary: userJSON) as VIMUser
}

return account
}
catch let error
{
_ = try? self.removeAccount(type)
_ = try? self.removeAccount(ofType: type)

throw error
}
Expand All @@ -152,8 +155,8 @@ final class AccountStore

- throws: an error if the data exists but could not be removed
*/
func removeAccount(type: AccountType) throws
func removeAccount(ofType type: AccountType) throws
{
try self.keychainStore.deleteDataForKey(type.keychainKey())
try self.keychainStore.deleteData(for: type.keychainKey())
}
}
Loading

0 comments on commit dc65878

Please sign in to comment.