Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shipping option for insurance #43

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

avido
Copy link
Contributor

@avido avido commented Nov 18, 2020

Description

Insurance shipment option added.

Motivation and context

Why is this change required? What problem does it solve?

If it fixes an open issue, please link to the issue here (if you write fixes #num
or closes #num, the issue will be automatically closed when the pull is accepted.)

How has this been tested?

Please describe in detail how you tested your changes.

Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • [x ] I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • If my change requires a change to the documentation, I have updated it accordingly.
  • My code follows the code style of this project.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

@mvdnbrk mvdnbrk changed the title Avido/feature shipping option insurance Add shipping option for insurance Nov 18, 2020
src/Resources/Parcel.php Outdated Show resolved Hide resolved
src/Resources/Parcel.php Show resolved Hide resolved
src/Resources/ShipmentOptions.php Outdated Show resolved Hide resolved
@mvdnbrk
Copy link
Owner

mvdnbrk commented Nov 18, 2020

The amount should be in passed in cents to the API of MyParcel.
Think we should make this clear in the documentation.

@mvdnbrk mvdnbrk self-requested a review November 18, 2020 17:09
src/Resources/Parcel.php Outdated Show resolved Hide resolved
@mvdnbrk
Copy link
Owner

mvdnbrk commented Nov 18, 2020

From the MyParcel API docs:

insurance

This option allows a shipment to be insured up to certain amount. Only package type 1 (package) shipments can be insured. > NL shipments can be insured for 500,- euros. EU shipments must be insured for 500,- euros. Global shipments must be >insured for 200,- euros. The following shipment options are mandatory when insuring an NL shipment: only_recipient and >signature.

only_recipient and signature are mandatory here for NL, this would mean you would have to call it like this:

$parcel->insurance(50000)->onlyRecipient->signature();

Bit cumbersome and one or the other method might be forgotten.
Would be easier if you could just do (and set the appropriate options internally):

$parcel->insurance(50000);

@avido
Copy link
Contributor Author

avido commented Nov 18, 2020

From the MyParcel API docs:

insurance

This option allows a shipment to be insured up to certain amount. Only package type 1 (package) shipments can be insured. > NL shipments can be insured for 500,- euros. EU shipments must be insured for 500,- euros. Global shipments must be >insured for 200,- euros. The following shipment options are mandatory when insuring an NL shipment: only_recipient and >signature.

only_recipient and signature are mandatory here for NL, this would mean you would have to call it like this:

$parcel->insurance(50000)->onlyRecipient->signature();

Bit cumbersome and one or the other method might be forgotten.
Would be easier if you could just do (and set the appropriate options internally):

$parcel->insurance(50000);

But only mandatory for NL therefore didn't set them internally

@mvdnbrk
Copy link
Owner

mvdnbrk commented Nov 18, 2020

Think this package will be used most for NL shipments, so it makes sense to set these internally, we could check if the recipients address is in NL?

@avido
Copy link
Contributor Author

avido commented Nov 18, 2020

Think this package will be used most for NL shipments, so it makes sense to set these internally, we could check if the recipients address is in NL?

That's a risky assumption :)
It's possible recipient is not set when setting insurance. Therefore the country code isn't present.
It's possible to check if the recipient is present, but this leads to some (unwanted) overhead in code. Also i believe the api of myparcel will auto add the mandatory options on request.

@mvdnbrk
Copy link
Owner

mvdnbrk commented Nov 18, 2020

True, but I think it might be worth the little overhead.
In stead of making notes in the docs like: "Hey don't forget to call this method and this method when setting an insurance for your parcel" 😉

In my opinion you should always set the recipient first before calling any additional option methods, even though this is possible at the moment.

README.md Show resolved Hide resolved
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.

None yet

2 participants