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

Update Library to have strongly typed objects. Add missing fields from API #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,10 +15,6 @@ Global
{6816FD58-3FC6-4EFC-95F8-D11E9C1D387F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6816FD58-3FC6-4EFC-95F8-D11E9C1D387F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6816FD58-3FC6-4EFC-95F8-D11E9C1D387F}.Release|Any CPU.Build.0 = Release|Any CPU
{7712EC9C-2581-49EE-8B61-745843F2CD6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7712EC9C-2581-49EE-8B61-745843F2CD6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7712EC9C-2581-49EE-8B61-745843F2CD6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7712EC9C-2581-49EE-8B61-745843F2CD6F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 4 additions & 1 deletion Shippo/APIResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ static string GetResponseAsString(WebResponse response)
// GET Requests
public virtual T DoRequest<T>(string endpoint, string method = "GET", string body = null)
{
var jsonSettings = new JsonSerializerSettings {
NullValueHandling = NullValueHandling.Ignore
};
var json = DoRequest(endpoint, method, body);
return JsonConvert.DeserializeObject<T>(json);
return JsonConvert.DeserializeObject<T>(json, jsonSettings);
}
// GET Requests Helper
public virtual string DoRequest(string endpoint)
Expand Down
30 changes: 15 additions & 15 deletions Shippo/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,52 @@ public class Address : ShippoId {
public object IsComplete { get; set; }

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

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

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

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

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

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

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

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

[JsonProperty(PropertyName = "street3")]
public string Street3;

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

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

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

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

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

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

[JsonProperty(PropertyName = "is_residential")]
public object IsResidential { get; set; }
public bool? IsResidential { get; set; }

[JsonProperty(PropertyName = "ip")]
public object IP { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Shippo/BatchShipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BatchShipment : ShippoId
public string Transaction;

[JsonProperty(PropertyName = "messages")]
public object Messages;
public IEnumerable<ShippoMessage> Messages;

[JsonProperty(PropertyName = "metadata")]
public string Metadata;
Expand Down
8 changes: 4 additions & 4 deletions Shippo/CarrierAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ namespace Shippo {
[JsonObject(MemberSerialization.OptIn)]
public class CarrierAccount : ShippoId {
[JsonProperty(PropertyName = "account_id")]
public object AccountId { get; set; }
public string AccountId { get; set; }

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

[JsonProperty(PropertyName = "parameters")]
public object Parameters { get; set; }

[JsonProperty(PropertyName = "test")]
public object Test { get; set; }
public bool Test { get; set; }

[JsonProperty(PropertyName = "active")]
public object Active { get; set; }
public bool Active { get; set; }

[JsonProperty(PropertyName = "metadata")]
public object Metadata { get; set; }
Expand Down
43 changes: 22 additions & 21 deletions Shippo/CustomsDeclaration.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Shippo {
[JsonObject(MemberSerialization.OptIn)]
public class CustomsDeclaration : ShippoId {
[JsonProperty(PropertyName = "object_created")]
public object ObjectCreated { get; set; }
public DateTime ObjectCreated { get; set; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[JsonProperty(PropertyName = "certify")]
public object Certify { get; set; }
public bool Certify { get; set; }

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

[JsonProperty (PropertyName = "address_importer")]
public Address AddressImporter { get; set; }

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

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

[JsonProperty(PropertyName = "items")]
public object Items { get; set; }
public List<string> Items { get; set; }

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

26 changes: 13 additions & 13 deletions Shippo/CustomsItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@ namespace Shippo {
[JsonObject(MemberSerialization.OptIn)]
public class CustomsItem : ShippoId {
[JsonProperty(PropertyName = "object_created")]
public object ObjectCreated { get; set; }
public DateTime ObjectCreated { get; set; }

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

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

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

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

[JsonProperty(PropertyName = "quantity")]
public object Quantity { get; set; }
public int Quantity { get; set; }

[JsonProperty(PropertyName = "net_weight")]
public object NetWeight { get; set; }
public decimal NetWeight { get; set; }

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

[JsonProperty(PropertyName = "value_amount")]
public object ValueAmount { get; set; }
public decimal ValueAmount { get; set; }

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

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

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

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

16 changes: 10 additions & 6 deletions Shippo/Manifest.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Shippo {
[JsonObject(MemberSerialization.OptIn)]
public class Manifest : ShippoId {
[JsonProperty(PropertyName = "object_created")]
public object ObjectCreated { get; set; }
public DateTime ObjectCreated { get; set; }

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

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

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

[JsonProperty(PropertyName = "provider")]
public object Provider { get; set; }

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

[JsonProperty(PropertyName = "address_from")]
public object AddressFrom { get; set; }

[JsonProperty(PropertyName = "documents")]
public object Documents { get; set; }
public List<string> Documents { get; set; }

[JsonProperty(PropertyName = "carrier_account")]
public string Carrier_Account { get; set; }
}
}

30 changes: 15 additions & 15 deletions Shippo/Parcel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ namespace Shippo
public class Parcel : ShippoId
{
[JsonProperty(PropertyName = "object_state")]
public object ObjectState { get; set; }
public string ObjectState { get; set; }

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

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

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

[JsonProperty(PropertyName = "length")]
public object Length { get; set; }
public decimal Length { get; set; }

[JsonProperty(PropertyName = "width")]
public object Width { get; set; }
public decimal Width { get; set; }

[JsonProperty(PropertyName = "height")]
public object Height { get; set; }
public decimal Height { get; set; }

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

[JsonProperty(PropertyName = "weight")]
public object Weight { get; set; }
public decimal Weight { get; set; }

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

[JsonProperty(PropertyName = "template")]
public string Template;

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

[JsonProperty(PropertyName = "extra")]
public object Extra;
Expand All @@ -52,11 +52,11 @@ public static Parcel createForShipment(double length, double width, double heigh
double weight, string massUnit)
{
Parcel p = new Parcel();
p.Length = length;
p.Width = width;
p.Height = height;
p.Length = Convert.ToDecimal(length);
p.Width = Convert.ToDecimal(width);
p.Height = Convert.ToDecimal(height);
p.DistanceUnit = distance_unit;
p.Weight = weight;
p.Weight = Convert.ToDecimal(weight);
p.MassUnit = massUnit;
return p;

Expand Down
Loading