-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Variants (Entry, VariantGroup & Type support) & package version bump #108
base: develop
Are you sure you want to change the base?
Changes from all commits
19c872b
7658bba
9d63045
800475f
89a0605
a630472
91f02d9
e9590c5
2a75eba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Base from "../stack/api/base"; | ||
import { GenericObjectType } from "../types/common.types"; | ||
|
||
/** | ||
* Class representing the Variant Group. | ||
*/ | ||
|
||
let connection = {}; | ||
|
||
class VariantGroup extends Base { | ||
constructor(uid: string) { | ||
if (!uid) { | ||
throw new Error("uid is required"); | ||
} | ||
super(uid); | ||
this._query = {}; | ||
return this; | ||
} | ||
|
||
static get connection() { | ||
return connection; | ||
} | ||
|
||
/** | ||
* @function | ||
* @name Stack#VariantGroup#createVariant | ||
* @description This method creates a new variant in a group. | ||
* @example appSDK.stack.VariantGroup("variant_group_uid").createVariant(variant_payload); | ||
* @return {external:Promise} | ||
*/ | ||
createVariant(payload: GenericObjectType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets not have it now. |
||
return this.fetch("createVariant", payload); | ||
} | ||
/** | ||
* @function | ||
* @name Stack#VariantGroup#getVariantsByGroup | ||
* @description This method returns all the variants within a group. | ||
* @example appSDK.stack.VariantGroup("variant_group_uid").getVariantsByGroup(); | ||
* @return {external:Promise} | ||
*/ | ||
getVariantsByGroup() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getVariants |
||
return this.fetch("getVariantsByGroup"); | ||
} | ||
|
||
/** | ||
* @function | ||
* @name Stack#VariantGroup#getVariantsByGroup#deleteVariant | ||
* @description This method deletes a specified variant from a group. | ||
* @example appSDK.stack.VariantGroup("variant_group_uid").deleteVariant("variant_uid"); | ||
* @return {external:Promise} | ||
*/ | ||
deleteVariant(variant_uid: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets not expose it now |
||
this._query.variant_uid = variant_uid; | ||
return this.fetch("deleteVariant"); | ||
} | ||
} | ||
|
||
export default (uiConnection: GenericObjectType) => { | ||
connection = uiConnection; | ||
return new Proxy(VariantGroup, { | ||
apply(Target: any, thisArg, argumentsList: any[]) { | ||
return new Target(...argumentsList); | ||
}, | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getVariantInfo