|
30 | 30 | from ask_sdk_model.services.monetization.error import Error
|
31 | 31 | from ask_sdk_model.services.monetization.in_skill_product import InSkillProduct
|
32 | 32 | 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 |
33 | 35 |
|
34 | 36 |
|
35 | 37 | class MonetizationServiceClient(BaseServiceClient):
|
@@ -182,3 +184,131 @@ def get_in_skill_product(self, accept_language, product_id, **kwargs):
|
182 | 184 | body=body_params,
|
183 | 185 | response_definitions=error_definitions,
|
184 | 186 | 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'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'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'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