From e201718f30853ba1f7a7c4c7545da1271baec81e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:08:46 +0000
Subject: [PATCH 001/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 3204 ++++++++++++++++++++-------------------
1 file changed, 1607 insertions(+), 1597 deletions(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 8091a7023..5ed8250d0 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1,1597 +1,1607 @@
-// ***********************************************************************
-// Assembly : VTEX
-// Author : Guilherme Branco Stracini
-// Created : 01-15-2023
-//
-// Last Modified By : Guilherme Branco Stracini
-// Last Modified On : 01-16-2023
-// ***********************************************************************
-//
-// © 2020 Guilherme Branco Stracini. All rights reserved.
-//
-//
-// ***********************************************************************
-namespace VTEX
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using CrispyWaffle.Extensions;
- using CrispyWaffle.Log;
- using CrispyWaffle.Serialization;
- using Newtonsoft.Json;
- using VTEX.DataEntities;
- using VTEX.Enums;
- using VTEX.Extensions;
- using VTEX.GoodPractices;
- using VTEX.Health;
- using VTEX.Transport;
- using VTEX.Transport.Bridge;
-
- ///
- /// A VTEX Context, that consumes the VTEX Wrapper
- ///
- ///
- public sealed class VTEXContext : IDisposable
- {
- #region Private fields
-
- ///
- /// The wrapper
- ///
- private readonly VTEXWrapper _wrapper;
-
- #endregion
-
- #region ~Ctor
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Name of the account.
- /// The application key.
- /// The application token.
- /// The cookie.
- /// appKey
- /// appToken
- public VTEXContext(string accountName, string appKey, string appToken, string cookie = null)
- {
- _wrapper = new VTEXWrapper(accountName);
- if (string.IsNullOrWhiteSpace(appKey))
- {
- throw new ArgumentNullException(nameof(appKey));
- }
-
- if (string.IsNullOrWhiteSpace(appToken))
- {
- throw new ArgumentNullException(nameof(appToken));
- }
-
- _wrapper.SetRestCredentials(appKey, appToken);
- if (string.IsNullOrWhiteSpace(cookie))
- {
- return;
- }
-
- _wrapper.SetVtexIdClientAuthCookie(cookie);
- }
-
- ///
- /// Retrieves a list of orders based on specified filtering criteria.
- ///
- /// The status of the orders to filter by (optional).
- /// The start date for filtering orders (optional).
- /// The end date for filtering orders (optional).
- /// The sales channel to filter by (optional).
- /// The affiliated ID to filter by (optional).
- /// The payment system name to filter by (optional).
- /// A generic query string for additional filtering (optional).
- /// An instance of containing the filtered orders.
- ///
- /// This method constructs a query string based on the provided parameters to filter the orders.
- /// It supports pagination and retrieves orders in pages of 50 until no more orders are found.
- /// The filtering criteria include order status, sales channel, affiliated ID, payment system name,
- /// and a date range defined by start and end dates. The results are logged indicating the number of orders found.
- ///
- private OrdersList GetOrdersListInternal(
- string status = null,
- DateTime? startDate = null,
- DateTime? endDate = null,
- string salesChannel = null,
- string affiliatedId = null,
- string paymentSystemName = null,
- string genericQuery = null
- )
- {
- OrdersList result = null;
- var currentPage = 1;
- var queryString = new Dictionary
- {
- { @"page", @"0" },
- { @"per_page", @"50" },
- };
- if (!string.IsNullOrWhiteSpace(status))
- {
- queryString.Add(@"f_status", status);
- }
-
- if (!string.IsNullOrWhiteSpace(salesChannel))
- {
- queryString.Add(@"f_salesChannel", salesChannel);
- }
-
- if (!string.IsNullOrWhiteSpace(affiliatedId))
- {
- queryString.Add(@"f_affiliateId", affiliatedId);
- }
-
- if (!string.IsNullOrWhiteSpace(paymentSystemName))
- {
- queryString.Add(@"f_paymentNames", paymentSystemName);
- }
-
- if (startDate.HasValue && endDate.HasValue)
- {
- queryString.Add(
- @"f_creationDate",
- $@"creationDate:[{startDate.Value.ToUniversalTime():s}Z TO {endDate.Value.ToUniversalTime():s}Z]"
- );
- }
-
- if (!string.IsNullOrWhiteSpace(genericQuery))
- {
- queryString.Add(@"q", genericQuery);
- }
-
- queryString.Add(@"orderBy", @"creationDate,asc");
- while (GetOrderListsValueInternal(queryString, currentPage, ref result))
- {
- currentPage++;
- }
-
- LogConsumer.Info("{0} orders found", result.List.Length);
- return result;
- }
-
- ///
- /// Gets the order lists value internal.
- ///
- /// The query string.
- /// The current page.
- /// The result.
- /// true if XXXX, false otherwise.
- ///
- private bool GetOrderListsValueInternal(
- Dictionary queryString,
- int currentPage,
- ref OrdersList result
- )
- {
- var json = string.Empty;
- try
- {
- LogConsumer.Trace("Getting page {0} of orders list", currentPage);
- queryString[@"page"] = currentPage.ToString(CultureInfo.InvariantCulture);
-
- json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- PlatformConstants.OmsOrders,
- CancellationToken.None,
- queryString
- )
- .Result;
- var temp = SerializerFactory.GetSerializer().Deserialize(json);
- if (result == null)
- {
- result = temp;
- }
- else
- {
- result.List = result.List.Concat(temp.List).ToArray();
- }
-
- if (temp.Paging.Pages == 1 || temp.Paging.CurrentPage >= temp.Paging.Pages)
- {
- return false;
- }
-
- if (currentPage == 1)
- {
- LogConsumer.Trace("{0} pages of orders list", temp.Paging.Pages);
- }
-
- return true;
- }
- catch (JsonSerializationException e)
- {
- throw new UnexpectedApiResponseException(json, e);
- }
- }
-
- ///
- /// Gets the orders by order's ids.
- ///
- /// The order's ids.
- /// IEnumerable<Order>.
- private IEnumerable GetOrdersInternal(IEnumerable ordersIds)
- {
- var list = new List();
- Parallel.ForEach(ordersIds, orderId => list.Add(GetOrder(orderId)));
- return list;
- }
-
- ///
- /// Get a order by order id
- ///
- /// The id of the order
- /// Order.
- ///
- ///
- private Order GetOrderInternal(string orderId)
- {
- LogConsumer.Trace("Getting order {0}", orderId);
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.OmsOrders}/{orderId}",
- CancellationToken.None
- )
- .Result;
- if (json == null)
- {
- return null;
- }
-
- try
- {
- var order = SerializerFactory.GetSerializer().Deserialize(json);
-
- #region Payment
-
- var transaction = order.PaymentData.Transactions.First();
- var payment = transaction.Payments.FirstOrDefault();
- if (
- payment != null
- && payment.PaymentSystem == 0
- && !string.IsNullOrWhiteSpace(order.AffiliateId)
- )
- {
- LogConsumer.Info(@"Marketplace {0}", order.AffiliateId);
- }
- else if (
- transaction.TransactionId != null
- && !transaction.TransactionId.Equals(
- @"NO-PAYMENT",
- StringComparison.InvariantCultureIgnoreCase
- )
- )
- {
- LogConsumer.Info(@"Bank bill {0}", order.Sequence);
- }
- else if (order.Totals.Sum(t => t.Value) == 0)
- {
- LogConsumer.Warning("Promotion / discount coupon - order subsidized");
- }
- else
- {
- throw new InvalidPaymentDataException(orderId);
- }
-
- #endregion
-
- #region Email
-
- if (!string.IsNullOrWhiteSpace(order.ClientProfileData.UserProfileId))
- {
- var client = SearchAsync(
- @"userId",
- order.ClientProfileData.UserProfileId,
- CancellationToken.None
- ).Result;
- if (client != null && !string.IsNullOrWhiteSpace(client.Email))
- {
- order.ClientProfileData.Email = client.Email;
- }
-
- if (
- order.ClientProfileData.Email.IndexOf(
- @"ct.vtex",
- StringComparison.InvariantCultureIgnoreCase
- ) != -1
- )
- {
- order.ClientProfileData.Email = @"pedido@editorainovacao.com.br";
- }
- }
-
- #endregion
-
- LogConsumer.Debug(order, $"vtex-order-{orderId}.js");
- var affiliated = string.IsNullOrWhiteSpace(order.AffiliateId)
- ? string.Empty
- : $" - Affiliated: {order.AffiliateId}";
- LogConsumer.Info(
- "Order: {0} - Sequence: {1} - Status: {2} - Sales channel: {3}{4}",
- order.OrderId,
- order.Sequence,
- order.Status.GetHumanReadableValue(),
- order.SalesChannel,
- affiliated
- );
- return order;
- }
- catch (JsonSerializationException e)
- {
- throw new UnexpectedApiResponseException(json, e);
- }
- }
-
- #endregion
-
- #region Public Methods
-
- #region OMS
-
- ///
- /// Gets the feed.
- ///
- /// The maximum lot.
- /// IEnumerable<OrderFeed>.
- public IEnumerable GetFeed(int maxLot = 20)
- {
- //VTEX limitation
- if (maxLot > 20)
- {
- maxLot = 20;
- }
-
- LogConsumer.Trace("Getting up to {0} events in order feed", maxLot);
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.OmsFeed}",
- CancellationToken.None,
- new Dictionary { { @"maxLot", maxLot.ToString() } }
- )
- .Result;
- return SerializerFactory.GetSerializer>().Deserialize(json);
- }
-
- ///
- /// Commits the feed.
- ///
- /// The feed.
- public void CommitFeed(OrderFeed feed)
- {
- LogConsumer.Trace("Commiting feed of order {0}", feed.OrderId);
- var data = (string)
- new OrderFeedCommit { CommitToken = feed.CommitToken }.GetSerializer();
- _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsFeed}confirm",
- CancellationToken.None,
- data: data
- )
- .Wait();
- }
-
- ///
- /// Get a order by order id
- ///
- /// The id of the order
- /// Order.
- ///
- public Order GetOrder(string orderId)
- {
- return GetOrderInternal(orderId);
- }
-
- ///
- /// Gets the orders list metadata.
- ///
- /// The status.
- /// IEnumerable<List>.
- public IEnumerable GetOrdersList(OrderStatus status)
- {
- LogConsumer.Warning("Getting orders with status {0}", status.GetHumanReadableValue());
- var orders = GetOrdersListInternal(status.GetInternalValue());
- return orders.List;
- }
-
- ///
- /// Get a Enumerable list of Order by status.
- ///
- /// The status of the orders to get
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(OrderStatus status)
- {
- var ordersIds = GetOrdersList(status).Select(order => order.OrderId).ToList();
- if (ordersIds.Any())
- {
- return GetOrdersInternal(ordersIds);
- }
-
- LogConsumer.Warning("No orders with status {0} found", status.GetHumanReadableValue());
- return new Order[0];
- }
-
- ///
- /// Gets the orders list by a date range of order's placed date.
- ///
- /// The start date of the range.
- /// The end date of the range.
- /// IEnumerable<String>.
- public IEnumerable GetOrdersList(DateTime startDate, DateTime endDate)
- {
- LogConsumer.Warning("Getting orders between {0:G} and {1:G}", startDate, endDate);
- var orders = GetOrdersListInternal(startDate: startDate, endDate: endDate);
- return orders.List;
- }
-
- ///
- /// Get a Enumerable list of Order by a date range of order's placed date.
- ///
- /// The start date of the range
- /// The end date of the range
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(DateTime startDate, DateTime endDate)
- {
- var ordersIds = GetOrdersList(startDate, endDate)
- .Select(order => order.OrderId)
- .ToList();
- if (ordersIds.Any())
- {
- return GetOrdersInternal(ordersIds);
- }
-
- LogConsumer.Warning("No orders between {0:G} and {1:G} found", startDate, endDate);
- return new Order[0];
- }
-
- ///
- /// Gets the orders list by status and date range of order's placed date.
- ///
- /// The status of orders to get.
- /// The start date of the range.
- /// The end date of the range.
- /// IEnumerable<String>.
- public IEnumerable GetOrdersList(
- OrderStatus status,
- DateTime startDate,
- DateTime endDate
- )
- {
- LogConsumer.Warning(
- "Getting orders with status {0} between {1:G} and {2:G}",
- status.GetHumanReadableValue(),
- startDate,
- endDate
- );
- var orders = GetOrdersListInternal(status.GetInternalValue(), startDate, endDate);
- return orders.List;
- }
-
- ///
- /// Get a Enumerable list of Order by status and date range of order's placed date.
- ///
- /// The status of orders to get.
- /// The start date of the range.
- /// The end date of the range.
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(
- OrderStatus status,
- DateTime startDate,
- DateTime endDate
- )
- {
- var ordersIds = GetOrdersList(status, startDate, endDate)
- .Select(order => order.OrderId)
- .ToList();
- if (ordersIds.Any())
- {
- return GetOrdersInternal(ordersIds);
- }
-
- LogConsumer.Warning(
- "No order with status {0} between {1:G} and {2:G} found",
- status.GetHumanReadableValue(),
- startDate,
- endDate
- );
- return new Order[0];
- }
-
- ///
- /// Gets the orders list by status and affiliated identifier (AKA marketplace).
- ///
- /// The status of orders to get.
- /// The affiliated identifier
- /// IEnumerable<String>.
- public IEnumerable GetOrdersList(OrderStatus status, string affiliatedId)
- {
- LogConsumer.Warning(
- "Getting orders with status {0} and affiliated {1}",
- status.GetHumanReadableValue(),
- affiliatedId
- );
- var orders = GetOrdersListInternal(
- status.GetInternalValue(),
- affiliatedId: affiliatedId
- );
- return orders.List;
- }
-
- ///
- /// Get a Enumerable list of Order by status and affiliated identifier (AKA marketplace).
- ///
- /// The status of orders to get.
- /// The affiliated identifier
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(OrderStatus status, string affiliatedId)
- {
- var ordersIds = GetOrdersList(status, affiliatedId)
- .Select(order => order.OrderId)
- .ToList();
- if (ordersIds.Any())
- {
- return GetOrdersInternal(ordersIds);
- }
-
- LogConsumer.Warning(
- "No order with status {0} and affiliated {1} found",
- status.GetHumanReadableValue(),
- affiliatedId
- );
- return new Order[0];
- }
-
- ///
- /// Gets the orders list by generic query (order id, client's document, sequence, etc).
- ///
- /// The query to lookup in orders.
- /// IEnumerable<String>.
- public IEnumerable GetOrdersList(string query)
- {
- LogConsumer.Warning("Getting orders with term '{0}'", query);
- var orders = GetOrdersListInternal(genericQuery: query);
- return orders.List;
- }
-
- ///
- /// Gets the orders by generic query (order identifier, client's document, sequence, etc).
- ///
- /// The query to lookup in orders.
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(string query)
- {
- var ordersIds = GetOrdersList(query).Select(order => order.OrderId).ToList();
- if (ordersIds.Any())
- {
- return GetOrdersInternal(ordersIds);
- }
-
- LogConsumer.Warning("No orders with term '{0}' found", query);
- return new Order[0];
- }
-
- ///
- /// Gets the orders by the array of orders identifiers
- ///
- /// The orders ids.
- /// IEnumerable<Order>.
- public IEnumerable GetOrders(string[] ordersIds)
- {
- return GetOrdersInternal(ordersIds);
- }
-
- ///
- /// Cancels the order asynchronous.
- ///
- /// The order identifier.
- /// A Task<System.String> representing the asynchronous operation.
- /// Order {orderId} cannot be canceled because isn't in pending payment status on VTEX
- public async Task CancelOrderAsync(string orderId)
- {
- try
- {
- LogConsumer.Warning("Cancelling order {0}", orderId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var order = GetOrder(orderId);
- if (order.Status == OrderStatus.CANCELED)
- {
- return string.Empty;
- }
-
- if (
- order.Status != OrderStatus.PAYMENT_PENDING
- && order.Status != OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH
- )
- {
- throw new InvalidOperationException(
- $"Order {orderId} cannot be canceled because isn't in pending payment status on VTEX"
- );
- }
-
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsOrders}/{orderId}/cancel",
- source.Token
- )
- .ConfigureAwait(false);
- var receipt = SerializerFactory
- .GetSerializer()
- .Deserialize(json);
- LogConsumer.Info(
- "Order {0} successfully canceled. Receipt: {1}",
- order.Sequence,
- receipt.Receipt
- );
- return receipt.Receipt;
- }
- catch (Exception e)
- {
- LogConsumer.Handle(new CancelOrderException(orderId, e));
- return string.Empty;
- }
- }
-
- ///
- /// Changes the order status asynchronous.
- ///
- /// The order identifier.
- /// The new status.
- /// A Task representing the asynchronous operation.
- ///
- public async Task ChangeOrderStatusAsync(string orderId, OrderStatus newStatus)
- {
- try
- {
- LogConsumer.Info(
- "Changing order {0} status to {1}",
- orderId,
- newStatus.GetHumanReadableValue()
- );
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsOrders}/{orderId}/changestate/{newStatus.GetInternalValue()}",
- source.Token
- )
- .ConfigureAwait(false);
- LogConsumer.Info(json);
- }
- catch (AggregateException e)
- {
- var ae = e.InnerExceptions.First();
- throw new ChangeStatusOrderException(
- orderId,
- newStatus.GetHumanReadableValue(),
- ae
- );
- }
- catch (Exception e)
- {
- throw new ChangeStatusOrderException(orderId, newStatus.GetHumanReadableValue(), e);
- }
- }
-
- ///
- /// Notifies the order paid asynchronous.
- ///
- /// The order identifier.
- /// A Task representing the asynchronous operation.
- public async Task NotifyOrderPaidAsync(string orderId)
- {
- try
- {
- LogConsumer.Info("Sending payment notification of order {0}", orderId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var order = GetOrder(orderId);
- if (
- order.Status != OrderStatus.PAYMENT_PENDING
- && order.Status != OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH
- )
- {
- return;
- }
-
- if (order.Status == OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH)
- {
- await ChangeOrderStatusAsync(order.OrderId, OrderStatus.AUTHORIZE_FULFILLMENT)
- .ConfigureAwait(false);
- return;
- }
- var paymentId = order.PaymentData.Transactions.First().Payments.First().Id;
- _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsOrders}/{order.OrderId}/payments/{paymentId}/payment-notification",
- source.Token
- )
- .Wait(source.Token);
- }
- catch (Exception e)
- {
- LogConsumer.Handle(new PaymentNotificationOrderException(orderId, e));
- }
- }
-
- ///
- /// Notifies the order shipped.
- ///
- /// The order identifier.
- /// The notification.
- ///
- public void NotifyOrderShipped(string orderId, ShippingNotification notification)
- {
- NotifyOrderShippedAsync(orderId, notification, CancellationToken.None).Wait();
- }
-
- ///
- /// Notifies the order shipped async.
- ///
- /// The order identifier.
- /// The notification.
- /// The token.
- /// A Task<System.String> representing the asynchronous operation.
- ///
- public async Task NotifyOrderShippedAsync(
- string orderId,
- ShippingNotification notification,
- CancellationToken token
- )
- {
- try
- {
- LogConsumer.Info("Sending shipping notification of order {0}", orderId);
- LogConsumer.Debug(
- notification,
- $"vtex-shipping-notification-{orderId}-{notification.InvoiceNumber}.js"
- );
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsInvoices}/{orderId}/invoice",
- token,
- data: (string)notification.GetSerializer()
- )
- .ConfigureAwait(false);
- var receipt = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Trace(receipt.Receipt);
- return receipt.Receipt;
- }
- catch (AggregateException e)
- {
- var ae = e.InnerExceptions.First();
- throw new ShippingNotificationOrderException(orderId, ae);
- }
- catch (Exception e)
- {
- throw new ShippingNotificationOrderException(orderId, e);
- }
- }
-
- ///
- /// Notifies the order delivered
- ///
- /// The tracking.
- /// System.String.
- ///
- public async ValueTask NotifyOrderDelivered(Tracking tracking)
- {
- try
- {
- LogConsumer.Info("Sending tracking info of order {0}", tracking.OrderId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- LogConsumer.Debug(
- tracking,
- $"vtex-tracking-info-{tracking.OrderId}-{tracking.InvoiceNumber}.js"
- );
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.PUT,
- string.Format(
- PlatformConstants.OmsTracking,
- tracking.OrderId,
- tracking.InvoiceNumber
- ),
- source.Token,
- data: (string)tracking.GetSerializer()
- )
- .ConfigureAwait(false);
- var receipt = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Trace(receipt.Receipt);
- return receipt.Receipt;
- }
- catch (Exception e)
- {
- throw new TrackingNotificationOrderException(tracking.OrderId, e);
- }
- }
-
- ///
- /// Updates the order invoice.
- ///
- /// The order identifier.
- /// The invoice identifier.
- /// The notification.
- ///
- public void UpdateOrderInvoice(
- string orderId,
- string invoiceId,
- ShippingNotificationPatch notification
- )
- {
- try
- {
- LogConsumer.Info("Patching fiscal invoice {1} of order {0}", orderId, invoiceId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- LogConsumer.Debug(
- notification,
- $"vtex-shipping-notification-{orderId}-{invoiceId}.js"
- );
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.PATCH,
- $"{PlatformConstants.OmsOrders}/{orderId}/invoice/{invoiceId}",
- source.Token,
- data: (string)notification.GetSerializer()
- )
- .Result;
- var receipt = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Trace(receipt.Receipt);
- }
- catch (Exception e)
- {
- throw new ShippingNotificationOrderException(orderId, e);
- }
- }
-
- ///
- /// Changes the order.
- ///
- /// The order identifier.
- /// The change.
- ///
- public void ChangeOrder(string orderId, ChangeOrder change)
- {
- try
- {
- LogConsumer.Info("Changing order {0}", orderId);
- LogConsumer.Debug(change, $"vtex-change-order-{orderId}.js");
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $"{PlatformConstants.OmsOrders}/{orderId}/changes",
- CancellationToken.None,
- data: (string)change.GetSerializer()
- )
- .Result;
- var receipt = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Trace(receipt.Receipt);
- }
- catch (Exception e)
- {
- throw new ChangeOrderException(orderId, e);
- }
- }
-
- #endregion
-
- #region PCI Gateway
-
- ///
- /// Gets the transaction interactions.
- ///
- /// The transaction identifier.
- /// IEnumerable<TransactionInteraction>.
- ///
- [Pure]
- public IEnumerable GetTransactionInteractions(string transactionId)
- {
- try
- {
- LogConsumer.Info("Getting interactions of transaction {0}", transactionId);
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.PciTransactions}/{transactionId}/interactions",
- CancellationToken.None,
- restEndpoint: RequestEndpoint.PAYMENTS
- )
- .Result;
- return SerializerFactory
- .GetSerializer>()
- .Deserialize(json);
- }
- catch (Exception e)
- {
- throw new TransactionException(transactionId, e);
- }
- }
-
- #endregion
-
- #region Stock
-
- ///
- /// get sku reservations as an asynchronous operation.
- ///
- /// The sku identifier.
- /// The warehouse identifier.
- /// A Task<System.Int32> representing the asynchronous operation.
- public async Task GetSkuReservationsAsync(int skuId, string warehouseId)
- {
- try
- {
- LogConsumer.Info(
- "Getting reservations of SKU {0} in the warehouse {1}",
- skuId,
- warehouseId
- );
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.LogReservations}/{warehouseId}/{skuId}",
- source.Token
- )
- .ConfigureAwait(false);
- var reservations = SerializerFactory
- .GetSerializer()
- .Deserialize(json);
- LogConsumer.Debug(reservations, $"vtex-sku-reservations-{skuId}.js");
- var total = !reservations.Items.Any() ? 0 : reservations.Items.Sum(r => r.Quantity);
- LogConsumer.Info(
- "The SKU {0} has {1} units reserved in warehouse {2}",
- skuId,
- total,
- warehouseId
- );
- return total;
- }
- catch (Exception e)
- {
- LogConsumer.Handle(new ProductExportException(skuId, e));
- return 0;
- }
- }
-
- ///
- /// Gets the sku inventory.
- ///
- /// The sku identifier.
- /// Inventory.
- public async Task GetSkuInventoryAsync(int skuId)
- {
- LogConsumer.Info("Getting inventory of SKU {0}", skuId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.LogInventory}/{skuId}",
- source.Token,
- restEndpoint: RequestEndpoint.LOGISTICS
- )
- .ConfigureAwait(false);
- var inventory = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Debug(inventory, $"vtex-sku-inventory-{skuId}.js");
- return inventory;
- }
-
- ///
- /// Updates the sku stock.
- ///
- /// The stock information.
- /// A Task representing the asynchronous operation.
- ///
- public async Task UpdateSkuStockAsync(StockInfo stockInfo)
- {
- try
- {
- if (stockInfo.Quantity < 0)
- {
- stockInfo.Quantity = 0;
- }
-
- stockInfo.DateUtcOnBalanceSystem = null;
- if (!stockInfo.UnlimitedQuantity)
- {
- stockInfo.Quantity += await GetSkuReservationsAsync(
- stockInfo.ItemId,
- stockInfo.WareHouseId
- )
- .ConfigureAwait(false);
- }
-
- LogConsumer.Info(
- "Updating inventory of SKU {0} on warehouse {1} with {2} units",
- stockInfo.ItemId,
- stockInfo.WareHouseId,
- stockInfo.Quantity
- );
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var data = @"[" + (string)stockInfo.GetSerializer() + @"]";
- LogConsumer.Debug(stockInfo, $"vtex-sku-stock-{stockInfo.ItemId}.js");
- await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- PlatformConstants.LogWarehouses,
- source.Token,
- data: data
- )
- .ConfigureAwait(false);
- }
- catch (Exception e)
- {
- throw new UpdateStockInfoSKUException(stockInfo.ItemId, e);
- }
- }
-
- #endregion
-
- #region Pricing
-
- ///
- /// Get the prices for an SKU.
- /// It is possible that on the property "fixedPrices" exists a list of specific prices for Trade Policies and Minimum Quantities of the SKU.Fixed Prices may also be scheduled.
- ///
- /// The stock keeping unit identifier
- /// A task of price
- public async Task GetPriceAsync(int skuId)
- {
- LogConsumer.Info("Getting the price of sku {0}", skuId);
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- try
- {
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $@"{PlatformConstants.Pricing}/{skuId}",
- source.Token,
- restEndpoint: RequestEndpoint.API
- )
- .ConfigureAwait(false);
- return SerializerFactory.GetSerializer().Deserialize(json);
- }
- catch (UnexpectedApiResponseException e)
- {
- if (e.StatusCode == 404)
- {
- return new Price();
- }
-
- throw;
- }
- }
-
- ///
- /// This method will create or update an SKU Price.
- /// The property "basePrice" is the base selling price of the SKU.The property "fixedPrices" is an array where each item is a Fixed Price.
- /// The Fixed Price is the price of the SKU for an specific Trade Policy with an specific Minimum Quantity to be activated.
- /// A Fixed Price may optionally be scheduled by using the property dateRange.
- /// A Fixed Price may optionally overwrite the listPrice specified in the Base Price by using the inner property listPrice.
- /// If you don't have specific prices for different Trade Policies, you do not need to send the property fixedPrices.
- ///
- /// The price data
- /// The stock keeping unit identifier
- /// The cancellation token.
- /// A Task representing the asynchronous operation.
- ///
- public async Task UpdatePriceAsync(Price price, int skuId, CancellationToken token)
- {
- try
- {
- var oldPrice = await GetPriceAsync(skuId).ConfigureAwait(false);
- if (oldPrice?.FixedPrices != null && oldPrice.FixedPrices.Any())
- {
- await DeletePriceAsync(skuId, token).ConfigureAwait(false);
- }
-
- LogConsumer.Info(
- "Updating the price of sku {0} to {1} (list price: {2})",
- skuId,
- price.CostPrice.ToMonetary(),
- price.ListPrice.HasValue ? price.ListPrice.Value.ToMonetary() : "no"
- );
- await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.PUT,
- $@"{PlatformConstants.Pricing}/{skuId}",
- token,
- data: (string)price.GetSerializer(),
- restEndpoint: RequestEndpoint.API
- )
- .ConfigureAwait(false);
- }
- catch (Exception e)
- {
- throw new UpdatePriceInfoSkuException(skuId, e);
- }
- }
-
- ///
- /// Removes an SKU price.
- /// This action removes both Base Price and all available Fixed Prices for and SKU in all trade policies.
- ///
- /// The stock keeping unit identifier.
- /// The cancellation token.
- /// Task
- public async Task DeletePriceAsync(int skuId, CancellationToken token)
- {
- LogConsumer.Info("Deleting the price of sku {0}", skuId);
- await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.DELETE,
- $@"{PlatformConstants.Pricing}/{skuId}",
- token,
- restEndpoint: RequestEndpoint.API
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Retrieves a collection of bridge facets based on the specified query and optional keywords.
- ///
- /// The query string used to filter the bridge facets.
- /// Optional keywords to further refine the search for bridge facets.
- /// An enumerable collection of objects that match the specified query and keywords.
- ///
- /// This method constructs a query to fetch bridge facets from a remote service. It logs the action of retrieving facets
- /// and sets a timeout of 5 minutes for the operation. The method builds a dictionary of query parameters, including
- /// facets to retrieve and the specified query. If keywords are provided, they are added to the query parameters as well.
- /// The method then invokes the service asynchronously and deserializes the resulting JSON response into a list of
- /// objects. If an exception occurs during this process, a custom
- /// is thrown, encapsulating the original exception and the query that caused the failure.
- ///
- /// Thrown when an error occurs while retrieving bridge facets.
- [Pure]
- public IEnumerable GetBridgeFacets(
- [Localizable(false)] string query,
- [Localizable(false)] string keywords = null
- )
- {
- try
- {
- LogConsumer.Info(
- "Getting facets in bridge module that satisfy the condition '{0}'",
- query
- );
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var queryString = new Dictionary
- {
- { @"_facets", @"Origin,Status" },
- { @"_where", query },
- };
- if (!string.IsNullOrWhiteSpace(keywords))
- {
- queryString.Add(@"_keywords", $@"*{keywords}*");
- }
-
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.BridgeSearch}/facets",
- source.Token,
- queryString,
- restEndpoint: RequestEndpoint.BRIDGE
- )
- .Result;
- return SerializerFactory.GetSerializer>().Deserialize(json);
- }
- catch (Exception e)
- {
- throw new BridgeException(query, e);
- }
- }
-
- ///
- /// Retrieves a collection of bridge items based on the specified query parameters.
- ///
- /// The query string used to filter the bridge items.
- /// The sorting criteria for the returned items.
- /// Additional keywords to refine the search results.
- /// The starting point for the items to be retrieved.
- /// The maximum number of items to return.
- /// An enumerable collection of that match the specified criteria.
- ///
- /// This method interacts with an external service to fetch bridge items based on the provided query, sort, and keywords.
- /// It logs the request details and checks for an offset limit to avoid exceeding the maximum allowed items from the service.
- /// If the offset exceeds 10,000, a warning is logged, and an empty list is returned.
- /// The method uses a cancellation token to set a timeout for the service call, ensuring that it does not hang indefinitely.
- /// In case of an error during the service call, it throws a custom exception with details about the failure.
- ///
- ///
- /// Thrown when an error occurs while retrieving bridge items from the external service.
- ///
- [Pure]
- public IEnumerable GetBridgeItems(
- [Localizable(false)] string query,
- [Localizable(false)] string sort,
- [Localizable(false)] string keywords,
- int offSet,
- int limit
- )
- {
- try
- {
- LogConsumer.Info(
- "Getting {0} items from {1} in bridge module that satisfy the condition '{2}'",
- limit,
- offSet,
- query
- );
- if (offSet >= 10000)
- {
- LogConsumer.Warning(
- "Cannot get more than 10000 items from Bridge / Master Data (VTEX Elastic Search limitation)"
- );
- return new List();
- }
- var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
- var queryString = new Dictionary
- {
- { @"_where", query },
- { @"_sort", sort },
- { @"offSet", offSet.ToString() },
- { @"limit", limit.ToString() },
- };
- if (!string.IsNullOrWhiteSpace(keywords))
- {
- queryString.Add(@"_keywords", $@"*{keywords}*");
- }
-
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- PlatformConstants.BridgeSearch,
- source.Token,
- queryString,
- restEndpoint: RequestEndpoint.BRIDGE
- )
- .Result;
- return SerializerFactory.GetSerializer>().Deserialize(json);
- }
- catch (AggregateException e)
- {
- throw new BridgeException(
- query,
- e.InnerExceptions.FirstOrDefault() ?? e.InnerException ?? e
- );
- }
- catch (Exception e)
- {
- throw new BridgeException(query, e);
- }
- }
-
- ///
- /// Gets all bridge items.
- ///
- /// The query.
- /// The sort.
- /// The keywords.
- /// Name of the facet.
- /// The facet value.
- /// IEnumerable<BridgeItem>.
- [Pure]
- public IEnumerable GetAllBridgeItems(
- [Localizable(false)] string query,
- [Localizable(false)] string sort,
- [Localizable(false)] string keywords,
- [Localizable(false)] string facetName,
- [Localizable(false)] string facetValue
- )
- {
- const int perPage = 100;
- var facets = GetBridgeFacets(query, keywords);
- var total = facets.Single(f => f.Field.Equals(facetName)).Facets[facetValue].ToInt32();
-
- var result = new List(total);
- var pages = (total / perPage) + 1;
- for (var x = 0; x < pages; x++)
- {
- result.AddRange(GetBridgeItems(query, sort, keywords, x * perPage, perPage));
- }
-
- return result;
- }
-
- #endregion
-
- #region Platform status
-
- ///
- /// Gets the platform status.
- ///
- /// IEnumerable<PlatformStatus>.
- public IEnumerable GetPlatformStatus()
- {
- return GetPlatformStatusAsync(CancellationToken.None).Result;
- }
-
- ///
- /// Gets the platform status asynchronous.
- ///
- /// The token.
- /// A Task<IEnumerable`1> representing the asynchronous operation.
- [Pure]
- public async Task> GetPlatformStatusAsync(
- CancellationToken token
- )
- {
- LogConsumer.Info("Getting platform status");
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- string.Empty,
- token,
- restEndpoint: RequestEndpoint.HEALTH
- )
- .ConfigureAwait(false);
- var status = SerializerFactory.GetSerializer>().Deserialize(json);
- LogConsumer.Debug(status, "vtex-platform-status.js");
- return status;
- }
-
- #endregion
-
- #region Order payments
-
- ///
- /// Gets the order payments.
- ///
- /// The transaction identifier.
- /// List<PciPayment>.
- [Pure]
- public List GetOrderPayments(string transactionId)
- {
- var json = _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $"{PlatformConstants.PciTransactions}/{transactionId}/payments",
- CancellationToken.None,
- restEndpoint: RequestEndpoint.PAYMENTS
- )
- .Result;
- if (json == null)
- {
- return new List();
- }
-
- var data = SerializerFactory
- .GetCustomSerializer>(SerializerFormat.Json)
- .Deserialize(json);
- LogConsumer.Debug(data, $"vtex-order-payemnts-{transactionId}.js");
- return data;
- }
-
- #endregion
-
- #region Catalog
-
- #region Specification
-
- ///
- /// Gets the specification field asynchronous.
- ///
- /// The field identifier.
- /// The token.
- /// A Task<SpecificationField> representing the asynchronous operation.
- [Pure]
- public async Task GetSpecificationFieldAsync(
- int fieldId,
- CancellationToken token
- )
- {
- LogConsumer.Info("Getting field for the field id {0}", fieldId);
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $@"{PlatformConstants.CatalogPub}/specification/fieldGet/{fieldId}",
- token
- )
- .ConfigureAwait(false);
- var field = SerializerFactory.GetSerializer().Deserialize(json);
- LogConsumer.Debug(field, $"vtex-specification-field-{fieldId}.js");
- return field;
- }
-
- ///
- /// Gets the specification field values asynchronous.
- ///
- /// The field identifier.
- /// The token.
- /// A Task<ICollection`1> representing the asynchronous operation.
- [Pure]
- public async Task> GetSpecificationFieldValuesAsync(
- int fieldId,
- CancellationToken token
- )
- {
- LogConsumer.Info("Getting field values for the field id {0}", fieldId);
- var json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $@"{PlatformConstants.CatalogPub}/specification/fieldvalue/{fieldId}",
- token
- )
- .ConfigureAwait(false);
- var fieldValues = SerializerFactory
- .GetSerializer>()
- .Deserialize(json);
- LogConsumer.Debug(fieldValues, $"vtex-specification-values-{fieldId}.js");
- return fieldValues;
- }
-
- ///
- /// Updates the product specification asynchronous.
- ///
- /// The specification.
- /// The product identifier.
- /// The token.
- /// A Task representing the asynchronous operation.
- public async Task UpdateProductSpecificationAsync(
- Specification specification,
- int productId,
- CancellationToken token
- )
- {
- await UpdateProductSpecificationsAsync(
- new List(new[] { specification }),
- productId,
- token
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Updates the product specifications asynchronous.
- ///
- /// The specifications list.
- /// The product identifier.
- /// The token.
- /// A Task representing the asynchronous operation.
- public async Task UpdateProductSpecificationsAsync(
- List specifications,
- int productId,
- CancellationToken token
- )
- {
- LogConsumer.Info(
- "Updating the specifications {1} of product {0}",
- productId,
- string.Join(@",", specifications.Select(s => s.Id))
- );
-
- var data = (string)specifications.GetSerializer();
- await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $@"{PlatformConstants.Catalog}/products/{productId}/specification",
- token,
- data: data
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Inserts the specification field value asynchronous.
- ///
- /// The field value.
- /// The token.
- /// A Task representing the asynchronous operation.
- public async Task InsertSpecificationFieldValueAsync(
- SpecificationFieldValue fieldValue,
- CancellationToken token
- )
- {
- LogConsumer.Info("Creating field value of field id {0}", fieldValue.FieldId);
- var data = (string)fieldValue.GetSerializer();
- await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.POST,
- $@"{PlatformConstants.Catalog}/specification/fieldValue",
- token,
- data: data
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Asynchronously searches for a data entity based on a specified field and value.
- ///
- /// The type of the data entity to search for, which must implement .
- /// The field of the data entity to search against.
- /// The value to search for in the specified field.
- /// A cancellation token to monitor for cancellation requests.
- /// A task that represents the asynchronous operation. The task result contains the found data entity of type or null if no entity is found.
- ///
- /// This method performs an asynchronous search for a data entity by sending a GET request to the specified endpoint.
- /// It constructs a query string using the provided field and value, and invokes a service to retrieve the data.
- /// If the search value is null or whitespace, an is thrown.
- /// In case of an unexpected API response, an is thrown, containing the JSON response and the original exception.
- /// The method logs the retrieved entity for debugging purposes.
- ///
- /// Thrown when is null or whitespace.
- /// Thrown when the API response is unexpected.
- [Pure]
- public async Task SearchAsync(
- string searchedField,
- string searchedValue,
- CancellationToken token
- )
- where TDataEntity : class, IDataEntity, new()
- {
- if (string.IsNullOrWhiteSpace(searchedValue))
- {
- throw new ArgumentNullException(nameof(searchedValue));
- }
-
- var queryString = new Dictionary
- {
- { searchedField, searchedValue },
- { @"_fields", @"_all" },
- };
- var json = string.Empty;
- try
- {
- var entityName = typeof(TDataEntity).GetDataEntityName();
- json = await _wrapper
- .ServiceInvokerAsync(
- HttpRequestMethod.GET,
- $@"dataentities/{entityName}/search/",
- token,
- queryString,
- restEndpoint: RequestEndpoint.MASTER_DATA
- )
- .ConfigureAwait(false);
- var entity = SerializerFactory
- .GetSerializer>()
- .Deserialize(json)
- .FirstOrDefault();
- if (entity == null)
- {
- return null;
- }
-
- LogConsumer.Debug(
- entity,
- $@"vtex-masterdata-entity-{entityName}-{searchedField}-{searchedValue}.js"
- );
- return entity;
- }
- catch (Exception e)
- {
- throw new UnexpectedApiResponseException(json, e);
- }
- }
-
- #endregion
-
- #endregion
-
- #endregion
-
- #region IDisposable
-
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- _wrapper.Dispose();
- }
-
- #endregion
- }
-}
+using System;
+using System.Collections.Generic;
+
+namespace VTEX
+{
+ public class Collection
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+// ***********************************************************************
+// Assembly : VTEX
+// Author : Guilherme Branco Stracini
+// Created : 01-15-2023
+//
+// Last Modified By : Guilherme Branco Stracini
+// Last Modified On : 01-16-2023
+// ***********************************************************************
+//
+// © 2020 Guilherme Branco Stracini. All rights reserved.
+//
+//
+// ***********************************************************************
+namespace VTEX
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics.Contracts;
+ using System.Globalization;
+ using System.Linq;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using CrispyWaffle.Extensions;
+ using CrispyWaffle.Log;
+ using CrispyWaffle.Serialization;
+ using Newtonsoft.Json;
+ using VTEX.DataEntities;
+ using VTEX.Enums;
+ using VTEX.Extensions;
+ using VTEX.GoodPractices;
+ using VTEX.Health;
+ using VTEX.Transport;
+ using VTEX.Transport.Bridge;
+
+ ///
+ /// A VTEX Context, that consumes the VTEX Wrapper
+ ///
+ ///
+ public sealed class VTEXContext : IDisposable
+ {
+ #region Private fields
+
+ ///
+ /// The wrapper
+ ///
+ private readonly VTEXWrapper _wrapper;
+
+ #endregion
+
+ #region ~Ctor
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Name of the account.
+ /// The application key.
+ /// The application token.
+ /// The cookie.
+ /// appKey
+ /// appToken
+ public VTEXContext(string accountName, string appKey, string appToken, string cookie = null)
+ {
+ _wrapper = new VTEXWrapper(accountName);
+ if (string.IsNullOrWhiteSpace(appKey))
+ {
+ throw new ArgumentNullException(nameof(appKey));
+ }
+
+ if (string.IsNullOrWhiteSpace(appToken))
+ {
+ throw new ArgumentNullException(nameof(appToken));
+ }
+
+ _wrapper.SetRestCredentials(appKey, appToken);
+ if (string.IsNullOrWhiteSpace(cookie))
+ {
+ return;
+ }
+
+ _wrapper.SetVtexIdClientAuthCookie(cookie);
+ }
+
+ ///
+ /// Retrieves a list of orders based on specified filtering criteria.
+ ///
+ /// The status of the orders to filter by (optional).
+ /// The start date for filtering orders (optional).
+ /// The end date for filtering orders (optional).
+ /// The sales channel to filter by (optional).
+ /// The affiliated ID to filter by (optional).
+ /// The payment system name to filter by (optional).
+ /// A generic query string for additional filtering (optional).
+ /// An instance of containing the filtered orders.
+ ///
+ /// This method constructs a query string based on the provided parameters to filter the orders.
+ /// It supports pagination and retrieves orders in pages of 50 until no more orders are found.
+ /// The filtering criteria include order status, sales channel, affiliated ID, payment system name,
+ /// and a date range defined by start and end dates. The results are logged indicating the number of orders found.
+ ///
+ private OrdersList GetOrdersListInternal(
+ string status = null,
+ DateTime? startDate = null,
+ DateTime? endDate = null,
+ string salesChannel = null,
+ string affiliatedId = null,
+ string paymentSystemName = null,
+ string genericQuery = null
+ )
+ {
+ OrdersList result = null;
+ var currentPage = 1;
+ var queryString = new Dictionary
+ {
+ { @"page", @"0" },
+ { @"per_page", @"50" },
+ };
+ if (!string.IsNullOrWhiteSpace(status))
+ {
+ queryString.Add(@"f_status", status);
+ }
+
+ if (!string.IsNullOrWhiteSpace(salesChannel))
+ {
+ queryString.Add(@"f_salesChannel", salesChannel);
+ }
+
+ if (!string.IsNullOrWhiteSpace(affiliatedId))
+ {
+ queryString.Add(@"f_affiliateId", affiliatedId);
+ }
+
+ if (!string.IsNullOrWhiteSpace(paymentSystemName))
+ {
+ queryString.Add(@"f_paymentNames", paymentSystemName);
+ }
+
+ if (startDate.HasValue && endDate.HasValue)
+ {
+ queryString.Add(
+ @"f_creationDate",
+ $@"creationDate:[{startDate.Value.ToUniversalTime():s}Z TO {endDate.Value.ToUniversalTime():s}Z]"
+ );
+ }
+
+ if (!string.IsNullOrWhiteSpace(genericQuery))
+ {
+ queryString.Add(@"q", genericQuery);
+ }
+
+ queryString.Add(@"orderBy", @"creationDate,asc");
+ while (GetOrderListsValueInternal(queryString, currentPage, ref result))
+ {
+ currentPage++;
+ }
+
+ LogConsumer.Info("{0} orders found", result.List.Length);
+ return result;
+ }
+
+ ///
+ /// Gets the order lists value internal.
+ ///
+ /// The query string.
+ /// The current page.
+ /// The result.
+ /// true if XXXX, false otherwise.
+ ///
+ private bool GetOrderListsValueInternal(
+ Dictionary queryString,
+ int currentPage,
+ ref OrdersList result
+ )
+ {
+ var json = string.Empty;
+ try
+ {
+ LogConsumer.Trace("Getting page {0} of orders list", currentPage);
+ queryString[@"page"] = currentPage.ToString(CultureInfo.InvariantCulture);
+
+ json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ PlatformConstants.OmsOrders,
+ CancellationToken.None,
+ queryString
+ )
+ .Result;
+ var temp = SerializerFactory.GetSerializer().Deserialize(json);
+ if (result == null)
+ {
+ result = temp;
+ }
+ else
+ {
+ result.List = result.List.Concat(temp.List).ToArray();
+ }
+
+ if (temp.Paging.Pages == 1 || temp.Paging.CurrentPage >= temp.Paging.Pages)
+ {
+ return false;
+ }
+
+ if (currentPage == 1)
+ {
+ LogConsumer.Trace("{0} pages of orders list", temp.Paging.Pages);
+ }
+
+ return true;
+ }
+ catch (JsonSerializationException e)
+ {
+ throw new UnexpectedApiResponseException(json, e);
+ }
+ }
+
+ ///
+ /// Gets the orders by order's ids.
+ ///
+ /// The order's ids.
+ /// IEnumerable<Order>.
+ private IEnumerable GetOrdersInternal(IEnumerable ordersIds)
+ {
+ var list = new List();
+ Parallel.ForEach(ordersIds, orderId => list.Add(GetOrder(orderId)));
+ return list;
+ }
+
+ ///
+ /// Get a order by order id
+ ///
+ /// The id of the order
+ /// Order.
+ ///
+ ///
+ private Order GetOrderInternal(string orderId)
+ {
+ LogConsumer.Trace("Getting order {0}", orderId);
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.OmsOrders}/{orderId}",
+ CancellationToken.None
+ )
+ .Result;
+ if (json == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ var order = SerializerFactory.GetSerializer().Deserialize(json);
+
+ #region Payment
+
+ var transaction = order.PaymentData.Transactions.First();
+ var payment = transaction.Payments.FirstOrDefault();
+ if (
+ payment != null
+ && payment.PaymentSystem == 0
+ && !string.IsNullOrWhiteSpace(order.AffiliateId)
+ )
+ {
+ LogConsumer.Info(@"Marketplace {0}", order.AffiliateId);
+ }
+ else if (
+ transaction.TransactionId != null
+ && !transaction.TransactionId.Equals(
+ @"NO-PAYMENT",
+ StringComparison.InvariantCultureIgnoreCase
+ )
+ )
+ {
+ LogConsumer.Info(@"Bank bill {0}", order.Sequence);
+ }
+ else if (order.Totals.Sum(t => t.Value) == 0)
+ {
+ LogConsumer.Warning("Promotion / discount coupon - order subsidized");
+ }
+ else
+ {
+ throw new InvalidPaymentDataException(orderId);
+ }
+
+ #endregion
+
+ #region Email
+
+ if (!string.IsNullOrWhiteSpace(order.ClientProfileData.UserProfileId))
+ {
+ var client = SearchAsync(
+ @"userId",
+ order.ClientProfileData.UserProfileId,
+ CancellationToken.None
+ ).Result;
+ if (client != null && !string.IsNullOrWhiteSpace(client.Email))
+ {
+ order.ClientProfileData.Email = client.Email;
+ }
+
+ if (
+ order.ClientProfileData.Email.IndexOf(
+ @"ct.vtex",
+ StringComparison.InvariantCultureIgnoreCase
+ ) != -1
+ )
+ {
+ order.ClientProfileData.Email = @"pedido@editorainovacao.com.br";
+ }
+ }
+
+ #endregion
+
+ LogConsumer.Debug(order, $"vtex-order-{orderId}.js");
+ var affiliated = string.IsNullOrWhiteSpace(order.AffiliateId)
+ ? string.Empty
+ : $" - Affiliated: {order.AffiliateId}";
+ LogConsumer.Info(
+ "Order: {0} - Sequence: {1} - Status: {2} - Sales channel: {3}{4}",
+ order.OrderId,
+ order.Sequence,
+ order.Status.GetHumanReadableValue(),
+ order.SalesChannel,
+ affiliated
+ );
+ return order;
+ }
+ catch (JsonSerializationException e)
+ {
+ throw new UnexpectedApiResponseException(json, e);
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ #region OMS
+
+ ///
+ /// Gets the feed.
+ ///
+ /// The maximum lot.
+ /// IEnumerable<OrderFeed>.
+ public IEnumerable GetFeed(int maxLot = 20)
+ {
+ //VTEX limitation
+ if (maxLot > 20)
+ {
+ maxLot = 20;
+ }
+
+ LogConsumer.Trace("Getting up to {0} events in order feed", maxLot);
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.OmsFeed}",
+ CancellationToken.None,
+ new Dictionary { { @"maxLot", maxLot.ToString() } }
+ )
+ .Result;
+ return SerializerFactory.GetSerializer>().Deserialize(json);
+ }
+
+ ///
+ /// Commits the feed.
+ ///
+ /// The feed.
+ public void CommitFeed(OrderFeed feed)
+ {
+ LogConsumer.Trace("Commiting feed of order {0}", feed.OrderId);
+ var data = (string)
+ new OrderFeedCommit { CommitToken = feed.CommitToken }.GetSerializer();
+ _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsFeed}confirm",
+ CancellationToken.None,
+ data: data
+ )
+ .Wait();
+ }
+
+ ///
+ /// Get a order by order id
+ ///
+ /// The id of the order
+ /// Order.
+ ///
+ public Order GetOrder(string orderId)
+ {
+ return GetOrderInternal(orderId);
+ }
+
+ ///
+ /// Gets the orders list metadata.
+ ///
+ /// The status.
+ /// IEnumerable<List>.
+ public IEnumerable GetOrdersList(OrderStatus status)
+ {
+ LogConsumer.Warning("Getting orders with status {0}", status.GetHumanReadableValue());
+ var orders = GetOrdersListInternal(status.GetInternalValue());
+ return orders.List;
+ }
+
+ ///
+ /// Get a Enumerable list of Order by status.
+ ///
+ /// The status of the orders to get
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(OrderStatus status)
+ {
+ var ordersIds = GetOrdersList(status).Select(order => order.OrderId).ToList();
+ if (ordersIds.Any())
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ LogConsumer.Warning("No orders with status {0} found", status.GetHumanReadableValue());
+ return new Order[0];
+ }
+
+ ///
+ /// Gets the orders list by a date range of order's placed date.
+ ///
+ /// The start date of the range.
+ /// The end date of the range.
+ /// IEnumerable<String>.
+ public IEnumerable GetOrdersList(DateTime startDate, DateTime endDate)
+ {
+ LogConsumer.Warning("Getting orders between {0:G} and {1:G}", startDate, endDate);
+ var orders = GetOrdersListInternal(startDate: startDate, endDate: endDate);
+ return orders.List;
+ }
+
+ ///
+ /// Get a Enumerable list of Order by a date range of order's placed date.
+ ///
+ /// The start date of the range
+ /// The end date of the range
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(DateTime startDate, DateTime endDate)
+ {
+ var ordersIds = GetOrdersList(startDate, endDate)
+ .Select(order => order.OrderId)
+ .ToList();
+ if (ordersIds.Any())
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ LogConsumer.Warning("No orders between {0:G} and {1:G} found", startDate, endDate);
+ return new Order[0];
+ }
+
+ ///
+ /// Gets the orders list by status and date range of order's placed date.
+ ///
+ /// The status of orders to get.
+ /// The start date of the range.
+ /// The end date of the range.
+ /// IEnumerable<String>.
+ public IEnumerable GetOrdersList(
+ OrderStatus status,
+ DateTime startDate,
+ DateTime endDate
+ )
+ {
+ LogConsumer.Warning(
+ "Getting orders with status {0} between {1:G} and {2:G}",
+ status.GetHumanReadableValue(),
+ startDate,
+ endDate
+ );
+ var orders = GetOrdersListInternal(status.GetInternalValue(), startDate, endDate);
+ return orders.List;
+ }
+
+ ///
+ /// Get a Enumerable list of Order by status and date range of order's placed date.
+ ///
+ /// The status of orders to get.
+ /// The start date of the range.
+ /// The end date of the range.
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(
+ OrderStatus status,
+ DateTime startDate,
+ DateTime endDate
+ )
+ {
+ var ordersIds = GetOrdersList(status, startDate, endDate)
+ .Select(order => order.OrderId)
+ .ToList();
+ if (ordersIds.Any())
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ LogConsumer.Warning(
+ "No order with status {0} between {1:G} and {2:G} found",
+ status.GetHumanReadableValue(),
+ startDate,
+ endDate
+ );
+ return new Order[0];
+ }
+
+ ///
+ /// Gets the orders list by status and affiliated identifier (AKA marketplace).
+ ///
+ /// The status of orders to get.
+ /// The affiliated identifier
+ /// IEnumerable<String>.
+ public IEnumerable GetOrdersList(OrderStatus status, string affiliatedId)
+ {
+ LogConsumer.Warning(
+ "Getting orders with status {0} and affiliated {1}",
+ status.GetHumanReadableValue(),
+ affiliatedId
+ );
+ var orders = GetOrdersListInternal(
+ status.GetInternalValue(),
+ affiliatedId: affiliatedId
+ );
+ return orders.List;
+ }
+
+ ///
+ /// Get a Enumerable list of Order by status and affiliated identifier (AKA marketplace).
+ ///
+ /// The status of orders to get.
+ /// The affiliated identifier
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(OrderStatus status, string affiliatedId)
+ {
+ var ordersIds = GetOrdersList(status, affiliatedId)
+ .Select(order => order.OrderId)
+ .ToList();
+ if (ordersIds.Any())
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ LogConsumer.Warning(
+ "No order with status {0} and affiliated {1} found",
+ status.GetHumanReadableValue(),
+ affiliatedId
+ );
+ return new Order[0];
+ }
+
+ ///
+ /// Gets the orders list by generic query (order id, client's document, sequence, etc).
+ ///
+ /// The query to lookup in orders.
+ /// IEnumerable<String>.
+ public IEnumerable GetOrdersList(string query)
+ {
+ LogConsumer.Warning("Getting orders with term '{0}'", query);
+ var orders = GetOrdersListInternal(genericQuery: query);
+ return orders.List;
+ }
+
+ ///
+ /// Gets the orders by generic query (order identifier, client's document, sequence, etc).
+ ///
+ /// The query to lookup in orders.
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(string query)
+ {
+ var ordersIds = GetOrdersList(query).Select(order => order.OrderId).ToList();
+ if (ordersIds.Any())
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ LogConsumer.Warning("No orders with term '{0}' found", query);
+ return new Order[0];
+ }
+
+ ///
+ /// Gets the orders by the array of orders identifiers
+ ///
+ /// The orders ids.
+ /// IEnumerable<Order>.
+ public IEnumerable GetOrders(string[] ordersIds)
+ {
+ return GetOrdersInternal(ordersIds);
+ }
+
+ ///
+ /// Cancels the order asynchronous.
+ ///
+ /// The order identifier.
+ /// A Task<System.String> representing the asynchronous operation.
+ /// Order {orderId} cannot be canceled because isn't in pending payment status on VTEX
+ public async Task CancelOrderAsync(string orderId)
+ {
+ try
+ {
+ LogConsumer.Warning("Cancelling order {0}", orderId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var order = GetOrder(orderId);
+ if (order.Status == OrderStatus.CANCELED)
+ {
+ return string.Empty;
+ }
+
+ if (
+ order.Status != OrderStatus.PAYMENT_PENDING
+ && order.Status != OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH
+ )
+ {
+ throw new InvalidOperationException(
+ $"Order {orderId} cannot be canceled because isn't in pending payment status on VTEX"
+ );
+ }
+
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsOrders}/{orderId}/cancel",
+ source.Token
+ )
+ .ConfigureAwait(false);
+ var receipt = SerializerFactory
+ .GetSerializer()
+ .Deserialize(json);
+ LogConsumer.Info(
+ "Order {0} successfully canceled. Receipt: {1}",
+ order.Sequence,
+ receipt.Receipt
+ );
+ return receipt.Receipt;
+ }
+ catch (Exception e)
+ {
+ LogConsumer.Handle(new CancelOrderException(orderId, e));
+ return string.Empty;
+ }
+ }
+
+ ///
+ /// Changes the order status asynchronous.
+ ///
+ /// The order identifier.
+ /// The new status.
+ /// A Task representing the asynchronous operation.
+ ///
+ public async Task ChangeOrderStatusAsync(string orderId, OrderStatus newStatus)
+ {
+ try
+ {
+ LogConsumer.Info(
+ "Changing order {0} status to {1}",
+ orderId,
+ newStatus.GetHumanReadableValue()
+ );
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsOrders}/{orderId}/changestate/{newStatus.GetInternalValue()}",
+ source.Token
+ )
+ .ConfigureAwait(false);
+ LogConsumer.Info(json);
+ }
+ catch (AggregateException e)
+ {
+ var ae = e.InnerExceptions.First();
+ throw new ChangeStatusOrderException(
+ orderId,
+ newStatus.GetHumanReadableValue(),
+ ae
+ );
+ }
+ catch (Exception e)
+ {
+ throw new ChangeStatusOrderException(orderId, newStatus.GetHumanReadableValue(), e);
+ }
+ }
+
+ ///
+ /// Notifies the order paid asynchronous.
+ ///
+ /// The order identifier.
+ /// A Task representing the asynchronous operation.
+ public async Task NotifyOrderPaidAsync(string orderId)
+ {
+ try
+ {
+ LogConsumer.Info("Sending payment notification of order {0}", orderId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var order = GetOrder(orderId);
+ if (
+ order.Status != OrderStatus.PAYMENT_PENDING
+ && order.Status != OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH
+ )
+ {
+ return;
+ }
+
+ if (order.Status == OrderStatus.AWAITING_AUTHORIZATION_TO_DISPATCH)
+ {
+ await ChangeOrderStatusAsync(order.OrderId, OrderStatus.AUTHORIZE_FULFILLMENT)
+ .ConfigureAwait(false);
+ return;
+ }
+ var paymentId = order.PaymentData.Transactions.First().Payments.First().Id;
+ _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsOrders}/{order.OrderId}/payments/{paymentId}/payment-notification",
+ source.Token
+ )
+ .Wait(source.Token);
+ }
+ catch (Exception e)
+ {
+ LogConsumer.Handle(new PaymentNotificationOrderException(orderId, e));
+ }
+ }
+
+ ///
+ /// Notifies the order shipped.
+ ///
+ /// The order identifier.
+ /// The notification.
+ ///
+ public void NotifyOrderShipped(string orderId, ShippingNotification notification)
+ {
+ NotifyOrderShippedAsync(orderId, notification, CancellationToken.None).Wait();
+ }
+
+ ///
+ /// Notifies the order shipped async.
+ ///
+ /// The order identifier.
+ /// The notification.
+ /// The token.
+ /// A Task<System.String> representing the asynchronous operation.
+ ///
+ public async Task NotifyOrderShippedAsync(
+ string orderId,
+ ShippingNotification notification,
+ CancellationToken token
+ )
+ {
+ try
+ {
+ LogConsumer.Info("Sending shipping notification of order {0}", orderId);
+ LogConsumer.Debug(
+ notification,
+ $"vtex-shipping-notification-{orderId}-{notification.InvoiceNumber}.js"
+ );
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsInvoices}/{orderId}/invoice",
+ token,
+ data: (string)notification.GetSerializer()
+ )
+ .ConfigureAwait(false);
+ var receipt = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Trace(receipt.Receipt);
+ return receipt.Receipt;
+ }
+ catch (AggregateException e)
+ {
+ var ae = e.InnerExceptions.First();
+ throw new ShippingNotificationOrderException(orderId, ae);
+ }
+ catch (Exception e)
+ {
+ throw new ShippingNotificationOrderException(orderId, e);
+ }
+ }
+
+ ///
+ /// Notifies the order delivered
+ ///
+ /// The tracking.
+ /// System.String.
+ ///
+ public async ValueTask NotifyOrderDelivered(Tracking tracking)
+ {
+ try
+ {
+ LogConsumer.Info("Sending tracking info of order {0}", tracking.OrderId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ LogConsumer.Debug(
+ tracking,
+ $"vtex-tracking-info-{tracking.OrderId}-{tracking.InvoiceNumber}.js"
+ );
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.PUT,
+ string.Format(
+ PlatformConstants.OmsTracking,
+ tracking.OrderId,
+ tracking.InvoiceNumber
+ ),
+ source.Token,
+ data: (string)tracking.GetSerializer()
+ )
+ .ConfigureAwait(false);
+ var receipt = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Trace(receipt.Receipt);
+ return receipt.Receipt;
+ }
+ catch (Exception e)
+ {
+ throw new TrackingNotificationOrderException(tracking.OrderId, e);
+ }
+ }
+
+ ///
+ /// Updates the order invoice.
+ ///
+ /// The order identifier.
+ /// The invoice identifier.
+ /// The notification.
+ ///
+ public void UpdateOrderInvoice(
+ string orderId,
+ string invoiceId,
+ ShippingNotificationPatch notification
+ )
+ {
+ try
+ {
+ LogConsumer.Info("Patching fiscal invoice {1} of order {0}", orderId, invoiceId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ LogConsumer.Debug(
+ notification,
+ $"vtex-shipping-notification-{orderId}-{invoiceId}.js"
+ );
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.PATCH,
+ $"{PlatformConstants.OmsOrders}/{orderId}/invoice/{invoiceId}",
+ source.Token,
+ data: (string)notification.GetSerializer()
+ )
+ .Result;
+ var receipt = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Trace(receipt.Receipt);
+ }
+ catch (Exception e)
+ {
+ throw new ShippingNotificationOrderException(orderId, e);
+ }
+ }
+
+ ///
+ /// Changes the order.
+ ///
+ /// The order identifier.
+ /// The change.
+ ///
+ public void ChangeOrder(string orderId, ChangeOrder change)
+ {
+ try
+ {
+ LogConsumer.Info("Changing order {0}", orderId);
+ LogConsumer.Debug(change, $"vtex-change-order-{orderId}.js");
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $"{PlatformConstants.OmsOrders}/{orderId}/changes",
+ CancellationToken.None,
+ data: (string)change.GetSerializer()
+ )
+ .Result;
+ var receipt = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Trace(receipt.Receipt);
+ }
+ catch (Exception e)
+ {
+ throw new ChangeOrderException(orderId, e);
+ }
+ }
+
+ #endregion
+
+ #region PCI Gateway
+
+ ///
+ /// Gets the transaction interactions.
+ ///
+ /// The transaction identifier.
+ /// IEnumerable<TransactionInteraction>.
+ ///
+ [Pure]
+ public IEnumerable GetTransactionInteractions(string transactionId)
+ {
+ try
+ {
+ LogConsumer.Info("Getting interactions of transaction {0}", transactionId);
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.PciTransactions}/{transactionId}/interactions",
+ CancellationToken.None,
+ restEndpoint: RequestEndpoint.PAYMENTS
+ )
+ .Result;
+ return SerializerFactory
+ .GetSerializer>()
+ .Deserialize(json);
+ }
+ catch (Exception e)
+ {
+ throw new TransactionException(transactionId, e);
+ }
+ }
+
+ #endregion
+
+ #region Stock
+
+ ///
+ /// get sku reservations as an asynchronous operation.
+ ///
+ /// The sku identifier.
+ /// The warehouse identifier.
+ /// A Task<System.Int32> representing the asynchronous operation.
+ public async Task GetSkuReservationsAsync(int skuId, string warehouseId)
+ {
+ try
+ {
+ LogConsumer.Info(
+ "Getting reservations of SKU {0} in the warehouse {1}",
+ skuId,
+ warehouseId
+ );
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.LogReservations}/{warehouseId}/{skuId}",
+ source.Token
+ )
+ .ConfigureAwait(false);
+ var reservations = SerializerFactory
+ .GetSerializer()
+ .Deserialize(json);
+ LogConsumer.Debug(reservations, $"vtex-sku-reservations-{skuId}.js");
+ var total = !reservations.Items.Any() ? 0 : reservations.Items.Sum(r => r.Quantity);
+ LogConsumer.Info(
+ "The SKU {0} has {1} units reserved in warehouse {2}",
+ skuId,
+ total,
+ warehouseId
+ );
+ return total;
+ }
+ catch (Exception e)
+ {
+ LogConsumer.Handle(new ProductExportException(skuId, e));
+ return 0;
+ }
+ }
+
+ ///
+ /// Gets the sku inventory.
+ ///
+ /// The sku identifier.
+ /// Inventory.
+ public async Task GetSkuInventoryAsync(int skuId)
+ {
+ LogConsumer.Info("Getting inventory of SKU {0}", skuId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.LogInventory}/{skuId}",
+ source.Token,
+ restEndpoint: RequestEndpoint.LOGISTICS
+ )
+ .ConfigureAwait(false);
+ var inventory = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Debug(inventory, $"vtex-sku-inventory-{skuId}.js");
+ return inventory;
+ }
+
+ ///
+ /// Updates the sku stock.
+ ///
+ /// The stock information.
+ /// A Task representing the asynchronous operation.
+ ///
+ public async Task UpdateSkuStockAsync(StockInfo stockInfo)
+ {
+ try
+ {
+ if (stockInfo.Quantity < 0)
+ {
+ stockInfo.Quantity = 0;
+ }
+
+ stockInfo.DateUtcOnBalanceSystem = null;
+ if (!stockInfo.UnlimitedQuantity)
+ {
+ stockInfo.Quantity += await GetSkuReservationsAsync(
+ stockInfo.ItemId,
+ stockInfo.WareHouseId
+ )
+ .ConfigureAwait(false);
+ }
+
+ LogConsumer.Info(
+ "Updating inventory of SKU {0} on warehouse {1} with {2} units",
+ stockInfo.ItemId,
+ stockInfo.WareHouseId,
+ stockInfo.Quantity
+ );
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var data = @"[" + (string)stockInfo.GetSerializer() + @"]";
+ LogConsumer.Debug(stockInfo, $"vtex-sku-stock-{stockInfo.ItemId}.js");
+ await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ PlatformConstants.LogWarehouses,
+ source.Token,
+ data: data
+ )
+ .ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ throw new UpdateStockInfoSKUException(stockInfo.ItemId, e);
+ }
+ }
+
+ #endregion
+
+ #region Pricing
+
+ ///
+ /// Get the prices for an SKU.
+ /// It is possible that on the property "fixedPrices" exists a list of specific prices for Trade Policies and Minimum Quantities of the SKU.Fixed Prices may also be scheduled.
+ ///
+ /// The stock keeping unit identifier
+ /// A task of price
+ public async Task GetPriceAsync(int skuId)
+ {
+ LogConsumer.Info("Getting the price of sku {0}", skuId);
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ try
+ {
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $@"{PlatformConstants.Pricing}/{skuId}",
+ source.Token,
+ restEndpoint: RequestEndpoint.API
+ )
+ .ConfigureAwait(false);
+ return SerializerFactory.GetSerializer().Deserialize(json);
+ }
+ catch (UnexpectedApiResponseException e)
+ {
+ if (e.StatusCode == 404)
+ {
+ return new Price();
+ }
+
+ throw;
+ }
+ }
+
+ ///
+ /// This method will create or update an SKU Price.
+ /// The property "basePrice" is the base selling price of the SKU.The property "fixedPrices" is an array where each item is a Fixed Price.
+ /// The Fixed Price is the price of the SKU for an specific Trade Policy with an specific Minimum Quantity to be activated.
+ /// A Fixed Price may optionally be scheduled by using the property dateRange.
+ /// A Fixed Price may optionally overwrite the listPrice specified in the Base Price by using the inner property listPrice.
+ /// If you don't have specific prices for different Trade Policies, you do not need to send the property fixedPrices.
+ ///
+ /// The price data
+ /// The stock keeping unit identifier
+ /// The cancellation token.
+ /// A Task representing the asynchronous operation.
+ ///
+ public async Task UpdatePriceAsync(Price price, int skuId, CancellationToken token)
+ {
+ try
+ {
+ var oldPrice = await GetPriceAsync(skuId).ConfigureAwait(false);
+ if (oldPrice?.FixedPrices != null && oldPrice.FixedPrices.Any())
+ {
+ await DeletePriceAsync(skuId, token).ConfigureAwait(false);
+ }
+
+ LogConsumer.Info(
+ "Updating the price of sku {0} to {1} (list price: {2})",
+ skuId,
+ price.CostPrice.ToMonetary(),
+ price.ListPrice.HasValue ? price.ListPrice.Value.ToMonetary() : "no"
+ );
+ await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.PUT,
+ $@"{PlatformConstants.Pricing}/{skuId}",
+ token,
+ data: (string)price.GetSerializer(),
+ restEndpoint: RequestEndpoint.API
+ )
+ .ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ throw new UpdatePriceInfoSkuException(skuId, e);
+ }
+ }
+
+ ///
+ /// Removes an SKU price.
+ /// This action removes both Base Price and all available Fixed Prices for and SKU in all trade policies.
+ ///
+ /// The stock keeping unit identifier.
+ /// The cancellation token.
+ /// Task
+ public async Task DeletePriceAsync(int skuId, CancellationToken token)
+ {
+ LogConsumer.Info("Deleting the price of sku {0}", skuId);
+ await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.DELETE,
+ $@"{PlatformConstants.Pricing}/{skuId}",
+ token,
+ restEndpoint: RequestEndpoint.API
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Retrieves a collection of bridge facets based on the specified query and optional keywords.
+ ///
+ /// The query string used to filter the bridge facets.
+ /// Optional keywords to further refine the search for bridge facets.
+ /// An enumerable collection of objects that match the specified query and keywords.
+ ///
+ /// This method constructs a query to fetch bridge facets from a remote service. It logs the action of retrieving facets
+ /// and sets a timeout of 5 minutes for the operation. The method builds a dictionary of query parameters, including
+ /// facets to retrieve and the specified query. If keywords are provided, they are added to the query parameters as well.
+ /// The method then invokes the service asynchronously and deserializes the resulting JSON response into a list of
+ /// objects. If an exception occurs during this process, a custom
+ /// is thrown, encapsulating the original exception and the query that caused the failure.
+ ///
+ /// Thrown when an error occurs while retrieving bridge facets.
+ [Pure]
+ public IEnumerable GetBridgeFacets(
+ [Localizable(false)] string query,
+ [Localizable(false)] string keywords = null
+ )
+ {
+ try
+ {
+ LogConsumer.Info(
+ "Getting facets in bridge module that satisfy the condition '{0}'",
+ query
+ );
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var queryString = new Dictionary
+ {
+ { @"_facets", @"Origin,Status" },
+ { @"_where", query },
+ };
+ if (!string.IsNullOrWhiteSpace(keywords))
+ {
+ queryString.Add(@"_keywords", $@"*{keywords}*");
+ }
+
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.BridgeSearch}/facets",
+ source.Token,
+ queryString,
+ restEndpoint: RequestEndpoint.BRIDGE
+ )
+ .Result;
+ return SerializerFactory.GetSerializer>().Deserialize(json);
+ }
+ catch (Exception e)
+ {
+ throw new BridgeException(query, e);
+ }
+ }
+
+ ///
+ /// Retrieves a collection of bridge items based on the specified query parameters.
+ ///
+ /// The query string used to filter the bridge items.
+ /// The sorting criteria for the returned items.
+ /// Additional keywords to refine the search results.
+ /// The starting point for the items to be retrieved.
+ /// The maximum number of items to return.
+ /// An enumerable collection of that match the specified criteria.
+ ///
+ /// This method interacts with an external service to fetch bridge items based on the provided query, sort, and keywords.
+ /// It logs the request details and checks for an offset limit to avoid exceeding the maximum allowed items from the service.
+ /// If the offset exceeds 10,000, a warning is logged, and an empty list is returned.
+ /// The method uses a cancellation token to set a timeout for the service call, ensuring that it does not hang indefinitely.
+ /// In case of an error during the service call, it throws a custom exception with details about the failure.
+ ///
+ ///
+ /// Thrown when an error occurs while retrieving bridge items from the external service.
+ ///
+ [Pure]
+ public IEnumerable GetBridgeItems(
+ [Localizable(false)] string query,
+ [Localizable(false)] string sort,
+ [Localizable(false)] string keywords,
+ int offSet,
+ int limit
+ )
+ {
+ try
+ {
+ LogConsumer.Info(
+ "Getting {0} items from {1} in bridge module that satisfy the condition '{2}'",
+ limit,
+ offSet,
+ query
+ );
+ if (offSet >= 10000)
+ {
+ LogConsumer.Warning(
+ "Cannot get more than 10000 items from Bridge / Master Data (VTEX Elastic Search limitation)"
+ );
+ return new List();
+ }
+ var source = new CancellationTokenSource(new TimeSpan(0, 5, 0));
+ var queryString = new Dictionary
+ {
+ { @"_where", query },
+ { @"_sort", sort },
+ { @"offSet", offSet.ToString() },
+ { @"limit", limit.ToString() },
+ };
+ if (!string.IsNullOrWhiteSpace(keywords))
+ {
+ queryString.Add(@"_keywords", $@"*{keywords}*");
+ }
+
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ PlatformConstants.BridgeSearch,
+ source.Token,
+ queryString,
+ restEndpoint: RequestEndpoint.BRIDGE
+ )
+ .Result;
+ return SerializerFactory.GetSerializer>().Deserialize(json);
+ }
+ catch (AggregateException e)
+ {
+ throw new BridgeException(
+ query,
+ e.InnerExceptions.FirstOrDefault() ?? e.InnerException ?? e
+ );
+ }
+ catch (Exception e)
+ {
+ throw new BridgeException(query, e);
+ }
+ }
+
+ ///
+ /// Gets all bridge items.
+ ///
+ /// The query.
+ /// The sort.
+ /// The keywords.
+ /// Name of the facet.
+ /// The facet value.
+ /// IEnumerable<BridgeItem>.
+ [Pure]
+ public IEnumerable GetAllBridgeItems(
+ [Localizable(false)] string query,
+ [Localizable(false)] string sort,
+ [Localizable(false)] string keywords,
+ [Localizable(false)] string facetName,
+ [Localizable(false)] string facetValue
+ )
+ {
+ const int perPage = 100;
+ var facets = GetBridgeFacets(query, keywords);
+ var total = facets.Single(f => f.Field.Equals(facetName)).Facets[facetValue].ToInt32();
+
+ var result = new List(total);
+ var pages = (total / perPage) + 1;
+ for (var x = 0; x < pages; x++)
+ {
+ result.AddRange(GetBridgeItems(query, sort, keywords, x * perPage, perPage));
+ }
+
+ return result;
+ }
+
+ #endregion
+
+ #region Platform status
+
+ ///
+ /// Gets the platform status.
+ ///
+ /// IEnumerable<PlatformStatus>.
+ public IEnumerable GetPlatformStatus()
+ {
+ return GetPlatformStatusAsync(CancellationToken.None).Result;
+ }
+
+ ///
+ /// Gets the platform status asynchronous.
+ ///
+ /// The token.
+ /// A Task<IEnumerable`1> representing the asynchronous operation.
+ [Pure]
+ public async Task> GetPlatformStatusAsync(
+ CancellationToken token
+ )
+ {
+ LogConsumer.Info("Getting platform status");
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ string.Empty,
+ token,
+ restEndpoint: RequestEndpoint.HEALTH
+ )
+ .ConfigureAwait(false);
+ var status = SerializerFactory.GetSerializer>().Deserialize(json);
+ LogConsumer.Debug(status, "vtex-platform-status.js");
+ return status;
+ }
+
+ #endregion
+
+ #region Order payments
+
+ ///
+ /// Gets the order payments.
+ ///
+ /// The transaction identifier.
+ /// List<PciPayment>.
+ [Pure]
+ public List GetOrderPayments(string transactionId)
+ {
+ var json = _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $"{PlatformConstants.PciTransactions}/{transactionId}/payments",
+ CancellationToken.None,
+ restEndpoint: RequestEndpoint.PAYMENTS
+ )
+ .Result;
+ if (json == null)
+ {
+ return new List();
+ }
+
+ var data = SerializerFactory
+ .GetCustomSerializer>(SerializerFormat.Json)
+ .Deserialize(json);
+ LogConsumer.Debug(data, $"vtex-order-payemnts-{transactionId}.js");
+ return data;
+ }
+
+ #endregion
+
+ #region Catalog
+
+ #region Specification
+
+ ///
+ /// Gets the specification field asynchronous.
+ ///
+ /// The field identifier.
+ /// The token.
+ /// A Task<SpecificationField> representing the asynchronous operation.
+ [Pure]
+ public async Task GetSpecificationFieldAsync(
+ int fieldId,
+ CancellationToken token
+ )
+ {
+ LogConsumer.Info("Getting field for the field id {0}", fieldId);
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $@"{PlatformConstants.CatalogPub}/specification/fieldGet/{fieldId}",
+ token
+ )
+ .ConfigureAwait(false);
+ var field = SerializerFactory.GetSerializer().Deserialize(json);
+ LogConsumer.Debug(field, $"vtex-specification-field-{fieldId}.js");
+ return field;
+ }
+
+ ///
+ /// Gets the specification field values asynchronous.
+ ///
+ /// The field identifier.
+ /// The token.
+ /// A Task<ICollection`1> representing the asynchronous operation.
+ [Pure]
+ public async Task> GetSpecificationFieldValuesAsync(
+ int fieldId,
+ CancellationToken token
+ )
+ {
+ LogConsumer.Info("Getting field values for the field id {0}", fieldId);
+ var json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $@"{PlatformConstants.CatalogPub}/specification/fieldvalue/{fieldId}",
+ token
+ )
+ .ConfigureAwait(false);
+ var fieldValues = SerializerFactory
+ .GetSerializer>()
+ .Deserialize(json);
+ LogConsumer.Debug(fieldValues, $"vtex-specification-values-{fieldId}.js");
+ return fieldValues;
+ }
+
+ ///
+ /// Updates the product specification asynchronous.
+ ///
+ /// The specification.
+ /// The product identifier.
+ /// The token.
+ /// A Task representing the asynchronous operation.
+ public async Task UpdateProductSpecificationAsync(
+ Specification specification,
+ int productId,
+ CancellationToken token
+ )
+ {
+ await UpdateProductSpecificationsAsync(
+ new List(new[] { specification }),
+ productId,
+ token
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Updates the product specifications asynchronous.
+ ///
+ /// The specifications list.
+ /// The product identifier.
+ /// The token.
+ /// A Task representing the asynchronous operation.
+ public async Task UpdateProductSpecificationsAsync(
+ List specifications,
+ int productId,
+ CancellationToken token
+ )
+ {
+ LogConsumer.Info(
+ "Updating the specifications {1} of product {0}",
+ productId,
+ string.Join(@",", specifications.Select(s => s.Id))
+ );
+
+ var data = (string)specifications.GetSerializer();
+ await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $@"{PlatformConstants.Catalog}/products/{productId}/specification",
+ token,
+ data: data
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Inserts the specification field value asynchronous.
+ ///
+ /// The field value.
+ /// The token.
+ /// A Task representing the asynchronous operation.
+ public async Task InsertSpecificationFieldValueAsync(
+ SpecificationFieldValue fieldValue,
+ CancellationToken token
+ )
+ {
+ LogConsumer.Info("Creating field value of field id {0}", fieldValue.FieldId);
+ var data = (string)fieldValue.GetSerializer();
+ await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.POST,
+ $@"{PlatformConstants.Catalog}/specification/fieldValue",
+ token,
+ data: data
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Asynchronously searches for a data entity based on a specified field and value.
+ ///
+ /// The type of the data entity to search for, which must implement .
+ /// The field of the data entity to search against.
+ /// The value to search for in the specified field.
+ /// A cancellation token to monitor for cancellation requests.
+ /// A task that represents the asynchronous operation. The task result contains the found data entity of type or null if no entity is found.
+ ///
+ /// This method performs an asynchronous search for a data entity by sending a GET request to the specified endpoint.
+ /// It constructs a query string using the provided field and value, and invokes a service to retrieve the data.
+ /// If the search value is null or whitespace, an is thrown.
+ /// In case of an unexpected API response, an is thrown, containing the JSON response and the original exception.
+ /// The method logs the retrieved entity for debugging purposes.
+ ///
+ /// Thrown when is null or whitespace.
+ /// Thrown when the API response is unexpected.
+ [Pure]
+ public async Task SearchAsync(
+ string searchedField,
+ string searchedValue,
+ CancellationToken token
+ )
+ where TDataEntity : class, IDataEntity, new()
+ {
+ if (string.IsNullOrWhiteSpace(searchedValue))
+ {
+ throw new ArgumentNullException(nameof(searchedValue));
+ }
+
+ var queryString = new Dictionary
+ {
+ { searchedField, searchedValue },
+ { @"_fields", @"_all" },
+ };
+ var json = string.Empty;
+ try
+ {
+ var entityName = typeof(TDataEntity).GetDataEntityName();
+ json = await _wrapper
+ .ServiceInvokerAsync(
+ HttpRequestMethod.GET,
+ $@"dataentities/{entityName}/search/",
+ token,
+ queryString,
+ restEndpoint: RequestEndpoint.MASTER_DATA
+ )
+ .ConfigureAwait(false);
+ var entity = SerializerFactory
+ .GetSerializer>()
+ .Deserialize(json)
+ .FirstOrDefault();
+ if (entity == null)
+ {
+ return null;
+ }
+
+ LogConsumer.Debug(
+ entity,
+ $@"vtex-masterdata-entity-{entityName}-{searchedField}-{searchedValue}.js"
+ );
+ return entity;
+ }
+ catch (Exception e)
+ {
+ throw new UnexpectedApiResponseException(json, e);
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #endregion
+
+ #region IDisposable
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ _wrapper.Dispose();
+ }
+
+ #endregion
+ }
+}
From ffb4fb5e25532601a724da33a0e89bd4a08e044d Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:09:13 +0000
Subject: [PATCH 002/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1072 ++++++++++++++++++++-------------------
1 file changed, 541 insertions(+), 531 deletions(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 3140fe613..6a8884df7 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -1,531 +1,541 @@
-// ***********************************************************************
-// Assembly : VTEX
-// Author : Guilherme Branco Stracini
-// Created : 01-15-2023
-//
-// Last Modified By : Guilherme Branco Stracini
-// Last Modified On : 01-16-2023
-// ***********************************************************************
-//
-// © 2020 Guilherme Branco Stracini. All rights reserved.
-//
-//
-// ***********************************************************************
-namespace VTEX
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using CrispyWaffle.Extensions;
- using CrispyWaffle.Log;
- using CrispyWaffle.Telemetry;
- using CrispyWaffle.Utilities;
- using Enums;
- using GoodPractices;
-
- ///
- /// Class Wrapper. This class cannot be inherited.
- ///
- ///
- // TODO change public to internal after remove from Integração Service
- public sealed class VTEXWrapper : IDisposable
- {
- #region Private fields
-
- ///
- /// The application key
- ///
- private string _appKey;
-
- ///
- /// The application token
- ///
- private string _appToken;
-
- ///
- /// The authentication cookie
- ///
- private string _authCookie;
-
- ///
- /// The account name
- ///
- private readonly string _accountName;
-
- ///
- /// The internal user agent
- ///
- private static string _internalUserAgent;
-
- ///
- /// Gets the internal user agent.
- ///
- /// The internal user agent.
- private static string InternalUserAgent
- {
- get
- {
- if (!string.IsNullOrWhiteSpace(_internalUserAgent))
- {
- return _internalUserAgent;
- }
-
- var assembly = System
- .Reflection.Assembly.GetAssembly(typeof(VTEXWrapper))
- .GetName();
- _internalUserAgent = $@"{assembly.Name}/{assembly.Version}";
- return _internalUserAgent;
- }
- }
-
- ///
- /// The request mediator
- ///
- private readonly ManualResetEvent _requestMediator = new ManualResetEvent(false);
-
- #endregion
-
- #region ~Ctor
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The account name.
- public VTEXWrapper(string accountName)
- {
- _accountName = accountName;
- _requestMediator.Set();
- }
-
- #endregion
-
- #region Implementation of IDisposable
-
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- _appKey = null;
- _appToken = null;
- _requestMediator.Dispose();
- }
-
- #endregion
-
- #region Private methods
-
- ///
- /// Services the invoker internal.
- ///
- /// The method.
- /// The endpoint.
- /// The token.
- /// The data.
- /// The URI builder.
- /// The cookie.
- /// if set to true [requires authentication].
- /// if set to true [is retry].
- /// System.String.
- private async Task ServiceInvokerInternal(
- HttpRequestMethod method,
- string endpoint,
- CancellationToken token,
- string data,
- UriBuilder uriBuilder,
- Cookie cookie,
- bool requiresAuthentication,
- bool isRetry = false
- )
- {
- HttpResponseMessage response = null;
- string result = null;
- Exception exr;
- try
- {
- _requestMediator.WaitOne();
-
- LogConsumer.Trace(
- "ServiceInvokerAsync -> Method: {0} | Endpoint: {1}",
- method.GetHumanReadableValue(),
- endpoint
- );
-
- LogConsumer.Debug(uriBuilder.ToString());
-
- var cookieContainer = new CookieContainer();
-
- using var handler = new HttpClientHandler { CookieContainer = cookieContainer };
-
- using var client = new HttpClient(handler);
-
- ConfigureClient(client, requiresAuthentication);
-
- if (cookie != null)
- {
- cookieContainer.Add(uriBuilder.Uri, cookie);
- }
-
- response = await RequestInternalAsync(method, token, data, client, uriBuilder)
- .ConfigureAwait(false);
-
- token.ThrowIfCancellationRequested();
-
- result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
-
- response.EnsureSuccessStatusCode();
-
- return result;
- }
- catch (AggregateException e)
- {
- var ex = e.InnerExceptions.FirstOrDefault() ?? e.InnerException ?? e;
-
- exr = HandleException(ex, response, uriBuilder.Uri, method, data, result);
-
- if (isRetry)
- {
- throw exr;
- }
- }
- catch (Exception e)
- {
- exr = HandleException(e, response, uriBuilder.Uri, method, data, result);
-
- if (isRetry)
- {
- throw exr;
- }
- }
-
- return await ServiceInvokerInternal(
- method,
- endpoint,
- token,
- data,
- uriBuilder,
- cookie,
- requiresAuthentication,
- true
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Handles the exception.
- ///
- /// The exception.
- /// The response.
- /// The URI.
- /// The method.
- /// The data.
- /// The result.
- /// Exception.
- ///
- private Exception HandleException(
- Exception exception,
- HttpResponseMessage response,
- Uri uri,
- HttpRequestMethod method,
- string data,
- string result
- )
- {
- var statusCode = 0;
- if (response != null)
- {
- statusCode = (int)response.StatusCode;
- }
-
- var ex = new UnexpectedApiResponseException(
- uri,
- method.ToString(),
- data,
- result,
- statusCode,
- exception
- );
- if (statusCode == 429 || statusCode == 503)
- {
- _requestMediator.Reset();
- LogConsumer.Warning(
- "HTTP {2} status code on method {0} - uri {1}",
- method.ToString(),
- uri,
- statusCode
- );
- Thread.Sleep(60 * 1000);
- _requestMediator.Set();
- return ex;
- }
- if (statusCode != 0 && statusCode != 408 && statusCode != 500 && statusCode != 502)
- {
- throw ex;
- }
-
- LogConsumer.Warning("Retrying the {0} request", method.ToString());
- TelemetryAnalytics.TrackHit(
- $"VTEX_handle_exception_retrying_{method.ToString()}_request"
- );
- return ex;
- }
-
- ///
- /// Configures the client.
- ///
- /// The client.
- /// if set to true [requires authentication].
- private void ConfigureClient(HttpClient client, bool requiresAuthentication)
- {
- client.DefaultRequestHeaders.ExpectContinue = false;
- client.DefaultRequestHeaders.Accept.Clear();
- client.DefaultRequestHeaders.Accept.Add(
- new MediaTypeWithQualityHeaderValue(@"application/json")
- );
- client.DefaultRequestHeaders.TryAddWithoutValidation(
- @"User-Agent",
- $@"guiBranco-VTEX-SDK-dotnet {InternalUserAgent} +https://github.com/guibranco/VTEX-SDK-dotnet"
- );
- if (!requiresAuthentication)
- {
- return;
- }
-
- client.DefaultRequestHeaders.Add(@"X-VTEX-API-AppKey", _appKey);
- client.DefaultRequestHeaders.Add(@"X-VTEX-API-AppToken", _appToken);
- }
-
- ///
- /// Sends an HTTP request asynchronously using the specified method and returns the response.
- ///
- /// The HTTP method to use for the request (e.g., GET, POST, DELETE, etc.).
- /// A cancellation token to cancel the operation if needed.
- /// The data to be sent in the request body, if applicable.
- /// The HttpClient instance used to send the request.
- /// The UriBuilder that constructs the URI for the request.
- /// A task that represents the asynchronous operation, containing the HttpResponseMessage received from the server.
- ///
- /// This method handles different HTTP methods such as GET, POST, PUT, DELETE, and PATCH.
- /// It constructs the appropriate request based on the provided method and sends it using the specified HttpClient.
- /// If the method requires a body (like POST, PUT, or PATCH), it creates a StringContent object with the provided data.
- /// The method also supports cancellation through the provided CancellationToken.
- /// The response from the server is returned as an HttpResponseMessage, which can be used to inspect the result of the request.
- ///
- /// Thrown when an unsupported HTTP method is provided.
- private static async Task RequestInternalAsync(
- HttpRequestMethod method,
- CancellationToken token,
- string data,
- HttpClient client,
- UriBuilder uriBuilder
- )
- {
- HttpResponseMessage response;
- StringContent content = null;
- if (!string.IsNullOrWhiteSpace(data))
- {
- content = new StringContent(data, Encoding.UTF8, @"application/json");
- }
-
- switch (method)
- {
- case HttpRequestMethod.DELETE:
- response = await client
- .DeleteAsync(uriBuilder.Uri, token)
- .ConfigureAwait(false);
- break;
- case HttpRequestMethod.GET:
- response = await client.GetAsync(uriBuilder.Uri, token).ConfigureAwait(false);
- break;
- case HttpRequestMethod.POST:
- response = await client
- .PostAsync(uriBuilder.Uri, content, token)
- .ConfigureAwait(false);
- break;
- case HttpRequestMethod.PUT:
- response = await client
- .PutAsync(uriBuilder.Uri, content, token)
- .ConfigureAwait(false);
- break;
- case HttpRequestMethod.PATCH:
- var request = new HttpRequestMessage(new HttpMethod(@"PATCH"), uriBuilder.Uri)
- {
- Content = content,
- };
- response = await client.SendAsync(request, token).ConfigureAwait(false);
- request.Dispose();
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(method), method, null);
- }
-
- return response;
- }
-
- #endregion
-
- #region Public methods
-
- ///
- /// Sets the rest credentials.
- ///
- /// The application key.
- /// The application token.
- public void SetRestCredentials(string appKey, string appToken)
- {
- _appKey = appKey;
- _appToken = appToken;
- }
-
- ///
- /// Sets the vtex identifier client authentication cookie.
- ///
- /// The cookie value.
- public void SetVtexIdClientAuthCookie(string cookieValue)
- {
- _authCookie = cookieValue;
- }
-
- ///
- /// Asynchronously invokes a service endpoint with the specified HTTP method and parameters.
- ///
- /// The HTTP request method to be used (e.g., GET, POST).
- /// The endpoint of the service to be invoked. This should not be localizable.
- /// A cancellation token to observe while waiting for the task to complete.
- /// An optional dictionary of query string parameters to be included in the request.
- /// An optional string containing data to be sent with the request.
- /// An optional parameter specifying the REST endpoint type. Defaults to .
- /// A task that represents the asynchronous operation, containing the response as a string.
- ///
- /// This method constructs a URI using the provided endpoint and query string parameters,
- /// and then invokes the service asynchronously. It handles authentication and cookie management
- /// as needed based on the service requirements. The method is designed to work with various
- /// HTTP methods and can send data in the request body if specified.
- /// The response from the service is returned as a string, allowing for further processing or
- /// parsing as needed by the caller.
- ///
- public async Task ServiceInvokerAsync(
- HttpRequestMethod method,
- [Localizable(false)] string endpoint,
- CancellationToken token,
- Dictionary queryString = null,
- string data = null,
- RequestEndpoint restEndpoint = RequestEndpoint.DEFAULT
- )
- {
- Cookie cookie = null;
- var requiresAuthentication = true;
- var protocol = @"https";
- var port = 443;
- var host = GetHostData(
- ref endpoint,
- ref queryString,
- restEndpoint,
- ref cookie,
- ref protocol,
- ref port,
- ref requiresAuthentication
- );
- var query = string.Empty;
- if (queryString is { Count: > 0 })
- {
- query = new QueryStringBuilder().AddRange(queryString).ToString();
- }
-
- var builder = new UriBuilder(protocol, host, port, endpoint)
- {
- Query = query.Replace(@"?", string.Empty),
- };
- return await ServiceInvokerInternal(
- method,
- endpoint,
- token,
- data,
- builder,
- cookie,
- requiresAuthentication
- )
- .ConfigureAwait(false);
- }
-
- ///
- /// Gets the host data.
- ///
- /// The endpoint.
- /// The query string.
- /// The rest endpoint.
- /// The cookie.
- /// The protocol.
- /// The port.
- /// if set to true [requires authentication].
- /// System.String.
- /// restEndpoint - null
- private string GetHostData(
- ref string endpoint,
- ref Dictionary queryString,
- RequestEndpoint restEndpoint,
- ref Cookie cookie,
- ref string protocol,
- ref int port,
- ref bool requiresAuthentication
- )
- {
- string host;
- switch (restEndpoint)
- {
- case RequestEndpoint.DEFAULT:
- host = $@"{_accountName}.{VTEXConstants.PlatformStableDomain}";
- endpoint = $@"api/{endpoint}";
- break;
- case RequestEndpoint.PAYMENTS:
- host = $@"{_accountName}.{VTEXConstants.PaymentsDomain}";
- endpoint = $@"api/{endpoint}";
- break;
- case RequestEndpoint.LOGISTICS:
- host = VTEXConstants.LogisticsDomain;
- endpoint = $@"api/{endpoint}";
- if (queryString == null)
- {
- queryString = new();
- }
-
- queryString.Add(@"an", _accountName);
- break;
- case RequestEndpoint.API:
- case RequestEndpoint.MASTER_DATA:
- host = VTEXConstants.ApiDomain;
- endpoint = $@"{_accountName}/{endpoint}";
- break;
- case RequestEndpoint.BRIDGE:
- host = $@"{_accountName}.{VTEXConstants.MyVtexDomain}";
- endpoint = $@"api/{endpoint}";
- if (!string.IsNullOrWhiteSpace(_authCookie))
- {
- cookie = new(VTEXConstants.VtexIdClientAuthCookieName, _authCookie);
- }
-
- break;
- case RequestEndpoint.HEALTH:
- protocol = @"http";
- port = 80;
- host = VTEXConstants.MonitoringDomain;
- endpoint = @"api/healthcheck/modules";
- requiresAuthentication = false;
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(restEndpoint), restEndpoint, null);
- }
-
- return host;
- }
-
- #endregion
- }
-}
+// ***********************************************************************
+// Assembly : VTEX
+// Author : Guilherme Branco Stracini
+// Created : 01-15-2023
+//
+// Last Modified By : Guilherme Branco Stracini
+// Last Modified On : 01-16-2023
+// ***********************************************************************
+//
+// © 2020 Guilherme Branco Stracini. All rights reserved.
+//
+//
+// ***********************************************************************
+namespace VTEX
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Net.Http.Headers;
+ using System.Text;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using CrispyWaffle.Extensions;
+ using CrispyWaffle.Log;
+ using CrispyWaffle.Telemetry;
+ using CrispyWaffle.Utilities;
+ using Enums;
+ using GoodPractices;
+
+ ///
+ /// Class Wrapper. This class cannot be inherited.
+ ///
+ ///
+ // TODO change public to internal after remove from Integração Service
+ public sealed class VTEXWrapper : IDisposable
+ {
+ #region Private fields
+
+ ///
+ /// The application key
+ ///
+ private string _appKey;
+
+ ///
+ /// The application token
+ ///
+ private string _appToken;
+
+ ///
+ /// The authentication cookie
+ ///
+ private string _authCookie;
+
+ ///
+ /// The account name
+ ///
+ private readonly string _accountName;
+
+ ///
+ /// The internal user agent
+ ///
+ private static string _internalUserAgent;
+
+ ///
+ /// Gets the internal user agent.
+ ///
+ /// The internal user agent.
+ private static string InternalUserAgent
+ {
+ get
+ {
+ if (!string.IsNullOrWhiteSpace(_internalUserAgent))
+ {
+ return _internalUserAgent;
+ }
+
+ var assembly = System
+ .Reflection.Assembly.GetAssembly(typeof(VTEXWrapper))
+ .GetName();
+ _internalUserAgent = $@"{assembly.Name}/{assembly.Version}";
+ return _internalUserAgent;
+ }
+ }
+
+ ///
+ /// The request mediator
+ ///
+ private readonly ManualResetEvent _requestMediator = new ManualResetEvent(false);
+
+ #endregion
+
+ #region ~Ctor
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The account name.
+ public VTEXWrapper(string accountName)
+ {
+ _accountName = accountName;
+ _requestMediator.Set();
+ }
+
+ #endregion
+
+ #region Implementation of IDisposable
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ _appKey = null;
+ _appToken = null;
+ _requestMediator.Dispose();
+ }
+
+ #endregion
+
+ #region Private methods
+
+ ///
+ /// Services the invoker internal.
+ ///
+ /// The method.
+ /// The endpoint.
+ /// The token.
+ /// The data.
+ /// The URI builder.
+ /// The cookie.
+ /// if set to true [requires authentication].
+ /// if set to true [is retry].
+ /// System.String.
+ private async Task ServiceInvokerInternal(
+ HttpRequestMethod method,
+ string endpoint,
+ CancellationToken token,
+ string data,
+ UriBuilder uriBuilder,
+ Cookie cookie,
+ bool requiresAuthentication,
+ bool isRetry = false
+ )
+ {
+ HttpResponseMessage response = null;
+ string result = null;
+ Exception exr;
+ try
+ {
+ _requestMediator.WaitOne();
+
+ LogConsumer.Trace(
+ "ServiceInvokerAsync -> Method: {0} | Endpoint: {1}",
+ method.GetHumanReadableValue(),
+ endpoint
+ );
+
+ LogConsumer.Debug(uriBuilder.ToString());
+
+ var cookieContainer = new CookieContainer();
+
+ using var handler = new HttpClientHandler { CookieContainer = cookieContainer };
+
+ using var client = new HttpClient(handler);
+
+ ConfigureClient(client, requiresAuthentication);
+
+ if (cookie != null)
+ {
+ cookieContainer.Add(uriBuilder.Uri, cookie);
+ }
+
+ response = await RequestInternalAsync(method, token, data, client, uriBuilder)
+ .ConfigureAwait(false);
+
+ token.ThrowIfCancellationRequested();
+
+ result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
+
+ response.EnsureSuccessStatusCode();
+
+ return result;
+ }
+ catch (AggregateException e)
+ {
+ var ex = e.InnerExceptions.FirstOrDefault() ?? e.InnerException ?? e;
+
+ exr = HandleException(ex, response, uriBuilder.Uri, method, data, result);
+
+ if (isRetry)
+ {
+ throw exr;
+ }
+ }
+ catch (Exception e)
+ {
+ exr = HandleException(e, response, uriBuilder.Uri, method, data, result);
+
+ if (isRetry)
+ {
+ throw exr;
+ }
+ }
+
+ return await ServiceInvokerInternal(
+ method,
+ endpoint,
+ token,
+ data,
+ uriBuilder,
+ cookie,
+ requiresAuthentication,
+ true
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Handles the exception.
+ ///
+ /// The exception.
+ /// The response.
+ /// The URI.
+ /// The method.
+ /// The data.
+ /// The result.
+ /// Exception.
+ ///
+ private Exception HandleException(
+ Exception exception,
+ HttpResponseMessage response,
+ Uri uri,
+ HttpRequestMethod method,
+ string data,
+ string result
+ )
+ {
+ var statusCode = 0;
+ if (response != null)
+ {
+ statusCode = (int)response.StatusCode;
+ }
+
+ var ex = new UnexpectedApiResponseException(
+ uri,
+ method.ToString(),
+ data,
+ result,
+ statusCode,
+ exception
+ );
+ if (statusCode == 429 || statusCode == 503)
+ {
+ _requestMediator.Reset();
+ LogConsumer.Warning(
+ "HTTP {2} status code on method {0} - uri {1}",
+ method.ToString(),
+ uri,
+ statusCode
+ );
+ Thread.Sleep(60 * 1000);
+ _requestMediator.Set();
+ return ex;
+ }
+ if (statusCode != 0 && statusCode != 408 && statusCode != 500 && statusCode != 502)
+ {
+ throw ex;
+ }
+
+ LogConsumer.Warning("Retrying the {0} request", method.ToString());
+ TelemetryAnalytics.TrackHit(
+ $"VTEX_handle_exception_retrying_{method.ToString()}_request"
+ );
+ return ex;
+ }
+
+ ///
+ /// Configures the client.
+ ///
+ /// The client.
+ /// if set to true [requires authentication].
+ private void ConfigureClient(HttpClient client, bool requiresAuthentication)
+ {
+ client.DefaultRequestHeaders.ExpectContinue = false;
+ client.DefaultRequestHeaders.Accept.Clear();
+ client.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue(@"application/json")
+ );
+ client.DefaultRequestHeaders.TryAddWithoutValidation(
+ @"User-Agent",
+ $@"guiBranco-VTEX-SDK-dotnet {InternalUserAgent} +https://github.com/guibranco/VTEX-SDK-dotnet"
+ );
+ if (!requiresAuthentication)
+ {
+ return;
+ }
+
+ client.DefaultRequestHeaders.Add(@"X-VTEX-API-AppKey", _appKey);
+ client.DefaultRequestHeaders.Add(@"X-VTEX-API-AppToken", _appToken);
+ }
+
+ ///
+ /// Sends an HTTP request asynchronously using the specified method and returns the response.
+ ///
+ /// The HTTP method to use for the request (e.g., GET, POST, DELETE, etc.).
+ /// A cancellation token to cancel the operation if needed.
+ /// The data to be sent in the request body, if applicable.
+ /// The HttpClient instance used to send the request.
+ /// The UriBuilder that constructs the URI for the request.
+ /// A task that represents the asynchronous operation, containing the HttpResponseMessage received from the server.
+ ///
+ /// This method handles different HTTP methods such as GET, POST, PUT, DELETE, and PATCH.
+ /// It constructs the appropriate request based on the provided method and sends it using the specified HttpClient.
+ /// If the method requires a body (like POST, PUT, or PATCH), it creates a StringContent object with the provided data.
+ /// The method also supports cancellation through the provided CancellationToken.
+ /// The response from the server is returned as an HttpResponseMessage, which can be used to inspect the result of the request.
+ ///
+ /// Thrown when an unsupported HTTP method is provided.
+ private static async Task RequestInternalAsync(
+ HttpRequestMethod method,
+ CancellationToken token,
+ string data,
+ HttpClient client,
+ UriBuilder uriBuilder
+ )
+ {
+ HttpResponseMessage response;
+ StringContent content = null;
+ if (!string.IsNullOrWhiteSpace(data))
+ {
+ content = new StringContent(data, Encoding.UTF8, @"application/json");
+ }
+
+ switch (method)
+ {
+ case HttpRequestMethod.DELETE:
+ response = await client
+ .DeleteAsync(uriBuilder.Uri, token)
+ .ConfigureAwait(false);
+ break;
+ case HttpRequestMethod.GET:
+ response = await client.GetAsync(uriBuilder.Uri, token).ConfigureAwait(false);
+ break;
+ case HttpRequestMethod.POST:
+ response = await client
+ .PostAsync(uriBuilder.Uri, content, token)
+ .ConfigureAwait(false);
+ break;
+ case HttpRequestMethod.PUT:
+ response = await client
+ .PutAsync(uriBuilder.Uri, content, token)
+ .ConfigureAwait(false);
+ break;
+ case HttpRequestMethod.PATCH:
+ var request = new HttpRequestMessage(new HttpMethod(@"PATCH"), uriBuilder.Uri)
+ {
+ Content = content,
+ };
+ response = await client.SendAsync(request, token).ConfigureAwait(false);
+ request.Dispose();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(method), method, null);
+ }
+
+ return response;
+ }
+
+ #endregion
+
+ #region Public methods
+
+ ///
+ /// Retrieves a list of all collections.
+ ///
+ /// A cancellation token to observe while waiting for the task to complete.
+ /// A task that represents the asynchronous operation, containing the list of collections as a string.
+ public async Task GetCollectionsAsync(CancellationToken token)
+ {
+ return await ServiceInvokerAsync(HttpRequestMethod.GET, "collections", token);
+ }
+
+ ///
+ /// Sets the rest credentials.
+ ///
+ /// The application key.
+ /// The application token.
+ public void SetRestCredentials(string appKey, string appToken)
+ {
+ _appKey = appKey;
+ _appToken = appToken;
+ }
+
+ ///
+ /// Sets the vtex identifier client authentication cookie.
+ ///
+ /// The cookie value.
+ public void SetVtexIdClientAuthCookie(string cookieValue)
+ {
+ _authCookie = cookieValue;
+ }
+
+ ///
+ /// Asynchronously invokes a service endpoint with the specified HTTP method and parameters.
+ ///
+ /// The HTTP request method to be used (e.g., GET, POST).
+ /// The endpoint of the service to be invoked. This should not be localizable.
+ /// A cancellation token to observe while waiting for the task to complete.
+ /// An optional dictionary of query string parameters to be included in the request.
+ /// An optional string containing data to be sent with the request.
+ /// An optional parameter specifying the REST endpoint type. Defaults to .
+ /// A task that represents the asynchronous operation, containing the response as a string.
+ ///
+ /// This method constructs a URI using the provided endpoint and query string parameters,
+ /// and then invokes the service asynchronously. It handles authentication and cookie management
+ /// as needed based on the service requirements. The method is designed to work with various
+ /// HTTP methods and can send data in the request body if specified.
+ /// The response from the service is returned as a string, allowing for further processing or
+ /// parsing as needed by the caller.
+ ///
+ public async Task ServiceInvokerAsync(
+ HttpRequestMethod method,
+ [Localizable(false)] string endpoint,
+ CancellationToken token,
+ Dictionary queryString = null,
+ string data = null,
+ RequestEndpoint restEndpoint = RequestEndpoint.DEFAULT
+ )
+ {
+ Cookie cookie = null;
+ var requiresAuthentication = true;
+ var protocol = @"https";
+ var port = 443;
+ var host = GetHostData(
+ ref endpoint,
+ ref queryString,
+ restEndpoint,
+ ref cookie,
+ ref protocol,
+ ref port,
+ ref requiresAuthentication
+ );
+ var query = string.Empty;
+ if (queryString is { Count: > 0 })
+ {
+ query = new QueryStringBuilder().AddRange(queryString).ToString();
+ }
+
+ var builder = new UriBuilder(protocol, host, port, endpoint)
+ {
+ Query = query.Replace(@"?", string.Empty),
+ };
+ return await ServiceInvokerInternal(
+ method,
+ endpoint,
+ token,
+ data,
+ builder,
+ cookie,
+ requiresAuthentication
+ )
+ .ConfigureAwait(false);
+ }
+
+ ///
+ /// Gets the host data.
+ ///
+ /// The endpoint.
+ /// The query string.
+ /// The rest endpoint.
+ /// The cookie.
+ /// The protocol.
+ /// The port.
+ /// if set to true [requires authentication].
+ /// System.String.
+ /// restEndpoint - null
+ private string GetHostData(
+ ref string endpoint,
+ ref Dictionary queryString,
+ RequestEndpoint restEndpoint,
+ ref Cookie cookie,
+ ref string protocol,
+ ref int port,
+ ref bool requiresAuthentication
+ )
+ {
+ string host;
+ switch (restEndpoint)
+ {
+ case RequestEndpoint.DEFAULT:
+ host = $@"{_accountName}.{VTEXConstants.PlatformStableDomain}";
+ endpoint = $@"api/{endpoint}";
+ break;
+ case RequestEndpoint.PAYMENTS:
+ host = $@"{_accountName}.{VTEXConstants.PaymentsDomain}";
+ endpoint = $@"api/{endpoint}";
+ break;
+ case RequestEndpoint.LOGISTICS:
+ host = VTEXConstants.LogisticsDomain;
+ endpoint = $@"api/{endpoint}";
+ if (queryString == null)
+ {
+ queryString = new();
+ }
+
+ queryString.Add(@"an", _accountName);
+ break;
+ case RequestEndpoint.API:
+ case RequestEndpoint.MASTER_DATA:
+ host = VTEXConstants.ApiDomain;
+ endpoint = $@"{_accountName}/{endpoint}";
+ break;
+ case RequestEndpoint.BRIDGE:
+ host = $@"{_accountName}.{VTEXConstants.MyVtexDomain}";
+ endpoint = $@"api/{endpoint}";
+ if (!string.IsNullOrWhiteSpace(_authCookie))
+ {
+ cookie = new(VTEXConstants.VtexIdClientAuthCookieName, _authCookie);
+ }
+
+ break;
+ case RequestEndpoint.HEALTH:
+ protocol = @"http";
+ port = 80;
+ host = VTEXConstants.MonitoringDomain;
+ endpoint = @"api/healthcheck/modules";
+ requiresAuthentication = false;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(restEndpoint), restEndpoint, null);
+ }
+
+ return host;
+ }
+
+ #endregion
+ }
+}
From 84d35de7c8e8cb5d502ea1b746796cdb1e01e707 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:09:20 +0000
Subject: [PATCH 003/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 6a8884df7..bbf857171 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -383,6 +383,16 @@ public async Task GetCollectionsAsync(CancellationToken token)
return await ServiceInvokerAsync(HttpRequestMethod.GET, "collections", token);
}
+ ///
+ /// Creates a new collection.
+ ///
+ /// The data representing the new collection to be created.
+ /// A cancellation token to observe while waiting for the task to complete.
+ /// A task that represents the asynchronous operation, containing the response as a string.
+ public async Task CreateCollectionAsync(string data, CancellationToken token)
+ {
+ return await ServiceInvokerAsync(HttpRequestMethod.POST, "collections", token, data: data);
+
///
/// Sets the rest credentials.
///
From e9ebb6b4cfeb76258c2012da3beab3040139b79a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:09:26 +0000
Subject: [PATCH 004/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index bbf857171..a0e9d756d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -383,6 +383,16 @@ public async Task GetCollectionsAsync(CancellationToken token)
return await ServiceInvokerAsync(HttpRequestMethod.GET, "collections", token);
}
+ ///
+ /// Updates an existing collection.
+ ///
+ /// The identifier of the collection to be updated.
+ /// The data representing the updated collection.
+ /// A cancellation token to observe while waiting for the task to complete.
+ /// A task that represents the asynchronous operation, containing the response as a string.
+ public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
+ {
+
///
/// Creates a new collection.
///
From d7243f4e9d9ad9900780463abb17fc2b6ca7a89e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:09:32 +0000
Subject: [PATCH 005/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index a0e9d756d..a22f7978d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -393,6 +393,16 @@ public async Task GetCollectionsAsync(CancellationToken token)
public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
{
+ ///
+ /// Deletes a collection.
+ ///
+ /// The identifier of the collection to be deleted.
+ /// A cancellation token to observe while waiting for the task to complete.
+ /// A task that represents the asynchronous operation, containing the response as a string.
+ public async Task DeleteCollectionAsync(int id, CancellationToken token)
+ {
+ return await ServiceInvokerAsync(HttpRequestMethod.DELETE, $"collections/{id}", token);
+
///
/// Creates a new collection.
///
From 861c7a55d50ead5d657bd184c0b24dd2efb240a2 Mon Sep 17 00:00:00 2001
From: codefactor-io
Date: Mon, 4 Nov 2024 00:09:49 +0000
Subject: [PATCH 006/102] [CodeFactor] Apply fixes
---
Src/VTEX/VTEXWrapper.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index a22f7978d..8911e1d7b 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -1,4 +1,4 @@
-// ***********************************************************************
+// ***********************************************************************
// Assembly : VTEX
// Author : Guilherme Branco Stracini
// Created : 01-15-2023
@@ -392,7 +392,6 @@ public async Task GetCollectionsAsync(CancellationToken token)
/// A task that represents the asynchronous operation, containing the response as a string.
public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
{
-
///
/// Deletes a collection.
///
From 607b96a4f1e476b91445e1fef3edf8cd6e84aaa1 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:10:12 +0000
Subject: [PATCH 007/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8911e1d7b..caaf6fbf9 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -392,6 +392,8 @@ public async Task GetCollectionsAsync(CancellationToken token)
/// A task that represents the asynchronous operation, containing the response as a string.
public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
{
+ return await ServiceInvokerAsync(HttpRequestMethod.PUT, $"collections/{id}", token, data: data);
+}
///
/// Deletes a collection.
///
From 5daa9302956e092800326f91e0769f8076a272e6 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:10:53 +0000
Subject: [PATCH 008/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index caaf6fbf9..2b061e0ef 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -404,6 +404,7 @@ public async Task DeleteCollectionAsync(int id, CancellationToken token)
{
return await ServiceInvokerAsync(HttpRequestMethod.DELETE, $"collections/{id}", token);
+ }
///
/// Creates a new collection.
///
From c609c69d6d995961c086dc8315dcbf597b1fbc1f Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:10:55 +0000
Subject: [PATCH 009/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 5ed8250d0..bb76f966c 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,4 +1604,3 @@ public void Dispose()
#endregion
}
-}
From efd196056b37fd7ebd9cb8d7bf81f5209fc011dc Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:10:57 +0000
Subject: [PATCH 010/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 2b061e0ef..20a7716f6 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -568,6 +568,7 @@ ref bool requiresAuthentication
return host;
}
+ }
#endregion
}
}
From ad78db9bcf135b11a64c8b1909cf1bcecd25ab4b Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:10:59 +0000
Subject: [PATCH 011/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index bb76f966c..5ed8250d0 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,3 +1604,4 @@ public void Dispose()
#endregion
}
+}
From dab2022c521d9ed90cb85476e3765664d17baca7 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:03 +0000
Subject: [PATCH 012/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 20a7716f6..fdee267b7 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -415,6 +415,7 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
{
return await ServiceInvokerAsync(HttpRequestMethod.POST, "collections", token, data: data);
+ }
///
/// Sets the rest credentials.
///
From 5a0bc93789e41f230be1470b42337cf0ccba174a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:06 +0000
Subject: [PATCH 013/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 5ed8250d0..6a469ec6e 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,4 +1604,5 @@ public void Dispose()
#endregion
}
+ }
}
From c25d1425ffab07f6d7a2ca518fb4c5e6306a0c34 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:08 +0000
Subject: [PATCH 014/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index fdee267b7..eb4673aa7 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -421,7 +421,6 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
///
/// The application key.
/// The application token.
- public void SetRestCredentials(string appKey, string appToken)
{
_appKey = appKey;
_appToken = appToken;
From 9eab0db82a0a86082fef69ba903ed520f6a8507f Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:11 +0000
Subject: [PATCH 015/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index eb4673aa7..516a397cf 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -12,7 +12,6 @@
//
// ***********************************************************************
namespace VTEX
-{
using System;
using System.Collections.Generic;
using System.ComponentModel;
From 719fe374a435abd3ca08f850a07853b05a8aeb79 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:12 +0000
Subject: [PATCH 016/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 516a397cf..0ce0f401d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -429,7 +429,6 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
/// Sets the vtex identifier client authentication cookie.
///
/// The cookie value.
- public void SetVtexIdClientAuthCookie(string cookieValue)
{
_authCookie = cookieValue;
}
From e8c417dbb686659907b046178f1696472357fa50 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:16 +0000
Subject: [PATCH 017/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 0ce0f401d..ca98023f8 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -401,6 +401,7 @@ public async Task UpdateCollectionAsync(int id, string data, Cancellatio
/// A task that represents the asynchronous operation, containing the response as a string.
public async Task DeleteCollectionAsync(int id, CancellationToken token)
{
+ public async Task DeleteCollectionAsync(int id, CancellationToken token)
return await ServiceInvokerAsync(HttpRequestMethod.DELETE, $"collections/{id}", token);
}
From ac54b2da29bdccf1bb9756244c0f05e5870a741a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:20 +0000
Subject: [PATCH 018/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 6a469ec6e..5ed8250d0 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,5 +1604,4 @@ public void Dispose()
#endregion
}
- }
}
From ec2186496a9254dea3e1222a0bd3c535ad62077c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:22 +0000
Subject: [PATCH 019/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index ca98023f8..09ce73cf4 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -508,7 +508,6 @@ ref requiresAuthentication
/// if set to true [requires authentication].
/// System.String.
/// restEndpoint - null
- private string GetHostData(
ref string endpoint,
ref Dictionary queryString,
RequestEndpoint restEndpoint,
From fbb2f220689244d770013194b77bdab352f612aa Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:27 +0000
Subject: [PATCH 020/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 09ce73cf4..b1047a970 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -566,7 +566,5 @@ ref bool requiresAuthentication
return host;
}
- }
#endregion
}
-}
From e01f6c736fbf79d1b1419fecdb91ab16895a521c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:28 +0000
Subject: [PATCH 021/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index b1047a970..037b6fa03 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -452,6 +452,7 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
/// The response from the service is returned as a string, allowing for further processing or
/// parsing as needed by the caller.
///
+ public async Task ServiceInvokerAsync(
public async Task ServiceInvokerAsync(
HttpRequestMethod method,
[Localizable(false)] string endpoint,
From 7a89a800f3e33161147ba3b350076077432f9ed1 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:32 +0000
Subject: [PATCH 022/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 037b6fa03..8eca0c870 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -510,6 +510,7 @@ ref requiresAuthentication
/// System.String.
/// restEndpoint - null
ref string endpoint,
+ ref string endpoint,
ref Dictionary queryString,
RequestEndpoint restEndpoint,
ref Cookie cookie,
From d9c8247d66296ea32b2d1c2b521629b67d9c020b Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:44 +0000
Subject: [PATCH 023/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8eca0c870..5017b687b 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -569,4 +569,5 @@ ref bool requiresAuthentication
}
#endregion
+ #endregion
}
From 07d62ec69115595719a32fdf1e8cee11a864feb7 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:11:51 +0000
Subject: [PATCH 024/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5017b687b..8eca0c870 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -569,5 +569,4 @@ ref bool requiresAuthentication
}
#endregion
- #endregion
}
From 664eb97c89992cff235f40fb3ea06cc07ddca6b7 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:10 +0000
Subject: [PATCH 025/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8eca0c870..78b829bcc 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -421,6 +421,7 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
///
/// The application key.
/// The application token.
+ public void SetRestCredentials(string appKey, string appToken)
{
_appKey = appKey;
_appToken = appToken;
From 0b13149524d71876f7bca70421e3ca9c8268df24 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:11 +0000
Subject: [PATCH 026/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 78b829bcc..612dda5c8 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -570,4 +570,3 @@ ref bool requiresAuthentication
}
#endregion
- }
From a3a9fe60bcb9219753541892f946111a9a24f91d Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:15 +0000
Subject: [PATCH 027/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 612dda5c8..c329540d0 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -431,6 +431,7 @@ public void SetRestCredentials(string appKey, string appToken)
/// Sets the vtex identifier client authentication cookie.
///
/// The cookie value.
+ public void SetVtexIdClientAuthCookie(string cookieValue)
{
_authCookie = cookieValue;
}
From 682648dd72448302fd5176d760e8f4064f824d3e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:16 +0000
Subject: [PATCH 028/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 5ed8250d0..bb76f966c 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,4 +1604,3 @@ public void Dispose()
#endregion
}
-}
From 519477c84787c8fa3402ba8b549dd02358e444ea Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:20 +0000
Subject: [PATCH 029/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index c329540d0..f963e7e6c 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -454,7 +454,6 @@ public void SetVtexIdClientAuthCookie(string cookieValue)
/// The response from the service is returned as a string, allowing for further processing or
/// parsing as needed by the caller.
///
- public async Task ServiceInvokerAsync(
public async Task ServiceInvokerAsync(
HttpRequestMethod method,
[Localizable(false)] string endpoint,
From 4cf747e2e479447d783171afdac14f7f3e14f501 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:24 +0000
Subject: [PATCH 030/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index f963e7e6c..c5899f721 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -509,7 +509,6 @@ ref requiresAuthentication
/// The port.
/// if set to true [requires authentication].
/// System.String.
- /// restEndpoint - null
ref string endpoint,
ref string endpoint,
ref Dictionary queryString,
From 6f58fb80fdd3d8075ebd2af655795044c88e0c5a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:29 +0000
Subject: [PATCH 031/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index bb76f966c..5ed8250d0 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1604,3 +1604,4 @@ public void Dispose()
#endregion
}
+}
From c98e3c9151acad68a98daad5e9b7445b8fc2c44b Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:41 +0000
Subject: [PATCH 032/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 5ed8250d0..889f94287 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1603,5 +1603,4 @@ public void Dispose()
}
#endregion
- }
}
From d86f418b19596fd5ec22e6540624f65c16aa5e19 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:12:54 +0000
Subject: [PATCH 033/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index c5899f721..7819e2b30 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -10,6 +10,7 @@
// © 2020 Guilherme Branco Stracini. All rights reserved.
//
//
+namespace VTEX
// ***********************************************************************
namespace VTEX
using System;
From 04d3750a969b5cae3f2a89713537814f5166c86c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:00 +0000
Subject: [PATCH 034/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 7819e2b30..1690423b8 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -11,6 +11,7 @@
//
//
namespace VTEX
+{
// ***********************************************************************
namespace VTEX
using System;
From 236d4ce864fc4cb0569828572a89d4de9d2adbd2 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:06 +0000
Subject: [PATCH 035/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 1690423b8..2b7abbb13 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -23,6 +23,7 @@ namespace VTEX
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
+ public class VTEXWrapper
using System.Threading.Tasks;
using CrispyWaffle.Extensions;
using CrispyWaffle.Log;
From da6faafdf109b305e9fdd819e9ea61ca731c843c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:19 +0000
Subject: [PATCH 036/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 2b7abbb13..f26571b84 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -38,6 +38,7 @@ public class VTEXWrapper
///
// TODO change public to internal after remove from Integração Service
public sealed class VTEXWrapper : IDisposable
+
{
#region Private fields
From 44d0d611b57a1d74ccadd96593f69cc01c5e8e65 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:25 +0000
Subject: [PATCH 037/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index f26571b84..fc3161d05 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -53,6 +53,7 @@ public sealed class VTEXWrapper : IDisposable
private string _appToken;
///
+
/// The authentication cookie
///
private string _authCookie;
From 29d3dd9bb2b1cb496e745cbb2236b4e0e22319d9 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:31 +0000
Subject: [PATCH 038/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index fc3161d05..bfb4e23ef 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -63,6 +63,7 @@ public sealed class VTEXWrapper : IDisposable
///
private readonly string _accountName;
+
///
/// The internal user agent
///
From 72133d2220ed5afd2ee63aaf57e6c1d8192b71e1 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:37 +0000
Subject: [PATCH 039/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index bfb4e23ef..e9d7bc103 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -73,6 +73,7 @@ public sealed class VTEXWrapper : IDisposable
/// Gets the internal user agent.
///
/// The internal user agent.
+
private static string InternalUserAgent
{
get
From 421bf434c6185337544468ae475b9ba26fe7a9b6 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:47 +0000
Subject: [PATCH 040/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index e9d7bc103..3b6414428 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -83,6 +83,7 @@ private static string InternalUserAgent
return _internalUserAgent;
}
+
var assembly = System
.Reflection.Assembly.GetAssembly(typeof(VTEXWrapper))
.GetName();
From 5344ebe8e54d535787a34f8d1caa2771c1d0902f Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:53 +0000
Subject: [PATCH 041/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 3b6414428..23c2822a2 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -93,6 +93,7 @@ private static string InternalUserAgent
}
///
+
/// The request mediator
///
private readonly ManualResetEvent _requestMediator = new ManualResetEvent(false);
From 267c75b10464fe8499749a984903862f57426654 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:13:59 +0000
Subject: [PATCH 042/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 23c2822a2..37d58268f 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -103,6 +103,7 @@ private static string InternalUserAgent
#region ~Ctor
///
+
/// Initializes a new instance of the class.
///
/// The account name.
From 3317e5548e86eb7ade034947efcbb18d19a232fe Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:05 +0000
Subject: [PATCH 043/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 37d58268f..306d60334 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -113,6 +113,7 @@ public VTEXWrapper(string accountName)
_requestMediator.Set();
}
+
#endregion
#region Implementation of IDisposable
From 2d63fa1908d3cf30902be7ab8c90c7bf6873189e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:12 +0000
Subject: [PATCH 044/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 306d60334..e48c0a29e 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -123,6 +123,7 @@ public VTEXWrapper(string accountName)
///
public void Dispose()
{
+
_appKey = null;
_appToken = null;
_requestMediator.Dispose();
From 4bb23732c5ed53e04d732f95ec87ea266f578549 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:19 +0000
Subject: [PATCH 045/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index e48c0a29e..989b609b0 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -129,6 +129,7 @@ public void Dispose()
_requestMediator.Dispose();
}
+
#endregion
#region Private methods
From c80b62050923bfc350f5f2bc1a6238a29be4d314 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:28 +0000
Subject: [PATCH 046/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 989b609b0..77b7cdaf8 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -143,6 +143,7 @@ public void Dispose()
/// The data.
/// The URI builder.
/// The cookie.
+
/// if set to true [requires authentication].
/// if set to true [is retry].
/// System.String.
From bdbdd7c4a9fc33c02a4622bc54240297fb2e9387 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:35 +0000
Subject: [PATCH 047/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 77b7cdaf8..d05377ee9 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -153,6 +153,7 @@ private async Task ServiceInvokerInternal(
CancellationToken token,
string data,
UriBuilder uriBuilder,
+
Cookie cookie,
bool requiresAuthentication,
bool isRetry = false
From c6f58b48564346619f2fcf7f14e458f4fa9a17fb Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:42 +0000
Subject: [PATCH 048/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index d05377ee9..3cca80190 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -163,6 +163,7 @@ private async Task ServiceInvokerInternal(
string result = null;
Exception exr;
try
+
{
_requestMediator.WaitOne();
From 34ccb7a069ab37572d0cee44416dd9016f025a03 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:49 +0000
Subject: [PATCH 049/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 3cca80190..dbee55c1d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -173,6 +173,7 @@ private async Task ServiceInvokerInternal(
endpoint
);
+
LogConsumer.Debug(uriBuilder.ToString());
var cookieContainer = new CookieContainer();
From d9f4bf14c6f87cc459468d35d6a65690b39150ad Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:14:55 +0000
Subject: [PATCH 050/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index dbee55c1d..515a38689 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -184,6 +184,7 @@ private async Task ServiceInvokerInternal(
ConfigureClient(client, requiresAuthentication);
+
if (cookie != null)
{
cookieContainer.Add(uriBuilder.Uri, cookie);
From 5f478d6047b842ef12ad7c8d5b656a78bc0d1ed4 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:03 +0000
Subject: [PATCH 051/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 515a38689..170be6208 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -193,6 +193,7 @@ private async Task ServiceInvokerInternal(
response = await RequestInternalAsync(method, token, data, client, uriBuilder)
.ConfigureAwait(false);
+
token.ThrowIfCancellationRequested();
result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
From 707d0bbc786215a69bdb145e6ab8b0bbe7b08c4f Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:10 +0000
Subject: [PATCH 052/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 170be6208..4dde11430 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -203,6 +203,7 @@ private async Task ServiceInvokerInternal(
return result;
}
catch (AggregateException e)
+
{
var ex = e.InnerExceptions.FirstOrDefault() ?? e.InnerException ?? e;
From 5763997db03c455a77783882c7e9baafb0ff2448 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:18 +0000
Subject: [PATCH 053/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 4dde11430..5debaeef0 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -213,6 +213,7 @@ private async Task ServiceInvokerInternal(
{
throw exr;
}
+
}
catch (Exception e)
{
From df8111367b4e5ab1b374c9225eb638fc733845ec Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:25 +0000
Subject: [PATCH 054/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5debaeef0..5b0610269 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -223,6 +223,7 @@ private async Task ServiceInvokerInternal(
{
throw exr;
}
+
}
return await ServiceInvokerInternal(
From 5b5793df836164b9852319f54b0d0fa9dbc125e8 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:32 +0000
Subject: [PATCH 055/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5b0610269..a723640bb 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -233,6 +233,7 @@ private async Task ServiceInvokerInternal(
data,
uriBuilder,
cookie,
+
requiresAuthentication,
true
)
From 123ffc9aa91744677252b3344f3d9dbded6bb07e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:40 +0000
Subject: [PATCH 056/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index a723640bb..3ae13cad6 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -243,6 +243,7 @@ private async Task ServiceInvokerInternal(
///
/// Handles the exception.
///
+
/// The exception.
/// The response.
/// The URI.
From 000975812bb737f382d96f9e7ee021b6d84169f6 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:47 +0000
Subject: [PATCH 057/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 3ae13cad6..6a1db61da 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -253,6 +253,7 @@ private async Task ServiceInvokerInternal(
/// Exception.
///
private Exception HandleException(
+
Exception exception,
HttpResponseMessage response,
Uri uri,
From 709ffcbf9907a0cfd393cbbc28b81feb55f20381 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:15:54 +0000
Subject: [PATCH 058/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 6a1db61da..c28c06510 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -263,6 +263,7 @@ string result
)
{
var statusCode = 0;
+
if (response != null)
{
statusCode = (int)response.StatusCode;
From 0dfd9601a662f3b554538a83facef523912c14e0 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:04 +0000
Subject: [PATCH 059/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index c28c06510..5cdf28666 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -273,6 +273,7 @@ string result
uri,
method.ToString(),
data,
+
result,
statusCode,
exception
From 1fc992e926d5d6e7be8b21c89a25c6ea407eb05a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:12 +0000
Subject: [PATCH 060/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5cdf28666..bcfecad29 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -283,6 +283,7 @@ string result
_requestMediator.Reset();
LogConsumer.Warning(
"HTTP {2} status code on method {0} - uri {1}",
+
method.ToString(),
uri,
statusCode
From 19ecd4c2b04876bf9d9556bdf0551c74d8435685 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:20 +0000
Subject: [PATCH 061/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index bcfecad29..235686c91 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -293,6 +293,7 @@ string result
return ex;
}
if (statusCode != 0 && statusCode != 408 && statusCode != 500 && statusCode != 502)
+
{
throw ex;
}
From 82bde3828a3edc2fee4b68539738529004047260 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:28 +0000
Subject: [PATCH 062/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 235686c91..b269a5cbc 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -303,6 +303,7 @@ string result
$"VTEX_handle_exception_retrying_{method.ToString()}_request"
);
return ex;
+
}
///
From 0f5c464479137c3941ca59f6d21627fb96e0b8bd Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:35 +0000
Subject: [PATCH 063/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index b269a5cbc..9d2f63225 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -313,6 +313,7 @@ string result
/// if set to true [requires authentication].
private void ConfigureClient(HttpClient client, bool requiresAuthentication)
{
+
client.DefaultRequestHeaders.ExpectContinue = false;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
From 8246b9e0e9f6505494c62d9fa449ee384fa7835b Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:43 +0000
Subject: [PATCH 064/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 9d2f63225..2d3bc6a3e 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -323,6 +323,7 @@ private void ConfigureClient(HttpClient client, bool requiresAuthentication)
@"User-Agent",
$@"guiBranco-VTEX-SDK-dotnet {InternalUserAgent} +https://github.com/guibranco/VTEX-SDK-dotnet"
);
+
if (!requiresAuthentication)
{
return;
From 104f3aaf76e3a11add9547ec9cce97ffb60e18c0 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:50 +0000
Subject: [PATCH 065/102] Update .github/workflows/dotnet-build-and-test.yml
---
.github/workflows/dotnet-build-and-test.yml | 29 +++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 .github/workflows/dotnet-build-and-test.yml
diff --git a/.github/workflows/dotnet-build-and-test.yml b/.github/workflows/dotnet-build-and-test.yml
new file mode 100644
index 000000000..ad34a345a
--- /dev/null
+++ b/.github/workflows/dotnet-build-and-test.yml
@@ -0,0 +1,29 @@
+name: .NET Build and Test
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: '6.0.x'
+
+ - name: Restore dependencies
+ run: dotnet restore
+
+ - name: Build
+ run: dotnet build --no-restore --configuration Release
+
+ - name: Test
+ run: dotnet test --no-build --verbosity normal --configuration Release
From a1e72bccc35cd157cabb30fbd5a080ead8f7e5d2 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:51 +0000
Subject: [PATCH 066/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 2d3bc6a3e..83fad44d1 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -333,6 +333,7 @@ private void ConfigureClient(HttpClient client, bool requiresAuthentication)
client.DefaultRequestHeaders.Add(@"X-VTEX-API-AppToken", _appToken);
}
+
///
/// Sends an HTTP request asynchronously using the specified method and returns the response.
///
From b19f9aa40bfa0b6f9bdac9e97aac9e7a8176c808 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:16:59 +0000
Subject: [PATCH 067/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 83fad44d1..758c0b79a 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -343,6 +343,7 @@ private void ConfigureClient(HttpClient client, bool requiresAuthentication)
/// The HttpClient instance used to send the request.
/// The UriBuilder that constructs the URI for the request.
/// A task that represents the asynchronous operation, containing the HttpResponseMessage received from the server.
+
///
/// This method handles different HTTP methods such as GET, POST, PUT, DELETE, and PATCH.
/// It constructs the appropriate request based on the provided method and sends it using the specified HttpClient.
From 4d4aa1734c893cab1cef86d7e5dc2f047402a85e Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:07 +0000
Subject: [PATCH 068/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 758c0b79a..5dfc96863 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -353,6 +353,7 @@ private void ConfigureClient(HttpClient client, bool requiresAuthentication)
///
/// Thrown when an unsupported HTTP method is provided.
private static async Task RequestInternalAsync(
+
HttpRequestMethod method,
CancellationToken token,
string data,
From dec291e26cf23e2ce9aaf9621b5602e064da4676 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:16 +0000
Subject: [PATCH 069/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5dfc96863..2927a5c7d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -363,6 +363,7 @@ UriBuilder uriBuilder
{
HttpResponseMessage response;
StringContent content = null;
+
if (!string.IsNullOrWhiteSpace(data))
{
content = new StringContent(data, Encoding.UTF8, @"application/json");
From 2408d96046948128b3f1d6747d8c1d9a165c6ac6 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:24 +0000
Subject: [PATCH 070/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 2927a5c7d..393bdcea9 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -373,6 +373,7 @@ UriBuilder uriBuilder
{
case HttpRequestMethod.DELETE:
response = await client
+
.DeleteAsync(uriBuilder.Uri, token)
.ConfigureAwait(false);
break;
From 5937cd442383847200f6fc88aec0dd28cb148c1d Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:33 +0000
Subject: [PATCH 071/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 393bdcea9..7c30ede48 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -383,6 +383,7 @@ UriBuilder uriBuilder
case HttpRequestMethod.POST:
response = await client
.PostAsync(uriBuilder.Uri, content, token)
+
.ConfigureAwait(false);
break;
case HttpRequestMethod.PUT:
From cafb14804a93b395b1d0c1f7f938cd59bc7deba1 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:42 +0000
Subject: [PATCH 072/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 7c30ede48..3d724d848 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -393,6 +393,7 @@ UriBuilder uriBuilder
break;
case HttpRequestMethod.PATCH:
var request = new HttpRequestMessage(new HttpMethod(@"PATCH"), uriBuilder.Uri)
+
{
Content = content,
};
From 8ed7945c433364c5502e1fa3f71d5f4c3c280857 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:50 +0000
Subject: [PATCH 073/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 3d724d848..795f748a2 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -404,6 +404,7 @@ UriBuilder uriBuilder
throw new ArgumentOutOfRangeException(nameof(method), method, null);
}
+
return response;
}
From 7e74845b1a661d450fefacb0ccca269f30da76d5 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:17:59 +0000
Subject: [PATCH 074/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 795f748a2..40162ee73 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -413,6 +413,7 @@ UriBuilder uriBuilder
#region Public methods
///
+
/// Retrieves a list of all collections.
///
/// A cancellation token to observe while waiting for the task to complete.
From a6690978681d716e64fe5ba4f0dc7f55c5c2b38f Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:07 +0000
Subject: [PATCH 075/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 40162ee73..415892277 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -423,6 +423,7 @@ public async Task GetCollectionsAsync(CancellationToken token)
return await ServiceInvokerAsync(HttpRequestMethod.GET, "collections", token);
}
+
///
/// Updates an existing collection.
///
From c9fc8a8f7771315976feaa4d24e48c67353561ce Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:16 +0000
Subject: [PATCH 076/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 415892277..cb0649f90 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -433,6 +433,7 @@ public async Task GetCollectionsAsync(CancellationToken token)
/// A task that represents the asynchronous operation, containing the response as a string.
public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
{
+
return await ServiceInvokerAsync(HttpRequestMethod.PUT, $"collections/{id}", token, data: data);
}
///
From 02afe1b371e3c7c648ef32fc7bf6a413aa77deb9 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:25 +0000
Subject: [PATCH 077/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index cb0649f90..6e2e54cf8 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -434,7 +434,7 @@ public async Task GetCollectionsAsync(CancellationToken token)
public async Task UpdateCollectionAsync(int id, string data, CancellationToken token)
{
- return await ServiceInvokerAsync(HttpRequestMethod.PUT, $"collections/{id}", token, data: data);
+ return await ServiceInvokerAsync(HttpRequestMethod.PUT, $"collections/{id}", token, data: data);
}
///
/// Deletes a collection.
From 5cc9d7add4e42dbe427e70332198d9837dc4067c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:33 +0000
Subject: [PATCH 078/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 6e2e54cf8..e2e69e87a 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -13,7 +13,6 @@
namespace VTEX
{
// ***********************************************************************
-namespace VTEX
using System;
using System.Collections.Generic;
using System.ComponentModel;
From 1887aefc6c66a1c508c60efe7dc6316f0bca3386 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:34 +0000
Subject: [PATCH 079/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index e2e69e87a..cfac9ede7 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -443,7 +443,6 @@ public async Task UpdateCollectionAsync(int id, string data, Cancellatio
/// A task that represents the asynchronous operation, containing the response as a string.
public async Task DeleteCollectionAsync(int id, CancellationToken token)
{
- public async Task DeleteCollectionAsync(int id, CancellationToken token)
return await ServiceInvokerAsync(HttpRequestMethod.DELETE, $"collections/{id}", token);
}
From 7a7532ff7bbbfe18ac7c9b6083690a9e16fe6edc Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:42 +0000
Subject: [PATCH 080/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index cfac9ede7..b0ec61ca9 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -22,7 +22,7 @@ namespace VTEX
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
- public class VTEXWrapper
+ using System.Threading.Tasks;
using System.Threading.Tasks;
using CrispyWaffle.Extensions;
using CrispyWaffle.Log;
From fe45782802a52ef429aa8cb00721ce6e5f75e228 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:43 +0000
Subject: [PATCH 081/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index b0ec61ca9..de4ac7371 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -457,6 +457,7 @@ public async Task CreateCollectionAsync(string data, CancellationToken t
return await ServiceInvokerAsync(HttpRequestMethod.POST, "collections", token, data: data);
}
+
///
/// Sets the rest credentials.
///
From c1cd186befd40858eb6ff3b022502ed3d675c02c Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:50 +0000
Subject: [PATCH 082/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index de4ac7371..8d893dc5b 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -435,7 +435,6 @@ public async Task UpdateCollectionAsync(int id, string data, Cancellatio
return await ServiceInvokerAsync(HttpRequestMethod.PUT, $"collections/{id}", token, data: data);
}
- ///
/// Deletes a collection.
///
/// The identifier of the collection to be deleted.
From 085d408eeca04065b6ff0d1942697f8c1593932a Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:57 +0000
Subject: [PATCH 083/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8d893dc5b..c5e989b1d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -468,6 +468,7 @@ public void SetRestCredentials(string appKey, string appToken)
_appToken = appToken;
}
+
///
/// Sets the vtex identifier client authentication cookie.
///
From 9560231dbc3b18729a29400998af8206c49b3407 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:18:58 +0000
Subject: [PATCH 084/102] Update Src/VTEX/VTEXContext.cs
---
Src/VTEX/VTEXContext.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Src/VTEX/VTEXContext.cs b/Src/VTEX/VTEXContext.cs
index 889f94287..5607d773a 100644
--- a/Src/VTEX/VTEXContext.cs
+++ b/Src/VTEX/VTEXContext.cs
@@ -1603,4 +1603,3 @@ public void Dispose()
}
#endregion
-}
From bb482da7540f68601b933bfc4345dcfb49d8c9e7 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:06 +0000
Subject: [PATCH 085/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index c5e989b1d..971bf5418 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -478,6 +478,7 @@ public void SetVtexIdClientAuthCookie(string cookieValue)
_authCookie = cookieValue;
}
+
///
/// Asynchronously invokes a service endpoint with the specified HTTP method and parameters.
///
From d42d25ecb19c3cdc1282f47cd13588316e223e18 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:15 +0000
Subject: [PATCH 086/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 971bf5418..fa19ec777 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -493,6 +493,7 @@ public void SetVtexIdClientAuthCookie(string cookieValue)
/// This method constructs a URI using the provided endpoint and query string parameters,
/// and then invokes the service asynchronously. It handles authentication and cookie management
/// as needed based on the service requirements. The method is designed to work with various
+
/// HTTP methods and can send data in the request body if specified.
/// The response from the service is returned as a string, allowing for further processing or
/// parsing as needed by the caller.
From 7e21472518923789ce3a5c9bbdfd0221bfd024cf Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:24 +0000
Subject: [PATCH 087/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index fa19ec777..beb5151ba 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -503,6 +503,7 @@ public async Task ServiceInvokerAsync(
[Localizable(false)] string endpoint,
CancellationToken token,
Dictionary queryString = null,
+
string data = null,
RequestEndpoint restEndpoint = RequestEndpoint.DEFAULT
)
From 7f0380fb58938154523632f1c126ba7f9a91560d Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:33 +0000
Subject: [PATCH 088/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index beb5151ba..46a305e33 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -513,6 +513,7 @@ public async Task ServiceInvokerAsync(
var protocol = @"https";
var port = 443;
var host = GetHostData(
+
ref endpoint,
ref queryString,
restEndpoint,
From c20734fc4fc152a164acf9ee577fe439d798a8b1 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:46 +0000
Subject: [PATCH 089/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 46a305e33..47f020932 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -523,6 +523,7 @@ public async Task ServiceInvokerAsync(
ref requiresAuthentication
);
var query = string.Empty;
+
if (queryString is { Count: > 0 })
{
query = new QueryStringBuilder().AddRange(queryString).ToString();
From 11dc7a49fcb9d8c43aa5beb7955301a6936aeec5 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:56 +0000
Subject: [PATCH 090/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 47f020932..5fda09c4f 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -533,6 +533,7 @@ ref requiresAuthentication
{
Query = query.Replace(@"?", string.Empty),
};
+
return await ServiceInvokerInternal(
method,
endpoint,
From 35b9812fe317a91fc000e1cac4126f152fe19e57 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:19:57 +0000
Subject: [PATCH 091/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 5fda09c4f..1f34016ea 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -11,25 +11,18 @@
//
//
namespace VTEX
-{
-// ***********************************************************************
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Threading.Tasks;
- using CrispyWaffle.Extensions;
- using CrispyWaffle.Log;
- using CrispyWaffle.Telemetry;
- using CrispyWaffle.Utilities;
- using Enums;
- using GoodPractices;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using CrispyWaffle.Extensions;
+using CrispyWaffle.Log;
///
/// Class Wrapper. This class cannot be inherited.
@@ -86,7 +79,7 @@ private static string InternalUserAgent
var assembly = System
.Reflection.Assembly.GetAssembly(typeof(VTEXWrapper))
.GetName();
- _internalUserAgent = $@"{assembly.Name}/{assembly.Version}";
+ _internalUserAgent = $"{assembly.Name}/{assembly.Version}";
return _internalUserAgent;
}
}
@@ -557,7 +550,7 @@ ref requiresAuthentication
/// The port.
/// if set to true [requires authentication].
/// System.String.
- ref string endpoint,
+ private string GetHostData(
ref string endpoint,
ref Dictionary queryString,
RequestEndpoint restEndpoint,
From b3a150a9a9275d4afa614d0b4a1653d4d8aa2d02 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:07 +0000
Subject: [PATCH 092/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 1f34016ea..8dd65de5d 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -539,6 +539,7 @@ ref requiresAuthentication
.ConfigureAwait(false);
}
+
///
/// Gets the host data.
///
From 91173ae11144926ceafa914b563bf46c59ed9702 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:18 +0000
Subject: [PATCH 093/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8dd65de5d..986673306 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -553,6 +553,7 @@ ref requiresAuthentication
/// System.String.
private string GetHostData(
ref string endpoint,
+
ref Dictionary queryString,
RequestEndpoint restEndpoint,
ref Cookie cookie,
From 2f9d91c6b4e9e285e851627de87d7cc8f91d75db Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:20 +0000
Subject: [PATCH 094/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 986673306..d601bce13 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -10,14 +10,14 @@
// © 2020 Guilherme Branco Stracini. All rights reserved.
//
//
-namespace VTEX
+using System.Net.Http.Headers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Http;
-using System.Net.Http.Headers;
+namespace VTEX
using System.Text;
using System.Threading;
using System.Threading.Tasks;
From 1dc8d177253d4afd32ba94e07b0427e8afb58e50 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:28 +0000
Subject: [PATCH 095/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index d601bce13..8a2af60fd 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -563,6 +563,7 @@ ref bool requiresAuthentication
)
{
string host;
+
switch (restEndpoint)
{
case RequestEndpoint.DEFAULT:
From 53e8f5e8a3179c4cc5c80144671580b7f0523756 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:38 +0000
Subject: [PATCH 096/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 8a2af60fd..67ff1993c 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -573,6 +573,7 @@ ref bool requiresAuthentication
case RequestEndpoint.PAYMENTS:
host = $@"{_accountName}.{VTEXConstants.PaymentsDomain}";
endpoint = $@"api/{endpoint}";
+
break;
case RequestEndpoint.LOGISTICS:
host = VTEXConstants.LogisticsDomain;
From 1ab041554b0ddd15e5d478a6620f2c84d08af353 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:42 +0000
Subject: [PATCH 097/102] Update Src/VTEX/VTEXContext.cs
From f4a68c2e364b40614bdceaa95ff05e8dea09dd2b Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:20:49 +0000
Subject: [PATCH 098/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 67ff1993c..d8bab718e 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -583,6 +583,7 @@ ref bool requiresAuthentication
queryString = new();
}
+
queryString.Add(@"an", _accountName);
break;
case RequestEndpoint.API:
From ce6d48b82245895cfd550624409912b00eeba554 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:21:00 +0000
Subject: [PATCH 099/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index d8bab718e..d95778d18 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -593,6 +593,7 @@ ref bool requiresAuthentication
break;
case RequestEndpoint.BRIDGE:
host = $@"{_accountName}.{VTEXConstants.MyVtexDomain}";
+
endpoint = $@"api/{endpoint}";
if (!string.IsNullOrWhiteSpace(_authCookie))
{
From ef677ca175d0120b3c7d94fb160f88f19bdc8845 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:21:10 +0000
Subject: [PATCH 100/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index d95778d18..d527f8311 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -603,6 +603,7 @@ ref bool requiresAuthentication
break;
case RequestEndpoint.HEALTH:
protocol = @"http";
+
port = 80;
host = VTEXConstants.MonitoringDomain;
endpoint = @"api/healthcheck/modules";
From fcef5e811f60505da353af1e51b8d9cf7e234d68 Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:21:20 +0000
Subject: [PATCH 101/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index d527f8311..064f9a81e 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -613,6 +613,7 @@ ref bool requiresAuthentication
throw new ArgumentOutOfRangeException(nameof(restEndpoint), restEndpoint, null);
}
+
return host;
}
From 01666c7decb631d1f56dfed7165c748498d0d3cd Mon Sep 17 00:00:00 2001
From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com>
Date: Mon, 4 Nov 2024 00:21:35 +0000
Subject: [PATCH 102/102] Update Src/VTEX/VTEXWrapper.cs
---
Src/VTEX/VTEXWrapper.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/VTEX/VTEXWrapper.cs b/Src/VTEX/VTEXWrapper.cs
index 064f9a81e..10520a1b3 100644
--- a/Src/VTEX/VTEXWrapper.cs
+++ b/Src/VTEX/VTEXWrapper.cs
@@ -618,3 +618,4 @@ ref bool requiresAuthentication
}
#endregion
+