public bool RequestAccess(int localId, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString, methodParameters: localId.ToString())); var requestAccess = AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var result = this._client.RequestAccess(this._credentials, localId); this.CheckCaSuccess(result); return(result.ResultData); }); ChannelAdvisorLogger.LogTraceEnd(this.CreateMethodCallInfo(mark: mark, methodResult: requestAccess.ToJson(), additionalInfo: this.AdditionalLogInfoString, methodParameters: localId.ToString())); return(requestAccess); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfoString), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void AssignLabelListToItemList(string[] labels, bool createLabelIfNotExist, IEnumerable <string> skus, string reason, Mark mark = null) { Condition.Requires(labels, "labels").IsShorterOrEqual(3, "Only up to 3 labels allowed.").IsNotNull(); if (mark.IsBlank()) { mark = Mark.CreateNew(); } var parameters = new { labels, createLabelIfNotExist, skus, reason }; try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); var skusByPages = ToChunks(skus, 500); foreach (var s in skusByPages) { AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson())); var resultOfBoolean = this._client.AssignLabelListToInventoryItemList(this._credentials, this.AccountId, labels, createLabelIfNotExist, s.ToArray(), reason); CheckCaSuccess(resultOfBoolean); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : s.ToJson())); }); } ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void DeleteItem(string sku, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: sku)); AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : sku)); var resultOfBoolean = this._client.DeleteInventoryItem(this._credentials, this.AccountId, sku); CheckCaSuccess(resultOfBoolean); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : sku)); }); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: sku)); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void UpdateQuantityAndPrices(IEnumerable <InventoryItemQuantityAndPrice> itemQuantityAndPrices, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: itemQuantityAndPrices.ToJson())); var itemQuantityAndPricesByPages = ToChunks(itemQuantityAndPrices, 500); foreach (var itemsPage in itemQuantityAndPricesByPages) { AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson())); var resultOfBoolean = this._client.UpdateInventoryItemQuantityAndPriceList(this._credentials, this.AccountId, itemsPage.ToArray()); CheckCaSuccess(resultOfBoolean); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : itemsPage.ToJson())); }); } ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: itemQuantityAndPrices.ToJson())); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void SynchItem(InventoryItemSubmit item, bool isCreateNew = false, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } var parameters = new { item, isCreateNew }; try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : parameters.ToJson())); if (!isCreateNew && !this.DoesSkuExist(item.Sku, mark)) { return; } var resultOfBoolean = this._client.SynchInventoryItem(this._credentials, this.AccountId, item); CheckCaSuccess(resultOfBoolean); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : parameters.ToJson())); }); ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }
public void SubmitOrderShipmentList(IEnumerable <OrderShipment> orderShipments) { orderShipments.DoWithPages(50, p => AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.SubmitOrderShipmentList(this._credentials, this.AccountId, p.ToArray()); this.CheckCaSuccess(result); })); }
public async Task <OrderShipmentHistoryResponse[]> GetOrderShipmentHistoryListAsync(int[] orderIdList, string[] clientOrderIdentifierList) { return(await AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(async() => { var result = await this._client.GetOrderShipmentHistoryListAsync(this._credentials, this.AccountId, orderIdList, clientOrderIdentifierList).ConfigureAwait(false); this.CheckCaSuccess(result.GetOrderShipmentHistoryListResult); return result.GetOrderShipmentHistoryListResult.ResultData; }).ConfigureAwait(false)); }
public OrderShipmentHistoryResponse[] GetOrderShipmentHistoryList(int[] orderIdList, string[] clientOrderIdentifierList) { return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var result = this._client.GetOrderShipmentHistoryList(this._credentials, this.AccountId, orderIdList, clientOrderIdentifierList); this.CheckCaSuccess(result); return result.ResultData; })); }
public IEnumerable <OrderUpdateResponse> UpdateOrderList(OrderUpdateSubmit[] orderUpdates) { return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var results = this._client.UpdateOrderList(this._credentials, this.AccountId, orderUpdates); this.CheckCaSuccess(results); return results.ResultData; })); }
/// <summary> /// Submits the order. /// </summary> /// <param name="orderSubmit">The order submit.</param> /// <returns>New order CA id.</returns> public int SubmitOrder(OrderSubmit orderSubmit) { return(AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Get(() => { var apiResults = this._client.SubmitOrder(this._credentials, this.AccountId, orderSubmit); this.CheckCaSuccess(apiResults); return apiResults.ResultData; })); }
public void WithdrawListing(IList <string> itemSkus, string withdrawReason) { if (itemSkus == null || itemSkus.Count == 0) { return; } itemSkus.DoWithPages(100, s => AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.WithdrawListings(this._credentials, this.AccountId, s.ToArray(), null, withdrawReason); this.CheckCaSuccess(result); })); }
public void MarkOrderShipped(int orderId, string carrierCode, string classCode, string trackingNumber, DateTime dateShipped) { try { AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.SubmitOrderShipmentList(this._credentials, this.AccountId, CreateShipmentByOrderId(orderId, carrierCode, classCode, trackingNumber, dateShipped)); this.CheckCaSuccess(result); }); } catch (Exception e) { throw new MarkOrderShippedException(orderId.ToString(CultureInfo.InvariantCulture), this.AccountId, carrierCode, classCode, trackingNumber, e); } }
public void MarkOrderShipped(string clientOrderId, PartialShipmentContents partialShipmentContents) { try { AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { var result = this._client.SubmitOrderShipmentList(this._credentials, this.AccountId, CreatePartialShipmentByClientId(clientOrderId, partialShipmentContents)); this.CheckCaSuccess(result); }); } catch (Exception e) { throw new MarkOrderShippedException(clientOrderId, this.AccountId, partialShipmentContents.CarrierCode, partialShipmentContents.ClassCode, partialShipmentContents.TrackingNumber, e); } }
public void SynchItems(IEnumerable <InventoryItemSubmit> items, bool isCreateNew = false, Mark mark = null) { if (mark.IsBlank()) { mark = Mark.CreateNew(); } var parameters = new { items, isCreateNew }; try { ChannelAdvisorLogger.LogStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); if (!isCreateNew) { var existSkus = this.DoSkusExist(items.Select(x => x.Sku), mark).Select(x => x.Sku); items = items.Where(x => existSkus.Contains(x.Sku)); } var itemsByPages = ToChunks(items, 100); foreach (var i in itemsByPages) { AP.CreateSubmit(ExtensionsInternal.CreateMethodCallInfo(this.AdditionalLogInfo)).Do(() => { ChannelAdvisorLogger.LogTraceRetryStarted(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : i.ToJson())); var resultOfBoolean = this._client.SynchInventoryItemList(this._credentials, this.AccountId, i.ToArray()); CheckCaSuccess(resultOfBoolean); ChannelAdvisorLogger.LogTraceRetryEnd(this.CreateMethodCallInfo(mark: mark, methodResult: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : resultOfBoolean.ToJson(), additionalInfo: this.AdditionalLogInfo(), methodParameters: !this.LogDetailsEnum.HasFlag(LogDetailsEnum.LogParametersAndResultForRetry) ? null : i.ToJson())); }); } ChannelAdvisorLogger.LogEnd(this.CreateMethodCallInfo(mark: mark, methodResult: "void", additionalInfo: this.AdditionalLogInfo(), methodParameters: parameters.ToJson())); } catch (Exception exception) { var channelAdvisorException = new ChannelAdvisorException(this.CreateMethodCallInfo(mark: mark, additionalInfo: this.AdditionalLogInfo()), exception); ChannelAdvisorLogger.LogTraceException(channelAdvisorException); throw channelAdvisorException; } }