YOUPAILZChatRoomGiftAttachment.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // YOUPAILZChatRoomGiftAttachment.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/17.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomGiftAttachment.h"
  9. @implementation YOUPAILZChatRoomGiftAttachment
  10. - (NSString *)encodeAttachment
  11. {
  12. NSDictionary *dict = @{
  13. CMType : @(CustomOnChatRoomGift),
  14. CMData : @{
  15. CMGiftId: self.gift_id ?[NSNumber numberWithInteger:self.gift_id]:@0,
  16. CMGiftName: self.gift_name?self.gift_name:@"",
  17. CMGiftUrl: self.gift_url ?self.gift_url:@"",
  18. CMGiftCount: self.gift_count ?[NSNumber numberWithInteger:self.gift_count]:@0,
  19. CMFrom: self.from_uid?[NSNumber numberWithInteger:self.from_uid]:@0,
  20. CMTo: self.to_uid?[NSNumber numberWithInteger:self.to_uid]:@0,
  21. CMLink_type: self.link_type?[NSNumber numberWithInteger:self.link_type]:@0,
  22. CMLink_url: self.link_url?self.link_url:@"",
  23. CMMd5String:self.md5_string ?self.md5_string:@"",
  24. CMGiftSvga:self.gift_svga ?self.gift_svga:@"",
  25. CMGiftType:self.gift_type?[NSNumber numberWithInteger:self.gift_type]:@0,
  26. CMFromNickname:self.from_nickname ?self.from_nickname:@"",
  27. CMSendGiftHide:self.send_gift_hide ?@(self.send_gift_hide):@0,
  28. CMFromAvatar:self.from_avatar ?self.from_avatar:@"",
  29. CMReceiveInfo:self.receiveInfo?self.receiveInfo:@[],
  30. }
  31. };
  32. NSData *data = [NSJSONSerialization dataWithJSONObject:dict
  33. options:0
  34. error:nil];
  35. NSString *content = nil;
  36. if (data) {
  37. content = [[NSString alloc] initWithData:data
  38. encoding:NSUTF8StringEncoding];
  39. }
  40. return content;
  41. }
  42. @end