This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ee5b309
Showing
482 changed files
with
37,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Autosave files | ||
*~ | ||
**/.vs | ||
**/TestResult.xml | ||
# build | ||
[Oo]bj/ | ||
[Bb]in/ | ||
packages/ | ||
TestResults/ | ||
|
||
# globs | ||
Makefile.in | ||
*.DS_Store | ||
.vscode | ||
*.sln.cache | ||
*.suo | ||
*.cache | ||
*.pidb | ||
*.userprefs | ||
*.usertasks | ||
config.log | ||
config.make | ||
config.status | ||
aclocal.m4 | ||
install-sh | ||
autom4te.cache/ | ||
*.user | ||
*.tar.gz | ||
tarballs/ | ||
test-results/ | ||
Thumbs.db | ||
|
||
# Mac bundle stuff | ||
*.dmg | ||
*.app | ||
|
||
# resharper | ||
*_Resharper.* | ||
*.Resharper | ||
|
||
# dotCover | ||
*.dotCover | ||
|
||
#creds | ||
**/credentials.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
tools: | ||
nuget: 4.1.0 | ||
dotnetsdk: 2.0.0 | ||
|
||
flows: | ||
default: | ||
- call: startup | ||
- call: build | ||
- call: unit_tests | ||
- call: integration_tests | ||
startup: | ||
- echo $NUGET_GALLERY | ||
- echo $NUGET_REPO_PUSH_URL | ||
- echo $NUGET_APIKEY | ||
sonar: | ||
- dir(Source): | ||
- | | ||
(name Sonar Build Process) | ||
docker -v | ||
dotnet ./sonar-scanner/SonarScanner.MSBuild.dll begin /d:sonar.verbose=true /d:sonar.host.url=$SONAR_URL /k:WalmartSdkMarketplaceDotNet /n:WalmartSdkMarketplaceDotNet /d:sonar.sources=Walmart.Sdk.Marketplace/ /d:sonar.tests=Walmart.Sdk.Marketplace.IntegrationTests/ /d:sonar.cs.opencover.reportsPaths=coveragereport.xml /d:sonar.cs.xunit.reportsPaths=TestResult.xml /d:sonar.dotnet.excludeGeneratedCode=true | ||
dotnet msbuild /t:Rebuild /p:Configuration=Release Walmart.Sdk.sln | ||
dotnet xunit -xml TestResult.xml Walmart.Sdk.Marketplace.IntegrationTests/Walmart.Sdk.Marketplace.IntegrationTests.csproj | ||
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover Walmart.Sdk.Marketplace.IntegrationTests/Walmart.Sdk.Marketplace.IntegrationTests.csproj | ||
dotnet ./sonar-scanner/SonarScanner.MSBuild.dll end | ||
unit_tests: | ||
- dir(Source/Walmart.Sdk.Base.Tests): | ||
- dotnet restore Walmart.Sdk.Base.Tests.csproj --source $NUGET_GALLERY | ||
- dotnet test -l trx | ||
integration_tests: | ||
- dir(Source/Walmart.Sdk.Marketplace.IntegrationTests): | ||
- dotnet restore Walmart.Sdk.Marketplace.IntegrationTests.csproj --source $NUGET_GALLERY | ||
- dotnet test -l trx | ||
build: | ||
- dir(Source): | ||
- dotnet restore Walmart.Sdk.sln --source $NUGET_GALLERY | ||
- dotnet build Walmart.Sdk.sln --configuration Release --verbosity detailed | ||
publish: | ||
- dir(Source/Walmart.Sdk.Marketplace): | ||
- | | ||
(name Package&Publish for NuGet Package) | ||
dotnet build -c Release Walmart.Sdk.Marketplace.csproj | ||
dotnet pack Walmart.Sdk.Marketplace.csproj /p:NuspecFile=$(pwd)/Walmart.Sdk.Marketplace.nuspec /p:NuspecProperties="config=Release;target=netstandard1.3" /p:NuspecBasePath=$(pwd) -c Release | ||
PACKAGE_FILE=$(find . -name "*.nupkg") | ||
dotnet nuget push $PACKAGE_FILE --api-key $NUGET_APIKEY --source $NUGET_REPO_PUSH_URL | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Version 1.0.0: | ||
* implemented initial version of SDK for Walmart Marketplace API Specification | ||
* added Unit, Integration, E2E Tests | ||
* implemented Sample Console application with functionality equal to Java SDK | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM microsoft/dotnet:2.0-sdk AS build-env | ||
WORKDIR /app | ||
|
||
# copy everything else and build | ||
COPY . ./ | ||
RUN ls -la Source | ||
RUN dotnet build Source/Walmart.Sdk.Marketplace/Walmart.Sdk.Marketplace.csproj | ||
RUN dotnet restore Sample/Sample.Core20.sln | ||
RUN dotnet publish Sample/Sample.Core20.csproj -o ../out | ||
|
||
# build runtime image | ||
FROM microsoft/dotnet:2.0-runtime | ||
WORKDIR /app | ||
COPY --from=build-env /app/out ./ | ||
RUN ls -la /app | ||
ENTRYPOINT ["dotnet", "Walmart.Sdk.Marketplace.Sample.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Documentation in this project is licensed under | ||
|
||
Creative Commons Attribution 4.0 International License. | ||
|
||
Full details available at https://creativecommons.org/licenses/by/4.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Code Examples | ||
|
||
In this folder you can find code examples on how to use SDK. | ||
|
||
## Snippets lits | ||
|
||
* [SDK Initialization](feed_upload.md) | ||
* [Simulation Mode](sdk_init.md) | ||
* [Retry Policy](retry_policy.md) | ||
* [Feed Upload Request](feed_upload.md) | ||
* [Order List Request](order_list.md) | ||
* [Logger Example](logger.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Order List Snippet | ||
|
||
Here is an example of how to get a list of all orders using SDK. | ||
You can check [SDK Initialization]() to see an example on how to configure SDK | ||
|
||
```csharp | ||
string absPath = ... | ||
ApiClient client = ... // check SDK Init snippet | ||
var feedEndpoint = new Walmart.Sdk.Marketplace.V3.Api.feedEndpoint(client); | ||
|
||
using (var feedStream = File.OpenRead(absPath)) | ||
{ | ||
try | ||
{ | ||
var feedAck = await feedEndpoint.UploadFeed(feedStream); | ||
// ... processing result | ||
} | ||
catch (V3.Api.Exception.ApiException apiEx) | ||
{ | ||
// process error from API | ||
// you can see list of possible errors here | ||
// https://developer.walmart.com/#/apicenter/marketPlace/latest#errors | ||
} | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Logger Example Snippet | ||
|
||
This snippet shows example on how to configure log4net logger with SDK | ||
```csharp | ||
class LoggerAdapter: ILoggerAdapter | ||
{ | ||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ApiClient)); | ||
|
||
public void Info(string message) => log.Info(message); | ||
public void Debug(string message) => log.Debug(message); | ||
public void Warning(string message) => log.Warn(message); | ||
public void Error(string message) => log.Error(message); | ||
public void Fatal(string message) => log.Fatal(message); | ||
|
||
public bool IsLevelEnabled(LogLevel level) | ||
{ | ||
switch (level) | ||
{ | ||
case LogLevel.INFO: | ||
return log.IsInfoEnabled; | ||
case LogLevel.DEBUG: | ||
return log.IsDebugEnabled; | ||
case LogLevel.WARNING: | ||
return log.IsWarnEnabled; | ||
case LogLevel.ERROR: | ||
return log.IsErrorEnabled; | ||
case LogLevel.FATAL: | ||
return log.IsFatalEnabled; | ||
default: | ||
return false; | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Order List Snippet | ||
|
||
Here is an example of how to get a list of all orders using SDK. | ||
You can check [SDK Initialization]() to see an example on how to configure SDK | ||
|
||
```csharp | ||
|
||
// (!) this block is using async call | ||
ApiClient client = ... // check SDK Init snippet | ||
var ordersEndpoint = new Walmart.Sdk.Marketplace.V2.Api.OrderEndpoint(client); | ||
|
||
var filter = new OrderFilter(); | ||
filter.CreatedEndDate = DateTime.Now; | ||
filter.CreatedStartDate = new DateTime(DateTime.Now.Year - 2, DateTime.Now.Month, 1); | ||
filter.ToExpectedShipDate = DateTime.Now; | ||
filter.FromExpectedShipDate = new DateTime(DateTime.Now.Year - 2, DateTime.Now.Month, 1); | ||
filter.CustomerOrderId = "<order-id>"; | ||
filter.PurchaseOrderId = "<purchase-id>"; | ||
filter.Status = OrderLineStatusValueType.Shipped; | ||
filter.Limit = 20; | ||
|
||
try | ||
{ | ||
var orderList = await ordersEndpoint.GetAllOrders(filter); | ||
foreach (var order in firstPage.Elements.Orders) | ||
{ | ||
Console.WriteLine("OrderId: {0}", PurchaseOrderId); | ||
} | ||
} | ||
catch (V2.Api.Exception.ApiException apiEx) | ||
{ | ||
// process error from API | ||
// you can see list of possible errors here | ||
// https://developer.walmart.com/#/apicenter/marketPlace/latest#errors | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Retry Policy Snippet | ||
|
||
|
||
```csharp | ||
|
||
ApiClient apiClient = ... // check SDK init snippet for more details | ||
apiClient.RetryPolicy = new CustomRetryPolicy(); | ||
|
||
``` | ||
|
||
Retry Policy class example | ||
```csharp | ||
|
||
public class CustomRetryPolicy: BasePolicy | ||
{ | ||
public override async Task<IResponse> GetResponse(Http.Fetcher.IFetcher fetcher, IRequest request) | ||
{ | ||
for (var i=0; i<10; i++) | ||
{ | ||
// give it a try | ||
if (await ExecuteOnce(fetcher, request)) | ||
return response; | ||
|
||
// give it a break before another retry | ||
await Task.Delay(1000); | ||
} | ||
throw Http.Exception.NoRetriesLeftException.Factory(RetryCount, latestException); | ||
} | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SDK Init Snippet | ||
|
||
This snippet gives you an example of SDK initialization, you need to do this step before you can use any of the available endpoints. | ||
|
||
```csharp | ||
Dictionary<string, string> settings = ...; | ||
|
||
config = new Marketplace.ClientConfig( | ||
settings["ConsumerId"], | ||
settings["PrivateKey"] | ||
); | ||
config.BaseUrl = settings["BaseUrl"]; | ||
config.ChannelType = settings["ChannelType"]; | ||
config.ServiceName = settings["ServiceName"]; | ||
client = new ApiClient(config); | ||
|
||
var orderEndpoint = new Walmart.Sdk.Marketplace.V2.Api.OrderEndpoint(client); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simulation Mode Snippet | ||
|
||
```csharp | ||
string absPathToMockFolder = .... | ||
// in case of simulation you can put fake credentials | ||
// it's going to ignore them | ||
var config = new Marketplace.ClientConfig("test", "test-key"); | ||
var apiClient = new Marketplace.ApiClient(config); | ||
apiClient.SimulationEnabled = true; | ||
|
||
|
||
|
||
// it's also possible to specify your own folder for mock files | ||
// this folder should have _mapping.json file | ||
// which works as a router for all requests | ||
// it maps request to an appropriate file | ||
// by choosing the longest key \ | ||
var fetcher = (LocalFetcher) apiClient.GetHttpHandler().Fetcher; | ||
fetcher.SetCustomMockFolder(absPathToMockFolder); | ||
|
||
|
||
|
||
feedApi = new Marketplace.V3.Api.FeedEndpoint(apiClient); | ||
// all responses now served from local files | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright (c) 2018-present, Walmart Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
Oops, something went wrong.