// // WithdrawRecordList.m // // Created by Yao on 2024/11/9 // Copyright (c) 2024 zL. All rights reserved. // #import "WithdrawRecordList.h" NSString *const kWithdrawRecordListAmount = @"amount"; NSString *const kWithdrawRecordListBankName = @"bankName"; NSString *const kWithdrawRecordListBankId = @"bankId"; NSString *const kWithdrawRecordListId = @"id"; NSString *const kWithdrawRecordListStatus = @"status"; NSString *const kWithdrawRecordListInviteId = @"inviteId"; NSString *const kWithdrawRecordListInviteCode = @"inviteCode"; NSString *const kWithdrawRecordListName = @"name"; NSString *const kWithdrawRecordListBalance = @"balance"; NSString *const kWithdrawRecordListCreateTime = @"createTime"; @interface WithdrawRecordList () - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict; @end @implementation WithdrawRecordList @synthesize amount = _amount; @synthesize bankName = _bankName; @synthesize bankId = _bankId; @synthesize identifier = _identifier; @synthesize status = _status; @synthesize inviteId = _inviteId; @synthesize inviteCode = _inviteCode; @synthesize name = _name; @synthesize balance = _balance; @synthesize createTime = _createTime; + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict { return [[self alloc] initWithDictionary:dict]; } - (instancetype)initWithDictionary:(NSDictionary *)dict { self = [super init]; // This check serves to make sure that a non-NSDictionary object // passed into the model class doesn't break the parsing. if (self && [dict isKindOfClass:[NSDictionary class]]) { self.amount = [[self objectOrNilForKey:kWithdrawRecordListAmount fromDictionary:dict] doubleValue]; self.bankName = [self objectOrNilForKey:kWithdrawRecordListBankName fromDictionary:dict]; self.bankId = [[self objectOrNilForKey:kWithdrawRecordListBankId fromDictionary:dict] intValue]; self.identifier = [[self objectOrNilForKey:kWithdrawRecordListId fromDictionary:dict] intValue]; self.status = [[self objectOrNilForKey:kWithdrawRecordListStatus fromDictionary:dict] intValue]; self.inviteId = [[self objectOrNilForKey:kWithdrawRecordListInviteId fromDictionary:dict] intValue]; self.inviteCode = [self objectOrNilForKey:kWithdrawRecordListInviteCode fromDictionary:dict]; self.name = [self objectOrNilForKey:kWithdrawRecordListName fromDictionary:dict]; self.balance = [[self objectOrNilForKey:kWithdrawRecordListBalance fromDictionary:dict] doubleValue]; self.createTime = [self objectOrNilForKey:kWithdrawRecordListCreateTime fromDictionary:dict]; } return self; } - (NSDictionary *)dictionaryRepresentation { NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary]; [mutableDict setValue:[NSNumber numberWithDouble:self.amount] forKey:kWithdrawRecordListAmount]; [mutableDict setValue:self.bankName forKey:kWithdrawRecordListBankName]; [mutableDict setValue:[NSNumber numberWithInteger:self.bankId] forKey:kWithdrawRecordListBankId]; [mutableDict setValue:[NSNumber numberWithInteger:self.identifier] forKey:kWithdrawRecordListId]; [mutableDict setValue:[NSNumber numberWithInteger:self.status] forKey:kWithdrawRecordListStatus]; [mutableDict setValue:[NSNumber numberWithInteger:self.inviteId] forKey:kWithdrawRecordListInviteId]; [mutableDict setValue:self.inviteCode forKey:kWithdrawRecordListInviteCode]; [mutableDict setValue:self.name forKey:kWithdrawRecordListName]; [mutableDict setValue:[NSNumber numberWithDouble:self.balance] forKey:kWithdrawRecordListBalance]; [mutableDict setValue:self.createTime forKey:kWithdrawRecordListCreateTime]; return [NSDictionary dictionaryWithDictionary:mutableDict]; } - (NSString *)description { return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]]; } #pragma mark - Helper Method - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict { id object = [dict objectForKey:aKey]; return [object isEqual:[NSNull null]] ? nil : object; } #pragma mark - NSCoding Methods - (id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; self.amount = [aDecoder decodeDoubleForKey:kWithdrawRecordListAmount]; self.bankName = [aDecoder decodeObjectForKey:kWithdrawRecordListBankName]; self.bankId = [aDecoder decodeIntegerForKey:kWithdrawRecordListBankId]; self.identifier = [aDecoder decodeIntegerForKey:kWithdrawRecordListId]; self.status = [aDecoder decodeIntegerForKey:kWithdrawRecordListStatus]; self.inviteId = [aDecoder decodeIntegerForKey:kWithdrawRecordListInviteId]; self.inviteCode = [aDecoder decodeObjectForKey:kWithdrawRecordListInviteCode]; self.name = [aDecoder decodeObjectForKey:kWithdrawRecordListName]; self.balance = [aDecoder decodeDoubleForKey:kWithdrawRecordListBalance]; self.createTime = [aDecoder decodeObjectForKey:kWithdrawRecordListCreateTime]; return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeDouble:_amount forKey:kWithdrawRecordListAmount]; [aCoder encodeObject:_bankName forKey:kWithdrawRecordListBankName]; [aCoder encodeInteger:_bankId forKey:kWithdrawRecordListBankId]; [aCoder encodeInteger:_identifier forKey:kWithdrawRecordListId]; [aCoder encodeInteger:_status forKey:kWithdrawRecordListStatus]; [aCoder encodeInteger:_inviteId forKey:kWithdrawRecordListInviteId]; [aCoder encodeObject:_inviteCode forKey:kWithdrawRecordListInviteCode]; [aCoder encodeObject:_name forKey:kWithdrawRecordListName]; [aCoder encodeDouble:_balance forKey:kWithdrawRecordListBalance]; [aCoder encodeObject:_createTime forKey:kWithdrawRecordListCreateTime]; } - (id)copyWithZone:(NSZone *)zone { WithdrawRecordList *copy = [[WithdrawRecordList alloc] init]; if (copy) { copy.amount = self.amount; copy.bankName = [self.bankName copyWithZone:zone]; copy.bankId = self.bankId; copy.identifier = self.identifier; copy.status = self.status; copy.inviteId = self.inviteId; copy.inviteCode = [self.inviteCode copyWithZone:zone]; copy.name = [self.name copyWithZone:zone]; copy.balance = self.balance; copy.createTime = [self.createTime copyWithZone:zone]; } return copy; } @end