diff --git a/corepos/api.py b/corepos/api.py index abe2afc..3a8b624 100644 --- a/corepos/api.py +++ b/corepos/api.py @@ -166,6 +166,29 @@ class CoreWebAPI(object): if result: return result + def get_stores(self, **columns): + """ + Fetch some or all of Store records from CORE. + + :returns: A (potentially empty) list of store dict records. + + To fetch all stores:: + + api.get_stores() + + To fetch only stores named "Headquarters":: + + api.get_stores(description='Headquarters') + """ + params = { + 'entity': 'Stores', + 'submethod': 'get', + 'columns': columns, + } + response = self.post(params) + result = self.parse_response(response) + return [json.loads(rec) for rec in result] + def get_departments(self, **columns): """ Fetch some or all of Department records from CORE. diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index a4da4fc..0e8bf49 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -92,6 +92,41 @@ class Parameter(Base): return "{}-{} {}".format(self.store_id, self.lane_id, self.param_key) +class Store(Base): + """ + Represents a known store. + """ + __tablename__ = 'Stores' + + storeID = sa.Column(sa.Integer(), nullable=False, primary_key=True, autoincrement=True) + id = orm.synonym('storeID') + + description = sa.Column(sa.String(length=50), nullable=True) + + db_host = sa.Column('dbHost', sa.String(length=50), nullable=True) + + db_driver = sa.Column('dbDriver', sa.String(length=15), nullable=True) + + db_user = sa.Column('dbUser', sa.String(length=25), nullable=True) + + db_password = sa.Column('dbPassword', sa.String(length=25), nullable=True) + + trans_db = sa.Column('transDB', sa.String(length=20), nullable=True) + + op_db = sa.Column('opDB', sa.String(length=20), nullable=True) + + push = sa.Column(sa.Boolean(), nullable=True, default=True) + + pull = sa.Column(sa.Boolean(), nullable=True, default=True) + + has_own_items = sa.Column('hasOwnItems', sa.Boolean(), nullable=True, default=True) + + web_service_url = sa.Column('webServiceUrl', sa.String(length=255), nullable=True) + + def __str__(self): + return self.description or "" + + class SuperDepartment(Base): """ Represents a "super" (parent/child) department mapping.