Skip to content

Commit

Permalink
Support Get/Save Address Barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Koval authored and Dmitry Koval committed Oct 20, 2021
1 parent 9a4ade1 commit 2fd3905
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 3 deletions.
19 changes: 19 additions & 0 deletions route4me-csharp-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.1.0.0] - 2021-10-07

### Added

The file [BarcodeDataRequest.cs: ](https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/Route4MeSDKLibrary/DataTypes/V5/AddressBarcodes/BarcodeDataRequest.cs)
**Class**: BarcodeDataRequest - for saving bar codes.

The file [BarcodeDataResponse.cs: ](https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/Route4MeSDKLibrary/DataTypes/V5/AddressBarcodes/BarcodeDataResponse.cs)
**Class**: BarcodeDataResponse - for reading bar codes from response.

The file [GetAddressBarcodesResponse.cs: ](https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/Route4MeSDKLibrary/DataTypes/V5/AddressBarcodes/GetAddressBarcodesResponse.cs)
**Class**: GetAddressBarcodesResponse - response for get bar codes request.

The file [GetAddressBarcodesParameters.cs: ](https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/Route4MeSDKLibrary/QueryTypes/V5/AddressBarcodes/GetAddressBarcodesResponse.cs)
**Class**: GetAddressBarcodesParameters - Query parameters for get bar codes request.

The file [SaveAddressBarcodesParameters.cs: ](https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/Route4MeSDKLibrary/QueryTypes/V5/AddressBarcodes/SaveAddressBarcodesParameters.cs)
**Class**: SaveAddressBarcodesParameters - Query parameters for save bar codes request.

## [1.0.2.0] - 2021-10-07

### Added
Expand Down
2 changes: 2 additions & 0 deletions route4me-csharp-sdk/Route4MeSDKLibrary/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public static class R4MEInfrastructureSettingsV5

#endregion

public const string AddressBarcodes = MainHost + "/address-barcodes";

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Runtime.Serialization;

namespace Route4MeSDK.DataTypes.V5
{
/// <summary>
/// Barcode data request
/// </summary>
[DataContract]
public class BarcodeDataRequest : QueryTypes.GenericParameters
{
/// <summary>
/// Barcode
/// </summary>
[DataMember(Name = "barcode", EmitDefaultValue = false)]
public string Barcode { get; set; }

/// <summary>
/// Scan type
/// </summary>
[DataMember(Name = "scan_type", EmitDefaultValue = false)]
public string ScanType { get; set; }

/// <summary>
/// Latitude
/// </summary>
[DataMember(Name = "lat", EmitDefaultValue = false)]
public double Latitude { get; set; }

/// <summary>
/// Longitude
/// </summary>
[DataMember(Name = "lan", EmitDefaultValue = false)]
public double Longitude { get; set; }

/// <summary>
/// Date
/// </summary>
[DataMember(Name = "timestamp_date", EmitDefaultValue = false)]
public long TimestampDate { get; set; }

/// <summary>
/// UTC data
/// </summary>
[DataMember(Name = "timestamp_utc", EmitDefaultValue = false)]
public long TimestampUtc { get; set; }

/// <summary>
/// Scanned at
/// </summary>
[DataMember(Name = "scanned_at", EmitDefaultValue = false)]
public string ScannedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Runtime.Serialization;

namespace Route4MeSDK.DataTypes.V5
{
/// <summary>
/// Barcode data response
/// </summary>
[DataContract]
public class BarcodeDataResponse
{
/// <summary>
/// The route ID.
/// </summary>
[DataMember(Name = "route_id", EmitDefaultValue = false)]
public string RouteId { get; set; }

/// <summary>
/// Route destination ID
/// </summary>
[DataMember(Name = "route_destination_id", EmitDefaultValue = false)]
public int RouteDestinationId { get; set; }

/// <summary>
/// Order id
/// </summary>
[DataMember(Name = "order_id", EmitDefaultValue = false)]
public int? OrderId { get; set; }

/// <summary>
/// Barcode
/// </summary>
[DataMember(Name = "barcode", EmitDefaultValue = false)]
public string Barcode { get; set; }

/// <summary>
/// Scan type
/// </summary>
[DataMember(Name = "scan_type", EmitDefaultValue = false)]
public string ScanType { get; set; }

/// <summary>
/// Latitude
/// </summary>
[DataMember(Name = "lat", EmitDefaultValue = false)]
public double Latitude { get; set; }

/// <summary>
/// Longitude
/// </summary>
[DataMember(Name = "lan", EmitDefaultValue = false)]
public double Longitude { get; set; }

/// <summary>
/// Date
/// </summary>
[DataMember(Name = "timestamp_date", EmitDefaultValue = false)]
public long TimestampDate { get; set; }

/// <summary>
/// UTC date
/// </summary>
[DataMember(Name = "timestamp_utc", EmitDefaultValue = false)]
public long TimestampUtc { get; set; }

/// <summary>
/// Scanned at
/// </summary>
[DataMember(Name = "scanned_at", EmitDefaultValue = false)]
public string ScannedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Runtime.Serialization;

namespace Route4MeSDK.DataTypes.V5
{
/// <summary>
/// Response from the get address barcodes request
/// </summary>
[DataContract]
public sealed class GetAddressBarcodesResponse : QueryTypes.GenericParameters
{
/// <summary>
/// The status
/// </summary>
[DataMember(Name = "status", EmitDefaultValue = false)]
public string Status { get; set; }

/// <summary>
/// Reference to the next page data
/// </summary>
[DataMember(Name = "next_page_cursor", EmitDefaultValue = false)]
public string NextPageData { get; set; }

/// <summary>
/// An array of the <see cref="BarcodeDataResponse"/> type objects
/// </summary>
[DataMember(Name = "data", EmitDefaultValue = false)]
public BarcodeDataResponse[] Data { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Route4MeSDK.QueryTypes.V5
{
/// <summary>
/// Parameters for the get address barcodes request.
/// </summary>
/// <seealso cref="Route4MeSDK.QueryTypes.GenericParameters" />
public sealed class GetAddressBarcodesParameters : GenericParameters
{
/// <summary>
/// The route ID.
/// <remarks><para>Query parameter.</para></remarks>
/// </summary>
[HttpQueryMemberAttribute(Name = "route_id", EmitDefaultValue = false)]
public string RouteId { get; set; }

/// <summary>
/// Route destination ID
/// </summary>
[HttpQueryMemberAttribute(Name = "route_destination_id", EmitDefaultValue = false)]
public int? RouteDestinationId { get; set; }

/// <summary>
/// Limit the number of records in response.
/// <remarks><para>Query parameter.</para></remarks>
/// </summary>
[HttpQueryMemberAttribute(Name = "limit", EmitDefaultValue = false)]
public uint? Limit { get; set; }

/// <summary>
/// The reference to the next data part
/// <remarks><para>Query parameter.</para></remarks>
/// </summary>
[HttpQueryMemberAttribute(Name = "cursor", EmitDefaultValue = false)]
public string Cursor { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Runtime.Serialization;
using Route4MeSDK.DataTypes.V5;

namespace Route4MeSDK.QueryTypes.V5
{
/// <summary>
/// Parameters for the add address barcodes request.
/// </summary>
/// <seealso cref="Route4MeSDK.QueryTypes.GenericParameters" />
[DataContract]
public sealed class SaveAddressBarcodesParameters : GenericParameters
{
/// <summary>
/// The route ID.
/// <remarks><para>Query parameter.</para></remarks>
/// </summary>
[DataMember(Name = "route_id", EmitDefaultValue = false)]
public string RouteId { get; set; }

/// <summary>
/// Route destination ID
/// </summary>
[DataMember(Name = "route_destination_id", EmitDefaultValue = false)]
public int RouteDestinationId { get; set; }

/// <summary>
/// Barcodes to be saved
/// </summary>
[DataMember(Name = "barcodes", EmitDefaultValue = false)]
public BarcodeDataRequest[] Barcodes { get; set; }
}
}
36 changes: 36 additions & 0 deletions route4me-csharp-sdk/Route4MeSDKLibrary/Route4MeManagerV5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,42 @@ public string GetAccountPreferedUnit(out ResultResponse failResponse)

#endregion

#region Barcodes

/// <summary>
/// Returns address barcodes
/// </summary>
/// <param name="getAddressBarcodesParameters">Request parameters</param>
/// <param name="resultResponse">Failing response</param>
/// <returns>An <see cref="GetAddressBarcodesResponse"/> type object</returns>
public GetAddressBarcodesResponse GetAddressBarcodes(GetAddressBarcodesParameters getAddressBarcodesParameters, out ResultResponse resultResponse)
{
var response = GetJsonObjectFromAPI<GetAddressBarcodesResponse>(getAddressBarcodesParameters,
R4MEInfrastructureSettingsV5.AddressBarcodes,
HttpMethodType.Get,
out resultResponse);

return response;
}

/// <summary>
/// Saves address bar codes
/// </summary>
/// <param name="saveAddressBarcodesParameters">The contact parameters</param>
/// <param name="resultResponse">Failing response</param>
/// <returns>Created address book contact</returns>
public StatusResponse SaveAddressBarcodes(SaveAddressBarcodesParameters saveAddressBarcodesParameters, out ResultResponse resultResponse)
{
saveAddressBarcodesParameters.PrepareForSerialization();

return GetJsonObjectFromAPI<StatusResponse>(saveAddressBarcodesParameters,
R4MEInfrastructureSettingsV5.AddressBarcodes,
HttpMethodType.Post,
out resultResponse);
}

#endregion

#region Team Management

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ The service is typically used by organizations who must route many drivers to ma
<RepositoryUrl>https://github.com/route4me/route4me-net-core/tree/master/route4me-csharp-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Route4Me, Route Optimization, SDK, GIS</PackageTags>
<Version>1.0.2.0</Version>
<Version>1.1.0.0</Version>
<PackageReleaseNotes>Changed the classes: DataContractResolver, FastBulkGeocoding, FastFileReading, PropertyValidation, Route4MeManagerV5
Added the classes: AddressBookContact (V5), AddressBookContactsResponse (V5), AddressBookParameters (V5), FastFileReading, FastValidateData

See https://github.com/route4me/route4me-net-core/blob/master/route4me-csharp-sdk/CHANGELOG.md for release note details.</PackageReleaseNotes>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<FileVersion>1.0.2.0</FileVersion>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Route4MeSDK;
using Route4MeSDK.DataTypes.V5;
using Route4MeSDK.QueryTypes.V5;
using Xunit;

namespace Route4MeSdkV5UnitTest.V5.AddressBarcodes
{
public class AddressBarcodesTests
{
[Fact]
public void AddressBarcodesGetSaveTest()
{
var route4me = new Route4MeManagerV5(ApiKeys.ActualApiKey);

var getAddressBarcodesParameters = new GetAddressBarcodesParameters()
{
RouteId = "893E6C33F0494572DEB2FAE34B2D3E0B",
RouteDestinationId = 705601646
};
var readResult1 = route4me.GetAddressBarcodes(getAddressBarcodesParameters, out var resultResponse);
Assert.NotEmpty(readResult1.Data);

var saveAddressBarcodesResponse = route4me.SaveAddressBarcodes(new SaveAddressBarcodesParameters()
{
RouteId = "893E6C33F0494572DEB2FAE34B2D3E0B",
RouteDestinationId = 705601646,
Barcodes = new BarcodeDataRequest[]
{
new BarcodeDataRequest()
{
Barcode = "TEST2",
Latitude = 40.610804,
Longitude = -73.920172,
TimestampDate = 1634169600,
TimestampUtc = 1634198666,
ScanType = "picked_up",
ScannedAt = "2021-10-15 19:18:11"
}
}

}, out resultResponse);

Assert.True(saveAddressBarcodesResponse.status);

var readResult2 = route4me.GetAddressBarcodes(getAddressBarcodesParameters, out resultResponse);

Assert.True(readResult2.Data.Length - readResult1.Data.Length == 1);

}
}
}

0 comments on commit 2fd3905

Please sign in to comment.