Skip to content
This repository has been archived by the owner on Jan 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from shmokmt/feature/jsonschema
Browse files Browse the repository at this point in the history
Feature/jsonschema
  • Loading branch information
shmokmt committed Apr 30, 2020
2 parents a3622b4 + fc73e41 commit 0e35ec9
Show file tree
Hide file tree
Showing 10 changed files with 922 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload the Python package to PyPI.
name: Release
on:
push:
tags:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Python package for App Store Connect API.

![python_version](https://img.shields.io/pypi/pyversions/app-store-connect-client) ![LICENSE](https://img.shields.io/pypi/l/app-store-connect-client)
![python_version](https://img.shields.io/pypi/pyversions/app-store-connect-client) ![latest_version](https://img.shields.io/pypi/v/app-store-connect-client) ![LICENSE](https://img.shields.io/pypi/l/app-store-connect-client)

It supports Python3.6.1+.

Expand Down Expand Up @@ -65,6 +65,8 @@ print(json.dumps(results, indent=4))
* Support 2FA Authentication
* Docstring
* Support Review API
* Support group_by method
* Support filter_by method

## Credit

Expand Down
9 changes: 8 additions & 1 deletion app_store_connect_client/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from requests.exceptions import Timeout
from urllib.parse import urlparse
import json
from . import query
import jsonschema
from . import query, exceptions
from .log import logger


Expand Down Expand Up @@ -113,4 +114,10 @@ def execute(self, query=None):
logger.error("This is your request body.")
logger.error(request_body)
raise Exception("400 Bad Request. Please check your config.")
with open(f'app_store_connect_client/jsonschema/{query.type}.json') as f:
schema = json.load(f)
try:
jsonschema.validate(res.json(), schema)
except jsonschema.exceptions.ValidationError:
raise exceptions.ValidationError("ERROR: response jsonschema is invalid.")
return res.json()
25 changes: 25 additions & 0 deletions app_store_connect_client/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from .dataclass import frequency

# TODO: use Config class Instead of config dict.
class Config():
def __init__(self, app_id):
self.startTime = None
self.endTime = None
self.adamId = [app_id]
self.group = None
self.frequency = frequency.days
self.dimensionFilters = []
self.measures = []


class MeasuresConfig(Config):
def __init__(self, app_id):
self.group = {}


class SourcesConfig(Config):
def __init__(self, app_id):
self.measures: list = []
self.dimension: str = None


9 changes: 9 additions & 0 deletions app_store_connect_client/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AppStoreConnectException(Exception):
pass


class AppStoreConnectValidationError(AppStoreConnectException):
pass

class AppStoreConnectValueError(AppStoreConnectException):
pass
Loading

0 comments on commit 0e35ec9

Please sign in to comment.