/// <summary>
        /// Gets a count of all of the shop's webhooks.
        /// </summary>
        /// <param name="address">An optional filter for the address property. When used, this method will only count webhooks with the given address.</param>
        /// <param name="topic">An optional filter for the topic property. When used, this method will only count webhooks with the given topic.</param>
        /// <returns>The count of all webhooks for the shop.</returns>
        public async Task<int> CountAsync(string address = null, ShopifyWebhookTopic? topic = null)
        {
            IRestRequest req = RequestEngine.CreateRequest("webhooks/count.json", Method.GET);

            //Add optional parameters to request
            if (string.IsNullOrEmpty(address) == false) req.AddParameter("address", address);
            if (topic != null && topic.HasValue) req.AddParameter("topic", topic.ToSerializedString());

            JToken responseObject = await RequestEngine.ExecuteRequestAsync(_RestClient, req);

            //Response looks like { "count" : 123 }. Does not warrant its own class.
            return responseObject.Value<int>("count");
        }
예제 #2
0
        public static ShopifyWebhook CreateValidWebhook(string path = null, ShopifyWebhookTopic topic = ShopifyWebhookTopic.OrderCreated)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Guid.NewGuid().ToString();
            }

            return new ShopifyWebhook()
            {
                Address = "https://requestb.in/" + path,
                CreatedAt = DateTime.Now,
                Fields = new List<string>() { "field1", "field2" },
                Format = "json",
                MetafieldNamespaces = new List<string>() { "metafield1", "metafield2" },
                Topic = topic,
            };
        }
예제 #3
0
        public static ShopifyWebhook CreateValidWebhook(string path = null, ShopifyWebhookTopic topic = ShopifyWebhookTopic.OrderCreated)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Guid.NewGuid().ToString();
            }

            return(new ShopifyWebhook()
            {
                Address = "https://requestb.in/" + path,
                CreatedAt = DateTime.Now,
                Fields = new List <string>()
                {
                    "field1", "field2"
                },
                Format = "json",
                MetafieldNamespaces = new List <string>()
                {
                    "metafield1", "metafield2"
                },
                Topic = topic,
            });
        }