class Backup(sdk.python.entities.Entity): resource = '/backups/' json_name = 'backup' id = Property(int) file = Property(File)
class ComponentTag(sdk.python.entities.Entity): json_name = 'componentTag' primary_key = 'name' id = Property(int) name = Property(str)
class EmailAddress(sdk.python.entities.Entity): resource = '/email_addresses/' json_name = 'email_address' id = Property(int) email_address = Property(str)
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)
class EnrolledDomain(sdk.python.entities.Entity): resource = '/enrolled_domains/' json_name = 'enrolled_domain' id = Property(int) role = Property(str) domain = Property(Domain)
class Page(sdk.python.entities.Entity): resource = '/pages/' json_name = 'page' id = Property(int) name = Property(str) slug = Property(str) template = Property(str)
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)
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)
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")
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)
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")
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)
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")
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)
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)
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")
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')
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)
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'))
class DefaultTheme(sdk.python.entities.Entity): """ Resource for the default theme. """ resource = '/default_themes/' json_name = 'defaultTheme' name = Property(str)
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
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)
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)
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')
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)
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)
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'}
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)
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())
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']