Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@icyavocado
Copy link

Using the new REST API from UPS.

  • UPS.pm to store a copy of the access key to tmp folder, and keep track of timestamp to get new token (default to 10 min before the access code actually expired)
  • API.pm shows all the supported endpoints.
  • Update tests for ups

icyavocado added 14 commits May 15, 2024 10:05
UPS API expects most incoming variables as strings, so we need to convert the request data to string type.

"preserve_token" returns the preserved access_token or triggered when a new access token is feched via Shipment::UPS::API.
  - This variable preserves the access token, attempting to reuse it until 10 minutes before it expires.
  As the UPS API now relies on access_token, and the current token lasts for 4 hours or 14400 seconds, and is rate-limited, this has necessitated a means to save and reuse the access_token.
  - "preserve_token" accepts a CodeRef, you have the option of using the default or replacing it with your own implementation.

To maintain backward compatibility, we preserve the "proxy_domain" variable.
  Setting a proxy_domain triggers an update to the environment variable, which, in turn, updates the Shipment::UPS::API object endpoints.
- https://developer.ups.com/api/reference#tag/Tracking_other
Track data mostly stay the same but the ship_date(), I wasnt able to find a good match data for PickupDate in the json response
- https://developer.ups.com/api/reference#operation/AddressValidation
UPS deprecated Address Validation v1, so default to v2, will need to enable Rating API to fully test
- replace username, password with client_id and client_secret
- make sure environment to run tests on is 'cie' development endpoints
- remove extra Request failed string
- the extra "\n" is to remove the extra error auto added at the end if there is no next line.
…ng ids

- change ["tracking_01","tracking_02"] to [tracking_01,tracking_02]
Copy link
Owner

@pullingshots pullingshots left a comment

Choose a reason for hiding this comment

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

This is awesome! Thanks so much for all the work on this, it's a big change.

Most of the requested changes have to do with re-applying PR #35

=cut

has 'surepost_bpm' => (
Copy link
Owner

Choose a reason for hiding this comment

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

Support for SurePost BPM and Media services has been removed. Was there a reason for this or can this be added back in?

name => $self->service_map->{92},
);

$services{surepost_oz} = $services{92};
Copy link
Owner

Choose a reason for hiding this comment

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

Support for SurePost service 92 has also been removed, can this be added back in or was there a reason it was removed? See commit b56dba8

https://www.ups.com/upsdeveloperkit
See related modules for documentation on options and how to access rates and labels:
Copy link
Owner

Choose a reason for hiding this comment

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

This POD documentation pointing to other Shipment modules needs to be restored.

=cut

has 'saturday_delivery' => (
Copy link
Owner

Choose a reason for hiding this comment

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

support for Saturday Delivery needs to be restored. See commit d400bd1

my $response;
my %services;

if ($self->weight_unit ne 'oz')
Copy link
Owner

Choose a reason for hiding this comment

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

As per previous comment, this logic is part of adding back additional surepost options - see commit b56dba8

$package_options->{DeclaredValue}->{CurrencyCode} = $self->currency;

# default return code is 9 which means we print a return label
my $return_code = $rc ? $rc : 9;
Copy link
Owner

Choose a reason for hiding this comment

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

need to re-apply commit 34ff8d4 here

},
Shipment => {
ReturnService => {
Code => $return_code,
Copy link
Owner

Choose a reason for hiding this comment

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

need to re-apply commit 34ff8d4 here

CountryCode => $self->to_address->country_code,
CountryCode => $country_code_map{$self->to_address->province_code} || $self->to_address->country_code,
},
EmailAddress => $self->from_address->email,
Copy link
Owner

Choose a reason for hiding this comment

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

need to re-apply commit 34ff8d4 here

CountryCode => $self->from_address->country_code,
},
EMailAddress => $self->to_address->email,
EmailAddress => $self->to_address->email,
Copy link
Owner

Choose a reason for hiding this comment

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

need to re-apply commit 34ff8d4 here

use namespace::clean;

use Exporter 'import';
our @EXPORT_OK = qw( coerce_datetime );
Copy link
Owner

Choose a reason for hiding this comment

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

Curious why adding this was required?

Copy link
Author

Choose a reason for hiding this comment

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

Running test in perl 5.40, I got a few complain about function not exported, therefor not usable.

This seem like a new error came from Perl.

@icyavocado
Copy link
Author

Will work on restoring the commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants