Showing
1 changed file
with
86 additions
and
51 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,35 +522,30 @@ public class swiftApi { | ... | @@ -521,35 +522,30 @@ 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) | ||
| 543 | - do { | ||
| 544 | - if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject] | ||
| 545 | - { | ||
| 546 | - extra_fields_parsed = jsonArray; | ||
| 547 | - self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" | ||
| 548 | - self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" | ||
| 549 | self.hasExtraFields = true | 545 | self.hasExtraFields = true | 
| 550 | - self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false" | 546 | + self.ccms_offer = extra_fields["ccms_offer"] as? String? ?? "false" | 
| 551 | - self.badge = extra_fields_parsed["badge"] as? String? ?? "" | 547 | + self.badge = extra_fields["badge"] as? String? ?? "" | 
| 552 | - self.type = extra_fields_parsed["type"] as? String? ?? "" | 548 | + self.type = extra_fields["type"] as? String? ?? "" | 
| 553 | } else { | 549 | } else { | 
| 554 | self.subcategory = "" | 550 | self.subcategory = "" | 
| 555 | self.loyaltyCampaignId = "" | 551 | self.loyaltyCampaignId = "" | 
| ... | @@ -557,48 +553,78 @@ public class swiftApi { | ... | @@ -557,48 +553,78 @@ public class swiftApi { | 
| 557 | self.ccms_offer = "false" | 553 | self.ccms_offer = "false" | 
| 558 | self.badge = "" | 554 | self.badge = "" | 
| 559 | self.type = "" | 555 | self.type = "" | 
| 560 | - print("bad json") | ||
| 561 | } | 556 | } | 
| 562 | - } catch let error as NSError { | ||
| 563 | - self.subcategory = "" | ||
| 564 | - self.loyaltyCampaignId = "" | ||
| 565 | - self.hasExtraFields = false | ||
| 566 | - self.ccms_offer = "false" | ||
| 567 | - self.badge = "" | ||
| 568 | - self.type = "" | ||
| 569 | - print(error) | ||
| 570 | - } | ||
| 571 | - | ||
| 572 | - // campaign_type_settings | ||
| 573 | - if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject { | ||
| 574 | 557 | ||
| 575 | - if ((!(campaign_type_settings_obj is NSNull)) && (campaign_type_settings_obj != nil)) { | 558 | + // let extra_fields = dictionary["extra_fields"] as AnyObject | 
| 576 | - var campaign_type_settings_parsed:[String: Any] | 559 | + // var extra_fields_parsed:[String: Any] | 
| 560 | + | ||
| 561 | + // let json = extra_fields.data(using: String.Encoding.utf8.rawValue) | ||
| 562 | + // do { | ||
| 563 | + // if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject] | ||
| 564 | + // { | ||
| 565 | + // extra_fields_parsed = jsonArray; | ||
| 566 | + // self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" | ||
| 567 | + // self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? "" | ||
| 568 | + // self.hasExtraFields = true | ||
| 569 | + // self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false" | ||
| 570 | + // self.badge = extra_fields_parsed["badge"] as? String? ?? "" | ||
| 571 | + // self.type = extra_fields_parsed["type"] as? String? ?? "" | ||
| 572 | + // } else { | ||
| 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 | + // } | ||
| 577 | 590 | ||
| 578 | - let campaign_type_settings_json = campaign_type_settings_obj.data(using: String.Encoding.utf8.rawValue) | 591 | + // campaign_type_settings | 
| 579 | - do { | 592 | + if let campaign_type_settings = dictionary["settings"] as? [String: Any] { | 
| 580 | - if let jsonArray = try JSONSerialization.jsonObject(with: campaign_type_settings_json!, options: .allowFragments) as? [String:AnyObject] | 593 | + self.couponset = campaign_type_settings["couponset"] as? String? ?? "" | 
| 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 { | 594 | } else { | 
| 596 | self.couponset = "" | 595 | self.couponset = "" | 
| 597 | } | 596 | } | 
| 598 | 597 | ||
| 599 | - } else { | 598 | + | 
| 600 | - self.couponset = "" | 599 | +// if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject { | 
| 601 | - } | 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 | +// } | ||
| 602 | 628 | ||
| 603 | } | 629 | } | 
| 604 | 630 | ||
| ... | @@ -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