2020from .person import PersonBasicPropertiesMixin
2121from .role import RoleBasicPropertiesMixin
2222from .room import RoomBasicPropertiesMixin
23+ from .simple import SimpleDataModel
2324from .sparkdata import SparkData
2425from .team import TeamBasicPropertiesMixin
2526from .team_membership import TeamMembershipBasicPropertiesMixin
2627from .webhook import WebhookBasicPropertiesMixin
2728from .webhook_event import WebhookEventBasicPropertiesMixin
29+ from ..utils import json_dict
2830
2931
3032__author__ = "Chris Lunsford"
@@ -85,7 +87,7 @@ class WebhookEvent(SparkData, WebhookEventBasicPropertiesMixin):
8587 """Cisco Spark Webhook-Events data model."""
8688
8789
88- sparkdata_models = defaultdict (
90+ spark_data_models = defaultdict (
8991 lambda : SparkData ,
9092 access_token = AccessToken ,
9193 event = Event ,
@@ -103,7 +105,7 @@ class WebhookEvent(SparkData, WebhookEventBasicPropertiesMixin):
103105)
104106
105107
106- def sparkdata_factory (model , json_data ):
108+ def spark_data_factory (model , json_data ):
107109 """Factory function for creating SparkData objects.
108110
109111 Args:
@@ -120,4 +122,45 @@ def sparkdata_factory(model, json_data):
120122 dictionary.
121123
122124 """
123- return sparkdata_models [model ](json_data )
125+ return spark_data_models [model ](json_data )
126+
127+
128+ def simple_data_factory (model , json_data ):
129+ """Factory function for creating SimpleDataModel objects.
130+
131+ Args:
132+ model(basestring): The data model to use when creating the SparkData
133+ object (message, room, membership, etc.).
134+ json_data(basestring, dict): The JSON string or dictionary data with
135+ which to initialize the object.
136+
137+ Returns:
138+ SimpleDataModel: The created SimpleDataModel object.
139+
140+ Raises:
141+ TypeError: If the json_data parameter is not a JSON string or
142+ dictionary.
143+
144+ """
145+ return SimpleDataModel (json_data )
146+
147+
148+ def dict_data_factory (model , json_data ):
149+ """Factory function for creating SimpleDataModel objects.
150+
151+ Args:
152+ model(basestring): The data model to use when creating the SparkData
153+ object (message, room, membership, etc.).
154+ json_data(basestring, dict): The JSON string or dictionary data with
155+ which to initialize the object.
156+
157+ Returns:
158+ OrderedDict: An ordered dictionary with the contents of the Spark JSON
159+ object.
160+
161+ Raises:
162+ TypeError: If the json_data parameter is not a JSON string or
163+ dictionary.
164+
165+ """
166+ return json_dict (json_data )
0 commit comments