2021-04-28 13:10:47 +00:00
|
|
|
export function createChannel({
|
|
|
|
isActive = true,
|
|
|
|
name,
|
|
|
|
slug = name,
|
2021-09-10 08:59:46 +00:00
|
|
|
currencyCode = "PLN",
|
2022-07-11 09:14:23 +00:00
|
|
|
defaultCountry = "PL",
|
2021-04-28 13:10:47 +00:00
|
|
|
}) {
|
2021-03-12 12:14:18 +00:00
|
|
|
const createChannelMutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
channelCreate(input: {
|
|
|
|
isActive: ${isActive}
|
|
|
|
name: "${name}"
|
|
|
|
slug: "${slug}"
|
|
|
|
currencyCode: "${currencyCode}"
|
2021-09-10 08:59:46 +00:00
|
|
|
defaultCountry: ${defaultCountry}
|
2021-03-12 14:57:02 +00:00
|
|
|
}){
|
|
|
|
channel{
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
2021-09-10 08:59:46 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
code
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-04-28 13:10:47 +00:00
|
|
|
return cy
|
|
|
|
.sendRequestWithQuery(createChannelMutation)
|
|
|
|
.its("body.data.channelCreate.channel");
|
2021-03-12 12:14:18 +00:00
|
|
|
}
|
2021-09-10 08:59:46 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function getChannels() {
|
|
|
|
const getChannelsInfoQuery = `query{
|
2021-03-12 14:57:02 +00:00
|
|
|
channels{
|
|
|
|
name
|
|
|
|
id
|
|
|
|
isActive
|
|
|
|
slug
|
|
|
|
currencyCode
|
2021-02-15 09:44:50 +00:00
|
|
|
}
|
2021-03-12 14:57:02 +00:00
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(getChannelsInfoQuery);
|
|
|
|
}
|
2021-02-02 11:34:10 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
export function deleteChannel(channelId, targetChannelId) {
|
|
|
|
const deleteChannelMutation = `mutation{
|
2021-03-12 14:57:02 +00:00
|
|
|
channelDelete(id: "${channelId}", input:{
|
2021-06-07 15:16:44 +00:00
|
|
|
channelId: "${targetChannelId}"
|
2021-03-12 14:57:02 +00:00
|
|
|
}){
|
|
|
|
channel{
|
|
|
|
name
|
|
|
|
}
|
2022-06-06 08:47:39 +00:00
|
|
|
errors{
|
2021-03-12 14:57:02 +00:00
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
2021-03-12 12:14:18 +00:00
|
|
|
return cy.sendRequestWithQuery(deleteChannelMutation);
|
2021-02-02 11:34:10 +00:00
|
|
|
}
|
2021-06-30 23:14:25 +00:00
|
|
|
|
|
|
|
export function activateChannel(channelId) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
channelActivate(id:"${channelId}"){
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
2022-07-11 09:14:23 +00:00
|
|
|
|
|
|
|
export function updateChannelWarehouses(channelId, warehouseId) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
channelUpdate(id:"${channelId}", input:{
|
|
|
|
addWarehouses:"${warehouseId}"
|
|
|
|
}){
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|
2023-05-11 06:46:33 +00:00
|
|
|
|
|
|
|
export function updateChannelOrderSettings({
|
|
|
|
channelId,
|
|
|
|
automaticallyConfirmAllNewOrders = true,
|
|
|
|
automaticallyFulfillNonShippableGiftCard = true,
|
|
|
|
expireOrdersAfter = 0,
|
|
|
|
markAsPaidStrategy = "PAYMENT_FLOW", // TRANSACTION_FLOW - creates the TransactionItem object.
|
|
|
|
defaultTransactionFlowStrategy = "AUTHORIZATION",
|
|
|
|
}) {
|
|
|
|
const mutation = `mutation{
|
|
|
|
channelUpdate(id:"${channelId}", input: {orderSettings: {
|
|
|
|
automaticallyConfirmAllNewOrders: ${automaticallyConfirmAllNewOrders},
|
|
|
|
automaticallyFulfillNonShippableGiftCard: ${automaticallyFulfillNonShippableGiftCard},
|
|
|
|
expireOrdersAfter: ${expireOrdersAfter},
|
|
|
|
markAsPaidStrategy: ${markAsPaidStrategy},
|
|
|
|
defaultTransactionFlowStrategy: ${defaultTransactionFlowStrategy}
|
|
|
|
}}){
|
|
|
|
errors{
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
channel {
|
|
|
|
orderSettings{
|
|
|
|
automaticallyConfirmAllNewOrders
|
|
|
|
automaticallyFulfillNonShippableGiftCard
|
|
|
|
expireOrdersAfter
|
|
|
|
markAsPaidStrategy
|
|
|
|
defaultTransactionFlowStrategy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
return cy.sendRequestWithQuery(mutation);
|
|
|
|
}
|