Skip to content

Commit d711e32

Browse files
committed
Minor release 1.2.0
1 parent 8bb4fdb commit d711e32

File tree

13 files changed

+1282
-1
lines changed

13 files changed

+1282
-1
lines changed

ask-sdk-model/CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ CHANGELOG
4545

4646
* Update Skill Event Models to include additional attributes like 'eventPublishingTime' etc.
4747

48+
1.2.0
49+
~~~~~
50+
51+
* Models for "PrintRequest" and "ReservationRequest" in Skill Connections.
52+

ask-sdk-model/ask_sdk_model/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
__pip_package_name__ = 'ask-sdk-model'
1515
__description__ = 'The ASK SDK Model package provides model definitions, for building Alexa Skills.'
1616
__url__ = 'https://github.com/alexa/alexa-apis-for-python'
17-
__version__ = '1.1.0'
17+
__version__ = '1.2.0'
1818
__author__ = 'Alexa Skills Kit'
1919
__author_email__ = 'ask-sdk-dynamic@amazon.com'
2020
__license__ = 'Apache 2.0'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
from __future__ import absolute_import
16+
17+
from .base_entity import BaseEntity
18+
from .postal_address import PostalAddress
19+
from .restaurant import Restaurant
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
from abc import ABCMeta, abstractmethod
22+
23+
24+
if typing.TYPE_CHECKING:
25+
from typing import Dict, List, Optional
26+
from datetime import datetime
27+
28+
29+
class BaseEntity(object):
30+
"""
31+
32+
:param object_type:
33+
:type object_type: (optional) str
34+
:param version: version of the request
35+
:type version: (optional) str
36+
37+
.. note::
38+
39+
This is an abstract class. Use the following mapping, to figure out
40+
the model class to be instantiated, that sets ``@type`` variable.
41+
42+
| Restaurant: :py:class:`ask_sdk_model.interfaces.connections.entities.restaurant.Restaurant`,
43+
|
44+
| PostalAddress: :py:class:`ask_sdk_model.interfaces.connections.entities.postal_address.PostalAddress`
45+
46+
"""
47+
deserialized_types = {
48+
'object_type': 'str',
49+
'version': 'str'
50+
}
51+
52+
attribute_map = {
53+
'object_type': '@type',
54+
'version': '@version'
55+
}
56+
57+
discriminator_value_class_map = {
58+
'Restaurant': 'ask_sdk_model.interfaces.connections.entities.restaurant.Restaurant',
59+
'PostalAddress': 'ask_sdk_model.interfaces.connections.entities.postal_address.PostalAddress'
60+
}
61+
62+
json_discriminator_key = "@type"
63+
64+
__metaclass__ = ABCMeta
65+
66+
@abstractmethod
67+
def __init__(self, object_type=None, version=None):
68+
# type: (Optional[str], Optional[str]) -> None
69+
"""
70+
71+
:param object_type:
72+
:type object_type: (optional) str
73+
:param version: version of the request
74+
:type version: (optional) str
75+
"""
76+
self.__discriminator_value = None
77+
78+
self.object_type = object_type
79+
self.version = version
80+
81+
@classmethod
82+
def get_real_child_model(cls, data):
83+
# type: (Dict[str, str]) -> str
84+
"""Returns the real base class specified by the discriminator"""
85+
discriminator_value = data[cls.json_discriminator_key]
86+
return cls.discriminator_value_class_map.get(discriminator_value)
87+
88+
def to_dict(self):
89+
# type: () -> Dict[str, object]
90+
"""Returns the model properties as a dict"""
91+
result = {}
92+
93+
for attr, _ in six.iteritems(self.deserialized_types):
94+
value = getattr(self, attr)
95+
if isinstance(value, list):
96+
result[attr] = list(map(
97+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
98+
x.value if isinstance(x, Enum) else x,
99+
value
100+
))
101+
elif isinstance(value, Enum):
102+
result[attr] = value.value
103+
elif hasattr(value, "to_dict"):
104+
result[attr] = value.to_dict()
105+
elif isinstance(value, dict):
106+
result[attr] = dict(map(
107+
lambda item: (item[0], item[1].to_dict())
108+
if hasattr(item[1], "to_dict") else
109+
(item[0], item[1].value)
110+
if isinstance(item[1], Enum) else item,
111+
value.items()
112+
))
113+
else:
114+
result[attr] = value
115+
116+
return result
117+
118+
def to_str(self):
119+
# type: () -> str
120+
"""Returns the string representation of the model"""
121+
return pprint.pformat(self.to_dict())
122+
123+
def __repr__(self):
124+
# type: () -> str
125+
"""For `print` and `pprint`"""
126+
return self.to_str()
127+
128+
def __eq__(self, other):
129+
# type: (object) -> bool
130+
"""Returns true if both objects are equal"""
131+
if not isinstance(other, BaseEntity):
132+
return False
133+
134+
return self.__dict__ == other.__dict__
135+
136+
def __ne__(self, other):
137+
# type: (object) -> bool
138+
"""Returns true if both objects are not equal"""
139+
return not self == other
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
from ask_sdk_model.interfaces.connections.entities.base_entity import BaseEntity
22+
23+
24+
if typing.TYPE_CHECKING:
25+
from typing import Dict, List, Optional
26+
from datetime import datetime
27+
28+
29+
class PostalAddress(BaseEntity):
30+
"""
31+
Postal Address
32+
33+
34+
:param version: version of the request
35+
:type version: (optional) str
36+
:param street_address: street address
37+
:type street_address: (optional) str
38+
:param locality: locality/city
39+
:type locality: (optional) str
40+
:param region: state/region
41+
:type region: (optional) str
42+
:param postal_code: postal/zip code
43+
:type postal_code: (optional) str
44+
:param country: country
45+
:type country: (optional) str
46+
47+
"""
48+
deserialized_types = {
49+
'object_type': 'str',
50+
'version': 'str',
51+
'street_address': 'str',
52+
'locality': 'str',
53+
'region': 'str',
54+
'postal_code': 'str',
55+
'country': 'str'
56+
}
57+
58+
attribute_map = {
59+
'object_type': '@type',
60+
'version': '@version',
61+
'street_address': 'streetAddress',
62+
'locality': 'locality',
63+
'region': 'region',
64+
'postal_code': 'postalCode',
65+
'country': 'country'
66+
}
67+
68+
def __init__(self, version=None, street_address=None, locality=None, region=None, postal_code=None, country=None):
69+
# type: (Optional[str], Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]) -> None
70+
"""Postal Address
71+
72+
:param version: version of the request
73+
:type version: (optional) str
74+
:param street_address: street address
75+
:type street_address: (optional) str
76+
:param locality: locality/city
77+
:type locality: (optional) str
78+
:param region: state/region
79+
:type region: (optional) str
80+
:param postal_code: postal/zip code
81+
:type postal_code: (optional) str
82+
:param country: country
83+
:type country: (optional) str
84+
"""
85+
self.__discriminator_value = "PostalAddress"
86+
87+
self.object_type = self.__discriminator_value
88+
super(PostalAddress, self).__init__(object_type=self.__discriminator_value, version=version)
89+
self.street_address = street_address
90+
self.locality = locality
91+
self.region = region
92+
self.postal_code = postal_code
93+
self.country = country
94+
95+
def to_dict(self):
96+
# type: () -> Dict[str, object]
97+
"""Returns the model properties as a dict"""
98+
result = {}
99+
100+
for attr, _ in six.iteritems(self.deserialized_types):
101+
value = getattr(self, attr)
102+
if isinstance(value, list):
103+
result[attr] = list(map(
104+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
105+
x.value if isinstance(x, Enum) else x,
106+
value
107+
))
108+
elif isinstance(value, Enum):
109+
result[attr] = value.value
110+
elif hasattr(value, "to_dict"):
111+
result[attr] = value.to_dict()
112+
elif isinstance(value, dict):
113+
result[attr] = dict(map(
114+
lambda item: (item[0], item[1].to_dict())
115+
if hasattr(item[1], "to_dict") else
116+
(item[0], item[1].value)
117+
if isinstance(item[1], Enum) else item,
118+
value.items()
119+
))
120+
else:
121+
result[attr] = value
122+
123+
return result
124+
125+
def to_str(self):
126+
# type: () -> str
127+
"""Returns the string representation of the model"""
128+
return pprint.pformat(self.to_dict())
129+
130+
def __repr__(self):
131+
# type: () -> str
132+
"""For `print` and `pprint`"""
133+
return self.to_str()
134+
135+
def __eq__(self, other):
136+
# type: (object) -> bool
137+
"""Returns true if both objects are equal"""
138+
if not isinstance(other, PostalAddress):
139+
return False
140+
141+
return self.__dict__ == other.__dict__
142+
143+
def __ne__(self, other):
144+
# type: (object) -> bool
145+
"""Returns true if both objects are not equal"""
146+
return not self == other

0 commit comments

Comments
 (0)