GACAppCheckTokenRefreshResult.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2021 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "AppCheckCore/Sources/Core/TokenRefresh/GACAppCheckTokenRefreshResult.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @interface GACAppCheckTokenRefreshResult ()
  19. - (instancetype)initWithStatus:(GACAppCheckTokenRefreshStatus)status
  20. expirationDate:(nullable NSDate *)tokenExpirationDate
  21. receivedAtDate:(nullable NSDate *)tokenReceivedAtDate NS_DESIGNATED_INITIALIZER;
  22. @end
  23. @implementation GACAppCheckTokenRefreshResult
  24. - (instancetype)initWithStatus:(GACAppCheckTokenRefreshStatus)status
  25. expirationDate:(nullable NSDate *)tokenExpirationDate
  26. receivedAtDate:(nullable NSDate *)tokenReceivedAtDate {
  27. self = [super init];
  28. if (self) {
  29. _status = status;
  30. _tokenExpirationDate = tokenExpirationDate;
  31. _tokenReceivedAtDate = tokenReceivedAtDate;
  32. }
  33. return self;
  34. }
  35. - (instancetype)initWithStatusNever {
  36. return [self initWithStatus:GACAppCheckTokenRefreshStatusNever
  37. expirationDate:nil
  38. receivedAtDate:nil];
  39. }
  40. - (instancetype)initWithStatusFailure {
  41. return [self initWithStatus:GACAppCheckTokenRefreshStatusFailure
  42. expirationDate:nil
  43. receivedAtDate:nil];
  44. }
  45. - (instancetype)initWithStatusSuccessAndExpirationDate:(NSDate *)tokenExpirationDate
  46. receivedAtDate:(NSDate *)tokenReceivedAtDate {
  47. return [self initWithStatus:GACAppCheckTokenRefreshStatusSuccess
  48. expirationDate:tokenExpirationDate
  49. receivedAtDate:tokenReceivedAtDate];
  50. }
  51. @end
  52. NS_ASSUME_NONNULL_END