Skip to content

Commit 4ed3917

Browse files
author
ask-pyth
committed
Release 1.17.0. For changelog, check CHANGELOG.rst
1 parent b805608 commit 4ed3917

9 files changed

+665
-1
lines changed

ask-sdk-model/CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,11 @@ This release contains the following changes :
224224
This release has the following changes :
225225

226226
- Support for building APL-T Documents (APL Character displays).
227+
228+
229+
1.17.0
230+
~~~~~~~
231+
232+
This release contains the following changes :
233+
234+
- APIs for `ISP support in kid skills <https://developer.amazon.com/docs/in-skill-purchase/isp-kid-skills.html>`__.

ask-sdk-model/ask_sdk_model/__version__.py

+1-1
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.16.0'
17+
__version__ = '1.17.0'
1818
__author__ = 'Alexa Skills Kit'
1919
__author_email__ = '[email protected]'
2020
__license__ = 'Apache 2.0'

ask-sdk-model/ask_sdk_model/services/monetization/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
from .product_type import ProductType
1919
from .in_skill_products_response import InSkillProductsResponse
2020
from .entitlement_reason import EntitlementReason
21+
from .transactions import Transactions
22+
from .metadata import Metadata
23+
from .status import Status
2124
from .purchasable_state import PurchasableState
25+
from .in_skill_product_transactions_response import InSkillProductTransactionsResponse
2226
from .in_skill_product import InSkillProduct
2327
from .monetization_service_client import MonetizationServiceClient
2428
from .purchase_mode import PurchaseMode
2529
from .entitled_state import EntitledState
30+
from .result_set import ResultSet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2019 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+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional, Union
25+
from datetime import datetime
26+
from ask_sdk_model.services.monetization.transactions import Transactions
27+
from ask_sdk_model.services.monetization.metadata import Metadata
28+
29+
30+
class InSkillProductTransactionsResponse(object):
31+
"""
32+
33+
:param results: List of transactions of in skill products purchases
34+
:type results: (optional) list[ask_sdk_model.services.monetization.transactions.Transactions]
35+
:param metadata:
36+
:type metadata: (optional) ask_sdk_model.services.monetization.metadata.Metadata
37+
38+
"""
39+
deserialized_types = {
40+
'results': 'list[ask_sdk_model.services.monetization.transactions.Transactions]',
41+
'metadata': 'ask_sdk_model.services.monetization.metadata.Metadata'
42+
} # type: Dict
43+
44+
attribute_map = {
45+
'results': 'results',
46+
'metadata': 'metadata'
47+
} # type: Dict
48+
49+
def __init__(self, results=None, metadata=None):
50+
# type: (Optional[List[Transactions]], Optional[Metadata]) -> None
51+
"""
52+
53+
:param results: List of transactions of in skill products purchases
54+
:type results: (optional) list[ask_sdk_model.services.monetization.transactions.Transactions]
55+
:param metadata:
56+
:type metadata: (optional) ask_sdk_model.services.monetization.metadata.Metadata
57+
"""
58+
self.__discriminator_value = None # type: str
59+
60+
self.results = results
61+
self.metadata = metadata
62+
63+
def to_dict(self):
64+
# type: () -> Dict[str, object]
65+
"""Returns the model properties as a dict"""
66+
result = {} # type: Dict
67+
68+
for attr, _ in six.iteritems(self.deserialized_types):
69+
value = getattr(self, attr)
70+
if isinstance(value, list):
71+
result[attr] = list(map(
72+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
73+
x.value if isinstance(x, Enum) else x,
74+
value
75+
))
76+
elif isinstance(value, Enum):
77+
result[attr] = value.value
78+
elif hasattr(value, "to_dict"):
79+
result[attr] = value.to_dict()
80+
elif isinstance(value, dict):
81+
result[attr] = dict(map(
82+
lambda item: (item[0], item[1].to_dict())
83+
if hasattr(item[1], "to_dict") else
84+
(item[0], item[1].value)
85+
if isinstance(item[1], Enum) else item,
86+
value.items()
87+
))
88+
else:
89+
result[attr] = value
90+
91+
return result
92+
93+
def to_str(self):
94+
# type: () -> str
95+
"""Returns the string representation of the model"""
96+
return pprint.pformat(self.to_dict())
97+
98+
def __repr__(self):
99+
# type: () -> str
100+
"""For `print` and `pprint`"""
101+
return self.to_str()
102+
103+
def __eq__(self, other):
104+
# type: (object) -> bool
105+
"""Returns true if both objects are equal"""
106+
if not isinstance(other, InSkillProductTransactionsResponse):
107+
return False
108+
109+
return self.__dict__ == other.__dict__
110+
111+
def __ne__(self, other):
112+
# type: (object) -> bool
113+
"""Returns true if both objects are not equal"""
114+
return not self == other
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2019 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+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional, Union
25+
from datetime import datetime
26+
from ask_sdk_model.services.monetization.result_set import ResultSet
27+
28+
29+
class Metadata(object):
30+
"""
31+
32+
:param result_set:
33+
:type result_set: (optional) ask_sdk_model.services.monetization.result_set.ResultSet
34+
35+
"""
36+
deserialized_types = {
37+
'result_set': 'ask_sdk_model.services.monetization.result_set.ResultSet'
38+
} # type: Dict
39+
40+
attribute_map = {
41+
'result_set': 'resultSet'
42+
} # type: Dict
43+
44+
def __init__(self, result_set=None):
45+
# type: (Optional[ResultSet]) -> None
46+
"""
47+
48+
:param result_set:
49+
:type result_set: (optional) ask_sdk_model.services.monetization.result_set.ResultSet
50+
"""
51+
self.__discriminator_value = None # type: str
52+
53+
self.result_set = result_set
54+
55+
def to_dict(self):
56+
# type: () -> Dict[str, object]
57+
"""Returns the model properties as a dict"""
58+
result = {} # type: Dict
59+
60+
for attr, _ in six.iteritems(self.deserialized_types):
61+
value = getattr(self, attr)
62+
if isinstance(value, list):
63+
result[attr] = list(map(
64+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
65+
x.value if isinstance(x, Enum) else x,
66+
value
67+
))
68+
elif isinstance(value, Enum):
69+
result[attr] = value.value
70+
elif hasattr(value, "to_dict"):
71+
result[attr] = value.to_dict()
72+
elif isinstance(value, dict):
73+
result[attr] = dict(map(
74+
lambda item: (item[0], item[1].to_dict())
75+
if hasattr(item[1], "to_dict") else
76+
(item[0], item[1].value)
77+
if isinstance(item[1], Enum) else item,
78+
value.items()
79+
))
80+
else:
81+
result[attr] = value
82+
83+
return result
84+
85+
def to_str(self):
86+
# type: () -> str
87+
"""Returns the string representation of the model"""
88+
return pprint.pformat(self.to_dict())
89+
90+
def __repr__(self):
91+
# type: () -> str
92+
"""For `print` and `pprint`"""
93+
return self.to_str()
94+
95+
def __eq__(self, other):
96+
# type: (object) -> bool
97+
"""Returns true if both objects are equal"""
98+
if not isinstance(other, Metadata):
99+
return False
100+
101+
return self.__dict__ == other.__dict__
102+
103+
def __ne__(self, other):
104+
# type: (object) -> bool
105+
"""Returns true if both objects are not equal"""
106+
return not self == other

ask-sdk-model/ask_sdk_model/services/monetization/monetization_service_client.py

+130
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from ask_sdk_model.services.monetization.error import Error
3131
from ask_sdk_model.services.monetization.in_skill_product import InSkillProduct
3232
from ask_sdk_model.services.monetization.in_skill_products_response import InSkillProductsResponse
33+
from ask_sdk_model.services.monetization.in_skill_product_transactions_response import InSkillProductTransactionsResponse
34+
import bool
3335

3436

3537
class MonetizationServiceClient(BaseServiceClient):
@@ -182,3 +184,131 @@ def get_in_skill_product(self, accept_language, product_id, **kwargs):
182184
body=body_params,
183185
response_definitions=error_definitions,
184186
response_type="ask_sdk_model.services.monetization.in_skill_product.InSkillProduct")
187+
188+
def get_in_skill_products_transactions(self, accept_language, **kwargs):
189+
# type: (str, **Any) -> Union[Error, InSkillProductTransactionsResponse]
190+
"""
191+
Returns transactions of all in skill products purchases of the customer
192+
193+
:param accept_language: (required) User's locale/language in context
194+
:type accept_language: str
195+
:param product_id: Product Id.
196+
:type product_id: str
197+
:param status: Transaction status for in skill product purchases. * 'PENDING_APPROVAL_BY_PARENT' - The transaction is pending approval from parent. * 'APPROVED_BY_PARENT' - The transaction was approved by parent and fulfilled successfully.. * 'DENIED_BY_PARENT' - The transaction was declined by parent and hence not fulfilled. * 'EXPIRED_NO_ACTION_BY_PARENT' - The transaction was expired due to no response from parent and hence not fulfilled. * 'ERROR' - The transaction was not fullfiled as there was an error while processing the transaction.
198+
:type status: str
199+
:param from_last_modified_time: Filter transactions based on last modified time stamp, FROM duration in format (UTC ISO 8601) i.e. yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
200+
:type from_last_modified_time: datetime
201+
:param to_last_modified_time: Filter transactions based on last modified time stamp, TO duration in format (UTC ISO 8601) i.e. yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
202+
:type to_last_modified_time: datetime
203+
:param next_token: When response to this API call is truncated, the response also includes the nextToken in metadata, the value of which can be used in the next request as the continuation-token to list the next set of objects. The continuation token is an opaque value that In-Skill Products API understands. Token has expiry of 24 hours.
204+
:type next_token: str
205+
:param max_results: sets the maximum number of results returned in the response body. If you want to retrieve fewer than upper limit of 100 results, you can add this parameter to your request. maxResults should not exceed the upper limit. The response might contain fewer results than maxResults, but it will never contain more. If there are additional results that satisfy the search criteria, but these results were not returned because maxResults was exceeded, the response contains nextToken which can be used to fetch next set of result.
206+
:type max_results: float
207+
:rtype: Union[Error, InSkillProductTransactionsResponse]
208+
"""
209+
operation_name = "get_in_skill_products_transactions"
210+
params = locals()
211+
for key, val in six.iteritems(params['kwargs']):
212+
params[key] = val
213+
del params['kwargs']
214+
# verify the required parameter 'accept_language' is set
215+
if ('accept_language' not in params) or (params['accept_language'] is None):
216+
raise ValueError(
217+
"Missing the required parameter `accept_language` when calling `" + operation_name + "`")
218+
219+
resource_path = '/v1/users/~current/skills/~current/inSkillProductsTransactions'
220+
resource_path = resource_path.replace('{format}', 'json')
221+
222+
path_params = {} # type: Dict
223+
224+
query_params = [] # type: List
225+
if 'product_id' in params:
226+
query_params.append(('productId', params['product_id']))
227+
if 'status' in params:
228+
query_params.append(('status', params['status']))
229+
if 'from_last_modified_time' in params:
230+
query_params.append(('fromLastModifiedTime', params['from_last_modified_time']))
231+
if 'to_last_modified_time' in params:
232+
query_params.append(('toLastModifiedTime', params['to_last_modified_time']))
233+
if 'next_token' in params:
234+
query_params.append(('nextToken', params['next_token']))
235+
if 'max_results' in params:
236+
query_params.append(('maxResults', params['max_results']))
237+
238+
header_params = [] # type: List
239+
if 'accept_language' in params:
240+
header_params.append(('Accept-Language', params['accept_language']))
241+
242+
body_params = None
243+
header_params.append(('Content-type', 'application/json'))
244+
245+
# Authentication setting
246+
authorization_value = "Bearer " + self._authorization_value
247+
header_params.append(("Authorization", authorization_value))
248+
249+
error_definitions = [] # type: List
250+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.in_skill_product_transactions_response.InSkillProductTransactionsResponse", status_code=200, message="Returns a list of transactions of all in skill products purchases in last 30 days on success."))
251+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=400, message="Invalid request"))
252+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=401, message="The authentication token is invalid or doesn&#39;t have access to make this request"))
253+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=403, message="Forbidden request"))
254+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=404, message="Product id doesn&#39;t exist / invalid / not found."))
255+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=412, message="Non-Child Directed Skill is not supported."))
256+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=429, message="The request is throttled."))
257+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=500, message="Internal Server Error"))
258+
259+
return self.invoke(
260+
method="GET",
261+
endpoint=self._api_endpoint,
262+
path=resource_path,
263+
path_params=path_params,
264+
query_params=query_params,
265+
header_params=header_params,
266+
body=body_params,
267+
response_definitions=error_definitions,
268+
response_type="ask_sdk_model.services.monetization.in_skill_product_transactions_response.InSkillProductTransactionsResponse")
269+
270+
def get_voice_purchase_setting(self, **kwargs):
271+
# type: (**Any) -> Union[bool, Error]
272+
"""
273+
Returns whether or not voice purchasing is enabled for the skill
274+
275+
:rtype: Union[bool, Error]
276+
"""
277+
operation_name = "get_voice_purchase_setting"
278+
params = locals()
279+
for key, val in six.iteritems(params['kwargs']):
280+
params[key] = val
281+
del params['kwargs']
282+
283+
resource_path = '/v1/users/~current/skills/~current/settings/voicePurchasing.enabled'
284+
resource_path = resource_path.replace('{format}', 'json')
285+
286+
path_params = {} # type: Dict
287+
288+
query_params = [] # type: List
289+
290+
header_params = [] # type: List
291+
292+
body_params = None
293+
header_params.append(('Content-type', 'application/json'))
294+
295+
# Authentication setting
296+
authorization_value = "Bearer " + self._authorization_value
297+
header_params.append(("Authorization", authorization_value))
298+
299+
error_definitions = [] # type: List
300+
error_definitions.append(ServiceClientResponse(response_type="bool", status_code=200, message="Returns a boolean value for voice purchase setting on success."))
301+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=400, message="Invalid request."))
302+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=401, message="The authentication token is invalid or doesn&#39;t have access to make this request"))
303+
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=500, message="Internal Server Error."))
304+
305+
return self.invoke(
306+
method="GET",
307+
endpoint=self._api_endpoint,
308+
path=resource_path,
309+
path_params=path_params,
310+
query_params=query_params,
311+
header_params=header_params,
312+
body=body_params,
313+
response_definitions=error_definitions,
314+
response_type="bool")

0 commit comments

Comments
 (0)