1/** 2 * @file MEGAPricing.mm 3 * @brief Details about pricing plans 4 * 5 * (c) 2013-2014 by Mega Limited, Auckland, New Zealand 6 * 7 * This file is part of the MEGA SDK - Client Access Engine. 8 * 9 * Applications using the MEGA API must present a valid application key 10 * and comply with the the rules set forth in the Terms of Service. 11 * 12 * The MEGA SDK is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * @copyright Simplified (2-clause) BSD License. 17 * 18 * You should have received a copy of the license along with this 19 * program. 20 */ 21#import "MEGAPricing.h" 22#import "megaapi.h" 23 24using namespace mega; 25 26@interface MEGAPricing () 27 28@property MegaPricing *pricing; 29@property BOOL cMemoryOwn; 30 31@end 32 33@implementation MEGAPricing 34 35- (instancetype)initWithMegaPricing:(MegaPricing *)pricing cMemoryOwn:(BOOL)cMemoryOwn { 36 self = [super init]; 37 38 if (self != nil) { 39 _pricing = pricing; 40 _cMemoryOwn = cMemoryOwn; 41 } 42 43 return self; 44} 45 46- (MegaPricing *)getCPtr { 47 return self.pricing; 48} 49 50- (void)dealloc { 51 if (self.cMemoryOwn) { 52 delete _pricing; 53 } 54} 55 56- (instancetype)clone { 57 return self.pricing ? [[MEGAPricing alloc] initWithMegaPricing:self.pricing->copy() cMemoryOwn:YES] : nil; 58} 59 60- (NSInteger)products { 61 return self.pricing ? self.pricing->getNumProducts() : 0; 62} 63 64- (uint64_t)handleAtProductIndex:(NSInteger)index { 65 return self.pricing ? self.pricing->getHandle((int)index) : INVALID_HANDLE; 66} 67 68- (MEGAAccountType)proLevelAtProductIndex:(NSInteger)index { 69 return (MEGAAccountType) (self.pricing ? self.pricing->getProLevel((int)index) : 0); 70} 71 72- (NSInteger)storageGBAtProductIndex:(NSInteger)index { 73 return self.pricing ? self.pricing->getGBStorage((int)index) : 0; 74} 75 76- (NSInteger)transferGBAtProductIndex:(NSInteger)index { 77 return self.pricing ? self.pricing->getGBTransfer((int)index) : 0; 78} 79 80- (NSInteger)monthsAtProductIndex:(NSInteger)index { 81 return self.pricing ? self.pricing->getMonths((int)index) : 0; 82} 83 84- (NSInteger)amountAtProductIndex:(NSInteger)index { 85 return self.pricing ? self.pricing->getAmount((int)index) : 0; 86} 87 88- (NSString *)currencyAtProductIndex:(NSInteger)index { 89 return self.pricing ? [[NSString alloc] initWithUTF8String:self.pricing->getCurrency((int)index)] : nil; 90} 91 92- (NSString *)descriptionAtProductIndex:(NSInteger)index { 93 return self.pricing ? [[NSString alloc] initWithUTF8String:self.pricing->getDescription((int)index)] : nil; 94} 95 96- (NSString *)iOSIDAtProductIndex:(NSInteger)index { 97 return self.pricing ? [[NSString alloc] initWithUTF8String:self.pricing->getIosID((int)index)] : nil; 98} 99 100@end 101