RLMJSONModels.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2017 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Foundation/Foundation.h>
  19. #import "RLMSyncUtil_Private.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @class RLMTokenDataModel, RLMSyncUserAccountInfo;
  22. #pragma mark - RLMTokenModel
  23. @interface RLMTokenModel : NSObject RLM_SYNC_UNINITIALIZABLE
  24. @property (nonatomic, readonly) NSString *token;
  25. @property (nonatomic, nullable, readonly) NSString *path;
  26. @property (nonatomic, readonly) RLMTokenDataModel *tokenData;
  27. - (instancetype)initWithDictionary:(NSDictionary *)jsonDictionary;
  28. @end
  29. #pragma mark - RLMTokenDataModel
  30. @interface RLMTokenDataModel : NSObject RLM_SYNC_UNINITIALIZABLE
  31. @property (nonatomic, readonly) NSString *identity;
  32. @property (nonatomic, nullable, readonly) NSString *appID;
  33. @property (nonatomic, nullable, readonly) NSString *path;
  34. @property (nonatomic, readonly) NSTimeInterval expires;
  35. @property (nonatomic, readonly) BOOL isAdmin;
  36. //@property (nonatomic, readonly) NSArray *access;
  37. - (instancetype)initWithDictionary:(NSDictionary *)jsonDictionary;
  38. @end
  39. #pragma mark - RLMAuthResponseModel
  40. /**
  41. An internal class representing a valid JSON response to an auth request.
  42. ```
  43. {
  44. "access_token": { ... } // (optional),
  45. "refresh_token": { ... } // (optional)
  46. }
  47. ```
  48. */
  49. @interface RLMAuthResponseModel : NSObject RLM_SYNC_UNINITIALIZABLE
  50. @property (nonatomic, readonly, nullable) RLMTokenModel *accessToken;
  51. @property (nonatomic, readonly, nullable) RLMTokenModel *refreshToken;
  52. - (instancetype)initWithDictionary:(NSDictionary *)jsonDictionary
  53. requireAccessToken:(BOOL)requireAccessToken
  54. requireRefreshToken:(BOOL)requireRefreshToken;
  55. @end
  56. #pragma mark - RLMUserInfoResponseModel
  57. @interface RLMUserResponseModel : NSObject RLM_SYNC_UNINITIALIZABLE
  58. @property (nonatomic, readonly) NSString *identity;
  59. @property (nonatomic, readonly) NSArray<RLMSyncUserAccountInfo *> *accounts;
  60. @property (nonatomic, readonly) NSDictionary *metadata;
  61. @property (nonatomic, readonly) BOOL isAdmin;
  62. - (instancetype)initWithDictionary:(NSDictionary *)jsonDictionary;
  63. @end
  64. #pragma mark - RLMSyncErrorResponseModel
  65. @interface RLMSyncErrorResponseModel : NSObject RLM_SYNC_UNINITIALIZABLE
  66. @property (nonatomic, readonly) NSInteger status;
  67. @property (nonatomic, readonly) NSInteger code;
  68. @property (nullable, nonatomic, readonly) NSString *title;
  69. @property (nullable, nonatomic, readonly) NSString *hint;
  70. - (instancetype)initWithDictionary:(NSDictionary *)jsonDictionary;
  71. @end
  72. NS_ASSUME_NONNULL_END