FIRCLSMockMXMetadata.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "Crashlytics/UnitTests/Mocks/FIRCLSMockMXMetadata.h"
  15. #if CLS_METRICKIT_SUPPORTED
  16. @interface FIRCLSMockMXMetadata ()
  17. @property(readwrite, strong, nonnull) NSString *regionFormat;
  18. @property(readwrite, strong, nonnull) NSString *osVersion;
  19. @property(readwrite, strong, nonnull) NSString *deviceType;
  20. @property(readwrite, strong, nonnull) NSString *applicationBuildVersion;
  21. @property(readwrite, strong, nonnull) NSString *platformArchitecture;
  22. @end
  23. @implementation FIRCLSMockMXMetadata
  24. @synthesize regionFormat = _regionFormat;
  25. @synthesize osVersion = _osVersion;
  26. @synthesize deviceType = _deviceType;
  27. @synthesize applicationBuildVersion = _applicationBuildVersion;
  28. @synthesize platformArchitecture = _platformArchitecture;
  29. - (instancetype)initWithRegionFormat:(NSString *)regionFormat
  30. osVersion:(NSString *)osVersion
  31. deviceType:(NSString *)deviceType
  32. applicationBuildVersion:(NSString *)applicationBuildVersion
  33. platformArchitecture:(NSString *)platformArchitecture {
  34. self = [super init];
  35. _regionFormat = regionFormat;
  36. _osVersion = osVersion;
  37. _deviceType = deviceType;
  38. _applicationBuildVersion = applicationBuildVersion;
  39. _platformArchitecture = platformArchitecture;
  40. return self;
  41. }
  42. - (NSData *)JSONRepresentation {
  43. NSDictionary *metadata = @{
  44. @"appBuildVersion" : self.applicationBuildVersion,
  45. @"osVersion" : self.osVersion,
  46. @"regionFormat" : self.regionFormat,
  47. @"platformArchitecture" : self.platformArchitecture,
  48. @"deviceType" : self.deviceType
  49. };
  50. return [NSJSONSerialization dataWithJSONObject:metadata options:0 error:nil];
  51. }
  52. @end
  53. #endif