コード例 #1
0
class Backup(sdk.python.entities.Entity):

    resource = '/backups/'
    json_name = 'backup'

    id = Property(int)
    file = Property(File)
コード例 #2
0
class ComponentTag(sdk.python.entities.Entity):

    json_name = 'componentTag'
    primary_key = 'name'

    id = Property(int)
    name = Property(str)
コード例 #3
0
class EmailAddress(sdk.python.entities.Entity):

    resource = '/email_addresses/'
    json_name = 'email_address'

    id = Property(int)
    email_address = Property(str)
コード例 #4
0
class PhoneNumber(sdk.python.entities.Entity):
    """ merchi python SDK object represent telephone numbers.

        Users and Companies are examples of entities which may have telephone
        numbers.

        The telephone number and (area) code are stored seperately, but they are
        both supplied as with type str, there is no other structure. Nonetheless
        the merchi backend is internally aware of more structure, and will not
        accept a telephone number which could not possibly be a valid format,
        or is not assigned to anyone.

        Methods for making requests to get or update the PhoneNumber are
        inherited from sdk.python.entities.Entity.
    """

    resource = '/phone_numbers/'
    json_name = 'phone_number'

    def __init__(self):
        super(PhoneNumber, self).__init__()
        self.escape_fields = ['code']

    id = Property(int)
    number = Property(str)
    code = Property(str)
    local_format_number = Property(str)
    international_format_number = Property(str)
コード例 #5
0
class EnrolledDomain(sdk.python.entities.Entity):

    resource = '/enrolled_domains/'
    json_name = 'enrolled_domain'

    id = Property(int)
    role = Property(str)
    domain = Property(Domain)
コード例 #6
0
ファイル: pages.py プロジェクト: merchisdk/sdk
class Page(sdk.python.entities.Entity):

    resource = '/pages/'
    json_name = 'page'

    id = Property(int)
    name = Property(str)
    slug = Property(str)
    template = Property(str)
コード例 #7
0
ファイル: discount.py プロジェクト: merchisdk/sdk
class Discount(sdk.python.entities.Entity):

    resource = '/discount/'
    json_name = 'discount'

    id = Property(int)
    lower_limit = Property(float)
    amount = Property(float)
    discount_group = Property(DiscountGroup)
コード例 #8
0
class DomainInvitation(sdk.python.entities.Entity):

    resource = '/domain_invitations/'
    json_name = 'domainInvitation'

    id = Property(int)
    user_name = Property(str)
    user_email = Property(str)
    role = Property(int)
コード例 #9
0
ファイル: discount_groups.py プロジェクト: merchisdk/sdk
class DiscountGroup(sdk.python.entities.Entity):

    resource = '/discount_group/'
    json_name = 'discountGroup'

    id = Property(int)
    discount_type = Property(int)
    discounts = Property("Discount")
    product = Property("Product")
コード例 #10
0
ファイル: exchange_rates.py プロジェクト: merchisdk/sdk
class ExchangeRate(sdk.python.entities.Entity):

    resource = '/exchange_rates/'
    json_name = 'exchangeRate'

    id = Property(int)
    from_currency = Property(str)
    to_currency = Property(str)
    rate = Property(str)
    last_updated = Property(datetime.datetime)
コード例 #11
0
class CartShipmentGroup(sdk.python.entities.Entity):

    resource = "/cart_shipment_groups/"
    json_name = "cartShipmentGroup"

    id = Property(int)
    items = Property("sdk.python.cart_items.CartItem")
    quotes = Property("sdk.python.cart_shipment_quotes.CartShipmentQuote")
    selectedQuote = Property(
        "sdk.python.cart_shipment_quotes.CartShipmentQuote")
コード例 #12
0
class ThemeCssSetting(sdk.python.entities.Entity):

    resource = '/theme_css_settings/'
    json_name = 'themeCssSetting'

    id = Property(int)
    created = Property(datetime.datetime)
    created_by = Property('sdk.python.users.User')
    allowed_attributes = Property(str)
    not_allowed_attributes = Property(str)
コード例 #13
0
class CartShipmentQuote(sdk.python.entities.Entity):

    resource = '/cart_shipment_quotes/'
    json_name = 'cartShipmentQuote'

    id = Property(int)
    subtotal_cost = Property(float)
    tax_amount = Property(float)
    total_cost = Property(float)
    shipment_method = Property("sdk.python.shipment_methods.ShipmentMethod")
コード例 #14
0
class MatchingInventory(sdk.python.entities.Entity):

    resource = '/matching_inventories/'
    json_name = 'matching_inventory'

    status = Property(int)
    deduction_date = Property(datetime.datetime)
    job = Property(Job, backref="matching_inventories")
    group = Property(VariationsGroup, backref="matching_inventory")
    inventory = Property(Inventory)
コード例 #15
0
ファイル: email_counters.py プロジェクト: merchisdk/sdk
class EmailCounter(sdk.python.entities.Entity):

    resource = '/email_counters/'
    json_name = 'emailCounter'
    primary_key = 'email_address'

    email_address = Property(str)
    unsubscribed = Property(bool)
    silenced = Property(bool)
    tokens = Property(int)
コード例 #16
0
class Category(sdk.python.entities.Entity):

    resource = '/categories/'
    json_name = 'category'

    id = Property(int)
    name = Property(str)
    show_dashboard = Property(bool)
    show_public = Property(bool)
    domain = Property(Domain, backref="categories")
コード例 #17
0
ファイル: supply_domains.py プロジェクト: merchisdk/sdk
class SupplyDomain(sdk.python.entities.Entity):

    resource = '/supply_domains/'
    json_name = 'supplyDomain'

    id = Property(int)
    needs_drafting = Property(bool)
    product = Property('sdk.python.products.Product', backref='supply_domains')
    supply_product = Property('sdk.python.products.Product',
                              backref='supplied_by_domains')
    domain = Property('sdk.python.domains.Domain', backref='supply_products')
コード例 #18
0
class UserCompany(sdk.python.entities.Entity):

    resource = '/user_companies/'
    json_name = 'userCompany'

    def __init__(self):
        super(UserCompany, self).__init__()
        self.escape_fields = ['main', 'is_admin']

    main = Property(bool)
    is_admin = Property(bool)
コード例 #19
0
class Menu(sdk.python.entities.Entity):

    resource = '/menus/'
    json_name = 'menu'

    id = Property(int)
    name = Property(str)
    menu_handle = Property(str)
    menu_type = Property(int)
    menu_items = Property(MenuItem)

    def menu_items_in_order(self):
        """ Return a list of menu_items sorted by their position """
        return sorted(self.menu_items, key=attrgetter('position'))
コード例 #20
0
ファイル: themes.py プロジェクト: merchisdk/sdk
class DefaultTheme(sdk.python.entities.Entity):
    """ Resource for the default theme. """

    resource = '/default_themes/'
    json_name = 'defaultTheme'

    name = Property(str)
コード例 #21
0
ファイル: sessions.py プロジェクト: merchisdk/sdk
class Session(sdk.python.entities.Entity):

    primary_key = 'token'
    resource = '/sessions/'
    json_name = 'session'

    ip = Property(str)
    user = Property(User)
    domain = Property(Domain)
    token = Property(str)
    remember = Property(bool)

    def cookie_ttl(self):
        if self.remember:
            return years_to_seconds(2)
        # session cookie
        return None
コード例 #22
0
class DraftComment(sdk.python.entities.Entity):

    resource = '/draft_comments/'
    json_name = 'draft_comment'

    id = Property(int)
    file = Property(File)
    urgency = Property(int)
    subject = Property(str)
    date = Property(datetime.datetime)
    text = Property(str)
    change_request = Property(bool)
    send_sms = Property(bool)
    send_email = Property(bool)
コード例 #23
0
ファイル: draft_templates.py プロジェクト: merchisdk/sdk
class DraftTemplate(sdk.python.entities.Entity):

    resource = '/draft_templates/'
    json_name = 'draft_template'

    id = Property(int)
    file = Property(File)
    product = Property(Product)
    job = Property(Job)
    description = Property(str)
    name = Property(str)
    date = Property(datetime.datetime)
    height = Property(int)
    width = Property(int)
コード例 #24
0
class ShipmentMethodVariation(sdk.python.entities.Entity):

    resource = '/shipment_method_variations/'
    json_name = 'shipmentMethodVariation'

    id = Property(int)
    destination_country = Property(str)
    destination_state = Property(str)
    cost = Property(float)
    currency = Property(str)
    buy_cost = Property(float)
    buy_currency = Property(str)
    max_weight = Property(float)
    tax_type = Property('sdk.python.country_taxes.CountryTax')
コード例 #25
0
ファイル: production_comments.py プロジェクト: merchisdk/sdk
class ProductionComment(sdk.python.entities.Entity):

    resource = '/production_comments/'
    json_name = 'production_comment'

    id = Property(int)
    file = Property(File)
    date = Property(datetime.datetime)
    text = Property(str)
    urgency = Property(int)
    subject = Property(str)
    is_urgent_question = Property(bool)
    send_sms = Property(bool)
    send_email = Property(bool)
コード例 #26
0
ファイル: job_comments.py プロジェクト: merchisdk/sdk
class JobComment(sdk.python.entities.Entity):

    resource = '/job_comments/'
    json_name = 'job_comment'

    id = Property(int)
    file = Property(File)
    date = Property(datetime.datetime)
    text = Property(str)
    urgency = Property(int)
    subject = Property(str)
    send_sms = Property(bool)
    send_email = Property(bool)
    open_to_client = Property(bool)
コード例 #27
0
class File(sdk.python.entities.Entity):

    resource = '/files/'
    json_name = 'file'
    url_fields = ['view_url', 'download_url']

    id = Property(int)
    name = Property(str)
    size = Property(int)
    mimetype = Property(str)
    view_url = Property(str)
    download_url = Property(str)
    creation_date = Property(datetime.datetime)

    def __init__(self):
        super(File, self).__init__()
        self.url_fields = ['view_url', 'download_url']
        self.file_data = []  # type: Any

    def from_flask_file(self, flask_file):
        self.name = secure_filename(flask_file.filename)
        self.mimetype = flask_file.mimetype
        self.file_data = (self.name, flask_file, flask_file.mimetype)

    @property
    def is_image(self):
        try:
            return self.mimetype.split('/')[0] == 'image'
        except AttributeError:
            return True

    @property
    def is_pdf(self):
        return self.mimetype in {'application/pdf', 'application/x-pdf'}
コード例 #28
0
ファイル: users.py プロジェクト: merchisdk/sdk
class SystemRole(sdk.python.entities.Entity):

    resource = '/system_roles/'
    json_name = 'system_role'

    role = Property(int)

    def __repr__(self, **kwargs):
        return "<role {}>".format(self.role)
コード例 #29
0
ファイル: country_taxes.py プロジェクト: merchisdk/sdk
class CountryTax(sdk.python.entities.Entity):

    resource = '/country_taxes/'
    json_name = 'countryTax'

    id = Property(int)
    country = Property(str)
    tax_name = Property(str)
    tax_percent = Property(float)

    def country_name(self):
        if not self.country:
            return "World Wide"
        return pycountry.countries.get(alpha_2=self.country).name

    @property
    def full_name(self):
        return "{} ({})".format(self.tax_name, self.country_name())
コード例 #30
0
class Bank(sdk.python.entities.Entity):

    resource = '/banks/'
    json_name = 'bank'

    id = Property(int)
    default = Property(bool)
    bank_name = Property(str)
    account_number = Property(str)
    account_name = Property(str)
    bsb = Property(str)
    swift_code = Property(str)
    iban = Property(str)
    bank_code = Property(str)
    bank_address = Property(Address)

    def __init__(self):
        super(Bank, self).__init__()
        self.escape_fields = ['default']