├── .coveralls.yml ├── PodioKitTests ├── InfoPlist.strings ├── Podio.png ├── EXPMatchers+PKTBeSupersetOf.h ├── PKTClient+Test.h ├── PKTAppTests.m ├── NSString+PKTURL.h ├── PKTNestedTestModel.h ├── PodioKitTests-Prefix.pch ├── NSJSONSerialization+PKTAdditions.h ├── NSURL+PKTParamatersHandling.h ├── PKTNestedTestModel.m ├── PKTItemField+PKTTest.h ├── NSString+PKTBase64Tests.m ├── PKTAsyncTestCase.h ├── PKTUserAPITests.m ├── PKTFormAPITests.m ├── PKTResponseTests.m ├── PKTTestModel.h ├── PodioKitTests.m ├── NSNumber+PKTAdditionsTests.m ├── PKTHTTPStubber.h ├── PKTURLValueTransformerTests.m ├── PKTEmbedsAPITests.m ├── PKTHTTPStubs.h ├── NSString+PKTURLEncodeTests.m ├── PKTBlockValueTransformerTests.m ├── PodioKitTests-Info.plist ├── PKTAvatarTypeValueTransformerTests.m ├── PKTNumberValueTransformerTests.m ├── NSString+PKTRandomTests.m ├── PKTReversibleBlockValueTransformerTests.m ├── NSString+PKTURLTests.m ├── NSURL+PKTParamatersHandling.m ├── PKTTestModel.m ├── NSJSONSerialization+PKTAdditions.m ├── PKTCalendarAPITests.m ├── PKTDurationTests.m ├── PKTSearchAPITests.m ├── PKTAppFieldConfigTests.m ├── PKTConversationsAPITests.m ├── PKTOrganizationAPITests.m ├── PKTModelValueTransformerTests.m ├── PKTDateValueTransformerTests.m ├── PKTDictionaryMappingValueTransformerTests.m ├── PKTLocationTests.m ├── PKTCommentAPITests.m ├── NSDictionary+PKTQueryParametersTests.m ├── PKTHTTPStubs.m ├── NSString+PKTURL.m ├── PKTAppAPITests.m └── PKTImageCacheTests.m ├── Gemfile ├── Podfile ├── PodioKit ├── Common │ ├── API │ │ ├── PKTBaseAPI.m │ │ ├── PKTBaseAPI.h │ │ ├── PKTUsersAPI.h │ │ ├── PKTFormsAPI.h │ │ ├── PKTRequestParameters.h │ │ ├── PKTEmbedsAPI.h │ │ ├── PKTLocationAPI.h │ │ ├── PKTUsersAPI.m │ │ ├── PKTFormsAPI.m │ │ ├── PKTEmbedsAPI.m │ │ ├── PKTLocationAPI.m │ │ ├── PKTOrganizationsAPI.h │ │ ├── PKTCommentsAPI.h │ │ ├── PKTWorkspaceMembersAPI.h │ │ ├── PKTSearchQuery.h │ │ ├── PKTWorkspacesAPI.h │ │ ├── PKTAuthenticationAPI.h │ │ ├── PKTAppsAPI.h │ │ ├── PKTFilesAPI.h │ │ ├── PKTStatusAPI.h │ │ ├── PKTSearchAPI.h │ │ ├── PKTReferenceAPI.h │ │ ├── PKTOrganizationsAPI.m │ │ ├── PKTSearchQuery.m │ │ ├── PKTNotificationsAPI.h │ │ ├── PKTCommentsAPI.m │ │ ├── PKTItemsAPI.h │ │ ├── PKTCalendarAPI.h │ │ ├── PKTWorkspacesAPI.m │ │ ├── PKTWorkspaceMembersAPI.m │ │ ├── PKTContactsAPI.h │ │ └── PKTNotificationsRequestParameters.h │ ├── Models │ │ ├── PKTTagItemFieldValue.h │ │ ├── PKTAppItemFieldValue.h │ │ ├── PKTDateItemFieldValue.h │ │ ├── PKTFileItemFieldValue.h │ │ ├── PKTNumberItemFieldValue.h │ │ ├── PKTDurationItemFieldValue.h │ │ ├── PKTEmbedItemFieldValue.h │ │ ├── PKTMoneyItemFieldValue.h │ │ ├── PKTProfileItemFieldValue.h │ │ ├── PKTProgressItemFieldValue.h │ │ ├── PKTStringItemFieldValue.h │ │ ├── PKTCategoryItemFieldValue.h │ │ ├── PKTLocationItemFieldValue.h │ │ ├── PKTCalculationItemFieldValue.h │ │ ├── PKTFormField.h │ │ ├── PKTFormField.m │ │ ├── PKTMoney.h │ │ ├── PKTReferenceGroup.h │ │ ├── PKTReferenceObjectFactory.h │ │ ├── PKTUser.h │ │ ├── PKTMessage.h │ │ ├── PKTFormSettings.h │ │ ├── PKTPushCredential.h │ │ ├── PKTCategoryOption.h │ │ ├── PKTNotificationGroup.h │ │ ├── PKTDuration.h │ │ ├── PKTCalculationItemFieldValue.m │ │ ├── PKTDateRange.h │ │ ├── PKTReferenceIdentifier.h │ │ ├── PKTNotificationGroup.m │ │ ├── PKTFormSettings.m │ │ ├── PKTReference.h │ │ ├── PKTUser.m │ │ ├── PKTAppField.h │ │ ├── PKTItemField.h │ │ ├── PKTTagItemFieldValue.m │ │ ├── PKTMessage.m │ │ ├── PKTProgressItemFieldValue.m │ │ ├── PKTAppItemFieldValue.m │ │ ├── PKTByLine.h │ │ ├── PKTStringItemFieldValue.m │ │ ├── PKTProfileItemFieldValue.m │ │ ├── PKTNumberItemFieldValue.m │ │ ├── PKTFileItemFieldValue.m │ │ ├── PKTMoney.m │ │ ├── PKTPushCredential.m │ │ ├── PKTDurationItemFieldValue.m │ │ ├── PKTOrganization.h │ │ ├── PKTReferenceGroup.m │ │ ├── PKTCategoryOption.m │ │ ├── PKTUserStatus.h │ │ ├── PKTForm.h │ │ ├── PKTMoneyItemFieldValue.m │ │ ├── PKTAction.h │ │ ├── PKTItemFieldValue.h │ │ ├── PKTApp.h │ │ ├── PKTEmbed.h │ │ ├── PKTLocationItemFieldValue.m │ │ ├── PKTCategoryItemFieldValue.m │ │ ├── PKTConversationEvent.h │ │ ├── PKTEmbedItemFieldValue.m │ │ ├── PKTAppFieldConfig.h │ │ ├── PKTStatus.h │ │ ├── PKTByLine.m │ │ ├── PKTAppField.m │ │ ├── PKTReferenceIdentifier.m │ │ ├── PKTNotificationContext.h │ │ ├── PKTFile.h │ │ ├── PKTDuration.m │ │ ├── PKTAppFieldConfig.m │ │ └── PKTDateRange.m │ ├── Support │ │ ├── PKTNumberValueTransformer.h │ │ ├── PKTEmojiValueTransformer.h │ │ ├── NSString+PKTBase64.h │ │ ├── PKTURLValueTransformer.h │ │ ├── PKTRightValueTransformer.h │ │ ├── NSString+PKTAdditions.h │ │ ├── NSDictionary+PKTAdditions.h │ │ ├── NSString+PKTRandom.h │ │ ├── PKTAvatarTypeValueTransformer.h │ │ ├── NSURL+PKTAdditions.h │ │ ├── NSURL+PKTImageURL.h │ │ ├── NSNumberFormatter+PKTAdditions.h │ │ ├── NSString+PKTURLEncode.h │ │ ├── PKTAppFieldTypeValueTransformer.h │ │ ├── PKTReferenceTypeValueTransformer.h │ │ ├── PKTNotificationTypeValueTransformer.h │ │ ├── NSNumber+PKTAdditions.h │ │ ├── PKTMeetingParticipantStatusValueTransformer.h │ │ ├── PKTDateValueTransformer.h │ │ ├── NSString+PKTAdditions.m │ │ ├── NSSet+PKTAdditions.h │ │ ├── PKTModelValueTransformer.h │ │ ├── PKTMacros.h │ │ ├── PKTURLValueTransformer.m │ │ ├── NSDateFormatter+PKTAdditions.h │ │ ├── NSObject+PKTIntrospection.h │ │ ├── NSDictionary+PKTAdditions.m │ │ ├── NSDictionary+PKTQueryParameters.h │ │ ├── NSMutableURLRequest+PKTHeaders.h │ │ ├── PKTDictionaryMappingValueTransformer.h │ │ ├── PKTAvatarTypeValueTransformer.m │ │ ├── PKTBlockValueTransformer.h │ │ ├── NSDate+PKTAdditions.h │ │ ├── PKTReversibleBlockValueTransformer.h │ │ ├── NSString+PKTRandom.m │ │ ├── NSNumberFormatter+PKTAdditions.m │ │ ├── NSValueTransformer+PKTConstants.h │ │ ├── NSArray+PKTAdditions.h │ │ ├── PKTMeetingParticipantStatusValueTransformer.m │ │ ├── NSError+PKTErrors.h │ │ ├── NSFileManager+PKTAdditions.h │ │ ├── PKTNumberValueTransformer.m │ │ ├── NSURL+PKTAdditions.m │ │ ├── NSNumber+PKTAdditions.m │ │ ├── NSSet+PKTAdditions.m │ │ ├── NSObject+PKTIntrospection.m │ │ ├── NSMutableURLRequest+PKTHeaders.m │ │ ├── PKTBlockValueTransformer.m │ │ ├── PKTAppFieldTypeValueTransformer.m │ │ ├── NSURL+PKTImageURL.m │ │ ├── NSValueTransformer+PKTTransformers.h │ │ ├── PKTDateValueTransformer.m │ │ ├── PKTReversibleBlockValueTransformer.m │ │ ├── NSDateFormatter+PKTAdditions.m │ │ ├── NSString+PKTBase64.m │ │ └── NSString+ PKTURLEncode.m │ ├── Core │ │ ├── PKTSecurity.h │ │ ├── PKTResponseSerializer.h │ │ ├── PKTTokenStore.h │ │ ├── PKTResponse.h │ │ ├── PKTResponse.m │ │ ├── PKTKeychainTokenStore.h │ │ ├── PKTRequestFileData.h │ │ ├── PKTKeychain.h │ │ ├── PKTResponseSerializer.m │ │ ├── PKTMultipartFormData.h │ │ ├── PKTRequestFileData.m │ │ ├── PKTRequestSerializer.h │ │ └── PKTKeychainTokenStore.m │ ├── PodioKit-Prefix.pch │ └── PodioKit.m ├── UIKit │ ├── PKTImageCache.h │ ├── PKTImageDownloader.h │ ├── UIImageView+PKTRemoteImage.h │ ├── PKTFile+UIImage.h │ ├── UIButton+PKTRemoteImage.h │ ├── PKTImageDownloader.m │ └── PKTImageCache.m └── Push │ └── PKTPushClient.h ├── Scripts ├── string_ext.rb └── run-tests ├── Description.md ├── .travis.yml ├── Rakefile ├── Podfile.lock ├── .gitignore ├── LICENSE ├── PodioKit.podspec └── Gemfile.lock /.coveralls.yml: -------------------------------------------------------------------------------- 1 | repo_token: ZZIRtHmCq7luTSJI8021JuySGmOYEZKSU 2 | service_name: travis-ci -------------------------------------------------------------------------------- /PodioKitTests/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PodioKitTests/Podio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/podio/podio-objc/master/PodioKitTests/Podio.png -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'cocoapods' 5 | gem 'xcpretty' 6 | gem 'travis-lint' -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | pod 'DDCometClient', '~> 1.0' 4 | pod 'FXReachability', '~> 1.3' 5 | 6 | target :podiokittests do 7 | link_with 'PodioKitTests' 8 | 9 | pod 'OHHTTPStubs' 10 | pod 'Expecta' 11 | pod 'OCMock' 12 | end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTBaseAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTBaseAPI.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 28/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @implementation PKTBaseAPI 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Scripts/string_ext.rb: -------------------------------------------------------------------------------- 1 | class String 2 | def to_bool 3 | return true if self == true || self =~ (/\A(true|t|yes|y|1)\Z/i) 4 | return false if self == false || self.empty? || self =~ (/\A(false|f|no|n|0)\Z/i) 5 | raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") 6 | end 7 | end -------------------------------------------------------------------------------- /Description.md: -------------------------------------------------------------------------------- 1 | PodioKit is a Objective-C client library for the Podio API. It provides an easy way to integrate your iOS and Mac apps with Podio. 2 | 3 | More documentation and examples can be found on [Github](http://podio.github.io/podio-objc/) and the official [Podio developer site](https://developers.podio.com/). -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | rvm: 3 | - 2.0.0 4 | gemfile: 5 | - Gemfile 6 | cache: bundler 7 | branches: 8 | only: 9 | - master 10 | before_script: 11 | - export LANG=en_US.UTF-8 12 | - sudo easy_install pyyaml 13 | script: 14 | - rake test:run 15 | after_success: 16 | - rake test:coverage -------------------------------------------------------------------------------- /PodioKitTests/EXPMatchers+PKTBeSupersetOf.h: -------------------------------------------------------------------------------- 1 | // 2 | // EXPMatchers+PKTBeSupersetOf.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "Expecta.h" 10 | 11 | EXPMatcherInterface(pkt_beSupersetOf, (id subset)); -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTBaseAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTBaseAPI.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 28/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTRequest.h" 11 | 12 | @interface PKTBaseAPI : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTTagItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTTagItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 02/11/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTTagItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKitTests/PKTClient+Test.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKSessionManager+Test.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 30/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTClient.h" 10 | 11 | @interface PKTClient (Test) 12 | 13 | - (PKTAsyncTask *)refreshToken; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTAppItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDateItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTDateItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFileItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFileItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTFileItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTNumberItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNumberItemFieldValue 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTNumberItemFieldValue : PKTItemFieldValue 12 | 13 | @end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTUsersAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUsersAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 17/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTUsersAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForUserStatus; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDurationItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDurationItemFieldValue 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTDurationItemFieldValue : PKTItemFieldValue 12 | 13 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTEmbedItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbedItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTEmbedItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMoneyItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMoneyItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTMoneyItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKitTests/PKTAppTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 03/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTAppTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PKTAppTests 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTProfileItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTProfileItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTProfileItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTProgressItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTProgressItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 08/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTProgressItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTStringItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTStringItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTStringItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTNumberValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNumberValueTransformer 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTNumberValueTransformer : NSValueTransformer 12 | 13 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCategoryItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCategoryItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTCategoryItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTLocationItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTLocationItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTLocationItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTEmojiValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmojiValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Pavel Prochazka on 06/09/15. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTEmojiValueTransformer : NSValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTBase64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString(PKTBase64) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/06/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface NSString (PKTBase64) 13 | 14 | - (NSString *)pkt_base64String; 15 | 16 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTURLValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTURLValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBlockValueTransformer.h" 10 | 11 | @interface PKTURLValueTransformer : PKTBlockValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTFormsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTFormsAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForFormWithID:(NSUInteger)formID; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTSecurity.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTSecurity.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 24/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTSecurity : NSObject 12 | 13 | - (BOOL)evaluateServerTrust:(SecTrustRef)trust; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCalculationItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCalculationItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTItemFieldValue.h" 10 | 11 | @interface PKTCalculationItemFieldValue : PKTItemFieldValue 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTRightValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTRightValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 20/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBlockValueTransformer.h" 10 | 11 | @interface PKTRightValueTransformer : PKTBlockValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTRequestParameters.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTRequestParameters.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol PKTRequestParameters 12 | 13 | - (NSDictionary *)queryParameters; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTEmbedsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbedsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTEmbedsAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestToAddEmbedWithURLString:(NSString *)URLString; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (PKTAdditions) 12 | 13 | - (BOOL)pkt_containsString:(NSString *)string; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTLocationAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTLocationAPI.h 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 04/11/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTLocationAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestToLookupLoactionWithAddressString:(NSString *)address; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDictionary+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 11/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDictionary (PKTAdditions) 12 | 13 | - (id)pkt_nonNullObjectForKey:(id)key; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTURL.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURL.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (PKTURL) 12 | 13 | - (instancetype)pkt_escapedURLString; 14 | - (instancetype)pkt_unescapedURLString; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTRandom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKRandom.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/5/12. 6 | // Copyright (c) 2012 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (PKTRandom) 12 | 13 | + (instancetype)pkt_randomHexStringOfLength:(NSUInteger)length; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTAvatarTypeValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAvatarTypeValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 21/04/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDictionaryMappingValueTransformer.h" 10 | 11 | @interface PKTAvatarTypeValueTransformer : PKTDictionaryMappingValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSURL+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSURL (PKTAdditions) 12 | 13 | - (NSURL *)pkt_URLByAppendingQueryParameters:(NSDictionary *)parameters; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSURL+PKTImageURL.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTImageURL.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 19/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTFile.h" 11 | 12 | @interface NSURL (PKTImageURL) 13 | 14 | - (NSURL *)pkt_imageURLForSize:(PKTImageSize)size; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSNumberFormatter+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter(PKTAdditions) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface NSNumberFormatter (PKTAdditions) 13 | 14 | + (NSNumberFormatter *)pkt_USNumberFormatter; 15 | 16 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTURLEncode.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURLEncode.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (PKTURLEncode) 12 | 13 | - (NSString *)pkt_encodeString; 14 | - (NSString *)pkt_decodeString; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTAppFieldTypeValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppFieldTypeValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDictionaryMappingValueTransformer.h" 10 | 11 | @interface PKTAppFieldTypeValueTransformer : PKTDictionaryMappingValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTReferenceTypeValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceTypeValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDictionaryMappingValueTransformer.h" 10 | 11 | @interface PKTReferenceTypeValueTransformer : PKTDictionaryMappingValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTNotificationTypeValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationTypeValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 21/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDictionaryMappingValueTransformer.h" 10 | 11 | @interface PKTNotificationTypeValueTransformer : PKTDictionaryMappingValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTUsersAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUsersAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 17/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTUsersAPI.h" 10 | 11 | @implementation PKTUsersAPI 12 | 13 | + (PKTRequest *)requestForUserStatus { 14 | return [PKTRequest GETRequestWithPath:@"/user/status" parameters:nil]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTResponseSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTResponseSerializer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTResponseSerializer : NSObject 12 | 13 | - (id)responseObjectForURLResponse:(NSURLResponse *)response data:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFormField.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormField.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTFormField : PKTModel 12 | 13 | @property (nonatomic, assign, readonly) NSUInteger fieldID; 14 | @property (nonatomic, assign, readonly) NSDictionary *settings; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/PodioKit-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PodioKit' target in the 'PodioKit' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #elif TARGET_OS_MAC 12 | #import 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSNumber+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber(PKTAdditions) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface NSNumber (PKTAdditions) 13 | 14 | + (NSNumber *)pkt_numberFromUSNumberString:(NSString *)numberString; 15 | - (NSString *)pkt_USNumberString; 16 | 17 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTMeetingParticipantStatusValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMeetingParticipantStatusValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 07/09/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDictionaryMappingValueTransformer.h" 10 | 11 | @interface PKTMeetingParticipantStatusValueTransformer : PKTDictionaryMappingValueTransformer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PodioKitTests/PKTNestedTestModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNestedTestModel.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 23/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTNestedTestModel : PKTModel 12 | 13 | @property (nonatomic, assign, readonly) NSUInteger objectID; 14 | @property (nonatomic, copy, readonly) NSString *firstValue; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKitTests/PodioKitTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PodioKitTests' target in the 'PodioKitTests' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #import 9 | 10 | #define EXP_SHORTHAND 11 | #import 12 | #import "EXPMatchers+PKTBeSupersetOf.h" 13 | #endif -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTDateValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTReversibleBlockValueTransformer.h" 10 | 11 | @interface PKTDateValueTransformer : PKTReversibleBlockValueTransformer 12 | 13 | @property (nonatomic, assign) BOOL ignoresTimeComponent; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKitTests/NSJSONSerialization+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSJSONSerialization+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSJSONSerialization (PKTAdditions) 12 | 13 | + (id)pkt_JSONObjectFromFileWithName:(NSString *)fileName inBundleForClass:(Class)klass; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PodioKitTests/NSURL+PKTParamatersHandling.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTParamatersHandling.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSURL (PKTParamatersHandling) 12 | 13 | - (NSString *)pkt_valueForQueryParameter:(NSString *)parameter; 14 | - (NSDictionary *)pkt_queryParameters; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSString+PKTAdditions.h" 10 | 11 | @implementation NSString (PKTAdditions) 12 | 13 | - (BOOL)pkt_containsString:(NSString *)string { 14 | return [self rangeOfString:string].location != NSNotFound; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSSet+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSSet+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 29/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSSet (PKTAdditions) 12 | 13 | - (instancetype)pkt_mappedSetWithBlock:(id (^)(id obj))block; 14 | 15 | - (instancetype)pkt_filteredSetWithBlock:(BOOL (^)(id obj))block; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTFormsAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormsAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTFormsAPI.h" 10 | 11 | @implementation PKTFormsAPI 12 | 13 | + (PKTRequest *)requestForFormWithID:(NSUInteger)formID { 14 | return [PKTRequest GETRequestWithPath:PKTRequestPath(@"/form/%lu", (unsigned long)formID) parameters:nil]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTTokenStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTTokenStore.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTOAuth2Token.h" 11 | 12 | @protocol PKTTokenStore 13 | 14 | - (void)storeToken:(PKTOAuth2Token *)token; 15 | 16 | - (void)deleteStoredToken; 17 | 18 | - (PKTOAuth2Token *)storedToken; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFormField.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormField.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTFormField.h" 10 | 11 | @implementation PKTFormField 12 | 13 | #pragma mark - PKTModel 14 | 15 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 16 | return @{ 17 | @"fieldID" : @"field_id" 18 | }; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMoney.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMoney.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTMoney : PKTModel 12 | 13 | @property (nonatomic, copy) NSNumber *amount; 14 | @property (nonatomic, copy) NSString *currency; 15 | 16 | - (instancetype)initWithAmount:(NSNumber *)amount currency:(NSString *)currency; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKitTests/PKTNestedTestModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNestedTestModel.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 23/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTNestedTestModel.h" 10 | 11 | @implementation PKTNestedTestModel 12 | 13 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 14 | return @{ 15 | @"objectID": @"object_id", 16 | @"firstValue": @"first_value", 17 | }; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTModelValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTModelValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTModelValueTransformer : NSValueTransformer 12 | 13 | - (instancetype)initWithModelClass:(Class)modelClass; 14 | 15 | + (instancetype)transformerWithModelClass:(Class)modelClass; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMacros.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | // References 10 | #define PKT_STRONG(obj) __typeof__(obj) 11 | #define PKT_WEAK(obj) __typeof__(obj) __weak 12 | #define PKT_WEAK_SELF PKT_WEAK(self) 13 | 14 | #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED 15 | #define PKT_IOS_SDK_AVAILABLE 1 16 | #else 17 | #define PKT_IOS_SDK_AVAILABLE 0 18 | #endif -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTURLValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTURLValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTURLValueTransformer.h" 10 | 11 | @implementation PKTURLValueTransformer 12 | 13 | - (instancetype)init { 14 | return [super initWithBlock:^id(NSString *URLString) { 15 | return [NSURL URLWithString:URLString]; 16 | }]; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKitTests/PKTItemField+PKTTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTItemField(PKTTest) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "PKTItemField.h" 12 | 13 | @interface PKTItemField (PKTTest) 14 | 15 | + (Class)valueClassForFieldType:(PKTAppFieldType)fieldType; 16 | 17 | + (id)unboxedValueFromBasicValue:(id)value forField:(PKTAppField *)field; 18 | 19 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDateFormatter+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDateFormatter (PKTAdditions) 12 | 13 | + (NSDateFormatter *)pkt_UTCDateFormatter; 14 | + (NSDateFormatter *)pkt_UTCDateTimeFormatter; 15 | + (NSDateFormatter *)pkt_UTCTimeFormatter; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # do not echo sh commands 2 | verbose(false) 3 | 4 | SCRIPTS = './Scripts' 5 | 6 | desc "Run the PodioKit unit test suite" 7 | task :test => 'test:run' 8 | 9 | namespace :test do 10 | task :run do 11 | sh "#{SCRIPTS}/run-tests" 12 | end 13 | 14 | desc "Generate a coverage report from the last test run" 15 | task :coverage do 16 | opts = '' 17 | opts << " --publish #{ENV['publish']}" if ENV['publish'] 18 | 19 | sh "#{SCRIPTS}/coverage-report#{opts}" 20 | end 21 | end -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReferenceGroup.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceSearchGroup.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/12/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTReferenceGroup : PKTModel 12 | 13 | @property (nonatomic, copy, readonly) NSString *name; 14 | @property (nonatomic, copy, readonly) NSDictionary *data; 15 | @property (nonatomic, copy, readonly) NSArray *contents; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReferenceObjectFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceObjectFactory.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTReferenceObjectFactory : NSObject 12 | 13 | + (id)referenceObjectFromDictionary:(NSDictionary *)dictionary; 14 | + (id)referenceObjectFromData:(NSDictionary *)data type:(NSUInteger)referenceType; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUser.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTAsyncTask, PKTPushCredential; 12 | 13 | @interface PKTUser : PKTModel 14 | 15 | @property (nonatomic, assign, readonly) NSUInteger userID; 16 | @property (nonatomic, copy, readonly) NSString *mail; 17 | 18 | + (PKTAsyncTask *)fetchCurrentUser; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTResponse.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTResponse.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTResponse : NSObject 12 | 13 | @property (nonatomic, assign, readonly) NSInteger statusCode; 14 | @property (nonatomic, copy, readonly) id body; 15 | 16 | - (instancetype)initWithStatusCode:(NSInteger)statusCode body:(id)body; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTEmbedsAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbedsAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTEmbedsAPI.h" 10 | 11 | @implementation PKTEmbedsAPI 12 | 13 | + (PKTRequest *)requestToAddEmbedWithURLString:(NSString *)URLString { 14 | NSParameterAssert(URLString); 15 | 16 | return [PKTRequest POSTRequestWithPath:@"/embed/" parameters:@{@"url" : URLString}]; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSObject+PKTIntrospection.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+PKTIntrospection.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (PKTIntrospection) 12 | 13 | + (id)pkt_valueByPerformingSelectorWithName:(NSString *)selectorName; 14 | 15 | + (id)pkt_valueByPerformingSelectorWithName:(NSString *)selectorName withObject:(id)object; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTLocationAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTLocationAPI.m 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 04/11/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTLocationAPI.h" 10 | 11 | @implementation PKTLocationAPI 12 | 13 | + (PKTRequest *)requestToLookupLoactionWithAddressString:(NSString *)address { 14 | NSDictionary *params = @{@"address": address}; 15 | return [PKTRequest GETRequestWithPath:@"/location/lookup" parameters:params]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTResponse.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTResponse.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTResponse.h" 10 | 11 | @implementation PKTResponse 12 | 13 | - (instancetype)initWithStatusCode:(NSInteger)statusCode body:(id)body { 14 | self = [super init]; 15 | if (!self) return nil; 16 | 17 | _statusCode = statusCode; 18 | _body = body; 19 | 20 | return self; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/UIKit/PKTImageCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTImageCache.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PKTFile; 12 | 13 | @interface PKTImageCache : NSCache 14 | 15 | + (instancetype)sharedCache; 16 | 17 | - (void)clearCache; 18 | 19 | - (UIImage *)cachedImageForFile:(PKTFile *)file; 20 | 21 | - (void)setCachedImage:(UIImage *)image forFile:(PKTFile *)file; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDictionary+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 11/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+PKTAdditions.h" 10 | 11 | @implementation NSDictionary (PKTAdditions) 12 | 13 | - (id)pkt_nonNullObjectForKey:(id)key { 14 | id value = self[key]; 15 | if (value == [NSNull null]) { 16 | value = nil; 17 | } 18 | 19 | return value; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDictionary+PKTQueryParameters.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+PKTQueryParameters.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDictionary (PKTQueryParameters) 12 | 13 | - (NSString *)pkt_queryString; 14 | - (NSString *)pkt_escapedQueryString; 15 | - (NSDictionary *)pkt_queryParametersPairs; 16 | - (NSDictionary *)pkt_escapedQueryParametersPairs; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSMutableURLRequest+PKTHeaders.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+PKTHeaders.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 21/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSMutableURLRequest (PKTHeaders) 12 | 13 | - (void)pkt_setAuthorizationHeaderWithOAuth2AccessToken:(NSString *)accessToken; 14 | - (void)pkt_setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTDictionaryMappingValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDictionaryMappingValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTDictionaryMappingValueTransformer : NSValueTransformer 12 | 13 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary; 14 | 15 | + (instancetype)transformerWithDictionary:(NSDictionary *)dictionary; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTOrganizationsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTOrganizationsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTOrganizationsAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForAllOrganizations; 14 | + (PKTRequest *)requestForOrganizationWithID:(NSUInteger)organizationID; 15 | + (PKTRequest *)requestToUpdateOrganizationWithID:(NSUInteger)organizationID withName:(NSString *)name; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMessage.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMessage.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 13/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTEmbed; 12 | 13 | @interface PKTMessage : PKTModel 14 | 15 | @property (nonatomic, readonly) NSUInteger messageID; 16 | @property (nonatomic, copy, readonly) NSString *text; 17 | @property (nonatomic, copy, readonly) NSArray *files; 18 | @property (nonatomic, copy, readonly) PKTEmbed *embed; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTAvatarTypeValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAvatarTypeValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 21/04/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTAvatarTypeValueTransformer.h" 10 | #import "PKTConstants.h" 11 | 12 | @implementation PKTAvatarTypeValueTransformer 13 | 14 | - (instancetype)init { 15 | return [super initWithDictionary:@{ 16 | @"file": @(PKTAvatarTypeFile), 17 | @"icon": @(PKTAvatarTypeIcon) 18 | }]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTCommentsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCommentsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTCommentsAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestToAddCommentToObjectWithReferenceID:(NSUInteger)referenceID referenceType:(PKTReferenceType)referenceType value:(NSString *)value files:(NSArray *)files embedID:(NSUInteger)embedID embedURL:(NSURL *)embedURL; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFormSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormSettings.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTFormSettings : PKTModel 12 | 13 | @property (nonatomic, copy, readonly) NSString *titleText; 14 | @property (nonatomic, copy, readonly) NSString *descriptionText; 15 | @property (nonatomic, copy, readonly) NSString *submitText; 16 | @property (nonatomic, copy, readonly) NSString *successText; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTPushCredential.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTPushCredential.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTPushCredential : PKTModel 12 | 13 | @property (nonatomic, copy, readonly) NSString *channel; 14 | @property (nonatomic, copy, readonly) NSDate *expiresOn; 15 | @property (nonatomic, copy, readonly) NSString *signature; 16 | @property (nonatomic, copy, readonly) NSNumber *timestamp; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTBlockValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTBlockValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef id (^PKTValueTransformationBlock) (id value); 12 | 13 | @interface PKTBlockValueTransformer : NSValueTransformer 14 | 15 | - (instancetype)initWithBlock:(PKTValueTransformationBlock)block; 16 | 17 | + (instancetype)transformerWithBlock:(PKTValueTransformationBlock)block; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTWorkspaceMembersAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTWorkspaceMembersAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 19/08/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTWorkspaceMembersAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestToAddMembersToSpaceWithID:(NSUInteger)workspaceID role:(PKTWorkspaceMemberRole)role message:(NSString *)message userIDs:(NSArray *)userIDs profileIDs:(NSArray *)profileIDs emails:(NSArray *)emails; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PodioKit/UIKit/PKTImageDownloader.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTImageDownloader.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTConstants.h" 11 | 12 | @class PKTFile; 13 | @class PKTAsyncTask; 14 | 15 | @interface PKTImageDownloader : NSObject 16 | 17 | + (PKTAsyncTask *)setImageWithFile:(PKTFile *)file placeholderImage:(UIImage *)placeholderImage imageSize:(PKTImageSize)imageSize imageSetterBlock:(void (^)(UIImage *image))imageSetterBlock; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTBase64Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTBase64Tests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+PKTBase64.h" 11 | 12 | @interface NSString_PKTBase64Tests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSString_PKTBase64Tests 17 | 18 | - (void)testBase64Encoding { 19 | expect([@"SomeString:SomeOtherString" pkt_base64String]).to.equal(@"U29tZVN0cmluZzpTb21lT3RoZXJTdHJpbmc="); 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCategoryOption.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCategoryOption 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTCategoryOption : PKTModel 13 | 14 | @property (nonatomic, assign, readonly) NSUInteger optionID; 15 | @property (nonatomic, assign, readonly) PKTCategoryOptionStatus status; 16 | @property (nonatomic, copy, readonly) NSString *text; 17 | @property (nonatomic, copy, readonly) NSString *color; 18 | 19 | @end -------------------------------------------------------------------------------- /PodioKitTests/PKTAsyncTestCase.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAsyncTestCase.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/17/11. 6 | // Copyright (c) 2012 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTAsyncTestCase : XCTestCase 12 | 13 | - (void)waitForCompletionWithBlock:(void (^)(void))block; 14 | - (void)waitForCompletion:(NSTimeInterval)timeoutSeconds block:(void (^)(void))block; 15 | 16 | - (void)finish; 17 | 18 | - (void)waitForNotificiationWithName:(NSString *)name object:(id)object inBlock:(void (^)(void))block; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKitTests/PKTUserAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUserAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 17/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTUsersAPI.h" 11 | 12 | @interface PKTUserAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTUserAPITests 17 | 18 | - (void)testRequestForUserStatus { 19 | PKTRequest *request = [PKTUsersAPI requestForUserStatus]; 20 | expect(request.method).to.equal(PKTRequestMethodGET); 21 | expect(request.path).to.equal(@"/user/status"); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKitTests/PKTFormAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTFormsAPI.h" 11 | 12 | @interface PKTFormAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTFormAPITests 17 | 18 | - (void)testRequestForForm { 19 | PKTRequest *request = [PKTFormsAPI requestForFormWithID:12345]; 20 | 21 | expect(request.path).to.equal(@"/form/12345"); 22 | expect(request.method).to.equal(PKTRequestMethodGET); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - DDCometClient (1.0.1) 3 | - Expecta (1.0.0) 4 | - FXReachability (1.3.1) 5 | - OCMock (3.1.2) 6 | - OHHTTPStubs (4.0.2) 7 | 8 | DEPENDENCIES: 9 | - DDCometClient (~> 1.0) 10 | - Expecta 11 | - FXReachability (~> 1.3) 12 | - OCMock 13 | - OHHTTPStubs 14 | 15 | SPEC CHECKSUMS: 16 | DDCometClient: d0c81b6bf58c74b29114440b94ef7027f450f055 17 | Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024 18 | FXReachability: 1d9a83617474f2a4e1b53c11a13ec4337428c126 19 | OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92 20 | OHHTTPStubs: dbd1957d414659783e07b49c961940b7564c23d9 21 | 22 | COCOAPODS: 0.37.2 23 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTSearchQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTSearchQuery.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTRequestParameters.h" 11 | #import "PKTConstants.h" 12 | 13 | @interface PKTSearchQuery : NSObject 14 | 15 | @property (nonatomic, copy, readonly) NSString *text; 16 | @property (nonatomic, assign) PKTReferenceType referenceType; 17 | @property (nonatomic, assign) BOOL returnCounts; 18 | 19 | + (instancetype)queryWithText:(NSString *)text; 20 | 21 | @end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTWorkspacesAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTWorkspacesAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/08/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTWorkspacesAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestForWorkspaceWithID:(NSUInteger)workspaceID; 15 | 16 | + (PKTRequest *)requestToCreateWorkspaceWithName:(NSString *)name organizationID:(NSUInteger)organization privacy:(PKTWorkspacePrivacy)privacy; 17 | 18 | + (PKTRequest *)requestForWorkspaceWithURLString:(NSString *)urlString; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTNotificationGroup.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationGroup.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 19/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTNotificationContext; 12 | 13 | @interface PKTNotificationGroup : PKTModel 14 | 15 | /* 16 | * The context of the group of notifications 17 | */ 18 | @property (nonatomic, strong, readonly) PKTNotificationContext *context; 19 | 20 | /* 21 | * The list of notifications for the given context 22 | */ 23 | @property (nonatomic, copy, readonly) NSArray *notifications; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDate+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDate (PKTAdditions) 12 | 13 | + (NSDate *)pkt_dateFromUTCDateString:(NSString *)dateString; 14 | + (NSDate *)pkt_dateFromUTCDateTimeString:(NSString *)dateTimeString; 15 | + (NSDate *)pkt_dateFromUTCTimeString:(NSString *)timeString; 16 | 17 | - (NSString *)pkt_UTCDateString; 18 | - (NSString *)pkt_UTCDateTimeString; 19 | - (NSString *)pkt_UTCTimeString; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | DerivedData/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | 18 | .DS_Store? 19 | Icon? 20 | 21 | # Thumbnails 22 | ._* 23 | 24 | # Files that might appear on external disk 25 | .Spotlight-V100 26 | .Trashes 27 | .DS_Store 28 | 29 | # appledoc 30 | docset-installed.txt 31 | */docset 32 | 33 | # Generated documentation 34 | Docs 35 | 36 | # AppCode 37 | .idea 38 | 39 | # CocoaPods 40 | Pods 41 | 42 | # Test coverage 43 | Coverage -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTReversibleBlockValueTransformer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReversibleBlockValueTransformer.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBlockValueTransformer.h" 10 | 11 | @interface PKTReversibleBlockValueTransformer : PKTBlockValueTransformer 12 | 13 | - (instancetype)initWithBlock:(PKTValueTransformationBlock)block reverseBlock:(PKTValueTransformationBlock)reverseBlock; 14 | 15 | + (instancetype)transformerWithBlock:(PKTValueTransformationBlock)block reverseBlock:(PKTValueTransformationBlock)reverseBlock; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PodioKitTests/PKTResponseTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTResponseTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTResponse.h" 11 | 12 | @interface PKTResponseTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTResponseTests 17 | 18 | - (void)testInit { 19 | NSDictionary *body = @{@"key" : @"value"}; 20 | PKTResponse *response = [[PKTResponse alloc] initWithStatusCode:200 body:body]; 21 | expect(response.statusCode).to.equal(200); 22 | expect(response.body).to.equal(body); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /PodioKitTests/PKTTestModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTTestModel.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTNestedTestModel; 12 | 13 | @interface PKTTestModel : PKTModel 14 | 15 | @property (nonatomic, readonly) NSUInteger objectID; 16 | @property (nonatomic, copy, readonly) NSString *firstValue; 17 | @property (nonatomic, copy, readonly) NSString *secondValue; 18 | @property (nonatomic, copy, readonly) NSArray *nestedObjects; 19 | @property (nonatomic, copy, readonly) PKTNestedTestModel *nestedObject; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /PodioKit/UIKit/UIImageView+PKTRemoteImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+PKTRemoteImage.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 10 | 11 | #import 12 | #import "PKTConstants.h" 13 | 14 | @class PKTFile; 15 | @class PKTAsyncTask; 16 | 17 | @interface UIImageView (PKTRemoteImage) 18 | 19 | - (PKTAsyncTask *)pkt_setImageWithFile:(PKTFile *)file placeholderImage:(UIImage *)placeholderImage imageSize:(PKTImageSize)imageSize; 20 | 21 | - (void)pkt_cancelCurrentImageDownload; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /PodioKitTests/PodioKitTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PodioKitTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 21/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PodioKit.h" 11 | #import "PKTClient.h" 12 | 13 | @interface PodioKitTests : XCTestCase 14 | 15 | @end 16 | 17 | @implementation PodioKitTests 18 | 19 | - (void)testSetupWithAPIKeyAndSecret { 20 | [PodioKit setupWithAPIKey:@"my-api-key" secret:@"my-api-secret"]; 21 | expect([PKTClient defaultClient].apiKey).to.equal(@"my-api-key"); 22 | expect([PKTClient defaultClient].apiSecret).to.equal(@"my-api-secret"); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDuration.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDuration 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTDuration : PKTModel 12 | 13 | @property (nonatomic, assign) NSUInteger hours; 14 | @property (nonatomic, assign) NSUInteger minutes; 15 | @property (nonatomic, assign) NSUInteger seconds; 16 | @property (nonatomic, assign) NSUInteger totalSeconds; 17 | 18 | - (instancetype)initWithHours:(NSUInteger)hours minutes:(NSUInteger)minutes seconds:(NSUInteger)seconds; 19 | - (instancetype)initWithTotalSeconds:(NSUInteger)totalSeconds; 20 | 21 | @end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTAuthenticationAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAuthenticationAPI.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 28/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTAuthenticationAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForAuthenticationWithEmail:(NSString *)email password:(NSString *)password; 14 | 15 | + (PKTRequest *)requestForAuthenticationWithAppID:(NSUInteger)appID token:(NSString *)appToken; 16 | 17 | + (PKTRequest *)requestForAuthenticationWithTransferToken:(NSString *)transferToken; 18 | 19 | + (PKTRequest *)requestToRefreshToken:(NSString *)refreshToken; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCalculationItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCalculationItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTCalculationItemFieldValue.h" 10 | 11 | @implementation PKTCalculationItemFieldValue 12 | 13 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 14 | self = [super initWithDictionary:valueDictionary]; 15 | if (!self) return nil; 16 | 17 | // Skip validation since we are setting this internally 18 | [self setUnboxedValue:valueDictionary[@"value"] validate:NO]; 19 | 20 | return self; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/UIKit/PKTFile+UIImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFile+UIImage.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 10 | 11 | #import 12 | #import "PKTFile.h" 13 | 14 | @interface PKTFile (UIImage) 15 | 16 | /** 17 | * Download the file as an UIImage. 18 | * 19 | * @return A task 20 | */ 21 | - (PKTAsyncTask *)downloadImage; 22 | 23 | /** 24 | * Download the file as an UIImage of a given size. 25 | * 26 | * @return A task 27 | */ 28 | - (PKTAsyncTask *)downloadImageOfSize:(PKTImageSize)imageSize; 29 | 30 | @end 31 | 32 | #endif -------------------------------------------------------------------------------- /PodioKitTests/NSNumber+PKTAdditionsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+PKTAdditionsTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSNumber+PKTAdditions.h" 11 | 12 | @interface NSNumber_PKTAdditionsTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSNumber_PKTAdditionsTests 17 | 18 | - (void)testStringToNumber { 19 | expect([NSNumber pkt_numberFromUSNumberString:@"123532.324400"]).to.equal(@123532.3244); 20 | } 21 | 22 | - (void)testNumberToString { 23 | expect([@123532.3244 pkt_USNumberString]).to.equal(@"123532.3244"); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTAppsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 03/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTAppsAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForAppWithID:(NSUInteger)appID; 14 | + (PKTRequest *)requestForAppsInWorkspaceWithID:(NSUInteger)spaceID; 15 | + (PKTRequest *)requestForMostFrequentlyUsedApps:(NSUInteger)limit; 16 | + (PKTRequest *)requestToAddAppToWorkspaceWithID:(NSUInteger)spaceID fields:(NSDictionary *)fields; 17 | + (PKTRequest *)requestForAppInWorkspaceWithID:(NSUInteger)spaceID urlLabel:(NSString *)urlLabel; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDateRange.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateRange.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @interface PKTDateRange : PKTModel 12 | 13 | @property (nonatomic, copy) NSDate *startDate; 14 | @property (nonatomic, copy) NSDate *endDate; 15 | @property (nonatomic, assign) BOOL includesTimeComponent; 16 | 17 | - (instancetype)initWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate; 18 | 19 | + (instancetype)rangeWithStartDate:(NSDate *)startDate; 20 | + (instancetype)rangeWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTRandom.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTRandom.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/5/12. 6 | // Copyright (c) 2012 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSString+PKTRandom.h" 10 | 11 | @implementation NSString (PKTRandom) 12 | 13 | + (instancetype)pkt_randomHexStringOfLength:(NSUInteger)length { 14 | char data[length]; 15 | 16 | for (NSUInteger i = 0; i < length; ++i) { 17 | u_int32_t rand = arc4random_uniform(36); 18 | data[i] = rand < 10 ? '0' + rand : 'a' + (rand - 10); 19 | } 20 | 21 | return [[NSString alloc] initWithBytes:data length:length encoding:NSUTF8StringEncoding]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTKeychainTokenStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTKeychainTokenStore.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTTokenStore.h" 11 | 12 | @class PKTKeychain; 13 | 14 | @interface PKTKeychainTokenStore : NSObject 15 | 16 | @property (nonatomic, strong, readonly) PKTKeychain *keychain; 17 | 18 | - (instancetype)initWithService:(NSString *)service; 19 | 20 | - (instancetype)initWithService:(NSString *)service accessGroup:(NSString *)accessGroup; 21 | 22 | - (instancetype)initWithKeychain:(PKTKeychain *)keychain; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSNumberFormatter+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter(PKTAdditions) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "NSNumberFormatter+PKTAdditions.h" 11 | 12 | @implementation NSNumberFormatter (PKTAdditions) 13 | 14 | + (NSNumberFormatter *)pkt_USNumberFormatter { 15 | NSNumberFormatter *formatter = [NSNumberFormatter new]; 16 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 17 | formatter.numberStyle = NSNumberFormatterDecimalStyle; 18 | formatter.usesGroupingSeparator = NO; 19 | 20 | return formatter; 21 | } 22 | 23 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSValueTransformer+PKTConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSValueTransformer+PKTConstants.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 11/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTConstants.h" 11 | 12 | @interface NSValueTransformer (PKTConstants) 13 | 14 | + (PKTReferenceType)pkt_referenceTypeFromString:(NSString *)string; 15 | + (NSString *)pkt_stringFromReferenceType:(PKTReferenceType)referenceType; 16 | 17 | + (PKTNotificationType)pkt_notificationTypeFromString:(NSString *)string; 18 | + (NSString *)pkt_stringFromNotificationType:(PKTNotificationType)notificationType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReferenceIdentifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceIdentifier.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTReferenceIdentifier : NSObject 13 | 14 | @property (nonatomic, assign, readonly) NSUInteger referenceID; 15 | @property (nonatomic, assign, readonly) PKTReferenceType referenceType; 16 | @property (nonatomic, copy, readonly) NSString *referenceTypeString; 17 | 18 | + (instancetype)identifierWithReferenceID:(NSUInteger)referenceID type:(PKTReferenceType)referenceType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKitTests/PKTHTTPStubber.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTHTTPStubber.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTHTTPStubber : NSObject 12 | 13 | @property (nonatomic, copy, readonly) NSString *path; 14 | @property (nonatomic, assign) int statusCode; 15 | @property (nonatomic, strong) id responseObject; 16 | @property (nonatomic, copy) NSError *error; 17 | @property (nonatomic, assign) NSTimeInterval requestTime; 18 | @property (nonatomic, assign) NSTimeInterval responseTime; 19 | 20 | + (instancetype)stubberForPath:(NSString *)path; 21 | 22 | - (void)stub; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKitTests/PKTURLValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTURLValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTURLValueTransformer.h" 11 | 12 | @interface PKTURLValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTURLValueTransformerTests 17 | 18 | - (void)testTransformURLStringToURL { 19 | PKTURLValueTransformer *transformer = [[PKTURLValueTransformer alloc] init]; 20 | NSURL *url = [transformer transformedValue:@"https://www.google.com"]; 21 | expect(url.absoluteString).to.equal(@"https://www.google.com"); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKitTests/PKTEmbedsAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbedsAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTEmbedsAPI.h" 11 | 12 | @interface PKTEmbedsAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTEmbedsAPITests 17 | 18 | - (void)testRequestToAddEmbed { 19 | PKTRequest *request = [PKTEmbedsAPI requestToAddEmbedWithURLString:@"https://www.google.com"]; 20 | 21 | expect(request.method).to.equal(PKTRequestMethodPOST); 22 | expect(request.path).to.equal(@"/embed/"); 23 | expect(request.parameters[@"url"]).to.equal(@"https://www.google.com"); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSArray+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 01/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (PKTAdditions) 12 | 13 | - (instancetype)pkt_mappedArrayWithBlock:(id (^)(id obj))block; 14 | - (instancetype)pkt_filteredArrayWithBlock:(BOOL (^)(id obj))block; 15 | - (id)pkt_reducedValueWithInitialValue:(id)initialValue block:(id (^)(id reduced, id obj))block; 16 | - (id)pkt_reducedValueWithBlock:(id (^)(id reduced, id obj))block; 17 | - (id)pkt_firstObjectPassingTest:(BOOL (^)(id obj))block; 18 | + (instancetype)pkt_arrayFromRange:(NSRange)range; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKitTests/PKTHTTPStubs.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTHTTPStubs.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTHTTPStubber.h" 11 | 12 | @interface PKTHTTPStubs : NSObject 13 | 14 | + (void)stubResponseForPath:(NSString *)path block:(void (^)(PKTHTTPStubber *stubber))block; 15 | 16 | + (void)stubResponseForPath:(NSString *)path responseObject:(id)responseObject; 17 | + (void)stubResponseForPath:(NSString *)path statusCode:(int)statusCode; 18 | + (void)stubResponseForPath:(NSString *)path requestTime:(int)requestTime responseTime:(int)responseTime; 19 | + (void)stubNetworkDownForPath:(NSString *)path; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTURLEncodeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURLEncodeTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+PKTURLEncode.h" 11 | 12 | @interface NSString_PKTURLEncodeTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSString_PKTURLEncodeTests 17 | 18 | - (void)testURLEncode { 19 | expect([@"some@%?=#string" pkt_encodeString]).to.equal(@"some%40%25%3F%3D%23string"); 20 | } 21 | 22 | - (void)testURLEncodeDecode { 23 | NSString *stringToEncode = @"some@%?=#string"; 24 | expect([[stringToEncode pkt_encodeString] pkt_decodeString]).to.equal(stringToEncode); 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PodioKitTests/PKTBlockValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTBlockValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTBlockValueTransformer.h" 11 | 12 | @interface PKTBlockValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTBlockValueTransformerTests 17 | 18 | - (void)testTransformationWithBlock { 19 | PKTBlockValueTransformer *transformer = [PKTBlockValueTransformer transformerWithBlock:^id(NSNumber *num) { 20 | return @([num integerValue] * [num integerValue]); 21 | }]; 22 | 23 | expect([transformer transformedValue:@3]).to.equal(@9); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTNotificationGroup.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationGroup.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 19/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTNotificationGroup.h" 10 | #import "PKTNotificationContext.h" 11 | #import "PKTNotification.h" 12 | #import "NSValueTransformer+PKTTransformers.h" 13 | 14 | @implementation PKTNotificationGroup 15 | 16 | + (NSValueTransformer *)contextValueTransformer { 17 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTNotificationContext class]]; 18 | } 19 | 20 | + (NSValueTransformer *)notificationsValueTransformer { 21 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTNotification class]]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFormSettings.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFormSettings.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTFormSettings.h" 10 | 11 | @implementation PKTFormSettings 12 | 13 | #pragma mark - PKTModel 14 | 15 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary { 16 | return [super initWithDictionary:dictionary]; 17 | } 18 | 19 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 20 | return @{ 21 | @"titleText" : @"text.heading", 22 | @"descriptionText" : @"text.description", 23 | @"successText" : @"text.success", 24 | @"submitText" : @"text.submit", 25 | }; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReference.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReference.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTReferenceAPI.h" 11 | #import "PKTConstants.h" 12 | 13 | @class PKTAsyncTask; 14 | 15 | @interface PKTReference : PKTModel 16 | 17 | @property (nonatomic, assign, readonly) NSUInteger referenceID; 18 | @property (nonatomic, assign, readonly) PKTReferenceType referenceType; 19 | @property (nonatomic, strong, readonly) id referenceObject; 20 | 21 | + (PKTAsyncTask *)searchForReferenceWithText:(NSString *)text target:(PKTReferenceTarget)target targetParameters:(NSDictionary *)targetParamers limit:(NSUInteger)limit; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUser.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTUser.h" 10 | #import "PKTUserStatus.h" 11 | #import "PKTAsyncTask.h" 12 | #import "NSValueTransformer+PKTTransformers.h" 13 | 14 | @implementation PKTUser 15 | 16 | #pragma mark - PKTModel 17 | 18 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 19 | return @{ 20 | @"userID" : @"user_id" 21 | }; 22 | } 23 | 24 | #pragma mark - Public 25 | 26 | + (PKTAsyncTask *)fetchCurrentUser { 27 | return [[PKTUserStatus fetchStatusForCurrentUser] map:^id(PKTUserStatus *status) { 28 | return status.user; 29 | }]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTMeetingParticipantStatusValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMeetingParticipantStatusValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 07/09/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTMeetingParticipantStatusValueTransformer.h" 10 | #import "PKTConstants.h" 11 | 12 | @implementation PKTMeetingParticipantStatusValueTransformer 13 | 14 | - (instancetype)init { 15 | return [super initWithDictionary:@{ 16 | @"invited": @(PKTMeetingParticipantStatusInvited), 17 | @"accepted": @(PKTMeetingParticipantStatusAccepted), 18 | @"declined": @(PKTMeetingParticipantStatusDeclined), 19 | @"tentative": @(PKTMeetingParticipantStatusTentative) 20 | }]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTRequestFileData.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTRequestFileData.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 01/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTRequestFileData : NSObject 12 | 13 | @property (nonatomic, strong) NSData *data; 14 | @property (nonatomic, copy, readonly) NSString *filePath; 15 | @property (nonatomic, copy, readonly) NSString *name; 16 | @property (nonatomic, copy, readonly) NSString *fileName; 17 | 18 | + (instancetype)fileDataWithData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName; 19 | 20 | + (instancetype)fileDataWithFilePath:(NSString *)filePath name:(NSString *)name fileName:(NSString *)fileName; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PodioKitTests/PodioKitTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.podio.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSError+PKTErrors.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+PKTErrors.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 11/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSString * const PodioServerErrorDomain; 12 | 13 | extern NSString * const PKTErrorKey; 14 | extern NSString * const PKTErrorDescriptionKey; 15 | extern NSString * const PKTErrorDetailKey; 16 | extern NSString * const PKTErrorParametersKey; 17 | extern NSString * const PKTErrorPropagateKey; 18 | 19 | @interface NSError (PKTErrors) 20 | 21 | + (NSError *)pkt_serverErrorWithStatusCode:(NSUInteger)statusCode body:(id)body; 22 | 23 | - (BOOL)pkt_isServerError; 24 | 25 | - (NSString *)pkt_localizedServerSideDescription; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppField.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppField.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | #import "PKTAppFieldConfig.h" 12 | 13 | @class PKTCategoryOption; 14 | 15 | @interface PKTAppField : PKTModel 16 | 17 | @property (nonatomic, assign, readonly) NSUInteger fieldID; 18 | @property (nonatomic, copy, readonly) NSString *externalID; 19 | @property (nonatomic, assign, readonly) PKTAppFieldType type; 20 | @property (nonatomic, strong, readonly) PKTAppFieldConfig *config; 21 | 22 | - (instancetype)initWithFieldID:(NSUInteger)fieldID externalID:(NSString *)externalID type:(PKTAppFieldType)type config:(PKTAppFieldConfig *)config; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTItemField.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTItemField.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTAppField.h" 10 | 11 | @interface PKTItemField : PKTAppField 12 | 13 | @property (nonatomic, strong) id value; // The unboxed value 14 | @property (nonatomic, copy) NSArray *values; // The unboxed values 15 | 16 | - (instancetype)initWithAppField:(PKTAppField *)appField basicValues:(NSArray *)basicValues; 17 | 18 | + (BOOL)isSupportedValue:value forFieldType:(PKTAppFieldType)fieldType error:(NSError **)error; 19 | 20 | - (void)addValue:(id)value; 21 | 22 | - (void)removeValue:(id)value; 23 | - (void)removeValueAtIndex:(NSUInteger)index; 24 | 25 | - (NSArray *)preparedValues; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSFileManager+PKTAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSFileManager+PKTAdditions.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSFileManager (PKTAdditions) 12 | 13 | - (BOOL)pkt_moveItemAtURL:(NSURL *)fromURL toPath:(NSString *)toPath withIntermediateDirectories:(BOOL)withIntermediateDirectories error:(NSError **)error; 14 | 15 | - (BOOL)pkt_moveItemAtPath:(NSString *)fromPath toURL:(NSURL *)toURL withIntermediateDirectories:(BOOL)withIntermediateDirectories error:(NSError **)error; 16 | 17 | - (BOOL)pkt_moveItemAtURL:(NSURL *)fromURL toURL:(NSURL *)toURL withIntermediateDirectories:(BOOL)withIntermediateDirectories error:(NSError **)error; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTFilesAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFilesAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 01/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTConstants.h" 11 | 12 | @interface PKTFilesAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestToDownloadFileWithURL:(NSURL *)fileURL; 15 | + (PKTRequest *)requestToDownloadFileWithURL:(NSURL *)fileURL toLocalFileWithPath:(NSString *)filePath; 16 | + (PKTRequest *)requestToUploadFileWithData:(NSData *)data fileName:(NSString *)fileName; 17 | + (PKTRequest *)requestToUploadFileWithPath:(NSString *)filePath fileName:(NSString *)fileName; 18 | + (PKTRequest *)requestToAttachFileWithID:(NSUInteger)fileID referenceID:(NSUInteger)referenceID referenceType:(PKTReferenceType)referenceType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTTagItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTTagItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Lauge Jepsen on 02/11/2015. 6 | // Copyright © 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTTagItemFieldValue.h" 10 | #import "NSArray+PKTAdditions.h" 11 | 12 | @implementation PKTTagItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initFromValueDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = valueDictionary[@"value"]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | NSString *tag = self.unboxedValue; 25 | 26 | return @{@"value": tag}; 27 | } 28 | 29 | + (Class)unboxedValueClass { 30 | return [NSString class]; 31 | } 32 | 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PodioKitTests/PKTAvatarTypeValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAvatarTypeValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 21/04/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "PKTAvatarTypeValueTransformer.h" 12 | #import "PKTConstants.h" 13 | 14 | @interface PKTAvatarTypeValueTransformerTests : XCTestCase 15 | 16 | @end 17 | 18 | @implementation PKTAvatarTypeValueTransformerTests 19 | 20 | - (void)testAvatarTypesValueTransformation { 21 | PKTAvatarTypeValueTransformer *transformer = [PKTAvatarTypeValueTransformer new]; 22 | expect([transformer transformedValue:@"icon"]).to.equal(PKTAvatarTypeIcon); 23 | expect([transformer transformedValue:@"file"]).to.equal(PKTAvatarTypeFile); 24 | } 25 | @end 26 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMessage.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMessage.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 13/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTMessage.h" 10 | #import "PKTFile.h" 11 | #import "PKTEmbed.h" 12 | #import "NSValueTransformer+PKTTransformers.h" 13 | 14 | @implementation PKTMessage 15 | 16 | #pragma mark - PKTModel 17 | 18 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 19 | return @{ 20 | @"messageID": @"message_id" 21 | }; 22 | } 23 | 24 | + (NSValueTransformer *)filesValueTransformer { 25 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTFile class]]; 26 | } 27 | 28 | + (NSValueTransformer *)embedValueTransformer { 29 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTEmbed class]]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTProgressItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTProgressItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 08/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTProgressItemFieldValue.h" 10 | #import "NSNumber+PKTAdditions.h" 11 | 12 | @implementation PKTProgressItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initFromValueDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = valueDictionary[@"value"]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | NSNumber *number = self.unboxedValue; 25 | 26 | return @{@"value" : number}; 27 | } 28 | 29 | + (Class)unboxedValueClass { 30 | return [NSNumber class]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTKeychain.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTKeychain.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PKTKeychain : NSObject 12 | 13 | @property (nonatomic, copy, readonly) NSString *service; 14 | @property (nonatomic, copy, readonly) NSString *accessGroup; 15 | 16 | - (instancetype)initWithService:(NSString *)service accessGroup:(NSString *)accessGroup; 17 | 18 | + (instancetype)keychainForService:(NSString *)service accessGroup:(NSString *)accessGroup; 19 | 20 | - (id)objectForKey:(id)key; 21 | - (BOOL)setObject:(id)object forKey:(id)key; 22 | 23 | - (NSData *)dataForKey:(id)key; 24 | - (BOOL)setData:(NSData *)data forKey:(id)key; 25 | 26 | - (BOOL)removeObjectForKey:(id)key; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTAppItemFieldValue.h" 10 | #import "PKTItem.h" 11 | 12 | @implementation PKTAppItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initWithDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = [[PKTItem alloc] initWithDictionary:valueDictionary[@"value"]]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | PKTItem *item = self.unboxedValue; 25 | 26 | return @{@"value" : @(item.itemID)}; 27 | } 28 | 29 | + (Class)unboxedValueClass { 30 | return [PKTItem class]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTByLine.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTByLine.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | 12 | @class PKTFile; 13 | 14 | @interface PKTByLine : PKTModel 15 | 16 | @property (nonatomic, assign, readonly) PKTReferenceType referenceType; 17 | @property (nonatomic, assign, readonly) NSUInteger referenceID; 18 | @property (nonatomic, assign, readonly) NSUInteger userID; 19 | @property (nonatomic, copy, readonly) NSString *name; 20 | @property (nonatomic, strong, readonly) PKTFile *imageFile; 21 | @property (nonatomic, copy, readonly) NSDate *lastSeenOn; 22 | @property (nonatomic, assign, readonly) NSUInteger avatarID; 23 | @property (nonatomic, assign, readonly) PKTAvatarType avatarType; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /PodioKitTests/PKTNumberValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNumberValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTNumberValueTransformer.h" 11 | 12 | @interface PKTNumberValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTNumberValueTransformerTests 17 | 18 | - (void)testTransformStringToNumber { 19 | PKTNumberValueTransformer *transformer = [PKTNumberValueTransformer new]; 20 | expect([transformer transformedValue:@"32.324"]).to.equal(@32.324); 21 | } 22 | 23 | - (void)testTransformNumberToString { 24 | PKTNumberValueTransformer *transformer = [PKTNumberValueTransformer new]; 25 | expect([transformer reverseTransformedValue:@32.324]).to.equal(@"32.324"); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTStringItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTStringItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTStringItemFieldValue.h" 10 | 11 | @interface PKTStringItemFieldValue () 12 | 13 | @end 14 | 15 | @implementation PKTStringItemFieldValue 16 | 17 | #pragma mark - PKTItemFieldValue 18 | 19 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 20 | self = [super initWithDictionary:valueDictionary]; 21 | if (!self) return nil; 22 | 23 | self.unboxedValue = valueDictionary[@"value"]; 24 | 25 | return self; 26 | } 27 | 28 | - (NSDictionary *)valueDictionary { 29 | return @{@"value" : self.unboxedValue }; 30 | } 31 | 32 | + (Class)unboxedValueClass { 33 | return [NSString class]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTProfileItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTProfileItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTProfileItemFieldValue.h" 10 | #import "PKTProfile.h" 11 | 12 | @implementation PKTProfileItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initWithDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = [[PKTProfile alloc] initWithDictionary:valueDictionary[@"value"]]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | PKTProfile *profile = self.unboxedValue; 25 | 26 | return @{@"value" : @(profile.profileID)}; 27 | } 28 | 29 | + (Class)unboxedValueClass { 30 | return [PKTProfile class]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTNumberValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNumberValueTransformer 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTNumberValueTransformer.h" 10 | #import "NSNumber+PKTAdditions.h" 11 | 12 | 13 | @implementation PKTNumberValueTransformer 14 | 15 | #pragma mark - NSValueTransformer 16 | 17 | + (BOOL)allowsReverseTransformation { 18 | return YES; 19 | } 20 | 21 | - (id)reverseTransformedValue:(id)value { 22 | if (![value isKindOfClass:[NSNumber class]]) { 23 | return nil; 24 | } 25 | 26 | return [(NSNumber *)value pkt_USNumberString]; 27 | } 28 | 29 | - (id)transformedValue:(id)value { 30 | if (![value isKindOfClass:[NSString class]]) { 31 | return nil; 32 | } 33 | 34 | return [NSNumber pkt_numberFromUSNumberString:value]; 35 | } 36 | 37 | 38 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTResponseSerializer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTResponseSerializer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTResponseSerializer.h" 10 | #import "NSString+PKTAdditions.h" 11 | 12 | @implementation PKTResponseSerializer 13 | 14 | - (id)responseObjectForURLResponse:(NSURLResponse *)response data:(NSData *)data { 15 | if (data == nil || ![response isKindOfClass:[NSHTTPURLResponse class]]) return nil; 16 | 17 | id object = nil; 18 | NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response; 19 | if ([HTTPResponse.allHeaderFields[@"Content-Type"] pkt_containsString:@"application/json"]) { 20 | object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 21 | } else { 22 | object = data; 23 | } 24 | 25 | return object; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTNumberItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNumberItemFieldValue 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "PKTNumberItemFieldValue.h" 11 | #import "NSNumber+PKTAdditions.h" 12 | 13 | @implementation PKTNumberItemFieldValue 14 | 15 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 16 | self = [super initFromValueDictionary:valueDictionary]; 17 | if (!self) return nil; 18 | 19 | self.unboxedValue = [NSNumber pkt_numberFromUSNumberString:valueDictionary[@"value"]]; 20 | 21 | return self; 22 | } 23 | 24 | - (NSDictionary *)valueDictionary { 25 | NSNumber *number = self.unboxedValue; 26 | 27 | return @{@"value" : [number pkt_USNumberString]}; 28 | } 29 | 30 | + (Class)unboxedValueClass { 31 | return [NSNumber class]; 32 | } 33 | 34 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSURL+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSURL+PKTAdditions.h" 10 | #import "NSString+PKTAdditions.h" 11 | #import "NSDictionary+PKTQueryParameters.h" 12 | 13 | @implementation NSURL (PKTAdditions) 14 | 15 | - (NSURL *)pkt_URLByAppendingQueryParameters:(NSDictionary *)parameters { 16 | if ([parameters count] == 0) return self; 17 | 18 | NSMutableString *query = [NSMutableString stringWithString:self.absoluteString]; 19 | 20 | if (![query pkt_containsString:@"?"]) { 21 | [query appendString:@"?"]; 22 | } else { 23 | [query appendString:@"&"]; 24 | } 25 | 26 | [query appendString:[parameters pkt_escapedQueryString]]; 27 | 28 | return [NSURL URLWithString:[query copy]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PodioKit/UIKit/UIButton+PKTRemoteImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+PKTRemoteImage.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 10 | 11 | #import 12 | #import "PKTConstants.h" 13 | 14 | @class PKTFile; 15 | @class PKTAsyncTask; 16 | 17 | @interface UIButton (PKTRemoteImage) 18 | 19 | - (PKTAsyncTask *)pkt_setImageWithFile:(PKTFile *)file forState:(UIControlState)state placeholderImage:(UIImage *)placeholderImage imageSize:(PKTImageSize)imageSize; 20 | - (PKTAsyncTask *)pkt_setBackgroundImageWithFile:(PKTFile *)file forState:(UIControlState)state placeholderImage:(UIImage *)placeholderImage imageSize:(PKTImageSize)imageSize; 21 | 22 | - (void)pkt_cancelCurrentImageDownload; 23 | - (void)pkt_cancelCurrentBackgroundImageDownload; 24 | 25 | @end 26 | 27 | #endif -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFileItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFileItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTFileItemFieldValue.h" 10 | #import "PKTFile.h" 11 | 12 | @implementation PKTFileItemFieldValue 13 | 14 | #pragma mark - PKTItemFieldValue 15 | 16 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 17 | self = [super initWithDictionary:valueDictionary]; 18 | if (!self) return nil; 19 | 20 | self.unboxedValue = [[PKTFile alloc] initWithDictionary:valueDictionary[@"value"]]; 21 | 22 | return self; 23 | } 24 | 25 | - (NSDictionary *)valueDictionary { 26 | PKTFile *file = self.unboxedValue; 27 | 28 | return @{@"value" : @(file.fileID)}; 29 | } 30 | 31 | + (Class)unboxedValueClass { 32 | return [PKTFile class]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTStatusAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTStatusAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTStatusAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForStatusMessageWithID:(NSUInteger)statusID; 14 | 15 | + (PKTRequest *)requestToAddNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID; 16 | 17 | + (PKTRequest *)requestToAddNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files; 18 | 19 | + (PKTRequest *)requestToAddNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files embedID:(NSUInteger)embedID; 20 | 21 | + (PKTRequest *)requestToAddNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files embedURL:(NSURL *)embedURL; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMoney.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMoney.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTMoney.h" 10 | #import "NSValueTransformer+PKTTransformers.h" 11 | 12 | @implementation PKTMoney 13 | 14 | - (instancetype)initWithAmount:(NSNumber *)amount currency:(NSString *)currency { 15 | self = [super init]; 16 | if (!self) return nil; 17 | 18 | _amount = [amount copy]; 19 | _currency = [currency copy]; 20 | 21 | return self; 22 | } 23 | 24 | #pragma mark - PKTModel 25 | 26 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 27 | return @{ 28 | @"amount" : @"value", 29 | @"currency" : @"currency" 30 | }; 31 | } 32 | 33 | + (NSValueTransformer *)amountValueTransformer { 34 | return [NSValueTransformer pkt_numberValueTransformer]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTPushCredential.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTPushCredential.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTPushCredential.h" 10 | #import "NSValueTransformer+PKTTransformers.h" 11 | 12 | @implementation PKTPushCredential 13 | 14 | #pragma mark - PKTModel 15 | 16 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 17 | return @{ @"expiresOn": @"expires_in" }; 18 | } 19 | 20 | + (NSValueTransformer *)expiresOnValueTransformer { 21 | return [NSValueTransformer pkt_transformerWithBlock:^id(NSNumber *expiresIn) { 22 | return [NSDate dateWithTimeIntervalSinceNow:[expiresIn doubleValue]]; 23 | }]; 24 | } 25 | 26 | #pragma mark - NSCopying 27 | 28 | - (id)copyWithZone:(NSZone *)zone { 29 | // Since this object is immutable, just return the same instance 30 | return self; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSNumber+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber(PKTAdditions) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "NSNumber+PKTAdditions.h" 11 | #import "NSNumberFormatter+PKTAdditions.h" 12 | 13 | static NSNumberFormatter *sNumberFormatter = nil; 14 | 15 | @implementation NSNumber (PKTAdditions) 16 | 17 | + (NSNumber *)pkt_numberFromUSNumberString:(NSString *)numberString { 18 | return [[self pkt_USNumberFormatter] numberFromString:numberString]; 19 | } 20 | 21 | - (NSString *)pkt_USNumberString { 22 | return [[[self class] pkt_USNumberFormatter] stringFromNumber:self]; 23 | } 24 | 25 | + (NSNumberFormatter *)pkt_USNumberFormatter { 26 | if (!sNumberFormatter) { 27 | sNumberFormatter = [NSNumberFormatter pkt_USNumberFormatter]; 28 | } 29 | 30 | return sNumberFormatter; 31 | } 32 | 33 | @end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTSearchAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTSearchAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTSearchQuery.h" 11 | 12 | @interface PKTSearchAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestToSearchGloballyWithQuery:(PKTSearchQuery *)query offset:(NSUInteger)offset limit:(NSUInteger)limit; 15 | 16 | + (PKTRequest *)requestToSearchInOrganizationWithID:(NSUInteger)organizationID query:(PKTSearchQuery *)query offset:(NSUInteger)offset limit:(NSUInteger)limit; 17 | 18 | + (PKTRequest *)requestToSearchInWorkspaceWithID:(NSUInteger)workspaceID Query:(PKTSearchQuery *)query offset:(NSUInteger)offset limit:(NSUInteger)limit; 19 | 20 | + (PKTRequest *)requestToSearchInAppWithID:(NSUInteger)appID query:(PKTSearchQuery *)query offset:(NSUInteger)offset limit:(NSUInteger)limit; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTMultipartFormData.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMultipartFormData.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PKTRequest; 12 | 13 | @interface PKTMultipartFormData : NSObject 14 | 15 | @property (nonatomic, strong, readonly) NSData *finalizedData; 16 | @property (nonatomic, copy, readonly) NSString *stringRepresentation; 17 | 18 | + (instancetype)multipartFormDataWithBoundary:(NSString *)boundary encoding:(NSStringEncoding)encoding; 19 | 20 | - (void)appendFileData:(NSData *)data fileName:(NSString *)fileName mimeType:(NSString *)mimeType name:(NSString *)name; 21 | 22 | - (void)appendContentsOfFileAtPath:(NSString *)filePath name:(NSString *)name; 23 | 24 | - (void)appendFormDataParameters:(NSDictionary *)parameters; 25 | 26 | - (void)finalizeData; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTRandomTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTRandomTests.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 30/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+PKTRandom.h" 11 | 12 | @interface NSString_PKTRandomTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSString_PKTRandomTests 17 | 18 | - (void)testRandomHexString { 19 | NSUInteger length = 8; 20 | NSString *testString1, *testString2; 21 | testString1 = [NSString pkt_randomHexStringOfLength:length]; 22 | testString2 = [NSString pkt_randomHexStringOfLength:length]; 23 | expect([testString1 length]).to.equal(length); 24 | expect([testString2 length]).to.equal(length); 25 | expect(testString2).notTo.equal(testString1); 26 | 27 | length = 4; 28 | expect([[NSString pkt_randomHexStringOfLength:length] length]).to.equal(length); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSSet+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSSet+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 29/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSSet+PKTAdditions.h" 10 | 11 | @implementation NSSet (PKTAdditions) 12 | 13 | - (instancetype)pkt_mappedSetWithBlock:(id (^)(id obj))block { 14 | NSParameterAssert(block); 15 | 16 | NSMutableSet *mutSet = [[NSMutableSet alloc] initWithCapacity:[self count]]; 17 | for (id object in self) { 18 | id mappedObject = block(object); 19 | if (mappedObject) { 20 | [mutSet addObject:mappedObject]; 21 | } 22 | } 23 | 24 | return [mutSet copy]; 25 | } 26 | 27 | - (instancetype)pkt_filteredSetWithBlock:(BOOL (^)(id obj))block { 28 | NSParameterAssert(block); 29 | 30 | return [self pkt_mappedSetWithBlock:^id(id obj) { 31 | return block(obj) ? obj : nil; 32 | }]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKitTests/PKTReversibleBlockValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReversibleBlockValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTReversibleBlockValueTransformer.h" 11 | 12 | @interface PKTReversibleBlockValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTReversibleBlockValueTransformerTests 17 | 18 | - (void)testTransformationWithReversibleBlock { 19 | PKTReversibleBlockValueTransformer *transformer = [PKTReversibleBlockValueTransformer transformerWithBlock:^id(NSNumber *num) { 20 | return @([num integerValue] * [num integerValue]); 21 | } reverseBlock:^id(NSNumber *num) { 22 | return @(sqrt([num integerValue])); 23 | }]; 24 | 25 | expect([transformer reverseTransformedValue:[transformer transformedValue:@3]]).to.equal(@3); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDurationItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDurationItemFieldValue 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDurationItemFieldValue.h" 10 | #import "PKTDuration.h" 11 | 12 | 13 | @implementation PKTDurationItemFieldValue 14 | 15 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 16 | self = [super initFromValueDictionary:valueDictionary]; 17 | if (!self) return nil; 18 | 19 | NSUInteger totalSeconds = [valueDictionary[@"value"] unsignedIntegerValue]; 20 | self.unboxedValue = [[PKTDuration alloc] initWithTotalSeconds:totalSeconds]; 21 | 22 | return self; 23 | } 24 | 25 | - (NSDictionary *)valueDictionary { 26 | PKTDuration *duration = self.unboxedValue; 27 | 28 | return @{@"value" : @(duration.totalSeconds)}; 29 | } 30 | 31 | + (Class)unboxedValueClass { 32 | return [PKTDuration class]; 33 | } 34 | 35 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTOrganization.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTOrganization.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | 12 | @class PKTFile, PKTAsyncTask; 13 | 14 | @interface PKTOrganization : PKTModel 15 | 16 | @property (nonatomic, assign, readonly) NSUInteger organizationID; 17 | @property (nonatomic, copy, readonly) NSString *name; 18 | @property (nonatomic, copy, readonly) NSArray *workspaces; 19 | @property (nonatomic, strong, readonly) PKTFile *imageFile; 20 | @property (nonatomic, assign, readonly) NSUInteger grantsCount; 21 | @property (nonatomic, assign, readonly) PKTRight rights; 22 | 23 | #pragma mark - API 24 | 25 | + (PKTAsyncTask *)fetchAll; 26 | + (PKTAsyncTask *)fetchWithID:(NSUInteger)organizationID; 27 | + (PKTAsyncTask *)updateOrganizationWithID:(NSUInteger)organizationID withName:(NSString *)name; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTURLTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURLTests.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+PKTURL.h" 11 | 12 | @interface NSString_PKTURLTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSString_PKTURLTests 17 | 18 | - (void)testEscapedURLString { 19 | NSString *unescapedString = @"Hello,!*'();:@&=+$,/?%#[]{}"; 20 | NSString *escapedString = @"Hello%2C%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23%5B%5D%7B%7D"; 21 | 22 | expect([unescapedString pkt_escapedURLString]).to.equal(escapedString); 23 | } 24 | 25 | - (void)testUnescapedURLString { 26 | NSString *unescapedString = @"Hello,!*'();:@&=+$,/?%#[]{}"; 27 | NSString *escapedString = @"Hello%2C%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23%5B%5D%7B%7D"; 28 | 29 | expect([escapedString pkt_unescapedURLString]).to.equal(unescapedString); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKitTests/NSURL+PKTParamatersHandling.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTParamatersHandling.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSURL+PKTParamatersHandling.h" 10 | #import "NSString+PKTURL.h" 11 | 12 | @implementation NSURL (PKTParamatersHandling) 13 | 14 | - (NSString *)pkt_valueForQueryParameter:(NSString *)parameter { 15 | return [self pkt_queryParameters][parameter]; 16 | } 17 | 18 | - (NSDictionary *)pkt_queryParameters { 19 | NSMutableDictionary *params = [NSMutableDictionary new]; 20 | 21 | NSArray *chunks = [[self query] componentsSeparatedByString:@"&"]; 22 | for (id obj in chunks) { 23 | NSArray *parts = [obj componentsSeparatedByString:@"="]; 24 | 25 | if ([parts count] == 2) { 26 | NSString *name = parts[0]; 27 | NSString *value = parts[1]; 28 | params[name] = [value pkt_unescapedURLString]; 29 | } 30 | } 31 | 32 | return [params copy]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReferenceGroup.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceGroup.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/12/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTReferenceGroup.h" 10 | #import "PKTProfile.h" 11 | #import "PKTApp.h" 12 | #import "PKTWorkspace.h" 13 | #import "PKTByLine.h" 14 | #import "NSValueTransformer+PKTTransformers.h" 15 | 16 | @implementation PKTReferenceGroup 17 | 18 | #pragma mark - PKTModel 19 | 20 | + (NSValueTransformer *)contentsValueTransformerWithDictionary:(NSDictionary *)dictionary { 21 | NSString *name = dictionary[@"name"]; 22 | 23 | Class klass = nil; 24 | if ([name isEqualToString:@"profiles"]) { 25 | klass = [PKTProfile class]; 26 | } else if ([name isEqualToString:@"app"]) { 27 | klass = [PKTApp class]; 28 | } else if ([name isEqualToString:@"spaces"]) { 29 | klass = [PKTWorkspace class]; 30 | } 31 | 32 | return [NSValueTransformer pkt_transformerWithModelClass:klass]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSObject+PKTIntrospection.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+PKTIntrospection.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+PKTIntrospection.h" 11 | 12 | @implementation NSObject (PKTIntrospection) 13 | 14 | + (id)pkt_valueByPerformingSelectorWithName:(NSString *)selectorName { 15 | return [self pkt_valueByPerformingSelectorWithName:selectorName withObject:nil]; 16 | } 17 | 18 | + (id)pkt_valueByPerformingSelectorWithName:(NSString *)selectorName withObject:(id)object { 19 | id value = nil; 20 | 21 | SEL selector = NSSelectorFromString(selectorName); 22 | if ([self respondsToSelector:selector]) { 23 | #pragma clang diagnostic push 24 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 25 | value = [self performSelector:selector withObject:object]; 26 | #pragma clang diagnostic pop 27 | } 28 | 29 | return value; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKitTests/PKTTestModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTTestModel.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTTestModel.h" 10 | #import "PKTNestedTestModel.h" 11 | #import "NSValueTransformer+PKTTransformers.h" 12 | 13 | @implementation PKTTestModel 14 | 15 | #pragma mark - PKTModel 16 | 17 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 18 | return @{ 19 | @"objectID": @"object_id", 20 | @"firstValue": @"first_value", 21 | @"secondValue": @"second_value", 22 | @"nestedObjects": @"nested_objects", 23 | @"nestedObject": @"nested_object", 24 | }; 25 | } 26 | 27 | + (NSValueTransformer *)nestedObjectsValueTransformer { 28 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTNestedTestModel class]]; 29 | } 30 | 31 | + (NSValueTransformer *)nestedObjectValueTransformer { 32 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTNestedTestModel class]]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKitTests/NSJSONSerialization+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSJSONSerialization+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSJSONSerialization+PKTAdditions.h" 10 | 11 | @implementation NSJSONSerialization (PKTAdditions) 12 | 13 | + (id)pkt_JSONObjectFromFileWithName:(NSString *)fileName inBundleForClass:(Class)klass { 14 | NSArray *comps = [fileName componentsSeparatedByString:@"."]; 15 | if ([comps count] != 2) { 16 | return nil; 17 | } 18 | 19 | NSString *resource = comps[0]; 20 | NSString *type = comps[1]; 21 | 22 | id obj = nil; 23 | 24 | NSString *path = [[NSBundle bundleForClass:klass] pathForResource:resource ofType:type]; 25 | if (path) { 26 | NSData *data = [NSData dataWithContentsOfFile:path]; 27 | if (data) { 28 | obj = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 29 | } 30 | } 31 | 32 | return obj; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKitTests/PKTCalendarAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCalendarAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTCalendarAPI.h" 11 | 12 | @interface PKTCalendarAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTCalendarAPITests 17 | 18 | - (void)testRequestForCalendarEvents { 19 | NSDate *fromDate = [NSDate dateWithTimeIntervalSince1970:1399617610.8431301]; // May 9th, 2014 20 | NSDate *toDate = [NSDate dateWithTimeInterval:24 * 60 * 60 sinceDate:fromDate]; // May 10th, 2014 21 | PKTRequest *request = [PKTCalendarAPI requestForGlobalCalendarWithFromDate:fromDate toDate:toDate priority:10]; 22 | 23 | expect(request.path).to.equal(@"/calendar/"); 24 | expect(request.parameters[@"date_from"]).to.equal(@"2014-05-09"); 25 | expect(request.parameters[@"date_to"]).to.equal(@"2014-05-10"); 26 | expect(request.parameters[@"priority"]).to.equal(@10); 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /PodioKitTests/PKTDurationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDurationTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTDuration.h" 11 | 12 | @interface PKTDurationTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTDurationTests 17 | 18 | - (void)testInitFromTotalSeconds { 19 | PKTDuration *duration = [[PKTDuration alloc] initWithTotalSeconds:101010]; 20 | expect(duration.hours).to.equal(28); 21 | expect(duration.minutes).to.equal(3); 22 | expect(duration.seconds).to.equal(30); 23 | expect(duration.totalSeconds).to.equal(101010); 24 | } 25 | 26 | - (void)testInitFromHoursAndMinutesAndSeconds { 27 | PKTDuration *duration = [[PKTDuration alloc] initWithHours:28 minutes:3 seconds:30]; 28 | expect(duration.hours).to.equal(28); 29 | expect(duration.minutes).to.equal(3); 30 | expect(duration.seconds).to.equal(30); 31 | expect(duration.totalSeconds).to.equal(101010); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCategoryOption.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCategoryOption 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "PKTCategoryOption.h" 11 | #import "NSValueTransformer+PKTTransformers.h" 12 | 13 | @implementation PKTCategoryOption 14 | 15 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 16 | return @{ 17 | @"optionID" : @"id", 18 | }; 19 | } 20 | 21 | + (NSValueTransformer *)statusValueTransformer { 22 | return [NSValueTransformer pkt_transformerWithDictionary:@{ 23 | @"active" : @(PKTCategoryOptionStatusActive), 24 | @"status" : @(PKTCategoryOptionStatusDeleted) 25 | }]; 26 | } 27 | 28 | #pragma mark - NSObject 29 | 30 | - (NSUInteger)hash { 31 | return [@(self.optionID) hash]; 32 | } 33 | 34 | - (BOOL)isEqual:(id)object { 35 | if (![object isKindOfClass:[self class]]) return NO; 36 | 37 | PKTCategoryOption *option = object; 38 | 39 | return option.optionID == self.optionID; 40 | } 41 | 42 | @end -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTReferenceAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/12/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | typedef NS_ENUM(NSUInteger, PKTReferenceTarget) { 12 | PKTReferenceTargetTaskReference, 13 | PKTReferenceTargetTaskResponsible, 14 | PKTReferenceTargetAlert, 15 | PKTReferenceTargetConversation, 16 | PKTReferenceTargetConversationPresence, 17 | PKTReferenceTargetGrant, 18 | PKTReferenceTargetItemField, 19 | PKTReferenceTargetItemCreatedBy, 20 | PKTReferenceTargetItemCreatedVia, 21 | PKTReferenceTargetItemTags, 22 | PKTReferenceTargetGlobalNav, 23 | PKTReferenceTargetScriptVariables, 24 | PKTReferenceTargetApps, 25 | PKTReferenceTargetInvite 26 | }; 27 | 28 | @interface PKTReferenceAPI : PKTBaseAPI 29 | 30 | + (PKTRequest *)requestToSearchForReferenceWithText:(NSString *)text target:(PKTReferenceTarget)target targetParameters:(NSDictionary *)targetParamers limit:(NSUInteger)limit; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTUserStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTUserStatus.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 11/12/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTUser, PKTProfile, PKTPushCredential, PKTAsyncTask; 12 | 13 | @interface PKTUserStatus : PKTModel 14 | 15 | @property (nonatomic, readonly) NSUInteger newNotificationsCount; 16 | @property (nonatomic, readonly) NSUInteger unreadMessagesCount; 17 | @property (nonatomic, copy, readonly) PKTUser *user; 18 | @property (nonatomic, copy, readonly) PKTProfile *profile; 19 | @property (nonatomic, copy, readonly) PKTPushCredential *pushCredential; 20 | @property (nonatomic, copy, readonly) NSArray *betas; 21 | @property (nonatomic, copy, readonly) NSArray *flags; 22 | @property (nonatomic, copy, readonly) NSString *calendarCode; 23 | @property (nonatomic, copy, readonly) NSString *mailbox; 24 | @property (nonatomic, readonly) NSUInteger globalCalendarPriority; 25 | 26 | + (PKTAsyncTask *)fetchStatusForCurrentUser; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTForm.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTForm.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | typedef NS_ENUM(NSUInteger, PKTFormStatus) { 12 | PKTFormStatusActive, 13 | PKTFormStatusDeleted, 14 | PKTFormStatusDisabled 15 | }; 16 | 17 | @class PKTFormSettings, PKTAsyncTask; 18 | 19 | @interface PKTForm : PKTModel 20 | 21 | @property (nonatomic, assign, readonly) NSUInteger formID; 22 | @property (nonatomic, assign, readonly) NSUInteger spaceID; 23 | @property (nonatomic, assign, readonly) NSUInteger appID; 24 | @property (nonatomic, assign, readonly) PKTFormStatus status; 25 | @property (nonatomic, assign, readonly) BOOL hasItemCapacity; 26 | @property (nonatomic, assign, readonly) BOOL allowsAttachments; 27 | @property (nonatomic, copy, readonly) PKTFormSettings *settings; 28 | @property (nonatomic, copy, readonly) NSArray *fields; // An array of PKTFormField objects 29 | 30 | + (PKTAsyncTask *)fetchWithID:(NSUInteger)formID; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTMoneyItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTMoneyItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTMoneyItemFieldValue.h" 10 | #import "PKTMoney.h" 11 | #import "NSNumber+PKTAdditions.h" 12 | 13 | static NSString * const kValueKey = @"value"; 14 | static NSString * const kCurrencyKey = @"currency"; 15 | 16 | @implementation PKTMoneyItemFieldValue 17 | 18 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 19 | self = [super initWithDictionary:valueDictionary]; 20 | if (!self) return nil; 21 | 22 | self.unboxedValue = [[PKTMoney alloc] initWithDictionary:valueDictionary]; 23 | 24 | return self; 25 | } 26 | 27 | - (NSDictionary *)valueDictionary { 28 | PKTMoney *money = self.unboxedValue; 29 | 30 | return @{kValueKey : [money.amount pkt_USNumberString], 31 | kCurrencyKey : money.currency}; 32 | } 33 | 34 | + (Class)unboxedValueClass { 35 | return [PKTMoney class]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTOrganizationsAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTOrganizationsAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTOrganizationsAPI.h" 10 | 11 | @implementation PKTOrganizationsAPI 12 | 13 | + (PKTRequest *)requestForAllOrganizations { 14 | return [PKTRequest GETRequestWithPath:@"/org/" parameters:nil]; 15 | } 16 | 17 | + (PKTRequest *)requestForOrganizationWithID:(NSUInteger)organizationID { 18 | NSString *path = PKTRequestPath(@"/org/%lu", (unsigned long)organizationID); 19 | PKTRequest *request = [PKTRequest GETRequestWithPath:path parameters:nil]; 20 | 21 | return request; 22 | } 23 | 24 | + (PKTRequest *)requestToUpdateOrganizationWithID:(NSUInteger)organizationID withName:(NSString *)name { 25 | NSString *path = PKTRequestPath(@"/org/%lu", (unsigned long)organizationID); 26 | NSDictionary *parameters = @{@"name": name}; 27 | PKTRequest *request = [PKTRequest PUTRequestWithPath:path parameters:parameters]; 28 | 29 | return request; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAction.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 27/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTByLine; 12 | 13 | typedef NS_ENUM(NSInteger, PKTActionType) { 14 | PKTActionTypeUnknown = 0, 15 | PKTActionTypeSpaceCreated, 16 | PKTActionTypeMemberAdded, 17 | PKTActionTypeMemberLeft, 18 | PKTActionTypeMemberKicked, 19 | PKTActionTypeAppCreated, 20 | PKTActionTypeAppUpdated, 21 | PKTActionTypeAppDeleted, 22 | PKTActionTypeAppInstalled, 23 | PKTActionTypeAppActivated, 24 | PKTActionTypeAppDeactivated 25 | }; 26 | 27 | @interface PKTAction : PKTModel 28 | 29 | @property (nonatomic, assign, readonly) NSUInteger actionID; 30 | @property (nonatomic, assign, readonly) PKTActionType actionType; 31 | @property (nonatomic, copy, readonly) NSString *text; 32 | @property (nonatomic, strong, readonly) PKTByLine *createdBy; 33 | @property (nonatomic, copy, readonly) NSDate *createdOn; 34 | @property (nonatomic, copy, readonly) NSArray *comments; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Copyright Citrix Systems, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to 8 | do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /PodioKitTests/PKTSearchAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTSearchAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTSearchAPI.h" 11 | 12 | @interface PKTSearchAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTSearchAPITests 17 | 18 | - (void)testGlobalSearchRequest { 19 | PKTSearchQuery *query = [PKTSearchQuery queryWithText:@"Some text"]; 20 | query.referenceType = PKTReferenceTypeItem; 21 | query.returnCounts = NO; 22 | 23 | PKTRequest *request = [PKTSearchAPI requestToSearchGloballyWithQuery:query offset:40 limit:20]; 24 | 25 | expect(request.path).to.equal(@"/search/v2"); 26 | expect(request.method).to.equal(PKTRequestMethodGET); 27 | expect(request.parameters[@"query"]).to.equal(@"Some text"); 28 | expect(request.parameters[@"offset"]).to.equal(@40); 29 | expect(request.parameters[@"limit"]).to.equal(@20); 30 | expect(request.parameters[@"ref_type"]).to.equal(@"item"); 31 | expect(request.parameters[@"counts"]).to.equal(@NO); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTItemFieldValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTItemFieldValue.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTAppField.h" 11 | 12 | extern NSString * const PKTItemFieldValueErrorDomain; 13 | 14 | @interface PKTItemFieldValue : PKTModel 15 | 16 | @property (nonatomic, strong) id unboxedValue; // The underlying value object. Its type will depend on the field type. 17 | 18 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary; 19 | 20 | - (void)setUnboxedValue:(id)unboxedValue validate:(BOOL)validate; 21 | 22 | + (BOOL)supportsBoxingOfValue:(id)value error:(NSError **)error; 23 | 24 | /** Override in subclass to return the expected unboxed value type */ 25 | + (Class)unboxedValueClass; 26 | 27 | /** Override in subclass to return an array of expected unboxed value types */ 28 | + (NSArray *)unboxedValueClasses; 29 | 30 | /** Override in subclass to serialize the boxed value into a dictionary to be saved as the field value */ 31 | - (NSDictionary *)valueDictionary; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSMutableURLRequest+PKTHeaders.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+PKTHeaders.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 21/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSMutableURLRequest+PKTHeaders.h" 10 | #import "NSString+PKTBase64.h" 11 | 12 | static NSString * const kHeaderAuthorization = @"Authorization"; 13 | static NSString * const kAuthorizationOAuth2AccessTokenFormat = @"OAuth2 %@"; 14 | 15 | @implementation NSMutableURLRequest (PKTHeaders) 16 | 17 | - (void)pkt_setAuthorizationHeaderWithOAuth2AccessToken:(NSString *)accessToken { 18 | NSString *value = [NSString stringWithFormat:kAuthorizationOAuth2AccessTokenFormat, accessToken]; 19 | [self setValue:value forHTTPHeaderField:kHeaderAuthorization]; 20 | } 21 | 22 | - (void)pkt_setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password { 23 | NSString *authString = [NSString stringWithFormat:@"%@:%@", username, password]; 24 | [self setValue:[NSString stringWithFormat:@"Basic %@", [authString pkt_base64String]] forHTTPHeaderField:@"Authorization"]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTBlockValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTBlockValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBlockValueTransformer.h" 10 | 11 | @interface PKTBlockValueTransformer () 12 | 13 | @property (nonatomic, copy) PKTValueTransformationBlock transformBlock; 14 | 15 | @end 16 | 17 | @implementation PKTBlockValueTransformer 18 | 19 | - (instancetype)init { 20 | return [self initWithBlock:nil]; 21 | } 22 | 23 | - (instancetype)initWithBlock:(PKTValueTransformationBlock)block { 24 | self = [super init]; 25 | if (!self) return nil; 26 | 27 | _transformBlock = [block copy]; 28 | 29 | return self; 30 | } 31 | 32 | + (instancetype)transformerWithBlock:(PKTValueTransformationBlock)block { 33 | return [[self alloc] initWithBlock:block]; 34 | } 35 | 36 | #pragma mark - NSValueTransformer 37 | 38 | + (BOOL)allowsReverseTransformation { 39 | return NO; 40 | } 41 | 42 | - (id)transformedValue:(id)value { 43 | return self.transformBlock ? self.transformBlock(value) : nil; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTApp.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTApp.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 03/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTAppField, PKTAsyncTask; 12 | 13 | @interface PKTApp : PKTModel 14 | 15 | @property (nonatomic, readonly) NSUInteger appID; 16 | @property (nonatomic, readonly) NSUInteger spaceID; 17 | @property (nonatomic, readonly) NSUInteger iconID; 18 | @property (nonatomic, copy, readonly) NSString *name; 19 | @property (nonatomic, copy, readonly) NSString *itemName; 20 | @property (nonatomic, copy, readonly) NSString *appDescription; 21 | @property (nonatomic, copy, readonly) NSURL *link; 22 | @property (nonatomic, copy, readonly) NSArray *fields; 23 | 24 | + (PKTAsyncTask *)fetchAppWithID:(NSUInteger)appID; 25 | + (PKTAsyncTask *)fetchAppsInWorkspaceWithID:(NSUInteger)spaceID; 26 | + (PKTAsyncTask *)fetchAppInWorkspaceWithID:(NSUInteger)spaceID urlLabel:(NSString *)urlLabel; 27 | + (PKTAsyncTask *)fetchMostFrequentlyUsedApps:(NSUInteger)limit; 28 | 29 | - (PKTAppField *)fieldWithExternalID:(NSString *)externalID; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTEmbed.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbed.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | 12 | @class PKTAsyncTask; 13 | 14 | @interface PKTEmbed : PKTModel 15 | 16 | @property (nonatomic, assign, readonly) NSUInteger embedID; 17 | @property (nonatomic, copy, readonly) NSURL *originalURL; 18 | @property (nonatomic, copy, readonly) NSURL *resolvedURL; 19 | @property (nonatomic, assign, readonly) PKTEmbedType type; 20 | @property (nonatomic, copy, readonly) NSString *title; 21 | @property (nonatomic, copy, readonly) NSString *descr; 22 | @property (nonatomic, copy, readonly) NSDate *createdOn; 23 | @property (nonatomic, copy, readonly) NSString *providerName; 24 | @property (nonatomic, copy, readonly) NSString *embedHTML; 25 | @property (nonatomic, assign, readonly) NSNumber *embedWidth; 26 | @property (nonatomic, assign, readonly) NSNumber *embedHeight; 27 | @property (nonatomic, copy, readonly) NSString *files; 28 | 29 | + (PKTAsyncTask *)createEmbedForURLString:(NSString *)URLString; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTLocationItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTLocationItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTLocationItemFieldValue.h" 10 | #import "PKTLocation.h" 11 | 12 | @implementation PKTLocationItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initFromValueDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = [[PKTLocation alloc] initWithDictionary:valueDictionary]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | PKTLocation *location = self.unboxedValue; 25 | 26 | NSDictionary *dict = nil; 27 | if (location.value) { 28 | dict = @{@"value" : location.value}; 29 | } else if (location.latitude > DBL_EPSILON && location.longitude > DBL_EPSILON) { 30 | dict = @{@"lat" : @(location.latitude), 31 | @"lng" : @(location.longitude)}; 32 | } 33 | 34 | return dict; 35 | } 36 | 37 | + (Class)unboxedValueClass { 38 | return [PKTLocation class]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PodioKit/UIKit/PKTImageDownloader.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTImageDownloader.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTImageDownloader.h" 10 | #import "PKTImageCache.h" 11 | #import "PKTFile+UIImage.h" 12 | 13 | @implementation PKTImageDownloader 14 | 15 | + (PKTAsyncTask *)setImageWithFile:(PKTFile *)file placeholderImage:(UIImage *)placeholderImage imageSize:(PKTImageSize)imageSize imageSetterBlock:(void (^)(UIImage *image))imageSetterBlock { 16 | NSParameterAssert(file); 17 | NSParameterAssert(imageSetterBlock); 18 | 19 | // Check for a cached image 20 | UIImage *image = [[PKTImageCache sharedCache] cachedImageForFile:file]; 21 | if (image) { 22 | imageSetterBlock(image); 23 | return nil; 24 | } 25 | 26 | imageSetterBlock(placeholderImage); 27 | 28 | PKTAsyncTask *task = [[file downloadImageOfSize:imageSize] then:^(UIImage *image, NSError *error) { 29 | if (image) { 30 | [[PKTImageCache sharedCache] setCachedImage:image forFile:file]; 31 | imageSetterBlock(image); 32 | } 33 | }]; 34 | 35 | return task; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTAppFieldTypeValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppFieldTypeValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTAppFieldTypeValueTransformer.h" 10 | #import "PKTAppField.h" 11 | 12 | @implementation PKTAppFieldTypeValueTransformer 13 | 14 | - (instancetype)init { 15 | return [super initWithDictionary:@{ 16 | @"text" : @(PKTAppFieldTypeText), 17 | @"number" : @(PKTAppFieldTypeNumber), 18 | @"image" : @(PKTAppFieldTypeImage), 19 | @"date" : @(PKTAppFieldTypeDate), 20 | @"app" : @(PKTAppFieldTypeApp), 21 | @"contact" : @(PKTAppFieldTypeContact), 22 | @"money" : @(PKTAppFieldTypeMoney), 23 | @"progress" : @(PKTAppFieldTypeProgress), 24 | @"location" : @(PKTAppFieldTypeLocation), 25 | @"duration" : @(PKTAppFieldTypeDuration), 26 | @"embed" : @(PKTAppFieldTypeEmbed), 27 | @"calculation" : @(PKTAppFieldTypeCalculation), 28 | @"category" : @(PKTAppFieldTypeCategory), 29 | @"phone" : @(PKTAppFieldTypePhone), 30 | @"email" : @(PKTAppFieldTypeEmail), 31 | @"tag" : @(PKTAppFieldTypeTag) 32 | }]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTCategoryItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCategoryItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTCategoryItemFieldValue.h" 10 | #import "PKTCategoryOption.h" 11 | 12 | @implementation PKTCategoryItemFieldValue 13 | 14 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 15 | self = [super initWithDictionary:valueDictionary]; 16 | if (!self) return nil; 17 | 18 | self.unboxedValue = [[PKTCategoryOption alloc] initWithDictionary:valueDictionary[@"value"]]; 19 | 20 | return self; 21 | } 22 | 23 | - (NSDictionary *)valueDictionary { 24 | PKTCategoryOption *option = self.unboxedValue; 25 | 26 | NSDictionary *dict = nil; 27 | 28 | if ([self.unboxedValue isKindOfClass:[PKTCategoryOption class]]) { 29 | dict = @{@"value" : @(option.optionID)}; 30 | } else if ([self.unboxedValue isKindOfClass:[NSNumber class]]) { 31 | dict = @{@"value" : self.unboxedValue}; 32 | } 33 | 34 | return dict; 35 | } 36 | 37 | + (NSArray *)unboxedValueClasses { 38 | return @[[PKTCategoryOption class], [NSNumber class]]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PodioKitTests/PKTAppFieldConfigTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppFieldConfigTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTAppFieldConfig.h" 11 | 12 | @interface PKTAppFieldConfigTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTAppFieldConfigTests 17 | 18 | - (void)testInitWithDictionary { 19 | NSDictionary *dict = @{ 20 | @"label" : @"What time?", 21 | @"description" : @"Some description", 22 | @"mapping" : @"meeting_time", 23 | @"settings" : @{@"key" : @"value"}, 24 | @"delta" : @3, 25 | @"required" : @YES, 26 | @"visible" : @YES, 27 | }; 28 | 29 | PKTAppFieldConfig *config = [[PKTAppFieldConfig alloc] initWithDictionary:dict]; 30 | expect(config.label).to.equal(@"What time?"); 31 | expect(config.descr).to.equal(@"Some description"); 32 | expect(config.mapping).to.equal(PKTAppFieldMappingMeetingTime); 33 | expect(config.settings).to.equal(@{@"key" : @"value"}); 34 | expect(config.delta).to.equal(3); 35 | expect(config.required).to.beTruthy(); 36 | expect(config.visible).to.beTruthy(); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTConversationEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTConversationEvent.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 13/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | typedef NS_ENUM(NSUInteger, PKTConversationEventAction) { 12 | PKTConversationEventActionUnknown = 0, 13 | PKTConversationEventActionMessage, 14 | PKTConversationEventActionParticipantAdd, 15 | PKTConversationEventActionParticipantLeave, 16 | PKTConversationEventActionSubjectChange 17 | }; 18 | 19 | @class PKTAsyncTask, PKTByLine; 20 | 21 | @interface PKTConversationEvent : PKTModel 22 | 23 | @property (nonatomic, readonly) NSUInteger eventID; 24 | @property (nonatomic, readonly) NSUInteger conversationID; 25 | @property (nonatomic, strong, readonly) PKTByLine *createdBy; 26 | @property (nonatomic, copy, readonly) NSDate *createdOn; 27 | @property (nonatomic, readonly) PKTConversationEventAction action; 28 | @property (nonatomic, strong, readonly) id data; 29 | 30 | + (PKTAsyncTask *)fetchEventWithID:(NSUInteger)eventID; 31 | + (PKTAsyncTask *)fetchAllInConversationWithID:(NSUInteger)conversationID offset:(NSUInteger)offset limit:(NSUInteger)limit; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKitTests/PKTConversationsAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTConversationsAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTConversationsAPI.h" 11 | 12 | @interface PKTConversationsAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTConversationsAPITests 17 | 18 | - (void)testGetConversationsRequest { 19 | PKTRequest *request = [PKTConversationsAPI requestForConversationsWithOffset:40 limit:20]; 20 | 21 | expect(request.method).to.equal(PKTRequestMethodGET); 22 | expect(request.path).to.equal(@"/conversation/"); 23 | expect(request.parameters[@"offset"]).to.equal(@40); 24 | expect(request.parameters[@"limit"]).to.equal(@20); 25 | } 26 | 27 | - (void)testGetConversationEventsRequest { 28 | PKTRequest *request = [PKTConversationsAPI requestForEventsInConversationWithID:1234 offset:40 limit:20]; 29 | 30 | expect(request.method).to.equal(PKTRequestMethodGET); 31 | expect(request.path).to.equal(@"/conversation/1234/event/"); 32 | expect(request.parameters[@"offset"]).to.equal(@40); 33 | expect(request.parameters[@"limit"]).to.equal(@20); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTEmbedItemFieldValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTEmbedItemFieldValue.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 28/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTEmbedItemFieldValue.h" 10 | #import "PKTEmbed.h" 11 | 12 | static NSString * const kEmbedKey = @"embed"; 13 | static NSString * const kURLKey = @"url"; 14 | 15 | @implementation PKTEmbedItemFieldValue 16 | 17 | - (instancetype)initFromValueDictionary:(NSDictionary *)valueDictionary { 18 | self = [super initWithDictionary:valueDictionary]; 19 | if (!self) return nil; 20 | 21 | self.unboxedValue = [[PKTEmbed alloc] initWithDictionary:valueDictionary[kEmbedKey]]; 22 | 23 | return self; 24 | } 25 | 26 | - (NSDictionary *)valueDictionary { 27 | NSDictionary *dict = nil; 28 | 29 | if ([self.unboxedValue isKindOfClass:[PKTEmbed class]]) { 30 | PKTEmbed *embed = self.unboxedValue; 31 | dict = @{kEmbedKey : @(embed.embedID)}; 32 | } else if ([self.unboxedValue isKindOfClass:[NSString class]]) { 33 | dict = @{kURLKey : self.unboxedValue}; 34 | } 35 | 36 | return dict; 37 | } 38 | 39 | + (NSArray *)unboxedValueClasses { 40 | return @[[PKTEmbed class], [NSString class]]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppFieldConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppFieldConfig 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | typedef NS_ENUM(NSUInteger, PKTAppFieldMapping) { 12 | PKTAppFieldMappingNone = 0, 13 | PKTAppFieldMappingMeetingTime, 14 | PKTAppFieldMappingMeetingParticipants, 15 | PKTAppFieldMappingMeetingAgenda, 16 | PKTAppFieldMappingMeetingLocation, 17 | }; 18 | 19 | @interface PKTAppFieldConfig : PKTModel 20 | 21 | @property (nonatomic, copy, readonly) NSString *label; 22 | @property (nonatomic, copy, readonly) NSString *descr; 23 | @property (nonatomic, copy, readonly) NSDictionary *settings; 24 | @property (nonatomic, assign, readonly) NSUInteger delta; 25 | @property (nonatomic, assign, readonly) PKTAppFieldMapping mapping; 26 | @property (nonatomic, assign, readonly, getter = isRequired) BOOL required; 27 | @property (nonatomic, assign, readonly, getter = isVisible) BOOL visible; 28 | 29 | - (instancetype)initWithLabel:(NSString *)label description:(NSString *)description settings:(NSDictionary *)settings delta:(NSUInteger)delta mapping:(PKTAppFieldMapping)mapping isRequired:(BOOL)isRequired isVisible:(BOOL)isVisible; 30 | 31 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTStatus.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 30/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | 11 | @class PKTByLine, PKTAsyncTask; 12 | 13 | @interface PKTStatus : PKTModel 14 | 15 | @property (nonatomic, assign, readonly) NSUInteger statusID; 16 | @property (nonatomic, copy, readonly) NSString *text; 17 | @property (nonatomic, copy, readonly) NSURL *link; 18 | @property (nonatomic, copy, readonly) PKTByLine *createdBy; 19 | @property (nonatomic, copy, readonly) NSDate *createdOn; 20 | @property (nonatomic, copy, readonly) NSArray *comments; 21 | 22 | + (PKTAsyncTask *)fetchWithID:(NSUInteger)statusID; 23 | 24 | + (PKTAsyncTask *)addNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID; 25 | 26 | + (PKTAsyncTask *)addNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files; 27 | 28 | + (PKTAsyncTask *)addNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files embedID:(NSUInteger)embedID; 29 | 30 | + (PKTAsyncTask *)addNewStatusMessageWithText:(NSString *)text spaceID:(NSUInteger)spaceID files:(NSArray *)files embedURL:(NSURL *)embedURL; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSURL+PKTImageURL.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+PKTImageURL.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 19/11/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSURL+PKTImageURL.h" 10 | 11 | @implementation NSURL (PKTImageURL) 12 | 13 | - (NSURL *)pkt_imageURLForSize:(PKTImageSize)size { 14 | NSURL *url = [self copy]; 15 | 16 | NSString *sizeString = nil; 17 | switch (size) { 18 | case PKTImageSizeDefault: 19 | sizeString = @"default"; 20 | break; 21 | case PKTImageSizeTiny: 22 | sizeString = @"tiny"; 23 | break; 24 | case PKTImageSizeSmall: 25 | sizeString = @"small"; 26 | break; 27 | case PKTImageSizeMedium: 28 | sizeString = @"medium"; 29 | break; 30 | case PKTImageSizeLarge: 31 | sizeString = @"large"; 32 | break; 33 | case PKTImageSizeExtraLarge: 34 | sizeString = @"extra_large"; 35 | break; 36 | default: 37 | break; 38 | } 39 | 40 | if (sizeString) { 41 | // Append x2 since most iOS devices are retina 42 | sizeString = [sizeString stringByAppendingString:@"_x2"]; 43 | url = [url URLByAppendingPathComponent:sizeString]; 44 | } 45 | 46 | return url; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /PodioKitTests/PKTOrganizationAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTOrganizationAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 12/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTOrganizationsAPI.h" 11 | 12 | @interface PKTOrganizationAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTOrganizationAPITests 17 | 18 | - (void)testRequestForAllOrganizations { 19 | PKTRequest *request = [PKTOrganizationsAPI requestForAllOrganizations]; 20 | expect(request.path).to.equal(@"/org/"); 21 | expect(request.method).to.equal(PKTRequestMethodGET); 22 | } 23 | 24 | - (void)testRequestForOrganizationWithID { 25 | PKTRequest *request = [PKTOrganizationsAPI requestForOrganizationWithID:123]; 26 | expect(request.path).to.equal(@"/org/123"); 27 | expect(request.method).to.equal(PKTRequestMethodGET); 28 | } 29 | 30 | - (void)testRequestToUpdateOrganizationWithID { 31 | PKTRequest *request = [PKTOrganizationsAPI requestToUpdateOrganizationWithID:123 withName:@"Organisation name"]; 32 | expect(request.path).to.equal(@"/org/123"); 33 | expect(request.method).to.equal(PKTRequestMethodPUT); 34 | expect(request.parameters[@"name"]).to.equal(@"Organisation name"); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTSearchQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTSearchQuery.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTSearchQuery.h" 10 | #import "NSValueTransformer+PKTConstants.h" 11 | 12 | @implementation PKTSearchQuery 13 | 14 | - (instancetype)init { 15 | return [self initWithText:nil]; 16 | } 17 | 18 | - (instancetype)initWithText:(NSString *)text { 19 | NSParameterAssert(text); 20 | 21 | self = [super init]; 22 | if (!self) return nil; 23 | 24 | _text = [text copy]; 25 | _returnCounts = YES; 26 | 27 | return self; 28 | } 29 | 30 | + (instancetype)queryWithText:(NSString *)text { 31 | return [[self alloc] initWithText:text]; 32 | } 33 | 34 | #pragma mark - PKTRequestParameters 35 | 36 | - (NSDictionary *)queryParameters { 37 | NSParameterAssert(self.text); 38 | 39 | NSMutableDictionary *params = [NSMutableDictionary new]; 40 | 41 | params[@"query"] = self.text; 42 | params[@"counts"] = @(self.returnCounts); 43 | 44 | if (self.referenceType != PKTReferenceTypeUnknown) { 45 | params[@"ref_type"] = [NSValueTransformer pkt_stringFromReferenceType:self.referenceType]; 46 | } 47 | 48 | return [params copy]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTByLine.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTByLine.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTByLine.h" 10 | #import "PKTFile.h" 11 | #import "NSValueTransformer+PKTTransformers.h" 12 | 13 | @implementation PKTByLine 14 | 15 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 16 | return @{ 17 | @"referenceType" : @"type", 18 | @"referenceID" : @"id", 19 | @"userID" : @"user_id", 20 | @"imageFile" : @"image", 21 | @"lastSeenOn": @"last_seen_on", 22 | @"avatarType": @"avatar_type", 23 | @"avatarID": @"avatar_id" 24 | }; 25 | } 26 | 27 | + (NSValueTransformer *)referenceTypeValueTransformer { 28 | return [NSValueTransformer pkt_referenceTypeTransformer]; 29 | } 30 | 31 | + (NSValueTransformer *)imageFileValueTransformer { 32 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTFile class]]; 33 | } 34 | 35 | + (NSValueTransformer *)lastSeenOnValueTransformer { 36 | return [NSValueTransformer pkt_dateValueTransformer]; 37 | } 38 | 39 | + (NSValueTransformer *)avatarTypeValueTransformer { 40 | return [NSValueTransformer pkt_avatarTypeValueTransformer]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSValueTransformer+PKTTransformers.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSValueTransformer+PKTTransformers.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTBlockValueTransformer.h" 11 | 12 | @interface NSValueTransformer (PKTTransformers) 13 | 14 | + (NSValueTransformer *)pkt_transformerWithBlock:(PKTValueTransformationBlock)block; 15 | + (NSValueTransformer *)pkt_transformerWithBlock:(PKTValueTransformationBlock)block reverseBlock:(PKTValueTransformationBlock)reverseBlock; 16 | + (NSValueTransformer *)pkt_transformerWithModelClass:(Class)modelClass; 17 | 18 | + (NSValueTransformer *)pkt_transformerWithDictionary:(NSDictionary *)dictionary; 19 | + (NSValueTransformer *)pkt_URLTransformer; 20 | + (NSValueTransformer *)pkt_dateValueTransformer; 21 | + (NSValueTransformer *)pkt_referenceTypeTransformer; 22 | + (NSValueTransformer *)pkt_notificationTypeTransformer; 23 | + (NSValueTransformer *)pkt_appFieldTypeTransformer; 24 | + (NSValueTransformer *)pkt_numberValueTransformer; 25 | + (NSValueTransformer *)pkt_rightValueTransformer; 26 | + (NSValueTransformer *)pkt_avatarTypeValueTransformer; 27 | + (NSValueTransformer *)pkt_emojiValueTransformer; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTRequestFileData.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTRequestFileData.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 01/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTRequestFileData.h" 10 | 11 | @implementation PKTRequestFileData 12 | 13 | - (instancetype)initWithData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName { 14 | self = [super init]; 15 | if (!self) return nil; 16 | 17 | _data = data; 18 | _name = [name copy]; 19 | _fileName = [fileName copy]; 20 | 21 | return self; 22 | } 23 | 24 | - (instancetype)initWithFilePath:(NSString *)filePath name:(NSString *)name fileName:(NSString *)fileName { 25 | self = [super init]; 26 | if (!self) return nil; 27 | 28 | _filePath = [filePath copy]; 29 | _name = [name copy]; 30 | _fileName = [fileName copy]; 31 | 32 | return self; 33 | } 34 | 35 | + (instancetype)fileDataWithData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName { 36 | return [[self alloc] initWithData:data name:name fileName:fileName]; 37 | } 38 | 39 | + (instancetype)fileDataWithFilePath:(NSString *)filePath name:(NSString *)name fileName:(NSString *)fileName { 40 | return [[self alloc] initWithFilePath:filePath name:name fileName:fileName]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppField.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppField.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTAppField.h" 10 | #import "PKTCategoryOption.h" 11 | #import "NSValueTransformer+PKTTransformers.h" 12 | #import "NSArray+PKTAdditions.h" 13 | 14 | @implementation PKTAppField 15 | 16 | - (instancetype)initWithFieldID:(NSUInteger)fieldID externalID:(NSString *)externalID type:(PKTAppFieldType)type config:(PKTAppFieldConfig *)config { 17 | self = [super init]; 18 | if (!self) return nil; 19 | 20 | _fieldID = fieldID; 21 | _externalID = [externalID copy]; 22 | _type = type; 23 | _config = config; 24 | 25 | return self; 26 | } 27 | 28 | #pragma mark - PKTModel 29 | 30 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 31 | return @{ 32 | @"fieldID" : @"field_id", 33 | @"externalID" : @"external_id", 34 | @"type" : @"type" 35 | }; 36 | } 37 | 38 | + (NSValueTransformer *)typeValueTransformer { 39 | return [NSValueTransformer pkt_appFieldTypeTransformer]; 40 | } 41 | 42 | + (NSValueTransformer *)configValueTransformer { 43 | return [NSValueTransformer pkt_transformerWithModelClass:[PKTAppFieldConfig class]]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTNotificationsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | #import "PKTNotificationsRequestParameters.h" 11 | 12 | @interface PKTNotificationsAPI : PKTBaseAPI 13 | 14 | + (PKTRequest *)requestForNotificationsWithOffset:(NSUInteger)offset limit:(NSUInteger)limit; 15 | 16 | + (PKTRequest *)requestForNotificationsWithParameters:(PKTNotificationsRequestParameters *)parameters offset:(NSUInteger)offset limit:(NSUInteger)limit; 17 | 18 | + (PKTRequest *)requestToMarkAllkNotificationsAsViewed; 19 | 20 | + (PKTRequest *)requestToMarkNotificationsAsViewedWithReferenceID:(NSUInteger)referenceID type:(PKTReferenceType)referenceType; 21 | 22 | + (PKTRequest *)requestToMarkNotificationsAsUnviewedWithReferenceID:(NSUInteger)referenceID type:(PKTReferenceType)referenceType; 23 | 24 | + (PKTRequest *)requestToMarkNotificationAsViewedWithID:(NSUInteger)notificationID; 25 | 26 | + (PKTRequest *)requestToMarkNotificationAsUnviewedWithID:(NSUInteger)notificationID; 27 | 28 | + (PKTRequest *)requestToStarNotificationWithID:(NSUInteger)notificationID; 29 | 30 | + (PKTRequest *)requestToUnstarNotificationWithID:(NSUInteger)notificationID; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTReferenceIdentifier.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReferenceIdentifier.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTReferenceIdentifier.h" 10 | #import "NSValueTransformer+PKTConstants.h" 11 | 12 | @implementation PKTReferenceIdentifier 13 | 14 | - (instancetype)init { 15 | return [self initWithReferenceID:0 type:PKTReferenceTypeUnknown]; 16 | } 17 | 18 | - (instancetype)initWithReferenceID:(NSUInteger)referenceID type:(PKTReferenceType)referenceType { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _referenceID = referenceID; 23 | _referenceType = referenceType; 24 | 25 | return self; 26 | } 27 | 28 | + (instancetype)identifierWithReferenceID:(NSUInteger)referenceID type:(PKTReferenceType)referenceType { 29 | return [[self alloc] initWithReferenceID:referenceID type:referenceType]; 30 | } 31 | 32 | #pragma mark - NSCopying 33 | 34 | - (instancetype)copyWithZone:(NSZone *)zone { 35 | return [[[self class] alloc] initWithReferenceID:self.referenceID type:self.referenceType]; 36 | } 37 | 38 | #pragma mark - Properties 39 | 40 | - (NSString *)referenceTypeString { 41 | return [NSValueTransformer pkt_stringFromReferenceType:self.referenceType]; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTDateValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDateValueTransformer.h" 10 | #import "NSDate+PKTAdditions.h" 11 | #import "PKTMacros.h" 12 | 13 | @implementation PKTDateValueTransformer 14 | 15 | - (instancetype)init { 16 | PKT_WEAK_SELF weakSelf = self; 17 | 18 | return [super initWithBlock:^id(NSString *dateString) { 19 | NSDate *date = [NSDate pkt_dateFromUTCDateTimeString:dateString]; 20 | if (!date) { 21 | // Failed to parse time component, try date only 22 | date = [NSDate pkt_dateFromUTCDateString:dateString]; 23 | 24 | if (!date) { 25 | // Still failed to parse, try time only 26 | date = [NSDate pkt_dateFromUTCTimeString:dateString]; 27 | } 28 | } 29 | 30 | return date; 31 | } reverseBlock:^id(NSDate *date) { 32 | PKT_STRONG(weakSelf) strongSelf = weakSelf; 33 | 34 | NSString *dateString = nil; 35 | 36 | if (strongSelf.ignoresTimeComponent) { 37 | dateString = [date pkt_UTCDateString]; 38 | } else { 39 | dateString = [date pkt_UTCDateTimeString]; 40 | } 41 | 42 | return dateString; 43 | }]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /PodioKitTests/PKTModelValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTModelValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTModelValueTransformer.h" 11 | #import "PKTTestModel.h" 12 | 13 | @interface PKTModelValueTransformerTests : XCTestCase 14 | 15 | @end 16 | 17 | @implementation PKTModelValueTransformerTests 18 | 19 | - (void)testForwardTransformationOfSingleObject { 20 | PKTModelValueTransformer *transformer = [PKTModelValueTransformer transformerWithModelClass:[PKTTestModel class]]; 21 | 22 | PKTTestModel *obj = [transformer transformedValue:@{}]; 23 | 24 | expect(obj).to.beInstanceOf([PKTTestModel class]); 25 | } 26 | 27 | - (void)testForwardTransformationOfArrayOfObjects { 28 | PKTModelValueTransformer *transformer = [PKTModelValueTransformer transformerWithModelClass:[PKTTestModel class]]; 29 | 30 | NSArray *objs = [transformer transformedValue:@[@{}, @{}, @{}]]; 31 | 32 | expect(objs).to.beKindOf([NSArray class]); 33 | expect(objs).to.haveCountOf(3); 34 | expect(objs[0]).to.beInstanceOf([PKTTestModel class]); 35 | expect(objs[1]).to.beInstanceOf([PKTTestModel class]); 36 | expect(objs[2]).to.beInstanceOf([PKTTestModel class]); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Scripts/run-tests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # Runs the PodioKit unit test suite. 4 | # 5 | # Usage: 6 | # 7 | # ./run-tests [--device ] [--sdk <6.0|7.0>] [--raw] 8 | # 9 | 10 | require 'getoptlong' 11 | 12 | SCHEME = 'PodioKit' 13 | WORKSPACE = 'PodioKit.xcworkspace' 14 | 15 | def destination_for_device(device = nil) 16 | device_name = case device 17 | when 'ipad' then 'iPad Retina' 18 | else 'iPhone Retina (4-inch)' 19 | end 20 | 21 | return "platform=iOS Simulator,name=#{device_name}" 22 | end 23 | 24 | opts = GetoptLong.new( 25 | ['--device', GetoptLong::OPTIONAL_ARGUMENT], 26 | ['--sdk', GetoptLong::OPTIONAL_ARGUMENT], 27 | ['--raw', GetoptLong::OPTIONAL_ARGUMENT] 28 | ) 29 | 30 | destination = destination_for_device() 31 | sdk_version = nil 32 | raw = false 33 | 34 | opts.each do |opt, arg| 35 | case opt 36 | when '--device' 37 | destination = destination_for_device(arg) 38 | when '--sdk' 39 | sdk_version = arg || nil 40 | when '--raw' 41 | raw = true 42 | end 43 | end 44 | 45 | cmd = "xcodebuild -scheme #{SCHEME} -workspace #{WORKSPACE} -destination \"#{destination}\"" 46 | cmd << " -sdk \"iphonesimulator#{sdk_version}\"" if sdk_version 47 | cmd << " test" 48 | cmd << "| xcpretty -c; exit ${PIPESTATUS[0]}" unless raw 49 | 50 | code = system(cmd) 51 | exit code if code != 0 -------------------------------------------------------------------------------- /PodioKitTests/PKTDateValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTDateValueTransformer.h" 11 | 12 | @interface PKTDateValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTDateValueTransformerTests 17 | 18 | - (void)testDateForwardTransformation { 19 | PKTDateValueTransformer *transformer = [PKTDateValueTransformer new]; 20 | expect([transformer transformedValue:@"2014-05-02 18:32:22"]).to.beKindOf([NSDate class]); 21 | } 22 | 23 | - (void)testDateReverseTransformation { 24 | PKTDateValueTransformer *transformer = [PKTDateValueTransformer new]; 25 | NSString *dateString = [transformer reverseTransformedValue:[NSDate dateWithTimeIntervalSince1970:0]]; 26 | expect(dateString).to.equal(@"1970-01-01 00:00:00"); 27 | } 28 | 29 | - (void)testDateReverseTransformationWithIgnoredTimeComponent { 30 | PKTDateValueTransformer *transformer = [PKTDateValueTransformer new]; 31 | transformer.ignoresTimeComponent = YES; 32 | 33 | NSString *dateString = [transformer reverseTransformedValue:[NSDate dateWithTimeIntervalSince1970:0]]; 34 | 35 | expect(dateString).to.equal(@"1970-01-01"); 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTRequestSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTRequestSerializer.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | @class PKTRequest; 10 | 11 | @class PKTMultipartFormData; 12 | 13 | extern NSString * const PKTRequestSerializerHTTPHeaderKeyAuthorization; 14 | extern NSString * const PKTRequestSerializerHTTPHeaderKeyUserAgent; 15 | extern NSString * const PKTRequestSerializerHTTPHeaderKeyContentType; 16 | extern NSString * const PKTRequestSerializerHTTPHeaderKeyContentLength; 17 | 18 | @interface PKTRequestSerializer : NSObject 19 | 20 | - (NSMutableURLRequest *)URLRequestForRequest:(PKTRequest *)request relativeToURL:(NSURL *)baseURL; 21 | - (NSMutableURLRequest *)URLRequestForRequest:(PKTRequest *)request multipartData:(PKTMultipartFormData *)multipartData relativeToURL:(NSURL *)baseURL; 22 | 23 | - (id)valueForHTTPHeader:(NSString *)header; 24 | 25 | - (void)setValue:(NSString *)value forHTTPHeader:(NSString *)header; 26 | - (void)setAuthorizationHeaderWithOAuth2AccessToken:(NSString *)accessToken; 27 | - (void)setAuthorizationHeaderWithAPIKey:(NSString *)key secret:(NSString *)secret; 28 | - (void)setUserAgentHeader:(NSString *)userAgent; 29 | 30 | - (PKTMultipartFormData *)multipartFormDataFromRequest:(PKTRequest *)request; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PodioKitTests/PKTDictionaryMappingValueTransformerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDictionaryMappingValueTransformerTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 22/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTDictionaryMappingValueTransformer.h" 11 | 12 | @interface PKTDictionaryMappingValueTransformerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTDictionaryMappingValueTransformerTests 17 | 18 | - (void)testDictionaryTransformation { 19 | NSDictionary *mapping = @{ 20 | @"A" : @1, 21 | @"B" : @2, 22 | }; 23 | 24 | PKTDictionaryMappingValueTransformer *transformer = [[PKTDictionaryMappingValueTransformer alloc] initWithDictionary:mapping]; 25 | 26 | expect([transformer transformedValue:@"A"]).to.equal(@1); 27 | expect([transformer transformedValue:@"B"]).to.equal(@2); 28 | } 29 | 30 | - (void)testReverseDictionaryTransformation { 31 | NSDictionary *mapping = @{ 32 | @"A" : @1, 33 | @"B" : @2, 34 | }; 35 | 36 | PKTDictionaryMappingValueTransformer *transformer = [[PKTDictionaryMappingValueTransformer alloc] initWithDictionary:mapping]; 37 | 38 | expect([transformer reverseTransformedValue:@1]).to.equal(@"A"); 39 | expect([transformer reverseTransformedValue:@2]).to.equal(@"B"); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/PKTReversibleBlockValueTransformer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTReversibleBlockValueTransformer.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTReversibleBlockValueTransformer.h" 10 | 11 | @interface PKTReversibleBlockValueTransformer () 12 | 13 | @property (nonatomic, copy) PKTValueTransformationBlock reverseBlock; 14 | 15 | @end 16 | 17 | @implementation PKTReversibleBlockValueTransformer 18 | 19 | - (instancetype)init { 20 | return [self initWithBlock:nil reverseBlock:nil]; 21 | } 22 | 23 | - (instancetype)initWithBlock:(PKTValueTransformationBlock)block reverseBlock:(PKTValueTransformationBlock)reverseBlock { 24 | self = [super initWithBlock:block]; 25 | if (!self) return nil; 26 | 27 | _reverseBlock = [reverseBlock copy]; 28 | 29 | return self; 30 | } 31 | 32 | + (instancetype)transformerWithBlock:(PKTValueTransformationBlock)block reverseBlock:(PKTValueTransformationBlock)reverseBlock { 33 | return [[self alloc] initWithBlock:block reverseBlock:reverseBlock]; 34 | } 35 | 36 | #pragma mark - NSValueTransformer 37 | 38 | + (BOOL)allowsReverseTransformation { 39 | return YES; 40 | } 41 | 42 | - (id)reverseTransformedValue:(id)value { 43 | return self.reverseBlock ? self.reverseBlock(value) : nil; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /PodioKit/UIKit/PKTImageCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTImageCache.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTImageCache.h" 10 | #import "PKTFile.h" 11 | 12 | @implementation PKTImageCache 13 | 14 | - (instancetype)init { 15 | self = [super init]; 16 | if (!self) return nil; 17 | 18 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearCache) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; 19 | 20 | return self; 21 | } 22 | 23 | - (void)dealloc { 24 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; 25 | } 26 | 27 | #pragma mark - Public 28 | 29 | + (instancetype)sharedCache { 30 | static id sharedCache; 31 | static dispatch_once_t once; 32 | 33 | dispatch_once(&once, ^{ 34 | sharedCache = [[self alloc] init]; 35 | }); 36 | 37 | return sharedCache; 38 | } 39 | 40 | - (void)clearCache { 41 | [self removeAllObjects]; 42 | } 43 | 44 | - (UIImage *)cachedImageForFile:(PKTFile *)file { 45 | return [self objectForKey:file.link.absoluteString]; 46 | } 47 | 48 | - (void)setCachedImage:(UIImage *)image forFile:(PKTFile *)file { 49 | [self setObject:image forKey:file.link.absoluteString]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PodioKitTests/PKTLocationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTLocationTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTLocation.h" 11 | 12 | @interface PKTLocationTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTLocationTests 17 | 18 | - (void)testInitFromDictionary { 19 | NSDictionary *dict = @{ 20 | @"city": @"Copenhagen", 21 | @"country": @"Denmark", 22 | @"street_name": @"Fisketorvet", 23 | @"formatted": @"Fisketorvet, 1560 Copenhagen, Denmark", 24 | @"value": @"Fisketorvet, 1560 Copenhagen, Denmark", 25 | @"postal_code": @"1560", 26 | @"lat": @55.6646305, 27 | @"lng": @12.5657289 28 | }; 29 | 30 | PKTLocation *location = [[PKTLocation alloc] initWithDictionary:dict]; 31 | expect(location.value).to.equal(@"Fisketorvet, 1560 Copenhagen, Denmark"); 32 | expect(location.formattedValue).to.equal(@"Fisketorvet, 1560 Copenhagen, Denmark"); 33 | expect(location.postalCode).to.equal(@"1560"); 34 | expect(location.city).to.equal(@"Copenhagen"); 35 | expect(location.country).to.equal(@"Denmark"); 36 | expect(location.streetName).to.equal(@"Fisketorvet"); 37 | expect(location.latitude).to.equal(55.6646305); 38 | expect(location.longitude).to.equal(12.5657289); 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PodioKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'PodioKit' 3 | s.version = '2.0.0' 4 | s.source = { :git => 'https://github.com/podio/podio-objc.git', :tag => s.version.to_s } 5 | 6 | s.summary = "PodioKit is an Objective-C client library for the Podio API." 7 | s.homepage = "https://github.com/podio/podio-objc" 8 | s.license = 'MIT' 9 | s.authors = { "Sebastian Rehnby" => "sebastian@podio.com", 10 | "Romain Briche" => "briche@podio.com"} 11 | 12 | s.ios.deployment_target = '7.0' 13 | s.osx.deployment_target = '10.9' 14 | s.requires_arc = true 15 | 16 | s.default_subspec = 'Common' 17 | 18 | s.subspec 'Common' do |sp| 19 | sp.source_files = 'PodioKit/Common/**/*.{h,m}' 20 | sp.public_header_files = 'PodioKit/Common/**/*.h' 21 | sp.prefix_header_file = 'PodioKit/Common/PodioKit-Prefix.pch' 22 | 23 | sp.ios.source_files = 'PodioKit/UIKit/**/*.{h,m}' 24 | sp.ios.public_header_files = 'PodioKit/UIKit/*.h' 25 | sp.ios.frameworks = 'UIKit' 26 | end 27 | 28 | s.subspec 'Push' do |sp| 29 | sp.source_files = 'PodioKit/Push/**/*.{h,m}' 30 | sp.public_header_files = 'PodioKit/Push/**/*.h' 31 | 32 | sp.dependency 'PodioKit/Common' 33 | sp.dependency 'DDCometClient', '~> 1.0' 34 | sp.dependency 'FXReachability', '~> 1.3' 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /PodioKitTests/PKTCommentAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCommentAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTCommentsAPI.h" 11 | 12 | @interface PKTCommentAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTCommentAPITests 17 | 18 | - (void)testExample { 19 | NSURL *embedURL = [NSURL URLWithString:@"https://www.google.com"]; 20 | PKTRequest *request = [PKTCommentsAPI requestToAddCommentToObjectWithReferenceID:123 21 | referenceType:PKTReferenceTypeItem 22 | value:@"Some text" 23 | files:@[@1, @2] 24 | embedID:222 25 | embedURL:embedURL]; 26 | expect(request.path).to.equal(@"/comment/item/123/"); 27 | expect(request.parameters[@"value"]).to.equal(@"Some text"); 28 | expect(request.parameters[@"file_ids"]).to.equal(@[@1, @2]); 29 | expect(request.parameters[@"embed_id"]).to.equal(222); 30 | expect(request.parameters[@"embed_url"]).to.equal([embedURL absoluteString]); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PodioKit/Common/Core/PKTKeychainTokenStore.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTKeychainTokenStore.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 10/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTKeychainTokenStore.h" 10 | #import "PKTKeychain.h" 11 | 12 | static NSString * const kTokenKeychainKey = @"PodioKitOAuthToken"; 13 | 14 | @interface PKTKeychainTokenStore () 15 | 16 | @end 17 | 18 | @implementation PKTKeychainTokenStore 19 | 20 | - (instancetype)initWithService:(NSString *)service { 21 | return [self initWithService:service accessGroup:nil]; 22 | } 23 | 24 | - (instancetype)initWithService:(NSString *)service accessGroup:(NSString *)accessGroup { 25 | PKTKeychain *keychain = [PKTKeychain keychainForService:service accessGroup:accessGroup]; 26 | return [self initWithKeychain:keychain]; 27 | } 28 | 29 | - (instancetype)initWithKeychain:(PKTKeychain *)keychain { 30 | self = [super init]; 31 | if (!self) return nil; 32 | 33 | _keychain = keychain; 34 | 35 | return self; 36 | } 37 | 38 | #pragma mark - PKTTokenStore 39 | 40 | - (void)storeToken:(PKTOAuth2Token *)token { 41 | [self.keychain setObject:token forKey:kTokenKeychainKey]; 42 | } 43 | 44 | - (void)deleteStoredToken { 45 | [self.keychain removeObjectForKey:kTokenKeychainKey]; 46 | } 47 | 48 | - (PKTOAuth2Token *)storedToken { 49 | return [self.keychain objectForKey:kTokenKeychainKey]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSDateFormatter+PKTAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+PKTAdditions.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSDateFormatter+PKTAdditions.h" 10 | 11 | @implementation NSDateFormatter (PKTAdditions) 12 | 13 | + (NSDateFormatter *)pkt_UTCDateFormatter { 14 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 15 | formatter.dateFormat = @"yyyy-MM-dd"; 16 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 17 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; 18 | 19 | return formatter; 20 | } 21 | 22 | + (NSDateFormatter *)pkt_UTCDateTimeFormatter { 23 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 24 | formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; 25 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 26 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; 27 | 28 | return formatter; 29 | } 30 | 31 | + (NSDateFormatter *)pkt_UTCTimeFormatter { 32 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 33 | formatter.dateFormat = @"HH:mm:ss"; 34 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 35 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; 36 | 37 | return formatter; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTCommentsAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCommentsAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTCommentsAPI.h" 10 | #import "NSValueTransformer+PKTConstants.h" 11 | 12 | @implementation PKTCommentsAPI 13 | 14 | + (PKTRequest *)requestToAddCommentToObjectWithReferenceID:(NSUInteger)referenceID referenceType:(PKTReferenceType)referenceType value:(NSString *)value files:(NSArray *)files embedID:(NSUInteger)embedID embedURL:(NSURL *)embedURL { 15 | NSParameterAssert(referenceID > 0); 16 | NSParameterAssert(referenceType != PKTReferenceTypeUnknown); 17 | NSParameterAssert(value); 18 | 19 | NSString *refTypeString = [NSValueTransformer pkt_stringFromReferenceType:referenceType]; 20 | NSString *path = PKTRequestPath(@"/comment/%@/%lu/", refTypeString, (unsigned long)referenceID); 21 | 22 | NSMutableDictionary *parameters = [NSMutableDictionary new]; 23 | parameters[@"value"] = value; 24 | 25 | if ([files count] > 0) { 26 | parameters[@"file_ids"] = files; 27 | } 28 | 29 | if (embedID > 0) { 30 | parameters[@"embed_id"] = @(embedID); 31 | } 32 | 33 | if (embedURL) { 34 | parameters[@"embed_url"] = [embedURL absoluteString]; 35 | } 36 | 37 | PKTRequest *request = [PKTRequest POSTRequestWithPath:path parameters:parameters]; 38 | 39 | return request; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTItemsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTItemsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 31/03/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTItemsAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForItemWithID:(NSUInteger)itemID; 14 | 15 | + (PKTRequest *)requestForItemWithExternalID:(NSUInteger)externalID inAppWithID:(NSUInteger)appID; 16 | 17 | + (PKTRequest *)requestForReferencesForItemWithID:(NSUInteger)itemID; 18 | 19 | + (PKTRequest *)requestForFilteredItemsInAppWithID:(NSUInteger)appID offset:(NSUInteger)offset limit:(NSUInteger)limit sortBy:(NSString *)sortBy descending:(BOOL)descending remember:(BOOL)remember; 20 | 21 | + (PKTRequest *)requestForFilteredItemsInAppWithID:(NSUInteger)appID offset:(NSUInteger)offset limit:(NSUInteger)limit sortBy:(NSString *)sortBy descending:(BOOL)descending remember:(BOOL)remember filters:(NSDictionary *)filters; 22 | 23 | + (PKTRequest *)requestForFilteredItemsInAppWithID:(NSUInteger)appID offset:(NSUInteger)offset limit:(NSUInteger)limit viewID:(NSUInteger)viewID remember:(BOOL)remember; 24 | 25 | + (PKTRequest *)requestToCreateItemInAppWithID:(NSUInteger)appID fields:(NSDictionary *)fields files:(NSArray *)files tags:(NSArray *)tags; 26 | 27 | + (PKTRequest *)requestToUpdateItemWithID:(NSUInteger)itemID fields:(NSDictionary *)fields files:(NSArray *)files tags:(NSArray *)tags; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTCalendarAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTCalendarAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | @interface PKTCalendarAPI : PKTBaseAPI 12 | 13 | + (PKTRequest *)requestForGlobalCalendarWithFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority; 14 | 15 | + (PKTRequest *)requestForGlobalCalendarWithFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority includeTasks:(BOOL)tasksIncluded; 16 | 17 | + (PKTRequest *)requestForAppCalendarWithAppId:(NSUInteger)appId fromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority; 18 | 19 | + (PKTRequest *)requestForAppCalendarWithAppId:(NSUInteger)appId fromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority includeTasks:(BOOL)tasksIncluded; 20 | 21 | + (PKTRequest *)requestForSpaceCalendarWithSpaceId:(NSUInteger)spaceId fromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority; 22 | 23 | + (PKTRequest *)requestForSpaceCalendarWithSpaceId:(NSUInteger)spaceId fromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority includeTasks:(BOOL)tasksIncluded; 24 | 25 | + (NSDictionary *)getParamsForCalendarRequestFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate priority:(NSUInteger)priority includeTasks:(BOOL)tasksIncluded; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTWorkspacesAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTWorkspacesAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/08/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTWorkspacesAPI.h" 10 | 11 | @implementation PKTWorkspacesAPI 12 | 13 | + (PKTRequest *)requestForWorkspaceWithID:(NSUInteger)workspaceID { 14 | return [PKTRequest GETRequestWithPath:PKTRequestPath(@"/space/%lu", (unsigned long)workspaceID) parameters:nil]; 15 | } 16 | 17 | + (PKTRequest *)requestToCreateWorkspaceWithName:(NSString *)name organizationID:(NSUInteger)organizationID privacy:(PKTWorkspacePrivacy)privacy { 18 | NSParameterAssert(name); 19 | NSParameterAssert(organizationID > 0); 20 | 21 | NSMutableDictionary *params = [NSMutableDictionary new]; 22 | params[@"name"] = name; 23 | params[@"org_id"] = @(organizationID); 24 | 25 | switch (privacy) { 26 | case PKTWorkspacePrivacyOpen: 27 | params[@"privacy"] = @"open"; 28 | break; 29 | case PKTWorkspacePrivacyClosed: 30 | params[@"privacy"] = @"closed"; 31 | break; 32 | default: 33 | break; 34 | } 35 | 36 | return [PKTRequest POSTRequestWithPath:@"/space/" parameters:params]; 37 | } 38 | 39 | + (PKTRequest *)requestForWorkspaceWithURLString:(NSString *)urlString { 40 | NSParameterAssert(urlString); 41 | 42 | return [PKTRequest GETRequestWithPath:@"/space/url" parameters:@{@"url": urlString}]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTWorkspaceMembersAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTWorkspaceMembersAPI.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 19/08/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTWorkspaceMembersAPI.h" 10 | 11 | @implementation PKTWorkspaceMembersAPI 12 | 13 | + (PKTRequest *)requestToAddMembersToSpaceWithID:(NSUInteger)workspaceID role:(PKTWorkspaceMemberRole)role message:(NSString *)message userIDs:(NSArray *)userIDs profileIDs:(NSArray *)profileIDs emails:(NSArray *)emails { 14 | NSMutableDictionary *params = [NSMutableDictionary new]; 15 | 16 | if (message) { 17 | params[@"message"] = message; 18 | } 19 | 20 | switch (role) { 21 | case PKTWorkspaceMemberRoleAdmin: 22 | params[@"role"] = @"admin"; 23 | break; 24 | case PKTWorkspaceMemberRoleRegular: 25 | params[@"role"] = @"regular"; 26 | break; 27 | case PKTWorkspaceMemberRoleLight: 28 | params[@"role"] = @"light"; 29 | break; 30 | default: 31 | break; 32 | } 33 | 34 | if ([userIDs count] > 0) { 35 | params[@"users"] = userIDs; 36 | } 37 | 38 | if ([profileIDs count] > 0) { 39 | params[@"profiles"] = profileIDs; 40 | } 41 | 42 | if ([emails count] > 0) { 43 | params[@"mails"] = emails; 44 | } 45 | 46 | return [PKTRequest POSTRequestWithPath:PKTRequestPath(@"/space/%lu/member/", (unsigned long)workspaceID) parameters:params]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTNotificationContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationContext.h 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 20/03/15. 6 | // Copyright (c) 2015 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTConstants.h" 11 | 12 | @class PKTReference, PKTWorkspace, PKTOrganization; 13 | 14 | @interface PKTNotificationContext : PKTModel 15 | 16 | /* 17 | * The reference of the context 18 | */ 19 | @property (nonatomic, strong, readonly) PKTReference *reference; 20 | 21 | /* 22 | * The data of the context, depends on the type of reference 23 | */ 24 | @property (nonatomic, strong, readonly) id data; 25 | 26 | /* 27 | * The title of the context 28 | */ 29 | @property (nonatomic, copy, readonly) NSString *title; 30 | 31 | /* 32 | * The list of rights the active user has on the context 33 | */ 34 | @property (nonatomic, assign, readonly) PKTRight rights; 35 | 36 | /* 37 | * The number of comments on the objects (only for objects of type status, task and item) 38 | */ 39 | @property (nonatomic, assign, readonly) NSUInteger commentCount; 40 | 41 | /* 42 | * The space the context belongs to, if any 43 | */ 44 | @property (nonatomic, strong, readonly) PKTWorkspace *space; 45 | 46 | /* 47 | * The organization the context belongs to, if any 48 | */ 49 | @property (nonatomic, strong, readonly) PKTOrganization *org; 50 | 51 | /* 52 | * The link of the context 53 | */ 54 | @property (nonatomic, copy, readonly) NSURL *link; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTContactsAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTContactsAPI.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 18/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTBaseAPI.h" 10 | 11 | typedef NS_OPTIONS(NSUInteger, PKTContactType) { 12 | PKTContactTypeUser = 1 << 0, 13 | PKTContactTypeSpace = 1 << 1, 14 | }; 15 | 16 | typedef NS_ENUM(NSUInteger, PKTContactsOrdering) { 17 | PKTContactsOrderingDefault = 0, 18 | PKTContactsOrderingAssign, 19 | PKTContactsOrderingMessage, 20 | PKTContactsOrderingReference, 21 | PKTContactsOrderingAlert, 22 | PKTContactsOrderingOverall 23 | }; 24 | 25 | @interface PKTContactsAPI : PKTBaseAPI 26 | 27 | + (PKTRequest *)requestForContactWithUserID:(NSUInteger)userID; 28 | 29 | + (PKTRequest *)requestForContactWithProfileID:(NSUInteger)profileID; 30 | 31 | + (PKTRequest *)requestForContactsWithProfileIDs:(NSArray *)profileIDs; 32 | 33 | + (PKTRequest *)requestForContactsInWorkspaceWithID:(NSUInteger)workspaceID contactType:(PKTContactType)contactType excludeSelf:(BOOL)excludeSelf ordering:(PKTContactsOrdering)ordering fields:(NSDictionary *)fields requiredFields:(NSArray *)requiredFields offset:(NSUInteger)offset limit:(NSUInteger)limit; 34 | 35 | + (PKTRequest *)requestForContactsOfType:(PKTContactType)contactType excludeSelf:(BOOL)excludeSelf ordering:(PKTContactsOrdering)ordering fields:(NSDictionary *)fields requiredFields:(NSArray *)requiredFields offset:(NSUInteger)offset limit:(NSUInteger)limit; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | activesupport (3.2.19) 5 | i18n (~> 0.6, >= 0.6.4) 6 | multi_json (~> 1.0) 7 | claide (0.6.1) 8 | cocoapods (0.33.1) 9 | activesupport (>= 3.2.15, < 4) 10 | claide (~> 0.6.1) 11 | cocoapods-core (= 0.33.1) 12 | cocoapods-downloader (~> 0.6.1) 13 | cocoapods-plugins (~> 0.2.0) 14 | cocoapods-trunk (~> 0.1.1) 15 | cocoapods-try (~> 0.3.0) 16 | colored (~> 1.2) 17 | escape (~> 0.0.4) 18 | json_pure (~> 1.8) 19 | nap (~> 0.7) 20 | open4 (~> 1.3) 21 | xcodeproj (~> 0.17.0) 22 | cocoapods-core (0.33.1) 23 | activesupport (>= 3.2.15) 24 | fuzzy_match (~> 2.0.4) 25 | json_pure (~> 1.8) 26 | nap (~> 0.5) 27 | cocoapods-downloader (0.6.1) 28 | cocoapods-plugins (0.2.0) 29 | nap 30 | cocoapods-trunk (0.1.4) 31 | json_pure (~> 1.8) 32 | nap (>= 0.6) 33 | netrc 34 | cocoapods-try (0.3.0) 35 | colored (1.2) 36 | escape (0.0.4) 37 | fuzzy_match (2.0.4) 38 | i18n (0.6.11) 39 | json (1.8.1) 40 | json_pure (1.8.1) 41 | multi_json (1.10.1) 42 | nap (0.8.0) 43 | netrc (0.7.7) 44 | open4 (1.3.4) 45 | rake (10.4.2) 46 | travis-lint (2.0.0) 47 | json 48 | xcodeproj (0.17.0) 49 | activesupport (~> 3.0) 50 | colored (~> 1.2) 51 | xcpretty (0.1.6) 52 | 53 | PLATFORMS 54 | ruby 55 | 56 | DEPENDENCIES 57 | cocoapods 58 | rake 59 | travis-lint 60 | xcpretty 61 | -------------------------------------------------------------------------------- /PodioKit/Push/PKTPushClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTPushClient.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/10/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTPushEvent.h" 11 | #import "PKTPushCredential.h" 12 | 13 | typedef void (^PKTPushEventBlock) (PKTPushEvent *event); 14 | 15 | @interface PKTPushSubscription : NSObject 16 | 17 | - (void)unsubscribe; 18 | 19 | @end 20 | 21 | @interface PKTPushClient : NSObject 22 | 23 | @property (nonatomic, copy) NSURL *endpointURL; 24 | 25 | /** 26 | * The shared singleton push client. 27 | * 28 | * @return The shared push client. 29 | */ 30 | + (PKTPushClient *)sharedClient; 31 | 32 | /** 33 | * Subscribe to a specific channel for a specific set of credentials, retrieved from the domain object to subscribe to. 34 | * 35 | * @param credential The push credential 36 | * @param eventBlock The event block to be executed whenever a new event occurs. The event block will be retained 37 | * by the client, so beware of retain cycles. 38 | * 39 | * @return The subscription. 40 | */ 41 | - (PKTPushSubscription *)subscribeWithCredential:(PKTPushCredential *)credential eventBlock:(PKTPushEventBlock)eventBlock; 42 | 43 | /** 44 | * Unsubscribe from a subscription. 45 | * 46 | * @see see -subscribeWithCredential:eventBlock: 47 | * 48 | * @param token The subscription to unsubscribe from. 49 | */ 50 | - (void)unsubscribe:(PKTPushSubscription *)subscription; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTFile.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTFile.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 27/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTModel.h" 10 | #import "PKTClient.h" 11 | #import "PKTConstants.h" 12 | 13 | @interface PKTFile : PKTModel 14 | 15 | @property (nonatomic, assign, readonly) NSUInteger fileID; 16 | @property (nonatomic, assign, readonly) NSUInteger size; 17 | @property (nonatomic, copy, readonly) NSString *name; 18 | @property (nonatomic, copy, readonly) NSString *fileDescription; 19 | @property (nonatomic, copy, readonly) NSString *mimeType; 20 | @property (nonatomic, copy, readonly) NSString *hostedBy; 21 | @property (nonatomic, copy, readonly) NSURL *link; 22 | @property (nonatomic, copy, readonly) NSURL *thumbnailLink; 23 | @property (nonatomic, copy, readonly) NSDate *createdOn; 24 | 25 | #pragma mrk - API 26 | 27 | + (PKTAsyncTask *)uploadWithData:(NSData *)data fileName:(NSString *)fileName; 28 | 29 | + (PKTAsyncTask *)uploadWithPath:(NSString *)filePath fileName:(NSString *)fileName; 30 | 31 | - (PKTAsyncTask *)attachWithReferenceID:(NSUInteger)referenceID referenceType:(PKTReferenceType)referenceType; 32 | 33 | + (PKTAsyncTask *)downloadFileWithURL:(NSURL *)fileURL; 34 | 35 | + (PKTAsyncTask *)downloadFileWithURL:(NSURL *)fileURL toFileWithPath:(NSString *)filePath; 36 | 37 | - (PKTAsyncTask *)download; 38 | 39 | - (PKTAsyncTask *)downloadToFileWithPath:(NSString *)filePath; 40 | 41 | - (NSURL *)downloadURLForImageSize:(PKTImageSize)imageSize; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+PKTBase64.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString(PKTBase64) 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 02/06/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "NSString+PKTBase64.h" 11 | 12 | @implementation NSString (PKTBase64) 13 | 14 | - (NSString *)pkt_base64String { 15 | NSData *data = [NSData dataWithBytes:[self UTF8String] length:[self lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; 16 | const uint8_t* input = (const uint8_t*)[data bytes]; 17 | NSInteger length = [data length]; 18 | 19 | static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 20 | 21 | NSMutableData* outputData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; 22 | uint8_t* output = (uint8_t*)outputData.mutableBytes; 23 | 24 | NSInteger i; 25 | for (i=0; i < length; i += 3) { 26 | NSInteger value = 0; 27 | NSInteger j; 28 | for (j = i; j < (i + 3); j++) { 29 | value <<= 8; 30 | 31 | if (j < length) { 32 | value |= (0xFF & input[j]); 33 | } 34 | } 35 | 36 | NSInteger theIndex = (i / 3) * 4; 37 | output[theIndex + 0] = table[(value >> 18) & 0x3F]; 38 | output[theIndex + 1] = table[(value >> 12) & 0x3F]; 39 | output[theIndex + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '='; 40 | output[theIndex + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '='; 41 | } 42 | 43 | return [[NSString alloc] initWithData:outputData encoding:NSASCIIStringEncoding]; 44 | } 45 | 46 | @end -------------------------------------------------------------------------------- /PodioKitTests/NSDictionary+PKTQueryParametersTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+PKTQueryParametersTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSDictionary+PKTQueryParameters.h" 11 | 12 | @interface NSDictionary_PKTQueryParametersTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSDictionary_PKTQueryParametersTests 17 | 18 | - (void)testUnescapedSerializeQueryParameters { 19 | NSString *queryString = [@{@"email1" : @"name1@domain.com", @"email2" : @"name2@domain.com"} pkt_queryString]; 20 | expect(queryString).to.equal(@"email2=name2@domain.com&email1=name1@domain.com"); 21 | } 22 | 23 | - (void)testEscapedSerializeQueryParameters { 24 | NSString *queryString = [@{@"email1" : @"name1@domain.com", @"email2" : @"name2@domain.com"} pkt_escapedQueryString]; 25 | expect(queryString).to.equal(@"email2=name2%40domain.com&email1=name1%40domain.com"); 26 | } 27 | 28 | - (void)testNestedSerializeQueryParameters { 29 | NSDictionary *params = @{@"level1" : @{@"param1" : @"value1"}, 30 | @"level2" : @{@"level21" : @{@"param21" : @"value21"}}, 31 | @"param2" : @"value2", 32 | }; 33 | 34 | NSString *queryString = [params pkt_queryString]; 35 | expect(queryString).to.contain(@"level1[param1]=value1"); 36 | expect(queryString).to.contain(@"level2[level21][param21]=value21"); 37 | expect(queryString).to.contain(@"param2=value2"); 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PodioKitTests/PKTHTTPStubs.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTHTTPStubs.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTHTTPStubs.h" 11 | 12 | @implementation PKTHTTPStubs 13 | 14 | + (void)stubResponseForPath:(NSString *)path block:(void (^)(PKTHTTPStubber *stubber))block { 15 | PKTHTTPStubber *stubber = [PKTHTTPStubber stubberForPath:path]; 16 | 17 | if (block) block(stubber); 18 | 19 | [stubber stub]; 20 | } 21 | 22 | + (void)stubResponseForPath:(NSString *)path responseObject:(id)responseObject { 23 | return [self stubResponseForPath:path block:^(PKTHTTPStubber *stubber) { 24 | stubber.responseObject = responseObject; 25 | }]; 26 | } 27 | 28 | + (void)stubResponseForPath:(NSString *)path statusCode:(int)statusCode { 29 | return [self stubResponseForPath:path block:^(PKTHTTPStubber *stubber) { 30 | stubber.statusCode = statusCode; 31 | }]; 32 | } 33 | 34 | + (void)stubResponseForPath:(NSString *)path requestTime:(int)requestTime responseTime:(int)responseTime { 35 | return [self stubResponseForPath:path block:^(PKTHTTPStubber *stubber) { 36 | stubber.requestTime = requestTime; 37 | stubber.responseTime = responseTime; 38 | }]; 39 | } 40 | 41 | + (void)stubNetworkDownForPath:(NSString *)path { 42 | return [self stubResponseForPath:path block:^(PKTHTTPStubber *stubber) { 43 | stubber.error = [NSError errorWithDomain:NSURLErrorDomain code:kCFURLErrorNotConnectedToInternet userInfo:nil]; 44 | }]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDuration.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDuration 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 15/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDuration.h" 10 | 11 | static NSUInteger const kSecondsInHour = 3600; 12 | static NSUInteger const kSecondsInMinute = 60; 13 | 14 | @implementation PKTDuration 15 | 16 | - (instancetype)initWithHours:(NSUInteger)hours minutes:(NSUInteger)minutes seconds:(NSUInteger)seconds { 17 | self = [super init]; 18 | if (!self) return nil; 19 | 20 | _hours = hours; 21 | _minutes = minutes; 22 | _seconds = seconds; 23 | 24 | return self; 25 | } 26 | 27 | - (instancetype)initWithTotalSeconds:(NSUInteger)totalSeconds { 28 | self = [super init]; 29 | if (!self) return nil; 30 | 31 | self.totalSeconds = totalSeconds; 32 | 33 | return self; 34 | } 35 | 36 | #pragma mark - Properties 37 | 38 | - (NSUInteger)totalSeconds { 39 | return self.hours * kSecondsInHour + self.minutes * kSecondsInMinute + self.seconds; 40 | } 41 | 42 | - (void)setTotalSeconds:(NSUInteger)totalSeconds { 43 | NSUInteger remainingSeconds = totalSeconds; 44 | 45 | self.hours = remainingSeconds / kSecondsInHour; 46 | 47 | remainingSeconds -= self.hours * kSecondsInHour; 48 | self.minutes = remainingSeconds / kSecondsInMinute; 49 | 50 | remainingSeconds -= self.minutes * kSecondsInMinute; 51 | self.seconds = remainingSeconds; 52 | } 53 | 54 | #pragma mark - PKTModel 55 | 56 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 57 | return @{ 58 | @"totalSeconds" : @"value" 59 | }; 60 | } 61 | 62 | @end -------------------------------------------------------------------------------- /PodioKitTests/NSString+PKTURL.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURL.m 3 | // PodioKit 4 | // 5 | // Created by Romain Briche on 22/01/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSString+PKTURL.h" 10 | 11 | @implementation NSString (PKTURL) 12 | 13 | - (instancetype)pkt_escapedURLString { 14 | NSString *escapedString = (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, 15 | (__bridge CFStringRef)self, 16 | NULL, 17 | (CFStringRef) @"!*'();:@&=+$,/?%#[]", 18 | kCFStringEncodingUTF8); 19 | return escapedString; 20 | } 21 | 22 | - (instancetype)pkt_unescapedURLString { 23 | NSString *unescapedString = (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, 24 | (__bridge CFStringRef)self, 25 | CFSTR(""), 26 | kCFStringEncodingUTF8); 27 | return unescapedString; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PodioKit/Common/API/PKTNotificationsRequestParameters.h: -------------------------------------------------------------------------------- 1 | // 2 | // PKTNotificationsRequestParameters.h 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 08/09/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTRequestParameters.h" 11 | #import "PKTConstants.h" 12 | 13 | typedef NS_ENUM(NSUInteger, PKTNotificationDirection) { 14 | PKTNotificationDirectionDefault = 0, 15 | PKTNotificationDirectionIncoming, 16 | PKTNotificationDirectionOutgoing 17 | }; 18 | 19 | typedef NS_ENUM(NSUInteger, PKTNotificationStarredState) { 20 | PKTNotificationStarredStateDefault = 0, 21 | PKTNotificationStarredStateStarred, 22 | PKTNotificationStarredStateUnstarred 23 | }; 24 | 25 | typedef NS_ENUM(NSUInteger, PKTNotificationViewedState) { 26 | PKTNotificationViewedStateDefault = 0, 27 | PKTNotificationViewedStateNotViewed, 28 | PKTNotificationViewedStateViewed 29 | }; 30 | 31 | @interface PKTNotificationsRequestParameters : NSObject 32 | 33 | @property (nonatomic, assign) PKTReferenceType contextType; 34 | @property (nonatomic, assign) PKTNotificationDirection direction; 35 | @property (nonatomic, assign) PKTNotificationStarredState starred; 36 | @property (nonatomic, assign) PKTNotificationViewedState viewed; 37 | @property (nonatomic, assign) PKTNotificationType notificationType; 38 | @property (nonatomic, assign) NSUInteger userID; 39 | @property (nonatomic, copy) NSDate *createdFromDate; 40 | @property (nonatomic, copy) NSDate *createdToDate; 41 | @property (nonatomic, copy) NSDate *viewedFromDate; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTAppFieldConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppFieldConfig 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 16/05/14 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | 10 | #import "PKTAppFieldConfig.h" 11 | #import "NSValueTransformer+PKTTransformers.h" 12 | 13 | @implementation PKTAppFieldConfig 14 | 15 | - (instancetype)initWithLabel:(NSString *)label 16 | description:(NSString *)description 17 | settings:(NSDictionary *)settings 18 | delta:(NSUInteger)delta 19 | mapping:(PKTAppFieldMapping)mapping 20 | isRequired:(BOOL)isRequired 21 | isVisible:(BOOL)isVisible { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _label = [label copy]; 26 | _descr = [description copy]; 27 | _settings = [settings copy]; 28 | _delta = delta; 29 | _mapping = mapping; 30 | _required = isRequired; 31 | _visible = isVisible; 32 | 33 | return self; 34 | } 35 | 36 | #pragma mark - PKTModel 37 | 38 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 39 | return @{ 40 | @"descr" : @"description", 41 | }; 42 | } 43 | 44 | + (NSValueTransformer *)mappingValueTransformer { 45 | return [NSValueTransformer pkt_transformerWithDictionary:@{ 46 | @"meeting_time" : @(PKTAppFieldMappingMeetingTime), 47 | @"meeting_participants" : @(PKTAppFieldMappingMeetingParticipants), 48 | @"meeting_agenda" : @(PKTAppFieldMappingMeetingAgenda), 49 | @"meeting_location" : @(PKTAppFieldMappingMeetingLocation), 50 | }]; 51 | } 52 | 53 | @end -------------------------------------------------------------------------------- /PodioKit/Common/Support/NSString+ PKTURLEncode.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+PKTURLEncode.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 09/07/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSString+PKTURLEncode.h" 10 | 11 | @implementation NSString (PKTURLEncode) 12 | 13 | - (NSString *)pkt_encodeString { 14 | NSString *escapedString = (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, 15 | (__bridge CFStringRef)self, 16 | NULL, 17 | (CFStringRef) @"!*'();:@&=+$,/?%#[]", 18 | kCFStringEncodingUTF8); 19 | return escapedString; 20 | } 21 | 22 | - (NSString *)pkt_decodeString { 23 | NSString *escapedString = (__bridge_transfer NSString *) CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, 24 | (__bridge CFStringRef)self, 25 | CFSTR(""), 26 | kCFStringEncodingUTF8); 27 | return escapedString; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PodioKit/Common/PodioKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // PodioKit.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 21/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PodioKit.h" 10 | #import "PKTClient.h" 11 | 12 | @implementation PodioKit 13 | 14 | + (void)setupWithAPIKey:(NSString *)key secret:(NSString *)secret { 15 | [[PKTClient currentClient] setupWithAPIKey:key secret:secret]; 16 | } 17 | 18 | + (PKTAsyncTask *)authenticateAsUserWithEmail:(NSString *)email password:(NSString *)password { 19 | return [[PKTClient currentClient] authenticateAsUserWithEmail:email password:password]; 20 | } 21 | 22 | + (PKTAsyncTask *)authenticateAsAppWithID:(NSUInteger)appID token:(NSString *)appToken { 23 | return [[PKTClient currentClient] authenticateAsAppWithID:appID token:appToken]; 24 | } 25 | 26 | + (void)authenticateAutomaticallyAsAppWithID:(NSUInteger)appID token:(NSString *)appToken { 27 | [[PKTClient currentClient] authenticateAutomaticallyAsAppWithID:appID token:appToken]; 28 | } 29 | 30 | + (BOOL)isAuthenticated { 31 | return [[PKTClient currentClient] isAuthenticated]; 32 | } 33 | 34 | + (void)automaticallyStoreTokenInKeychainForServiceWithName:(NSString *)name { 35 | [PKTClient currentClient].tokenStore = [[PKTKeychainTokenStore alloc] initWithService:name]; 36 | [[PKTClient currentClient] restoreTokenIfNeeded]; 37 | } 38 | 39 | + (void)automaticallyStoreTokenInKeychainForCurrentApp { 40 | NSString *name = [[NSBundle mainBundle] objectForInfoDictionaryKey:(__bridge id)kCFBundleIdentifierKey]; 41 | [self automaticallyStoreTokenInKeychainForServiceWithName:name]; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /PodioKitTests/PKTAppAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTAppAPITests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 03/04/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTAppsAPI.h" 11 | 12 | @interface PKTAppAPITests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PKTAppAPITests 17 | 18 | - (void)testRequestForGetApp { 19 | PKTRequest *request = [PKTAppsAPI requestForAppWithID:123]; 20 | 21 | expect(request.path).to.equal(@"/app/123"); 22 | expect(request.method).to.equal(PKTRequestMethodGET); 23 | } 24 | 25 | - (void)testRequestForMostFrequentlyUsedApps { 26 | NSUInteger limit = 5; 27 | PKTRequest *request = [PKTAppsAPI requestForMostFrequentlyUsedApps:limit]; 28 | 29 | expect(request.path).to.equal(@"/app/top/"); 30 | expect(request.method).to.equal(PKTRequestMethodGET); 31 | expect(request.parameters[@"limit"]).to.equal(@(limit)); 32 | } 33 | 34 | - (void)testRequestToAddAppToWorkspace { 35 | PKTRequest *request = [PKTAppsAPI requestToAddAppToWorkspaceWithID:123 fields:@{@"text" : @"Some text"}]; 36 | 37 | expect(request.path).to.equal(@"/app/"); 38 | expect(request.method).to.equal(PKTRequestMethodPOST); 39 | expect(request.parameters[@"space_id"]).to.equal(@123); 40 | expect(request.parameters[@"fields"]).to.equal(@{@"text" : @"Some text"}); 41 | } 42 | 43 | - (void)testRequestForAppByURLLabel { 44 | PKTRequest *request = [PKTAppsAPI requestForAppInWorkspaceWithID:123 urlLabel:@"text"]; 45 | 46 | expect(request.path).to.equal(@"/app/space/123/text"); 47 | expect(request.method).to.equal(PKTRequestMethodGET); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /PodioKit/Common/Models/PKTDateRange.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTDateRange.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 14/05/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import "PKTDateRange.h" 10 | #import "NSValueTransformer+PKTTransformers.h" 11 | 12 | @implementation PKTDateRange 13 | 14 | - (instancetype)initWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate { 15 | self = [super init]; 16 | if (!self) return nil; 17 | 18 | _startDate = [startDate copy]; 19 | _endDate = [endDate copy]; 20 | _includesTimeComponent = YES; 21 | 22 | return self; 23 | } 24 | 25 | + (instancetype)rangeWithStartDate:(NSDate *)startDate { 26 | return [[self alloc] initWithStartDate:startDate endDate:nil]; 27 | } 28 | 29 | + (instancetype)rangeWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate { 30 | return [[self alloc] initWithStartDate:startDate endDate:endDate]; 31 | } 32 | 33 | #pragma mark - PKTModel 34 | 35 | + (NSDictionary *)dictionaryKeyPathsForPropertyNames { 36 | return @{ 37 | @"startDate" : @"start_utc", 38 | @"endDate" : @"end_utc", 39 | @"includesTimeComponent" : @"start_time_utc", 40 | }; 41 | } 42 | 43 | + (NSValueTransformer *)startDateValueTransformer { 44 | return [NSValueTransformer pkt_dateValueTransformer]; 45 | } 46 | 47 | + (NSValueTransformer *)endDateValueTransformer { 48 | return [NSValueTransformer pkt_dateValueTransformer]; 49 | } 50 | 51 | + (NSValueTransformer *)includesTimeComponentValueTransformer { 52 | return [NSValueTransformer pkt_transformerWithBlock:^id(NSString *timeString) { 53 | return @(timeString != nil); 54 | }]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /PodioKitTests/PKTImageCacheTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PKTImageCacheTests.m 3 | // PodioKit 4 | // 5 | // Created by Sebastian Rehnby on 25/06/14. 6 | // Copyright (c) 2014 Citrix Systems, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PKTImageCache.h" 11 | #import "PKTFile.h" 12 | 13 | @interface PKTImageCacheTests : XCTestCase 14 | 15 | @end 16 | 17 | @implementation PKTImageCacheTests 18 | 19 | - (void)testSetAndGetImage { 20 | PKTFile *file = [[self class] dummyFile]; 21 | UIImage *image = [[self class] dummyImage]; 22 | 23 | PKTImageCache *cache = [PKTImageCache new]; 24 | expect([cache cachedImageForFile:file]).to.beNil(); 25 | 26 | [cache setCachedImage:image forFile:file]; 27 | expect([cache cachedImageForFile:file]).to.equal(image); 28 | } 29 | 30 | - (void)testClearCache { 31 | PKTFile *file = [[self class] dummyFile]; 32 | UIImage *image = [[self class] dummyImage]; 33 | 34 | PKTImageCache *cache = [PKTImageCache new]; 35 | [cache setCachedImage:image forFile:file]; 36 | 37 | [cache clearCache]; 38 | expect([cache cachedImageForFile:file]).to.beNil(); 39 | } 40 | 41 | #pragma mark - Helpers 42 | 43 | + (UIImage *)dummyImage { 44 | static UIImage *image = nil; 45 | static dispatch_once_t onceToken; 46 | 47 | dispatch_once(&onceToken, ^{ 48 | NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Podio" ofType:@"png"]; 49 | image = [UIImage imageWithContentsOfFile:path]; 50 | }); 51 | 52 | return image; 53 | } 54 | 55 | + (PKTFile *)dummyFile { 56 | return [[PKTFile alloc] initWithDictionary:@{ 57 | @"file_id" : @11111, 58 | @"link" : @"https://files.podio.com/11111" 59 | }]; 60 | } 61 | 62 | @end 63 | --------------------------------------------------------------------------------