Add basic support for Stores schema and API
This commit is contained in:
parent
d398e706c4
commit
ee9451588c
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue