Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Engt 7316 new goshippo sdk version #84

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,4 @@ __pycache__/

# Editor Config
.editorconfig
ShippoTesting/.env
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: csharp
dist: xenial
mono: none
dotnet: 3.1
install:
- dotnet restore
script:
- dotnet build
- dotnet test ShippoTesting/ShippoTesting.csproj
2 changes: 0 additions & 2 deletions Shippo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.28010.2019
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shippo", "Shippo\Shippo.csproj", "{6816FD58-3FC6-4EFC-95F8-D11E9C1D387F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShippoExample", "ShippoExample\ShippoExample.csproj", "{7712EC9C-2581-49EE-8B61-745843F2CD6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShippoTesting", "ShippoTesting\ShippoTesting.csproj", "{4AF39DE0-2FA9-43D1-9254-CF8546FF22C8}"
EndProject
Global
Expand Down
16 changes: 12 additions & 4 deletions Shippo/APIResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@
using System.Net;
using System.Text;
using System.Web;

using Microsoft.Extensions.Logging;
using Newtonsoft.Json;


namespace Shippo {
public class APIResource {
public static readonly string api_endpoint = "https://api.goshippo.com";
static readonly string user_agent = "Shippo/v1 CSharpBindings/1.0";
public static readonly int RatesReqTimeout = 25;
public static readonly int TransactionReqTimeout = 25;

public readonly ILogger logger;
static readonly Encoding encoding = Encoding.UTF8;
String accessToken;
String apiVersion;

// API Resource Constructor
public APIResource(string inputToken)
public APIResource(ILogger logger, string inputToken)
{
this.logger = logger;
accessToken = inputToken;
TimeoutSeconds = 25;
apiVersion = null;
Expand Down Expand Up @@ -103,7 +105,9 @@ public virtual string DoRequest(string endpoint, string method, string body)
{
string result = null;
WebRequest req = SetupRequest(method, endpoint);
logger.LogInformation($"GoShippo Http request endpoint: {endpoint}, method: {method}");
if (body != null) {
logger.LogInformation($"GoShippo Http request body: {body}");
byte[] bytes = encoding.GetBytes(body.ToString());
req.ContentLength = bytes.Length;
using (Stream st = req.GetRequestStream()) {
Expand All @@ -123,11 +127,15 @@ public virtual string DoRequest(string endpoint, string method, string body)
if (resp != null)
status_code = resp.StatusCode;

logger.LogInformation($"GoShippo Http request statuscode: {status_code}");

if ((int) status_code <= 500)
throw new ShippoException(json_error, wexc);
}
throw;
}
logger.LogInformation($"GoShippo Http request result: {result}");

return result;
}

Expand Down Expand Up @@ -391,7 +399,7 @@ public ShippoCollection<CarrierAccount> AllCarrierAccount(Hashtable parameters)

public ShippoCollection<CarrierAccount> AllCarrierAccount()
{
string ep = String.Format("{0}/carrier_accounts", api_endpoint);
string ep = String.Format("{0}/carrier_accounts/?carrier=usps", api_endpoint);
return DoRequest<ShippoCollection<CarrierAccount>>(ep);
}

Expand Down
4 changes: 2 additions & 2 deletions Shippo/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class Manifest : ShippoId {
[JsonProperty(PropertyName = "provider")]
public object Provider { get; set; }

[JsonProperty(PropertyName = "submission_date")]
public object SubmissionDate { get; set; }
[JsonProperty(PropertyName = "shipment_date")]
public object ShipmentDate { get; set; }

[JsonProperty(PropertyName = "address_from")]
public object AddressFrom { get; set; }
Expand Down
39 changes: 4 additions & 35 deletions Shippo/Shippo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;net40</TargetFrameworks>
<Version>2.1.15</Version>
<Title>Shippo client library</Title>
<Description>.NET library which integrates with Shippo Multi Carrier Shipping API. This library provides access to Shippo (goshippo.com) API capabilities. Including label generation, rating, tracking and more.</Description>
Expand All @@ -12,10 +11,7 @@
<PackageReleaseNotes>Bug fix for extra slash in Shippo API URL</PackageReleaseNotes>
<RepositoryType>Github</RepositoryType>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
<WarningLevel>0</WarningLevel>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -30,37 +26,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.6" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45'">
<DefineConstants>NET45;NETFULL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'">
<WarningLevel>4</WarningLevel>
</PropertyGroup>


<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<ItemGroup>
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions Shippo/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class Transaction : ShippoId {
public object ObjectState { get; set; }

[JsonProperty(PropertyName = "status")]
public object Status { get; set; }
public string Status { get; set; }

[JsonProperty(PropertyName = "object_created")]
public object ObjectCreated { get; set; }

[JsonProperty(PropertyName = "object_updated")]
public object ObjectUPdated { get; set; }
public object ObjectUpdated { get; set; }

[JsonProperty(PropertyName = "object_owner")]
public object ObjectOwner { get; set; }
Expand All @@ -26,16 +26,16 @@ public class Transaction : ShippoId {
public object Rate { get; set; }

[JsonProperty(PropertyName = "tracking_number")]
public object TrackingNumber { get; set; }
public string TrackingNumber { get; set; }

[JsonProperty(PropertyName = "tracking_status")]
public object TrackingStatus { get; set; }
public ShippoEnums.TrackingStatus TrackingStatus { get; set; }

[JsonProperty(PropertyName = "tracking_url_provider")]
public object TrackingUrlProvider { get; set; }
public string TrackingUrlProvider { get; set; }

[JsonProperty(PropertyName = "label_url")]
public object LabelURL { get; set; }
public string LabelURL { get; set; }

[JsonProperty(PropertyName = "commercial_invoice_url")]
public object CommercialInvoiceUrl { get; set; }
Expand Down
6 changes: 0 additions & 6 deletions ShippoExample/App.config

This file was deleted.

158 changes: 0 additions & 158 deletions ShippoExample/Program.cs

This file was deleted.

Loading