diff --git a/javascript/company.js b/javascript/company.js index 405c3160..445359d6 100644 --- a/javascript/company.js +++ b/javascript/company.js @@ -16,6 +16,8 @@ import { ShipmentMethod } from './shipment_method.js'; import { User } from './user.js'; import { UserCompany } from './user_company.js'; import { PaymentDevice } from './payment_device.js'; +import { InternalTag } from './internal_tag.js'; + export function Company() { this.resource = '/companies'; @@ -94,6 +96,7 @@ export function Company() { addPropertyTo(this, 'aiContext'); addPropertyTo(this, 'internalUseNotes'); addPropertyTo(this, 'internalUseAiContext'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, as_domain) { var data = serialise(this), diff --git a/javascript/domain.js b/javascript/domain.js index eecc0930..b584c439 100644 --- a/javascript/domain.js +++ b/javascript/domain.js @@ -13,6 +13,7 @@ import { Menu } from './menu.js'; import { SupplyDomain } from './supply_domain.js'; import { SeoDomainPage } from './seo_domain_page.js'; import { User, Users } from './user.js'; +import { InternalTag } from './internal_tag.js'; export function Domain() { this.resource = '/domains'; @@ -76,6 +77,7 @@ export function Domain() { addPropertyTo(this, 'domainInvitations', DomainInvitation); addPropertyTo(this, 'jobsAssignees', User); addPropertyTo(this, 'tags', DomainTag); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, as_domain) { var data = serialise(this), diff --git a/javascript/internal_tag.js b/javascript/internal_tag.js new file mode 100644 index 00000000..e822ced6 --- /dev/null +++ b/javascript/internal_tag.js @@ -0,0 +1,90 @@ +import { generateUUID } from './uuid.js'; +import { addPropertyTo, serialise, create, fromJson, patchOne, deleteOne, + fromJsonList, getList, enumerateFiles, getOne } from './model.js'; +import { Company } from './company.js'; +import { Domain } from './domain.js'; +import { Invoice } from './invoice.js'; +import { Job } from './job.js'; +import { Product } from './product.js'; +import { Shipment } from './shipment.js'; +import { Theme } from './theme.js'; +import { User } from './user.js'; + +export function InternalTag() { + this.resource = '/internal_tags'; + this.json = 'internalTag'; + this.temporaryId = generateUUID(); + + addPropertyTo(this, 'id'); + addPropertyTo(this, 'name'); + addPropertyTo(this, 'description'); + addPropertyTo(this, 'colour'); + addPropertyTo(this, 'companies', Company); + addPropertyTo(this, 'domains', Domain); + addPropertyTo(this, 'invoices', Invoice); + addPropertyTo(this, 'jobs', Job); + addPropertyTo(this, 'products', Product); + addPropertyTo(this, 'shipments', Shipment); + addPropertyTo(this, 'themes', Theme); + addPropertyTo(this, 'users', User) + + this.create = function (success, error, embed, domainId) { + var data = serialise(this), + self = this; + function handleResponse(result) { + success(fromJson(self, result[self.json])); + } + create({resource: this.resource, + parameters: data[0], + files: enumerateFiles(data[1]), + success: handleResponse, + error: error, + embed: embed, + as_domain: domainId}); + }; + + this.get = function (success, error) { + var self = this; + function handleResponse(result) { + success(fromJson(self, result[self.json], + {makesDirty: false})); + } + getOne({resource: this.resource, + id: this.id(), + success: handleResponse, + error: error}); + }; + + this.patch = function (success, error, embed) { + var self = this, + data = serialise(this)[0]; + function handleResponse(result) { + success(fromJson(self, result[self.json], + {makesDirty: false})); + } + patchOne({resource: this.resource, + id: this.id(), + success: handleResponse, + error: error, + data: data, + embed: embed}); + }; + + this.destroy = function (success, error) { + deleteOne(this.resource + "/" + this.id(), success, error); + }; +} + +export function InternalTags() { + this.resource = '/internal_tags'; + this.json = 'internalTags'; + this.single = InternalTag; + + this.get = function (success, error, parameters) { + var self = this; + function handleResponse(result) { + success(fromJsonList(self, result, {makesDirty: false})); + } + getList(this.resource, handleResponse, error, parameters); + }; +} diff --git a/javascript/invoice.js b/javascript/invoice.js index 145e071d..a1a85577 100644 --- a/javascript/invoice.js +++ b/javascript/invoice.js @@ -16,6 +16,7 @@ import { MerchiFile } from './merchi_file.js'; import { Quote } from './quote.js'; import { Payment } from './payment.js'; import { Job } from './job.js'; +import { InternalTag } from './internal_tag.js'; export function Invoice() { this.resource = '/invoices'; @@ -67,6 +68,7 @@ export function Invoice() { addPropertyTo(this, 'isCompletelyPaid'); addPropertyTo(this, 'shipments', Shipment); addPropertyTo(this, 'shopifyOrderId'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, asDomain) { var data = serialise(this), diff --git a/javascript/job.js b/javascript/job.js index 2e5d0e7f..5b12c3c7 100644 --- a/javascript/job.js +++ b/javascript/job.js @@ -28,6 +28,7 @@ import { User } from './user.js'; import { Variation } from './variation.js'; import { VariationsGroup } from './variations_group.js'; import { JobComment } from './job_comment.js'; +import { InternalTag } from './internal_tag.js'; export function Job() { @@ -125,6 +126,7 @@ export function Job() { addPropertyTo(this, 'shopifyShopUrl'); addPropertyTo(this, 'shopifyOrderId'); addPropertyTo(this, 'shopifyOrderLineItemId'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function ( success, error, embed, asDomain, withRights) { diff --git a/javascript/merchi.js b/javascript/merchi.js index c29ac89d..cd686fea 100644 --- a/javascript/merchi.js +++ b/javascript/merchi.js @@ -77,6 +77,7 @@ import { VariationFieldsOption } from './variation_fields_option.js'; import { VariationsGroup } from './variations_group.js'; import { QuoteItem, QuoteItems } from './quote_item.js'; import { Quotes, Quote } from './quote.js'; +import { InternalTag, InternalTags } from './internal_tag.js'; export function merchi(backendUri, websocketUri) { getGlobal().merchiJsonpHandlers = {}; @@ -941,6 +942,8 @@ export function merchi(backendUri, websocketUri) { 'inventories': new Inventories(), 'InventoryUnitVariation': InventoryUnitVariation, 'matchiingInventory': MatchingInventory, + 'InternalTag': InternalTag, + 'internalTags': new InternalTags(), 'Invoice': Invoice, 'invoices': new Invoices(), 'Job': Job, diff --git a/javascript/product.js b/javascript/product.js index 955544bd..f081642c 100644 --- a/javascript/product.js +++ b/javascript/product.js @@ -21,6 +21,7 @@ import { SupplyDomain } from './supply_domain.js'; import { User } from './user.js'; import { Job } from './job.js'; import { SeoDomainPage } from './seo_domain_page.js'; +import { InternalTag } from './internal_tag.js'; export function Product() { this.resource = '/products'; @@ -109,6 +110,7 @@ export function Product() { addPropertyTo(this, 'aiContext'); addPropertyTo(this, 'internalUseNotes'); addPropertyTo(this, 'internalUseAiContext'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, asDomain) { var data = serialise(this), diff --git a/javascript/shipment.js b/javascript/shipment.js index 3c11296d..1a8b9651 100644 --- a/javascript/shipment.js +++ b/javascript/shipment.js @@ -13,6 +13,7 @@ import { Job } from './job.js'; import { MerchiFile } from './merchi_file.js'; import { ShipmentItem } from './shipment_item.js'; import { ShipmentMethod } from './shipment_method.js'; +import { InternalTag } from './internal_tag.js'; export function Shipment() { this.resource = '/shipments'; @@ -56,6 +57,7 @@ export function Shipment() { addPropertyTo(this, 'tags', DomainTag); addPropertyTo(this, 'shipmentItems', ShipmentItem) addPropertyTo(this, 'shipmentMethod', ShipmentMethod); + addPropertyTo(this, 'internalTags', InternalTag); this.get = function (success, error, embed) { var self = this; diff --git a/javascript/theme.js b/javascript/theme.js index 507fc2f9..37b35115 100644 --- a/javascript/theme.js +++ b/javascript/theme.js @@ -7,6 +7,7 @@ import { Component } from './component.js'; import { Domain } from './domain.js'; import { Page } from './page.js'; import { User } from './user.js'; +import { InternalTag } from './internal_tag.js'; export function Theme() { this.resource = '/themes'; @@ -89,6 +90,7 @@ export function Theme() { addPropertyTo(this, 'author', User); addPropertyTo(this, 'domain', Domain); addPropertyTo(this, 'defaultForDomainType'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, as_domain) { var self = this, diff --git a/javascript/user.js b/javascript/user.js index a9d94e75..0f7073e0 100644 --- a/javascript/user.js +++ b/javascript/user.js @@ -15,6 +15,7 @@ import { Domain } from './domain.js'; import { MerchiFile } from './merchi_file.js'; import { SystemRole } from './system_role.js'; import { UserCompany } from './user_company.js'; +import { InternalTag } from './internal_tag.js'; export function User() { this.resource = '/users'; @@ -51,6 +52,7 @@ export function User() { addPropertyTo(this, 'aiContext'); addPropertyTo(this, 'internalUseNotes'); addPropertyTo(this, 'internalUseAiContext'); + addPropertyTo(this, 'internalTags', InternalTag); this.create = function (success, error, embed, as_domain) { var self = this, diff --git a/python/internal_tags.py b/python/internal_tags.py new file mode 100644 index 00000000..8d3108d7 --- /dev/null +++ b/python/internal_tags.py @@ -0,0 +1,40 @@ +import sdk.python.entities +from sdk.python.companies import Company +from sdk.python.domains import Domain +from sdk.python.invoices import Invoice +from sdk.python.jobs import Job +from sdk.python.products import Product +from sdk.python.entities import Property +from sdk.python.shipments import Shipment +from sdk.python.themes import Theme +from sdk.python.users import User + + +class InternalTag(sdk.python.entities.Entity): + + json_name = 'internalTag' + resource = '/internal_tags/' + + id = Property(int) + name = Property(str) + # colour is in RRGGBB format. + colour = Property(int) + description = Property(str) + + companies = Property(Company, backref="internal_tags") + domains = Property(Domain, backref="internal_tags") + invoices = Property(Invoice, backref="internal_tags") + jobs = Property(Job, backref="internal_tags") + products = Property(Product, backref="internal_tags") + shipments = Property(Shipment, backref="internal_tags") + themes = Property(Theme, backref="internal_tags") + users = Property(User, backref="internal_tags") + + +class InternalTags(sdk.python.entities.Resource): + + entity_class = InternalTag + json_name = 'internalTags' + + +internal_tags = InternalTags() diff --git a/typescript/src/entities/company.ts b/typescript/src/entities/company.ts index cccfaf76..27c09ed6 100644 --- a/typescript/src/entities/company.ts +++ b/typescript/src/entities/company.ts @@ -8,6 +8,7 @@ import { Domain } from './domain'; import { EmailAddress } from './email_address'; import { Entity } from '../entity'; import { MerchiFile } from './file'; +import { InternalTag } from './internal_tag'; import { Invoice } from './invoice'; import { Job } from './job'; import { PhoneNumber } from './phone_number'; @@ -188,6 +189,9 @@ export class Company extends Entity { @Company.property() public country?: string; + @Company.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Company.property({type: MerchiFile}) public logo?: MerchiFile | null; diff --git a/typescript/src/entities/domain.ts b/typescript/src/entities/domain.ts index 7358e4b2..8c47d481 100644 --- a/typescript/src/entities/domain.ts +++ b/typescript/src/entities/domain.ts @@ -6,6 +6,7 @@ import { DomainTag } from './domain_tag'; import { EnrolledDomain } from './enrolled_domain'; import { Entity } from '../entity'; import { MerchiFile } from './file'; +import { InternalTag } from './internal_tag'; import { Invoice } from './invoice'; import { Job } from './job'; import { Menu } from './menu'; @@ -164,6 +165,9 @@ export class Domain extends Entity { @Domain.property() public activeTheme?: Theme; + @Domain.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Domain.property({arrayType: 'DomainTag'}) public tags?: DomainTag[]; diff --git a/typescript/src/entities/internal_tag.test.ts b/typescript/src/entities/internal_tag.test.ts new file mode 100644 index 00000000..5e82f27e --- /dev/null +++ b/typescript/src/entities/internal_tag.test.ts @@ -0,0 +1,7 @@ +import { Merchi } from '../merchi'; + +test('can make InternalTag', () => { + const merchi = new Merchi(); + const internalTag = new merchi.InternalTag(); + expect(internalTag).toBeTruthy(); +}); diff --git a/typescript/src/entities/internal_tag.ts b/typescript/src/entities/internal_tag.ts new file mode 100644 index 00000000..a38477a7 --- /dev/null +++ b/typescript/src/entities/internal_tag.ts @@ -0,0 +1,51 @@ +import { Company } from './company'; +import { Domain } from './domain'; +import { Entity } from '../entity'; +import { Invoice } from './invoice'; +import { Job } from './job'; +import { Product } from './product'; +import { Shipment } from './shipment'; +import { Theme } from './theme'; +import { User } from './user'; + +export class InternalTag extends Entity { + protected static resourceName = 'internal_tags'; + protected static singularName = 'internalTag'; + protected static pluralName = 'internalTags'; + + @InternalTag.property() + public id?: number; + + @InternalTag.property() + public colour?: number; + + @InternalTag.property() + public name?: string; + + @InternalTag.property() + public description?: string; + + @InternalTag.property({arrayType: 'Company'}) + public companies?: Company[]; + + @InternalTag.property({arrayType: 'Domain'}) + public domains?: Domain[]; + + @InternalTag.property({arrayType: 'Job'}) + public jobs?: Job[]; + + @InternalTag.property({arrayType: 'Product'}) + public products?: Product[]; + + @InternalTag.property({arrayType: 'Invoice'}) + public invoices?: Invoice[]; + + @InternalTag.property({arrayType: 'Shipment'}) + public shipments?: Shipment[]; + + @InternalTag.property({arrayType: 'Theme'}) + public themes?: Theme[]; + + @InternalTag.property({arrayType: 'User'}) + public users?: User[]; +} diff --git a/typescript/src/entities/invoice.ts b/typescript/src/entities/invoice.ts index b33249dd..6087d5cb 100644 --- a/typescript/src/entities/invoice.ts +++ b/typescript/src/entities/invoice.ts @@ -6,6 +6,7 @@ import { DomainTag } from './domain_tag'; import { EmailAddress } from './email_address'; import { Entity } from '../entity'; import { MerchiFile } from './file'; +import { InternalTag } from './internal_tag'; import { Item } from './item'; import { Job } from './job'; import { Quote } from './quote'; @@ -152,6 +153,9 @@ export class Invoice extends Entity { @Invoice.property({type: EmailAddress}) public clientCompanyEmail?: EmailAddress | null; + @Invoice.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Invoice.property({arrayType: 'DomainTag'}) public tags?: DomainTag[]; diff --git a/typescript/src/entities/job.ts b/typescript/src/entities/job.ts index 86832bd0..1c57f688 100644 --- a/typescript/src/entities/job.ts +++ b/typescript/src/entities/job.ts @@ -10,6 +10,7 @@ import { EmailAddress } from './email_address'; import { Entity } from '../entity'; import { MerchiFile } from './file'; import { MatchingInventory } from './matching_inventory'; +import { InternalTag } from './internal_tag'; import { Invoice } from './invoice'; import { JobComment } from './job_comment'; import { Notification } from './notification'; @@ -244,6 +245,9 @@ export class Job extends Entity { @Job.property({type: CountryTax}) public taxType?: CountryTax | null; + @Job.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Job.property({arrayType: 'DomainTag'}) public tags?: DomainTag[]; diff --git a/typescript/src/entities/product.ts b/typescript/src/entities/product.ts index b2596816..f5452fea 100644 --- a/typescript/src/entities/product.ts +++ b/typescript/src/entities/product.ts @@ -10,6 +10,7 @@ import { DomainTag } from './domain_tag'; import { DraftTemplate } from './draft_template'; import { Entity } from '../entity'; import { MerchiFile } from './file'; +import { InternalTag } from './internal_tag'; import { Inventory } from './inventory'; import { Job } from './job'; import { SupplyDomain } from './supply_domain'; @@ -245,6 +246,9 @@ export class Product extends Entity { @Product.property({arrayType: 'DomainTag'}) public tags?: DomainTag[]; + @Product.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Product.property({arrayType: 'SeoDomainPage'}) public seoDomainPages?: SeoDomainPage[]; diff --git a/typescript/src/entities/shipment.ts b/typescript/src/entities/shipment.ts index 7e676e25..4a53ca84 100644 --- a/typescript/src/entities/shipment.ts +++ b/typescript/src/entities/shipment.ts @@ -4,6 +4,7 @@ import { Company } from './company'; import { CountryTax } from './country_tax'; import { DomainTag } from './domain_tag'; import { Entity } from '../entity'; +import { InternalTag } from './internal_tag'; import { Invoice } from './invoice'; import { Quote } from './quote'; import { Job } from './job'; @@ -39,6 +40,9 @@ export class Shipment extends Entity { @Shipment.property() public pickUp?: boolean; + @Shipment.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Shipment.property({type: MerchiFile}) public shipmentLabel?: MerchiFile | null; diff --git a/typescript/src/entities/theme.ts b/typescript/src/entities/theme.ts index 3e0d7934..5c75a354 100644 --- a/typescript/src/entities/theme.ts +++ b/typescript/src/entities/theme.ts @@ -2,6 +2,7 @@ import { Component } from './component'; import { Domain } from './domain'; import { Entity } from '../entity'; import { MerchiFile } from './file'; +import { InternalTag } from './internal_tag'; import { User } from './user'; import { Menu } from './menu'; import { Page } from './page'; @@ -21,6 +22,9 @@ export class Theme extends Entity { @Theme.property() public foundation?: number; + @Theme.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @Theme.property({arrayType: 'Component'}) public components?: Component[]; diff --git a/typescript/src/entities/user.ts b/typescript/src/entities/user.ts index 724cee04..c5babf72 100644 --- a/typescript/src/entities/user.ts +++ b/typescript/src/entities/user.ts @@ -31,6 +31,7 @@ import { Role, BUSINESS_ACCOUNTS, ROLES_RANK } from '../constants/roles'; +import { InternalTag } from './internal_tag'; import { UserType } from '../constants/user_types'; import { SystemRoles as SR } from '../constants/system_roles'; @@ -56,6 +57,9 @@ export class User extends Entity { @User.property() public registeredAsGuest?: boolean; + @User.property({arrayType: 'InternalTag'}) + public internalTags?: InternalTag[]; + @User.property({arrayType: 'Domain'}) public registeredUnderDomains?: Domain[]; diff --git a/typescript/src/merchi.ts b/typescript/src/merchi.ts index 2da02aaa..7cf6d255 100644 --- a/typescript/src/merchi.ts +++ b/typescript/src/merchi.ts @@ -15,6 +15,7 @@ import { VariationField } from './entities/variation_field'; import { VariationOption } from './entities/variation_option'; import { ProductionComment } from './entities/production_comment'; import { Product } from './entities/product'; +import { InternalTag } from './entities/internal_tag'; import { Inventory } from './entities/inventory'; import { QuoteItem } from './entities/quote_item'; import { Category } from './entities/category'; @@ -114,6 +115,7 @@ export class Merchi { public MenuItem: typeof MenuItem; public VariationField: typeof VariationField; public Assignment: typeof Assignment; + public InternalTag: typeof InternalTag; public Inventory: typeof Inventory; public JobComment: typeof JobComment; public VariationOption: typeof VariationOption; @@ -219,6 +221,7 @@ export class Merchi { this.ThemeCssSetting = this.setupClass(ThemeCssSetting) as typeof ThemeCssSetting; this.Company = this.setupClass(Company) as typeof Company; this.MenuItem = this.setupClass(MenuItem) as typeof MenuItem; + this.InternalTag = this.setupClass(InternalTag) as typeof InternalTag; this.Inventory = this.setupClass(Inventory) as typeof Inventory; this.Notification = this.setupClass(Notification) as typeof Notification; this.Shipment = this.setupClass(Shipment) as typeof Shipment;