Skip to content

Commit 1f72efa

Browse files
authored
Merge pull request #134 from purplship/purplship-sdk-2021.6
[release] purplship SDK 2021.6
2 parents 9cf02e2 + 91c6fd4 commit 1f72efa

File tree

138 files changed

+4974
-2054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+4974
-2054
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ branch = True
44
omit =
55
*/purplship/extensions/boxknight/*
66
*/purplship/extensions/dicom/*
7-
*/purplship/extensions/usps/*
87

98
[report]
109
include =

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: puprlship-sdk
4+
name: purplship-sdk
55

66
on: [push]
77

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<p align="center">
22
<p align="center">
33
<a href="https://purplship.com" target="_blank">
4-
<img src="https://github.com/PurplShip/purplship/raw/main/docs/images/icon.png" alt="Purplship" height="100">
4+
<img src="https://github.com/purplship/purplship/raw/main/docs/images/icon.png" alt="purplship" height="100">
55
</a>
66
</p>
77
<h2 align="center">
8-
Purplship - The Open Source multi-carrier shipping SDK
8+
purplship - The Open Source multi-carrier shipping SDK
99
</h2>
1010
<p align="center">
11-
<a href="https://github.com/Purplship/Purplship/actions"><img src="https://github.com/Purplship/Purplship/workflows/puprlship-sdk/badge.svg" alt="CI" style="max-width:100%;"></a>
12-
<a href="https://www.gnu.org/licenses/lgpl-3.0" rel="nofollow"><img src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" alt="License: LGPL v3" data-canonical-src="https://img.shields.io/badge/License-AGPL%20v3-blue.svg" style="max-width:100%;"></a>
11+
<a href="https://github.com/purplship/purplship/actions"><img src="https://github.com/purplship/purplship/workflows/purplship-sdk/badge.svg" alt="CI" style="max-width:100%;"></a>
12+
<a href="https://www.gnu.org/licenses/lgpl-3.0" rel="nofollow"><img src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" alt="License: LGPL v3" data-canonical-src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" style="max-width:100%;"></a>
1313
<a href="https://github.com/python/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black" style="max-width:100%;"></a>
14-
<a href="https://codecov.io/gh/PurplShip/purplship"><img src="https://codecov.io/gh/PurplShip/purplship/branch/main/graph/badge.svg?token=D07fio4Dn6"/></a>
15-
<a href="https://app.codacy.com/manual/DanH91/Purplship?utm_source=github.com&utm_medium=referral&utm_content=Purplship/Purplship&utm_campaign=Badge_Grade_Dashboard"><img src="https://api.codacy.com/project/badge/Grade/a57baa23a1ca4403a37a8b7134609709" alt="Codacy Badge" style="max-width:100%;"></a>
14+
<a href="https://codecov.io/gh/purplship/purplship"><img src="https://codecov.io/gh/purplship/purplship/branch/main/graph/badge.svg?token=D07fio4Dn6"/></a>
15+
<a href="https://www.codacy.com/gh/purplship/purplship/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=purplship/purplship&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/cc2ac4fcb6004bca84e42a90d8acfe41"></a>
1616
</p>
1717
</p>
1818

19-
Puprlship is a modern development kit that simplifies the integration of shipping carriers services into an app.
19+
puprlship is a modern development kit that simplifies the integration of shipping carriers services into an app.
2020

2121
The key features are:
2222

2323
- **Unified API**: A standardized set of models representing the common shipping data (`Address`, `Parcel`, `Shipment`...)
24-
- **Intuitive API**: A library that abstracts and unifies the typical shipping API services (`Rating`, `Pickup`, `Tracking`...)
25-
- **Multi-carrier**: Integrate Purplship once and connect to multiple shipping carrier APIs
24+
- **Intuitive API**: A library that abstracts and unifies the typical shipping API services (`Rating`, `Shipping`, `Tracking`...)
25+
- **Multi-carrier**: Integrate purplship once and connect to multiple shipping carrier APIs
2626
- **Custom carrier**: A framework to integrate a shipping carrier services within hours instead of months
2727

2828

29-
*For a complete shipping management REST API with a dashboard checkout [purplship-server](https://github.com/PurplShip/purplship-server).*
29+
*For a complete shipping management REST API with a dashboard checkout [purplship-server](https://github.com/puprlship/purplship-server).*
3030

3131

3232
## Requirements
@@ -56,12 +56,14 @@ Additional extensions:
5656
- `purplship.dhl-universal`
5757
- `purplship.dicom`
5858
- `purplship.fedex`
59-
- `purplship.purolator-courier`
59+
- `purplship.purolator`
6060
- `purplship.royalmail`
6161
- `purplship.sendle`
6262
- `purplship.sf-express`
63+
- `purplship.tnt`
6364
- `purplship.ups`
6465
- `purplship.usps`
66+
- `purplship.usps-international`
6567
- `purplship.yanwen`
6668
- `purplship.yunexpress`
6769

@@ -156,16 +158,16 @@ print(rates)
156158
## Resources
157159

158160
- [**Documentation**](https://sdk.purplship.com)
159-
- [**Bug Tracker**](https://github.com/PurplShip/purplship/issues)
161+
- [**Bug Tracker**](https://github.com/puprlship/purplship/issues)
160162
- [**Community on Discord**](https://discord.gg/kXEa3UMRHd)
161163

162164
## Contributing
163165

164-
We encourage you to contribute to Purplship! Please check out the
165-
[Contributing to Purplship guide](/docs/development/contributing.md) for guidelines about how to proceed.
166-
[Join us!](https://gitter.im/Purplship/Purplship?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
166+
We encourage you to contribute to puprlship! Please check out the
167+
[Contributing to purplship guide](/docs/development/contributing.md) for guidelines about how to proceed.
168+
[Join the purplship Community!](https://github.com/purplship/purplship/discussions)
167169

168-
Do you want to extend Purplship and integrate a custom carrier, check out [Extending Purplship](https://sdk.purplship.com/development/extending/)
170+
Do you want to extend purplship and integrate a custom carrier, check out [Extending purplship](https://sdk.purplship.com/development/extending/)
169171

170172
## License
171173

@@ -176,4 +178,4 @@ Please see [LICENSE.md](/LICENSE) for licensing details.
176178
## Authors
177179

178180
- **Daniel K.** | [@DanHK91](https://twitter.com/DanHK91) | [danielk.xyz](https://danielk.xyz/)
179-
- **Purplship Team** | hello@purplship.com | [purplship.com](https://purplship.com)
181+
- **purplship** | hello@purplship.com | [purplship.com](https://purplship.com)

docs/contributing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## Contribute to Purplship
1+
## Contribute to purplship
22

33
### **Did you find a bug?**
44

55
* **Do not open up a GitHub issue if the bug is a security vulnerability
6-
in Purplship**, and instead send us an email at hello@purplship.com.
6+
in purplship**, and instead send us an email at hello@purplship.com.
77

88
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/PurplShip/purplship/issues).
99

@@ -23,11 +23,11 @@
2323

2424
### **Do you have questions about the source code?**
2525

26-
* Ask any question about how to use Purplship in the [purplship room](https://gitter.im/Purplship/Purplship).
26+
* Ask any question about how to use purplship in the [purplship room](https://gitter.im/purplship/purplship).
2727

2828
* Check out the [architecture overview](/architecture)
2929

3030

3131
Thanks!
3232

33-
Daniel K, Purplship
33+
Daniel K, purplship

docs/development/architecture.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
## Overview
22

3-
Purplship proposes a set of unified APIs accepting all required data to send requests to the supported carrier services.
3+
purplship proposes a set of unified APIs accepting all required data to send requests to the supported carrier services.
44

5-
The typical data flows for all requests processed by Purplship is illustrated bellow.
5+
The typical data flows for all requests processed by purplship is illustrated bellow.
66

77
<figure>
88
<img src="/images/purplship-sequence-diagram.svg" height="300" />
9-
<figcaption>Purplship - Sequence</figcaption>
9+
<figcaption>purplship - Sequence</figcaption>
1010
</figure>
1111

12-
To accomplish this, the overall abstraction proposed by Purplship come down to the implementation these abstract classes.
12+
To accomplish this, the overall abstraction proposed by purplship come down to the implementation these abstract classes.
1313

1414
<figure>
1515
<img src="/images/purplship-class-diagram.svg" height="300" />
16-
<figcaption>Purplship - Class Diagram</figcaption>
16+
<figcaption>purplship - Class Diagram</figcaption>
1717
</figure>
1818

1919
### The `Settings`
@@ -30,7 +30,7 @@ To accomplish this, the overall abstraction proposed by Purplship come down to t
3030
### The `Mapper`
3131

3232
!!! abstract ""
33-
The `Mapper` class translates the unified Purplship API data into carrier specific data to send requests
33+
The `Mapper` class translates the unified purplship API data into carrier specific data to send requests
3434
and also takes care or parsing the response returned back into a unified data model
3535

3636
Learn more about the Mapper pattern from [Martin Fowler Enterprise Pattern](https://martinfowler.com/eaaCatalog/dataMapper.html)
@@ -70,7 +70,7 @@ canadapost_proxy = Proxy(canadapost_settings)
7070
from purplship.core.models import PickupRequest, Address
7171

7272

73-
# A Purplship unified Pickup request type
73+
# A purplship unified Pickup request type
7474
pickup_request: PickupRequest = PickupRequest(
7575
pickup_date="2021-12-15",
7676
ready_time="10:00",
@@ -90,7 +90,7 @@ canadapost_pickup_request = canadapost_mapper.create_pickup_request(pickup_reque
9090
# Send the request the carrier
9191
canadapost_pickup_response = canadapost_proxy.schedule_pickup(canadapost_pickup_request)
9292

93-
# Parse the response into a Purplship unified Pickup response type
93+
# Parse the response into a purplship unified Pickup response type
9494
pickup_response = canadapost_mapper.parse_pickup_response(canadapost_pickup_response)
9595

9696
print(pickup_response)
@@ -112,20 +112,20 @@ print(pickup_response)
112112
```
113113

114114
!!! info
115-
The example above illustrates a Pickup scheduling but the idea is that all requests made by Purplship follow the same lifecycle:
115+
The example above illustrates a Pickup scheduling but the idea is that all requests made by purplship follow the same lifecycle:
116116

117-
- convert unified Purplship API data into a carrier specific request using the `Mapper`
117+
- convert unified purplship API data into a carrier specific request using the `Mapper`
118118
- send the request to the carrier using the `Proxy`
119-
- and parse back the response into a unified Purplship data using the `Mapper`
119+
- and parse back the response into a unified purplship data using the `Mapper`
120120

121121
!!! caution
122-
Note that Purplship does not raise exceptions when there is a failure during requests but rather always return
122+
Note that purplship does not raise exceptions when there is a failure during requests but rather always return
123123
a tuple of a `response` if `successful` with a list of `messages` if any **notes**, **messages** or **errors**
124124
in case of `failures` are returned.
125125

126126
## Fluent API
127127

128-
Once you understand the lifecycle above, you can send any requests supported by Purplship with the same mental model.
128+
Once you understand the lifecycle above, you can send any requests supported by purplship with the same mental model.
129129
However, this looks a little verbose. That's why we introduced a Fluent interface to handle this process with fewer lines.
130130

131131
```python

docs/development/developing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Clone the repo
66

77
```bash
8-
git clone git@github.com:Purplship/purplship.git
8+
git clone git@github.com:purplship/purplship.git
99
```
1010

1111
## Source the `bash` script

docs/development/extending.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The question we are most asked is: **How to add a custom carrier?**
44

5-
We have experimented and studied approximately ~25 shipping carriers API/web services to design the Purplship structure as is.
5+
We have experimented and studied approximately ~25 shipping carriers API/web services to design the purplship structure as is.
66

7-
The good news is that making adding a custom carrier easy fits perfectly in Purplship vision.
7+
The good news is that making adding a custom carrier easy fits perfectly in purplship vision.
88

99
!!! caution
1010
To integrate a custom carrier at this stage, you will need:
@@ -23,8 +23,8 @@ The good news is that making adding a custom carrier easy fits perfectly in Purp
2323
1. Generate Python data types from the carrier API schemas using the type generators bellow
2424
2. Package the generated data types as a library in [purplship-carriers](https://github.com/PurplShip/purplship-carriers)
2525

26-
1. Create a Purplship extension package
27-
1. Create a new Purplship extension by copying [.templates/carrier](https://github.com/PurplShip/purplship/tree/main/.templates/carrier)
26+
1. Create a purplship extension package
27+
1. Create a new purplship extension by copying [.templates/carrier](https://github.com/PurplShip/purplship/tree/main/.templates/carrier)
2828
into [extensions/[carrier-name]](https://github.com/PurplShip/purplship/tree/main/extensions)
2929

3030
2. Rename all instance for [carrier] to the appropriate carrier name you are integrating. This must be done for files
@@ -42,37 +42,37 @@ The good news is that making adding a custom carrier easy fits perfectly in Purp
4242

4343
### Extension anatomy
4444

45-
Considering the vision we aimed to achieve with Purplship, the codebase has been modularized with a clear separation of
45+
Considering the vision we aimed to achieve with purplship, the codebase has been modularized with a clear separation of
4646
concerns to decouple clearly the carrier integration from the integration abstraction. Additionally, each carrier
4747
integration is done in an isolated self-contained package.
4848

4949
As a result, we have a very modular ecosystem where one can only select the carrier integrations of interest without
5050
carrying the whole codebase.
5151

52-
**Most importantly, this flexibility allows the integration of additional carrier services under the Purplship umbrella.**
52+
**Most importantly, this flexibility allows the integration of additional carrier services under the purplship umbrella.**
5353

5454
!!! info
55-
Purplship makes shipping API integration easy for a single carrier and in a multi-carrier scenario, the benefit
55+
purplship makes shipping API integration easy for a single carrier and in a multi-carrier scenario, the benefit
5656
is exponential.
5757

5858

5959
#### Module convention
6060

61-
Two modules are required to create a Purplship extension.
61+
Two modules are required to create a purplship extension.
6262

6363
!!! abstract "`purplship.mappers.[carrier_name]`"
64-
This is where the Purplship abstract classes are implemented. Also, the Metadata require to identified
64+
This is where the purplship abstract classes are implemented. Also, the Metadata require to identified
6565
the extension is also provided there.
6666

6767
> on runtime, purplship retrieves all mappers by going trought the `purplship.mappers` modules
6868

6969
!!! abstract "`purplship.providers.[carrier_name]`"
70-
This is where the mapping between Purplship Unified API data is mapped on the carrier data type corresponding requests
70+
This is where the mapping between purplship Unified API data is mapped on the carrier data type corresponding requests
7171

7272
#### extension signature
7373

74-
The Mapper is the cornerstone of Purplship's abstraction. A `Metadata` declared at `purplship.mappers.[carrier_name].__init__`
75-
specifies the integration classes required to define a Purplship compatible extension.
74+
The Mapper is the cornerstone of purplship's abstraction. A `Metadata` declared at `purplship.mappers.[carrier_name].__init__`
75+
specifies the integration classes required to define a purplship compatible extension.
7676

7777
```text
7878
from purplship.core.metadata import Metadata
@@ -150,7 +150,7 @@ The mapper function implementations consists of instantiating carrier specific r
150150
=== "Mapper"
151151

152152
```python
153-
# Import Purplship unified API models
153+
# Import purplship unified API models
154154
from purplship.core.models import PickupRequest
155155

156156
# Import requirements from the DHL generated data types library (py-dhl)
@@ -271,7 +271,7 @@ The mapper function implementations consists of instantiating carrier specific r
271271

272272
### Generated schema data types
273273

274-
To keep to robustness and simplify the maintenance of the codebase, In Purplship, we use Python data types reflecting
274+
To keep to robustness and simplify the maintenance of the codebase, In purplship, we use Python data types reflecting
275275
the schemas of carriers we want to integrate.
276276
That said, defining every schema object's structure can be tedious, long and unproductive. Therefore, code generators
277277
are used to generate Python data types based of the schema format definition.
@@ -305,7 +305,7 @@ to define yours.
305305
#### Multi requests
306306

307307
Generally, the carrier web services expose one API endpoint to accomplish most operations describe supported by
308-
the Purplship unified interface. In some case, more than one API call are required to fulfil certain operation.
308+
the purplship unified interface. In some case, more than one API call are required to fulfil certain operation.
309309

310310
##### Abstraction
311311

docs/guide/address.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,3 @@ request = purplship.Address.validate(
9797

9898
tracking_details_list, messages = request.from_(carrier_gateway).parse()
9999
```
100-
101-
???+ check "Tracking output"
102-
103-
```python
104-
print(tracking_details_list)
105-
# [
106-
# TrackingDetails(
107-
# carrier_name="canadapost",
108-
# carrier_id="canadapost",
109-
# tracking_number="7023210039414604",
110-
# events=[
111-
# TrackingEvent(
112-
# date="2011-04-04",
113-
# description="Order information received by Canada Post",
114-
# location="",
115-
# code="INDUCTION",
116-
# time="13:34",
117-
# signatory="",
118-
# )
119-
# ],
120-
# delivered=None,
121-
# )
122-
# ]
123-
```

0 commit comments

Comments
 (0)