Showing
1 changed file
with
97 additions
and
62 deletions
... | @@ -501,6 +501,7 @@ public class swiftApi { | ... | @@ -501,6 +501,7 @@ public class swiftApi { |
501 | // public var campaign_type_settings: [String: Any]? | 501 | // public var campaign_type_settings: [String: Any]? |
502 | public var couponset: String? | 502 | public var couponset: String? |
503 | public var type: String? | 503 | public var type: String? |
504 | + public var sorting: Int? | ||
504 | 505 | ||
505 | public init() { | 506 | public init() { |
506 | self.index_url = "" | 507 | self.index_url = "" |
... | @@ -521,85 +522,110 @@ public class swiftApi { | ... | @@ -521,85 +522,110 @@ public class swiftApi { |
521 | // self.campaign_type_settings = [String: Any]() | 522 | // self.campaign_type_settings = [String: Any]() |
522 | self.couponset = "" | 523 | self.couponset = "" |
523 | self.type = "" | 524 | self.type = "" |
525 | + self.sorting = nil | ||
524 | } | 526 | } |
525 | 527 | ||
526 | public init(dictionary: [String: Any]) { | 528 | public init(dictionary: [String: Any]) { |
527 | self.index_url = dictionary["index_url"] as? String? ?? "" | 529 | self.index_url = dictionary["index_url"] as? String? ?? "" |
528 | self.logo_url = dictionary["logo_url"] as? String? ?? "" | 530 | self.logo_url = dictionary["logo_url"] as? String? ?? "" |
529 | - self.offer_category = dictionary["offer_category"] as? String? ?? "" | 531 | + self.offer_category = dictionary["communication_category"] as? String? ?? "" |
530 | self.title = dictionary["title"] as? String? ?? "" | 532 | self.title = dictionary["title"] as? String? ?? "" |
531 | self.subtitle = dictionary["subtitle"] as? String? ?? "" | 533 | self.subtitle = dictionary["subtitle"] as? String? ?? "" |
532 | - self.session_uuid = dictionary["session_uuid"] as? String? ?? "" | 534 | + self.session_uuid = dictionary["communication_uuid"] as? String? ?? "" |
533 | self.is_new = dictionary["is_new"] as? Bool? ?? false | 535 | self.is_new = dictionary["is_new"] as? Bool? ?? false |
534 | self.message = dictionary["message"] as? String? ?? "" | 536 | self.message = dictionary["message"] as? String? ?? "" |
535 | self.loyaltyPackageId = "" | 537 | self.loyaltyPackageId = "" |
536 | self.campaign_type = dictionary["campaign_type"] as? String? ?? "" | 538 | self.campaign_type = dictionary["campaign_type"] as? String? ?? "" |
539 | + self.sorting = dictionary["sorting"] as? Int? ?? nil | ||
537 | 540 | ||
538 | - // let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""] | 541 | +// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""] |
539 | - let extra_fields = dictionary["extra_fields"] as AnyObject | 542 | + if let extra_fields = dictionary["extra_fields"] as? [String: Any] { |
540 | - var extra_fields_parsed:[String: Any] | 543 | + self.subcategory = extra_fields["subcategory"] as? String? ?? "" |
541 | - | 544 | + self.loyaltyCampaignId = extra_fields["loyaltyCampaignId"] as? String? ?? "" |
542 | - let json = extra_fields.data(using: String.Encoding.utf8.rawValue) | 545 | + self.hasExtraFields = true |
543 | - do { | 546 | + self.ccms_offer = extra_fields["ccms_offer"] as? String? ?? "false" |
544 | - if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject] | 547 | + self.badge = extra_fields["badge"] as? String? ?? "" |
545 | - { | 548 | + self.type = extra_fields["type"] as? String? ?? "" |
546 | - extra_fields_parsed = jsonArray; | 549 | + } else { |
547 | - self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" | 550 | + self.subcategory = "" |
548 | - self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" | 551 | + self.loyaltyCampaignId = "" |
549 | - self.hasExtraFields = true | 552 | + self.hasExtraFields = false |
550 | - self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false" | 553 | + self.ccms_offer = "false" |
551 | - self.badge = extra_fields_parsed["badge"] as? String? ?? "" | 554 | + self.badge = "" |
552 | - self.type = extra_fields_parsed["type"] as? String? ?? "" | 555 | + self.type = "" |
553 | - } else { | 556 | + } |
554 | - self.subcategory = "" | 557 | + |
555 | - self.loyaltyCampaignId = "" | 558 | + // let extra_fields = dictionary["extra_fields"] as AnyObject |
556 | - self.hasExtraFields = false | 559 | + // var extra_fields_parsed:[String: Any] |
557 | - self.ccms_offer = "false" | 560 | + |
558 | - self.badge = "" | 561 | + // let json = extra_fields.data(using: String.Encoding.utf8.rawValue) |
559 | - self.type = "" | 562 | + // do { |
560 | - print("bad json") | 563 | + // if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject] |
561 | - } | 564 | + // { |
562 | - } catch let error as NSError { | 565 | + // extra_fields_parsed = jsonArray; |
563 | - self.subcategory = "" | 566 | + // self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" |
564 | - self.loyaltyCampaignId = "" | 567 | + // self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" |
565 | - self.hasExtraFields = false | 568 | + // self.hasExtraFields = true |
566 | - self.ccms_offer = "false" | 569 | + // self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false" |
567 | - self.badge = "" | 570 | + // self.badge = extra_fields_parsed["badge"] as? String? ?? "" |
568 | - self.type = "" | 571 | + // self.type = extra_fields_parsed["type"] as? String? ?? "" |
569 | - print(error) | 572 | + // } else { |
570 | - } | 573 | + // self.subcategory = "" |
574 | + // self.loyaltyCampaignId = "" | ||
575 | + // self.hasExtraFields = false | ||
576 | + // self.ccms_offer = "false" | ||
577 | + // self.badge = "" | ||
578 | + // self.type = "" | ||
579 | + // print("bad json") | ||
580 | + // } | ||
581 | + // } catch let error as NSError { | ||
582 | + // self.subcategory = "" | ||
583 | + // self.loyaltyCampaignId = "" | ||
584 | + // self.hasExtraFields = false | ||
585 | + // self.ccms_offer = "false" | ||
586 | + // self.badge = "" | ||
587 | + // self.type = "" | ||
588 | + // print(error) | ||
589 | + // } | ||
571 | 590 | ||
572 | // campaign_type_settings | 591 | // campaign_type_settings |
573 | - if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject { | 592 | + if let campaign_type_settings = dictionary["settings"] as? [String: Any] { |
574 | - | 593 | + self.couponset = campaign_type_settings["couponset"] as? String? ?? "" |
575 | - if ((!(campaign_type_settings_obj is NSNull)) && (campaign_type_settings_obj != nil)) { | ||
576 | - var campaign_type_settings_parsed:[String: Any] | ||
577 | - | ||
578 | - let campaign_type_settings_json = campaign_type_settings_obj.data(using: String.Encoding.utf8.rawValue) | ||
579 | - do { | ||
580 | - if let jsonArray = try JSONSerialization.jsonObject(with: campaign_type_settings_json!, options: .allowFragments) as? [String:AnyObject] | ||
581 | - { | ||
582 | - campaign_type_settings_parsed = jsonArray; | ||
583 | - // self.campaign_type_settings = campaign_type_settings_parsed as? [String: Any]? ?? [String: Any]() | ||
584 | - self.couponset = campaign_type_settings_parsed["couponset"] as? String? ?? "" | ||
585 | - } else { | ||
586 | - // self.campaign_type_settings = [String: Any]() | ||
587 | - self.couponset = "" | ||
588 | - print("bad json") | ||
589 | - } | ||
590 | - } catch let error as NSError { | ||
591 | - // self.campaign_type_settings = [String: Any]() | ||
592 | - self.couponset = "" | ||
593 | - print(error) | ||
594 | - } | ||
595 | - } else { | ||
596 | - self.couponset = "" | ||
597 | - } | ||
598 | - | ||
599 | } else { | 594 | } else { |
600 | - self.couponset = "" | 595 | + self.couponset = "" |
601 | } | 596 | } |
602 | 597 | ||
598 | + | ||
599 | +// if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject { | ||
600 | +// | ||
601 | +// if ((!(campaign_type_settings_obj is NSNull)) && (campaign_type_settings_obj != nil)) { | ||
602 | +// var campaign_type_settings_parsed:[String: Any] | ||
603 | +// | ||
604 | +// let campaign_type_settings_json = campaign_type_settings_obj.data(using: String.Encoding.utf8.rawValue) | ||
605 | +// do { | ||
606 | +// if let jsonArray = try JSONSerialization.jsonObject(with: campaign_type_settings_json!, options: .allowFragments) as? [String:AnyObject] | ||
607 | +// { | ||
608 | +// campaign_type_settings_parsed = jsonArray; | ||
609 | +// // self.campaign_type_settings = campaign_type_settings_parsed as? [String: Any]? ?? [String: Any]() | ||
610 | +// self.couponset = campaign_type_settings_parsed["couponset"] as? String? ?? "" | ||
611 | +// } else { | ||
612 | +// // self.campaign_type_settings = [String: Any]() | ||
613 | +// self.couponset = "" | ||
614 | +// print("bad json") | ||
615 | +// } | ||
616 | +// } catch let error as NSError { | ||
617 | +// // self.campaign_type_settings = [String: Any]() | ||
618 | +// self.couponset = "" | ||
619 | +// print(error) | ||
620 | +// } | ||
621 | +// } else { | ||
622 | +// self.couponset = "" | ||
623 | +// } | ||
624 | +// | ||
625 | +// } else { | ||
626 | +// self.couponset = "" | ||
627 | +// } | ||
628 | + | ||
603 | } | 629 | } |
604 | 630 | ||
605 | public var _logo_url: String? { | 631 | public var _logo_url: String? { |
... | @@ -673,6 +699,15 @@ public class swiftApi { | ... | @@ -673,6 +699,15 @@ public class swiftApi { |
673 | self.type = newValue | 699 | self.type = newValue |
674 | } | 700 | } |
675 | } | 701 | } |
702 | + | ||
703 | + public var _sorting: Int? { | ||
704 | + get { // getter | ||
705 | + return self.sorting | ||
706 | + } | ||
707 | + set(newValue) { //setter | ||
708 | + self.sorting = newValue | ||
709 | + } | ||
710 | + } | ||
676 | } | 711 | } |
677 | 712 | ||
678 | public class CampaignDataModel { | 713 | public class CampaignDataModel { | ... | ... |
-
Please register or login to post a comment