PPOTAppSwitchUtil.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // PPOTAppSwitchUtil.h
  3. // PayPalOneTouch
  4. //
  5. // Copyright © 2014 PayPal, Inc. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. @class PPOTConfigurationRecipe;
  9. #define kPPOTAppSwitchCurrentVersionNumber 3
  10. // Dictionary keys for PPTouch v1 protocol
  11. #define kPPOTAppSwitchEnvironmentKey @"environment"
  12. #define kPPOTAppSwitchEnvironmentURLKey @"environment_url"
  13. #define kPPOTAppSwitchCustomEnvironmentKey @"custom"
  14. #define kPPOTAppSwitchAppNameKey @"app_name"
  15. #define kPPOTAppSwitchAppGuidKey @"app_guid"
  16. #define kPPOTAppSwitchResponseTypeKey @"response_type"
  17. #define kPPOTAppSwitchClientIdKey @"client_id"
  18. #define kPPOTAppSwitchPayloadKey @"payload"
  19. #define kPPOTAppSwitchHermesTokenKey @"token"
  20. #define kPPOTAppSwitchHermesBATokenKey @"ba_token"
  21. #define kPPOTAppSwitchXCancelKey @"x-cancel"
  22. #define kPPOTAppSwitchXSuccessKey @"x-success"
  23. #define kPPOTAppSwitchXSourceKey @"x-source"
  24. #define kPPOTAppSwitchAuthenticateAction @"authenticate"
  25. #define kPPOTAppSwitchSuccessAction @"success"
  26. #define kPPOTAppSwitchCancelAction @"cancel"
  27. #define kPPOTAppSwitchResponseTypeCode @"code"
  28. #define kPPOTAppSwitchResponseTypeToken @"token"
  29. #define kPPOTAppSwitchDisplayNameKey @"display_name"
  30. #define kPPOTAppSwitchAccessTokenKey @"access_token"
  31. #define kPPOTAppSwitchAuthorizationCodeKey @"authorization_code"
  32. #define kPPOTAppSwitchExpiresInKey @"expires_in"
  33. #define kPPOTAppSwitchScopesKey @"scope"
  34. #define kPPOTAppSwitchEmailKey @"email"
  35. #define kPPOTAppSwitchPhotoURLKey @"photo_url"
  36. #define kPPOTAppSwitchAccountCountryKey @"account_country"
  37. #define kPPOTAppSwitchLanguageKey @"language"
  38. #define kPPOTAppSwitchProtocolVersionKey @"version"
  39. #define kPPOTAppSwitchPrivacyURLKey @"privacy_url"
  40. #define kPPOTAppSwitchAgreementURLKey @"agreement_url"
  41. #define kPPOTAppSwitchErrorKey @"error"
  42. #define kPPOTAppSwitchMessageKey @"message"
  43. // v2 extension
  44. #define kPPOTAppSwitchResponseTypeWeb @"web"
  45. #define kPPOTAppSwitchWebURLKey @"webURL"
  46. // v3
  47. #define kPPOTAppSwitchMetadataClientIDKey @"client_metadata_id"
  48. #define kPPOTAppSwitchKeyIDKey @"key_id"
  49. #define kPPOTAppSwitchMsgGUIDKey @"msg_GUID"
  50. #define kPPOTAppSwitchSymKey @"sym_key"
  51. #define kPPOTAppSwitchTimestampKey @"timestamp"
  52. #define kPPOTAppSwitchLoginAction @"login"
  53. #define kPPOTAppSwitchEncryptedPayloadKey @"payloadEnc"
  54. #define kPPOTAppSwitchPaymentCodeTypeKey @"payment_code_type"
  55. #define kPPOTAppSwitchPaymentCodeKey @"payment_code"
  56. #define kPPOTAppSwitchResposneAuthCodeKey @"authcode"
  57. #define kPPOTAppSwitchKeyDeviceName @"device_name"
  58. #define PPRequestEnvironmentProduction @"live"
  59. #define PPRequestEnvironmentNoNetwork @"mock"
  60. #define PPRequestEnvironmentSandbox @"sandbox"
  61. typedef NS_ENUM(NSUInteger, PPAppSwitchResponseAction) {
  62. PPAppSwitchResponseActionUnknown,
  63. PPAppSwitchResponseActionCancel,
  64. PPAppSwitchResponseActionSuccess
  65. };
  66. typedef NS_ENUM(NSUInteger, PPAppSwitchResponseType) {
  67. PPAppSwitchResponseTypeUnknown,
  68. PPAppSwitchResponseTypeToken,
  69. PPAppSwitchResponseTypeAuthorizationCode,
  70. PPAppSwitchResponseTypeWeb,
  71. };
  72. @interface PPOTAppSwitchUtil : NSObject
  73. + (NSString *)bundleId;
  74. + (NSString *)bundleName;
  75. + (BOOL)isCallbackURLSchemeValid:(NSString *)callbackURLScheme;
  76. /**
  77. handles urlencoding
  78. */
  79. + (NSDictionary *)parseQueryString:(NSString *)query;
  80. + (NSURL *)URLAction:(NSString *)action
  81. targetAppURLScheme:(NSString *)targetAppURLScheme
  82. callbackURLScheme:(NSString *)callbackURLScheme
  83. payload:(NSDictionary *)payload;
  84. + (NSURL *)URLAction:(NSString *)action
  85. callbackURLScheme:(NSString *)callbackURLScheme
  86. payload:(NSDictionary *)payload;
  87. + (void)redirectURLsForCallbackURLScheme:(NSString *)callbackURLScheme withReturnURL:(NSString **)returnURL withCancelURL:(NSString **)cancelURL;
  88. + (BOOL)isValidURLAction:(NSURL *)urlAction;
  89. + (NSString *)actionFromURLAction:(NSURL *)urlAction;
  90. @end