Exemplo n.º 1
0
        public override async Task <Collect> Create(bool skipAddToCreatedList = false)
        {
            // Create a product to use with these tests.
            var product = await new ProductService(Utils.AuthState).CreateAsync(new Product
            {
                CreatedOn   = DateTime.UtcNow,
                Name        = "Burton Custom Freestlye 151",
                Vendor      = "Burton",
                Content     = "<strong>Good snowboard!</strong>",
                ProductType = "Snowboard",
                Alias       = Guid.NewGuid().ToString(),
                Images      = new List <ProductImage> {
                    new ProductImage {
                        Base64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
                    }
                },
                PublishedScope = "published"
            });
            var obj = await Service.CreateAsync(new Collect()
            {
                CollectionId = CollectionId,
                ProductId    = product.Id.Value,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 2
0
 public VerificationToken(string user, TimeSpan duration, string code)
 {
     this.User    = user;
     this.Created = DateTime.Now;
     this.Expires = Created.Add(duration);
     this.Code    = code;
 }
Exemplo n.º 3
0
        public override async Task <PriceRule> Create(bool skipAddToCreatedList = false)
        {
            return(null);

            var obj = await Service.CreateAsync(new PriceRule
            {
                Title                     = this.TitlePrefix + Guid.NewGuid().ToString(),
                ValueType                 = this.ValueType,
                TargetType                = this.TargetType,
                TargetSelection           = this.TargetSelection,
                AllocationMethod          = this.AllocationMethod,
                Value                     = this.Value,
                CustomerSelection         = this.CustomerSelection,
                OncePerCustomer           = this.OncePerCustomer,
                PrerequisiteSubtotalRange = new PrerequisiteSubtotalRange
                {
                    GreaterThanOrEqualTo = 40
                },
                StartsOn = new DateTimeOffset(DateTime.Now)
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 4
0
 public CommonItem(CommonItem item, bool transient, bool expired) // for cloning
 {
     SysProps     = new NamedValueSet();
     ItemKind     = item.ItemKind;
     Transient    = transient;
     Id           = Guid.NewGuid();
     AppScope     = item.AppScope;
     NetScope     = item.NetScope;
     Name         = item.Name;
     AppProps     = new NamedValueSet(item.AppProps);
     DataTypeName = item.DataTypeName;
     Created      = DateTimeOffset.Now;
     StoreUSN     = item.StoreUSN;
     if (expired)
     {
         Expires = Created;
         SysProps.Clear();
     }
     else
     {
         Expires   = Created.Add(item.Expires - item.Created);
         YData     = item.YData;
         YDataHash = CalculateBufferHash(YData);
         YSign     = item.YSign;
         SysProps  = new NamedValueSet(item.SysProps);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <Collect> Create(bool skipAddToCreatedList = false)
        {
            // Create a product to use with these tests.
            var product = await ProductService.CreateAsync(new ShopifySharp.Product()
            {
                CreatedAt   = DateTime.UtcNow,
                Title       = "Burton Custom Freestlye 151",
                Vendor      = "Burton",
                BodyHtml    = "<strong>Good snowboard!</strong>",
                ProductType = "Snowboard",
                Handle      = Guid.NewGuid().ToString(),
                Images      = new List <ProductImage> {
                    new ProductImage {
                        Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
                    }
                },
                PublishedScope = "published"
            });

            var obj = await CollectService.CreateAsync(new Collect()
            {
                CollectionId = CollectionId,
                ProductId    = product.Id.Value,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 6
0
        public override async Task <SmartCollection> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new SmartCollection
            {
                //BodyHtml = BodyHtml,
                Alias = Alias,
                Name  = Name,
                Rules = new List <SmartCollectionRule>
                {
                    new SmartCollectionRule
                    {
                        Column    = "variant_price",
                        Condition = "20",
                        Relation  = "less_than"
                    }
                }
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 7
0
        public Dungeon()
        {
            Serial = new DungeonSerial();

            Created  = DateTime.UtcNow;
            Deadline = Created.Add(Duration);

            LootMode = DungeonLootMode.Advanced;

            EnsureConstructDefaults();
        }
Exemplo n.º 8
0
        public override async Task <Order> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new Order()
            {
                CreatedOn      = DateTime.UtcNow,
                BillingAddress = new Address()
                {
                    Address1     = "123 4th Street",
                    City         = "Minneapolis",
                    Province     = "Minnesota",
                    ProvinceCode = "MN",
                    Zip          = "55401",
                    Phone        = "555-555-5555",
                    FirstName    = "John",
                    LastName     = "Doe",
                    Company      = "Tomorrow Corporation",
                    Country      = "United States",
                    CountryCode  = "US",
                    Default      = true,
                },
                LineItems = new List <LineItem>()
                {
                    new LineItem()
                    {
                        Name     = "Test Line Item",
                        Title    = "Test Line Item Title",
                        Quantity = 2,
                        Price    = 5
                    },
                    new LineItem()
                    {
                        Name     = "Test Line Item 2",
                        Title    = "Test Line Item Title 2",
                        Quantity = 2,
                        Price    = 5
                    }
                },
                FinancialStatus = OrderFinancialStatus.Paid,
                TotalPrice      = 5.00m,
                Email           = Guid.NewGuid() + "@example.com",
                Note            = Note,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }
            CreatedCustomers.Add(obj.Customer);

            return(obj);
        }
Exemplo n.º 9
0
        public override async Task <Redirect> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new Redirect()
            {
                Path   = Guid.NewGuid().ToString(),
                Target = Target,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 10
0
        public override async Task <CustomCollection> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new CustomCollection
            {
                Name      = Name,
                Published = false
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <ProductImage> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(ProductId, new ProductImage()
            {
                Filename   = ImageFileName,
                Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <GiftCardAdjustment> Create(bool skipAddToCreateList = false)
        {
            var obj = await Service.CreateAsync(GiftCardId, new GiftCardAdjustment()
            {
                Amount = 1.00m,
                Note   = "Integration test from ShopifySharp"
            });

            if (!skipAddToCreateList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <ProductVariant> Create(string option1 = null, bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(ProductId, new ProductVariant()
            {
                Option1 = Guid.NewGuid().ToString(),
                Price   = Price,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 14
0
        public override async Task <Page> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new Page
            {
                CreatedOn = DateTime.UtcNow,
                Title     = Title,
                Content   = Content,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 15
0
        public override async Task <ScriptTag> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new ScriptTag
            {
                Event = Event,
                Src   = Src,
                //DisplayScope = Scope,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 16
0
        public DungeonLootEntry(Dungeon dungeon, Item item, TimeSpan decay, IEnumerable <PlayerMobile> group)
        {
            Dungeon = dungeon;

            Item = item;

            Created = DateTime.UtcNow;
            Expire  = Created.Add(decay);

            Rolls = group.Where(m => m != null && !m.Deleted).ToDictionary(m => m, m => (DungeonLootRoll?)null);

            if (Item != null)
            {
                Item.Movable = false;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Convenience function for running tests. Creates the object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <Asset> Create(string key, bool skipAddToCreatedList = false)
        {
            var asset = await Service.CreateOrUpdateAsync(ThemeId, new Asset()
            {
                ContentType = "text/x-liquid",
                Value       = AssetValue,
                Key         = key
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(asset);
            }

            return(asset);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <ProductVariant> Create(string option1 = null, bool skipAddToCreatedList = false)
        {
            var obj = await VariantService.CreateAsync(ProductId, new ProductVariant()
            {
                Option1             = Guid.NewGuid().ToString(),
                Price               = Price,
                InventoryManagement = "shopify",
                SKU = "Some sku"
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 19
0
        public override async Task <Webhook> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new Webhook()
            {
                Address = UrlPrefix + Guid.NewGuid(),
                Fields  = new string[] { "field1", "field2" },
                Format  = "json",
                Topic   = WebhookTopic.OrderCreated,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <MetaField> Create(long targetId, string resourceType, long parentTargetId, string parentResourceType, bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new MetaField()
            {
                Namespace   = Namespace,
                Key         = Guid.NewGuid().ToString().Substring(0, 25),
                Value       = "5",
                ValueType   = "integer",
                Description = Description,
            }, targetId, resourceType, parentTargetId, parentResourceType);

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <MetaField> Create(bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(new MetaField()
            {
                Namespace   = Namespace,
                Key         = Guid.NewGuid().ToString().Substring(0, 25),
                Value       = "5",
                ValueType   = "integer",
                Description = Description,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 22
0
        public override async Task <Theme> Create(bool skipAddToCreatedList = false)
        {
            var uploadResponse = await Utils.UploadToFileIoAsync("theme_bizweb.zip");

            var theme = new Theme
            {
                Name = (NamePrefix + Guid.NewGuid()).Substring(0, 50),
                Role = Role,
            };
            var obj = await Service.CreateAsync(theme, uploadResponse.Link);

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 23
0
        public async Task <Fulfillment> Create(long orderId, bool multipleTrackingNumbers = false, IEnumerable <LineItem> items = null)
        {
            Fulfillment fulfillment;

            if (multipleTrackingNumbers)
            {
                fulfillment = new Fulfillment()
                {
                    TrackingCompany = "Jack Black's Pack, Stack and Track",
                    TrackingUrls    = new string[]
                    {
                        "https://example.com/da10038ee679f9afc93a785cafdd8d52",
                        "https://example.com/6349a40313ae3c7544331ff9fb44f28c",
                        "https://example.com/ca0b2d7bcccec4b58a94a24fa04101d3"
                    },
                    TrackingNumbers = new string[]
                    {
                        "da10038ee679f9afc93a785cafdd8d52",
                        "6349a40313ae3c7544331ff9fb44f28c",
                        "ca0b2d7bcccec4b58a94a24fa04101d3"
                    }
                };
            }
            else
            {
                fulfillment = new Fulfillment()
                {
                    TrackingCompany = "Jack Black's Pack, Stack and Track",
                    TrackingUrl     = "https://example.com/123456789",
                    TrackingNumber  = "123456789",
                };
            }

            if (items != null)
            {
                fulfillment.LineItems = items;
            }

            fulfillment = await Service.CreateAsync(orderId, fulfillment, false);

            Created.Add(fulfillment);

            return(fulfillment);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <OrderRisk> Create(long orderId, bool skipAddToCreatedList = false)
        {
            var obj = await Service.CreateAsync(orderId, new OrderRisk()
            {
                Message        = Message,
                Score          = Score,
                Recommendation = Recommendation,
                Source         = Source,
                CauseCancel    = CauseCancel,
                Display        = Display,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <Transaction> Create(long orderId, string kind = "capture", bool skipAddToCreatedList = false, string currency = "USD")
        {
            var obj = await Service.CreateAsync(orderId, new Transaction()
            {
                Amount   = Amount,
                Currency = currency,
                Gateway  = Gateway,
                Status   = Status,
                Test     = true,
                Kind     = kind
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Convenience function for running tests. Gets an object from the list of already created objects, or creates the object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <Address> Create(string streetAddress, bool skipAddToDeleteList = false)
        {
            var obj = await Service.CreateAsync(CustomerId.Value, new Address()
            {
                Address1     = streetAddress,
                City         = "Minneapolis",
                Province     = "Minnesota",
                ProvinceCode = "MN",
                Zip          = "55401",
                Phone        = "555-555-5555",
                FirstName    = FirstName,
                LastName     = LastName,
                Company      = "Tomorrow Corporation",
                Country      = "United States",
                CountryCode  = "US",
            });

            if (!skipAddToDeleteList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        public void Freeze()
        {
            if (_frozen)
            {
                return;
            }
            if (Name == null)
            {
                throw new ApplicationException("Item name not set!");
            }
            TimeSpan maxLifetime = DateTimeOffset.MaxValue - DateTimeOffset.Now - TimeSpan.FromDays(1);

            if (_lifetime > maxLifetime)
            {
                _lifetime = maxLifetime;
            }
            if (_lifetime < TimeSpan.Zero)
            {
                _lifetime = TimeSpan.Zero;
            }
            Created = DateTimeOffset.Now;
            Expires = Created.Add(_lifetime);
            // serialise the data if required
            Serialise();
            if (DataTypeName == null)
            {
                DataTypeName = "";
            }
            if (_text == null)
            {
                //_Text = "";
                SysProps.Set(SysPropName.SAlg, (int)SerialFormat.Undefined);
            }
            SysProps.Set(SysPropName.TLen, _text?.Length ?? 0);
            // compress the data
            _zData = CompressionHelper.CompressToBuffer(_text);
            SysProps.Set(SysPropName.ZAlg, 1);
            SysProps.Set(SysPropName.ZLen, _zData?.Length ?? 0);
            // do symmetric encryption 1st, if required
            var xtki = SysProps.GetValue <String>(SysPropName.XTKI, null);

            if (xtki != null)
            {
                _xData = _cryptoManager.EncryptWithTranspKey(xtki, _zData);
                SysProps.Set(SysPropName.XAlg, 1);
            }
            else
            {
                _xData = _zData;
            }
            SysProps.Set(SysPropName.XLen, _xData?.Length ?? 0);
            // do asymmetric encryption 2nd, if required
            var yrki = SysProps.GetValue <String>(SysPropName.YRKI, null);

            if (yrki != null)
            {
                SysProps.Set(SysPropName.YAlg, 1);
                YData = _cryptoManager.EncryptWithPublicKey(yrki, _xData);
            }
            else
            {
                YData = _xData;
            }
            YDataHash = CalculateBufferHash(YData);
            SysProps.Set(SysPropName.YLen, YData?.Length ?? 0);
            // do public signature 3rd, if required
            var yski = SysProps.GetValue <String>(SysPropName.YSKI, null);

            if (yski != null)
            {
                SysProps.Set(SysPropName.YAlg, 1);
                YSign = _cryptoManager.CreateSignature(yski, YData);
            }
            // add other publisher properties
            SysProps.Set(SysPropName.ApplName, _moduleInfo.ApplName);
            SysProps.Set(SysPropName.ApplFVer, _moduleInfo.ApplFVer);
            SysProps.Set(SysPropName.ApplPTok, _moduleInfo.ApplPTok);
            SysProps.Set(SysPropName.CoreFVer, _moduleInfo.CoreFVer);
            SysProps.Set(SysPropName.CorePTok, _moduleInfo.CorePTok);
            SysProps.Set(SysPropName.HostName, _moduleInfo.HostName);
            SysProps.Set(SysPropName.UserName, _moduleInfo.UserName);
            SysProps.Set(SysPropName.UserWDom, _moduleInfo.UserWDom);
            SysProps.Set(SysPropName.UserIdentity, _moduleInfo.Name);
            SysProps.Set(SysPropName.UserFullName, _moduleInfo.UserFullName);
            SysProps.Set(SysPropName.OrgEnvId, EnvHelper.EnvName(_moduleInfo.ConfigEnv));
            SysProps.Set(SysPropName.NodeGuid, _moduleInfo.NodeGuid);

            // done
            _frozen = true;
        }
Exemplo n.º 28
0
 private void InitCart()
 {
     Created    = DateTime.Now;
     Expires    = Created.Add(ShopSettings.CookieExpiration);
     CartCookie = Guid.NewGuid().ToString();
 }
Exemplo n.º 29
0
 public UserSession(int userId, TimeSpan duration)
 {
     Created = DateTime.UtcNow;
     Expires = Created.Add(duration);
     UserId  = userId;
 }
Exemplo n.º 30
0
 public bool IsExpired()
 {
     return(Created.Add(LifeSpan) < DateTime.Now);
 }