"""Local Client for ows-sales-goals.""" import json import application class LocalClient: """A client to hit the local flask server.""" def get_territories(self): """Get the territories.""" response = application.app.test_client().get('/territories') return response.status_code, json.loads(response.data.decode('utf8')) def create_sales_goals(self, product_id, data): """Get the territories.""" response = application.app.test_client().post( '/goals/{}'.format(product_id), data=json.dumps({'sales_goals': data}), content_type='application/json' ) return response.status_code, json.loads(response.data.decode('utf8')) def get_sales_goals(self, product_id): """Get the territories.""" response = application.app.test_client().get( '/goals/{}'.format(product_id) ) return response.status_code, json.loads(response.data.decode('utf8')) def create_target_market_goal(self, product_id, country_id, data): """Get the territories.""" response = application.app.test_client().post( '/goals/{}/{}'.format(product_id, country_id), data=json.dumps(data), content_type='application/json' ) return response.status_code, json.loads(response.data.decode('utf8')) def delete_target_market_goal(self, product_id, country_id): """Get the territories.""" response = application.app.test_client().delete( '/goals/{}/{}'.format(product_id, country_id) ) return response.status_code, json.loads(response.data.decode('utf8')) def update_target_market_goal(self, product_id, data): """Update target market goal.""" response = application.app.test_client().patch( '/goals/{}'.format(product_id), data=json.dumps(data), content_type='application/json' ) return response.status_code, json.loads(response.data.decode('utf8')) def upsert_digital_global_projection(self, product_id, data): """Upsert the projection.""" response = application.app.test_client().post( '/digital/{}'.format(product_id), data=json.dumps(data), content_type='application/json' ) return response.status_code, json.loads(response.data.decode('utf8')) def upsert_digital_territory_projection(self, product_id, data): """Upsert the projection.""" response = application.app.test_client().post( '/digital/{}/projections'.format(product_id), data=json.dumps(data), content_type='application/json' ) return response.status_code, json.loads(response.data.decode('utf8'))