ASUserModel.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // ASUserModel.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/11/27.
  6. //
  7. #import "ASUserModel.h"
  8. @implementation ASUserModel
  9. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  10. return @{
  11. @"Id": @"id",
  12. @"is_subscribed": @"extension_attributes.is_subscribed",
  13. };
  14. }
  15. + (NSDictionary *)mj_objectClassInArray{
  16. return @{
  17. @"addresses" : [ASAddressModel class]
  18. };
  19. }
  20. @end
  21. @implementation ASAddressModel
  22. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  23. return @{
  24. @"Id": @"id",
  25. @"title": @"extension_attributes.title",
  26. @"country": @"extension_attributes.country",
  27. @"addressType": @"extension_attributes.address_type",
  28. };
  29. }
  30. + (ASAddressModel *)defualtData {
  31. ASAddressModel *m = [ASAddressModel new];
  32. m.title = @"";
  33. m.firstname = @"";
  34. m.lastname = @"";
  35. m.street = @[@""];
  36. m.postcode = @"";
  37. m.city = @"";
  38. // m.region = @"";
  39. ASAddressReginModel *re = [ASAddressReginModel new];
  40. re.region = @"";
  41. re.region_code = @"";
  42. re.region_id = @"";
  43. m.region = re;
  44. m.region_id = @"";
  45. m.telephone = @"";
  46. m.country = @"Unites States";
  47. m.country_id = @"US";
  48. return m;
  49. }
  50. - (NSDictionary *)params {
  51. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  52. dic[@"id"] = self.Id;
  53. dic[@"firstname"] = self.firstname;
  54. dic[@"lastname"] = self.lastname;
  55. NSString *stre = [self.street componentsJoinedByString:@","];
  56. dic[@"street[]"] = stre;
  57. dic[@"postcode"] = self.postcode;
  58. dic[@"city"] = self.city;
  59. dic[@"country_id"] = self.country_id;
  60. dic[@"region_id"] = self.region_id;
  61. dic[@"region"] = self.region.region;
  62. dic[@"telephone"] = self.telephone;
  63. dic[@"default_billing"] = @"0";
  64. dic[@"default_shipping"] = @"0";
  65. if (self.addressType == 3) {
  66. dic[@"default_billing"] = @"1";
  67. dic[@"default_shipping"] = @"1";
  68. }
  69. if (self.addressType == 2) {
  70. dic[@"default_billing"] = @"0";
  71. dic[@"default_shipping"] = @"1";
  72. }
  73. if (self.addressType == 1) {
  74. dic[@"default_billing"] = @"1";
  75. dic[@"default_shipping"] = @"0";
  76. }
  77. return dic;
  78. }
  79. @end
  80. @implementation ASAddressReginModel
  81. @end