Skip to content

Commit

Permalink
Release 1.17.0. For changelog, check CHANGELOG.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
ask-pyth committed Oct 24, 2019
1 parent b805608 commit 4ed3917
Show file tree
Hide file tree
Showing 9 changed files with 665 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ask-sdk-model/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,11 @@ This release contains the following changes :
This release has the following changes :

- Support for building APL-T Documents (APL Character displays).


1.17.0
~~~~~~~

This release contains the following changes :

- APIs for `ISP support in kid skills <https://developer.amazon.com/docs/in-skill-purchase/isp-kid-skills.html>`__.
2 changes: 1 addition & 1 deletion ask-sdk-model/ask_sdk_model/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
__pip_package_name__ = 'ask-sdk-model'
__description__ = 'The ASK SDK Model package provides model definitions, for building Alexa Skills.'
__url__ = 'https://github.com/alexa/alexa-apis-for-python'
__version__ = '1.16.0'
__version__ = '1.17.0'
__author__ = 'Alexa Skills Kit'
__author_email__ = 'ask-sdk-dynamic@amazon.com'
__license__ = 'Apache 2.0'
Expand Down
5 changes: 5 additions & 0 deletions ask-sdk-model/ask_sdk_model/services/monetization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
from .product_type import ProductType
from .in_skill_products_response import InSkillProductsResponse
from .entitlement_reason import EntitlementReason
from .transactions import Transactions
from .metadata import Metadata
from .status import Status
from .purchasable_state import PurchasableState
from .in_skill_product_transactions_response import InSkillProductTransactionsResponse
from .in_skill_product import InSkillProduct
from .monetization_service_client import MonetizationServiceClient
from .purchase_mode import PurchaseMode
from .entitled_state import EntitledState
from .result_set import ResultSet
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# coding: utf-8

#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
# except in compliance with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
# the specific language governing permissions and limitations under the License.
#

import pprint
import re # noqa: F401
import six
import typing
from enum import Enum


if typing.TYPE_CHECKING:
from typing import Dict, List, Optional, Union
from datetime import datetime
from ask_sdk_model.services.monetization.transactions import Transactions
from ask_sdk_model.services.monetization.metadata import Metadata


class InSkillProductTransactionsResponse(object):
"""
:param results: List of transactions of in skill products purchases
:type results: (optional) list[ask_sdk_model.services.monetization.transactions.Transactions]
:param metadata:
:type metadata: (optional) ask_sdk_model.services.monetization.metadata.Metadata
"""
deserialized_types = {
'results': 'list[ask_sdk_model.services.monetization.transactions.Transactions]',
'metadata': 'ask_sdk_model.services.monetization.metadata.Metadata'
} # type: Dict

attribute_map = {
'results': 'results',
'metadata': 'metadata'
} # type: Dict

def __init__(self, results=None, metadata=None):
# type: (Optional[List[Transactions]], Optional[Metadata]) -> None
"""
:param results: List of transactions of in skill products purchases
:type results: (optional) list[ask_sdk_model.services.monetization.transactions.Transactions]
:param metadata:
:type metadata: (optional) ask_sdk_model.services.monetization.metadata.Metadata
"""
self.__discriminator_value = None # type: str

self.results = results
self.metadata = metadata

def to_dict(self):
# type: () -> Dict[str, object]
"""Returns the model properties as a dict"""
result = {} # type: Dict

for attr, _ in six.iteritems(self.deserialized_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else
x.value if isinstance(x, Enum) else x,
value
))
elif isinstance(value, Enum):
result[attr] = value.value
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else
(item[0], item[1].value)
if isinstance(item[1], Enum) else item,
value.items()
))
else:
result[attr] = value

return result

def to_str(self):
# type: () -> str
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __repr__(self):
# type: () -> str
"""For `print` and `pprint`"""
return self.to_str()

def __eq__(self, other):
# type: (object) -> bool
"""Returns true if both objects are equal"""
if not isinstance(other, InSkillProductTransactionsResponse):
return False

return self.__dict__ == other.__dict__

def __ne__(self, other):
# type: (object) -> bool
"""Returns true if both objects are not equal"""
return not self == other
106 changes: 106 additions & 0 deletions ask-sdk-model/ask_sdk_model/services/monetization/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# coding: utf-8

#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
# except in compliance with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
# the specific language governing permissions and limitations under the License.
#

import pprint
import re # noqa: F401
import six
import typing
from enum import Enum


if typing.TYPE_CHECKING:
from typing import Dict, List, Optional, Union
from datetime import datetime
from ask_sdk_model.services.monetization.result_set import ResultSet


class Metadata(object):
"""
:param result_set:
:type result_set: (optional) ask_sdk_model.services.monetization.result_set.ResultSet
"""
deserialized_types = {
'result_set': 'ask_sdk_model.services.monetization.result_set.ResultSet'
} # type: Dict

attribute_map = {
'result_set': 'resultSet'
} # type: Dict

def __init__(self, result_set=None):
# type: (Optional[ResultSet]) -> None
"""
:param result_set:
:type result_set: (optional) ask_sdk_model.services.monetization.result_set.ResultSet
"""
self.__discriminator_value = None # type: str

self.result_set = result_set

def to_dict(self):
# type: () -> Dict[str, object]
"""Returns the model properties as a dict"""
result = {} # type: Dict

for attr, _ in six.iteritems(self.deserialized_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else
x.value if isinstance(x, Enum) else x,
value
))
elif isinstance(value, Enum):
result[attr] = value.value
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else
(item[0], item[1].value)
if isinstance(item[1], Enum) else item,
value.items()
))
else:
result[attr] = value

return result

def to_str(self):
# type: () -> str
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __repr__(self):
# type: () -> str
"""For `print` and `pprint`"""
return self.to_str()

def __eq__(self, other):
# type: (object) -> bool
"""Returns true if both objects are equal"""
if not isinstance(other, Metadata):
return False

return self.__dict__ == other.__dict__

def __ne__(self, other):
# type: (object) -> bool
"""Returns true if both objects are not equal"""
return not self == other
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from ask_sdk_model.services.monetization.error import Error
from ask_sdk_model.services.monetization.in_skill_product import InSkillProduct
from ask_sdk_model.services.monetization.in_skill_products_response import InSkillProductsResponse
from ask_sdk_model.services.monetization.in_skill_product_transactions_response import InSkillProductTransactionsResponse
import bool


class MonetizationServiceClient(BaseServiceClient):
Expand Down Expand Up @@ -182,3 +184,131 @@ def get_in_skill_product(self, accept_language, product_id, **kwargs):
body=body_params,
response_definitions=error_definitions,
response_type="ask_sdk_model.services.monetization.in_skill_product.InSkillProduct")

def get_in_skill_products_transactions(self, accept_language, **kwargs):
# type: (str, **Any) -> Union[Error, InSkillProductTransactionsResponse]
"""
Returns transactions of all in skill products purchases of the customer
:param accept_language: (required) User's locale/language in context
:type accept_language: str
:param product_id: Product Id.
:type product_id: str
: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.
:type status: str
: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'
:type from_last_modified_time: datetime
: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'
:type to_last_modified_time: datetime
: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.
:type next_token: str
: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.
:type max_results: float
:rtype: Union[Error, InSkillProductTransactionsResponse]
"""
operation_name = "get_in_skill_products_transactions"
params = locals()
for key, val in six.iteritems(params['kwargs']):
params[key] = val
del params['kwargs']
# verify the required parameter 'accept_language' is set
if ('accept_language' not in params) or (params['accept_language'] is None):
raise ValueError(
"Missing the required parameter `accept_language` when calling `" + operation_name + "`")

resource_path = '/v1/users/~current/skills/~current/inSkillProductsTransactions'
resource_path = resource_path.replace('{format}', 'json')

path_params = {} # type: Dict

query_params = [] # type: List
if 'product_id' in params:
query_params.append(('productId', params['product_id']))
if 'status' in params:
query_params.append(('status', params['status']))
if 'from_last_modified_time' in params:
query_params.append(('fromLastModifiedTime', params['from_last_modified_time']))
if 'to_last_modified_time' in params:
query_params.append(('toLastModifiedTime', params['to_last_modified_time']))
if 'next_token' in params:
query_params.append(('nextToken', params['next_token']))
if 'max_results' in params:
query_params.append(('maxResults', params['max_results']))

header_params = [] # type: List
if 'accept_language' in params:
header_params.append(('Accept-Language', params['accept_language']))

body_params = None
header_params.append(('Content-type', 'application/json'))

# Authentication setting
authorization_value = "Bearer " + self._authorization_value
header_params.append(("Authorization", authorization_value))

error_definitions = [] # type: List
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."))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=400, message="Invalid request"))
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"))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=403, message="Forbidden request"))
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."))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=412, message="Non-Child Directed Skill is not supported."))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=429, message="The request is throttled."))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=500, message="Internal Server Error"))

return self.invoke(
method="GET",
endpoint=self._api_endpoint,
path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
response_definitions=error_definitions,
response_type="ask_sdk_model.services.monetization.in_skill_product_transactions_response.InSkillProductTransactionsResponse")

def get_voice_purchase_setting(self, **kwargs):
# type: (**Any) -> Union[bool, Error]
"""
Returns whether or not voice purchasing is enabled for the skill
:rtype: Union[bool, Error]
"""
operation_name = "get_voice_purchase_setting"
params = locals()
for key, val in six.iteritems(params['kwargs']):
params[key] = val
del params['kwargs']

resource_path = '/v1/users/~current/skills/~current/settings/voicePurchasing.enabled'
resource_path = resource_path.replace('{format}', 'json')

path_params = {} # type: Dict

query_params = [] # type: List

header_params = [] # type: List

body_params = None
header_params.append(('Content-type', 'application/json'))

# Authentication setting
authorization_value = "Bearer " + self._authorization_value
header_params.append(("Authorization", authorization_value))

error_definitions = [] # type: List
error_definitions.append(ServiceClientResponse(response_type="bool", status_code=200, message="Returns a boolean value for voice purchase setting on success."))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=400, message="Invalid request."))
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"))
error_definitions.append(ServiceClientResponse(response_type="ask_sdk_model.services.monetization.error.Error", status_code=500, message="Internal Server Error."))

return self.invoke(
method="GET",
endpoint=self._api_endpoint,
path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
response_definitions=error_definitions,
response_type="bool")
Loading

0 comments on commit 4ed3917

Please sign in to comment.