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

Add tracking api #19

Merged
merged 21 commits into from
Feb 16, 2017
Merged

Add tracking api #19

merged 21 commits into from
Feb 16, 2017

Conversation

vinhhv
Copy link
Contributor

@vinhhv vinhhv commented Feb 13, 2017

No description provided.

@vinhhv vinhhv requested a review from manishtomar February 13, 2017 20:36
Copy link
Contributor

@manishtomar manishtomar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good expect few comments. My main confusion is shipment object ID being used in test.


public Track RetrieveTracking (String carrier, String id)
{
string ep = String.Format ("{0}/tracks/{1}/{2}", api_endpoint, carrier, id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you encode carrier and id in case they end up having reserved characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

public void TestValidGetStatus ()
{
Shipment shipment = ShipmentTest.getDefaultObject ();
Track track = getAPIResource ().RetrieveTracking ("usps", shipment.ObjectId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for taking shipment ID from the Shipment.getDefaultObject(). I had hardcoded in Java. Will do the same there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait I just realized doesn't this take tracking number given by the carrier. Instead takes shipment ID from shippo. If so, how is this test working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the test never worked? If so, could you please avoid requesting a review before completely testing it? My assumption before reviewing is that the code has been completed and tested. Let me know if this is ok with you.

Shippo/Track.cs Outdated
[JsonObject (MemberSerialization.OptIn)]
public class Track : ShippoId {
[JsonProperty (PropertyName = "carrier")]
public object Carrier { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tracking information is primarily for consumption do you think its best to leave out setters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the getters for it to be initially filled out, else they will always be NULL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to say that JsonProperty needs the setters? If so, then its good. Interestingly Java's GSON doesn't need the setters. It is able to set private variables using Java reflection.

I also just realized that all the members are public. They should probably be private with getter/setter. The getter/setter are not required if they are public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried changing them to private, it doesn't allow me to access the properties. Instead I just removed the getters and setters and tests pass 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They probably pass because attributes are still public. Can you try making them private with only getter? If this works, could you please do the same for TrackingEvent and TrackingHistory? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried changing them to private with 'get', but it doesn't work

Shipment shipment = ShipmentTest.getDefaultObject ();
Track track = getAPIResource ().RetrieveTracking ("usps", shipment.ObjectId);
Assert.IsNotNull (track.TrackingNumber);
Assert.IsNotNull (track.TrackingHistory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asserting these is duplicate effort already done in TestValidGetStatus. I think it can be skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@manishtomar
Copy link
Contributor

And thank you very much for splitting the PRs. It is really helpful.


private static void RunTrackingExample (Shipment shipment, APIResource resource)
{
Track track = resource.RetrieveTracking ("usps", shipment.ObjectId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracking number instead of shipment.ObjectId

@manishtomar
Copy link
Contributor

Thank you so much for adding types to the class. It makes it way better. I left a comment about public attributes and shipmentID being used in example. Could you please address those? Once done I think this is good to go :)

@manishtomar
Copy link
Contributor

Created #20 for immutable classes. Without that this LGTM 👍

@manishtomar manishtomar merged commit 10fed88 into master Feb 16, 2017
@manishtomar manishtomar deleted the add-tracking-api branch February 16, 2017 00:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants