Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
234 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.apis.apibase import ApiBase | ||
|
||
|
||
class ApiControlAdresse(ApiBase): | ||
def __init__(self, api_key): | ||
super(ApiControlAdresse, self).__init__(api_key, | ||
product='controladresse', entity='Adresse') | ||
super(ApiControlAdresse, self).__init__( | ||
api_key, | ||
product='controladresse', | ||
entity='Adresse') | ||
|
||
def search(self, address): | ||
payload = {'q': address} | ||
return self._get('adresses', params=payload) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.apis.apibase import ApiBase | ||
|
||
|
||
class ApiSuivi(ApiBase): | ||
def __init__(self, api_key): | ||
super(ApiSuivi, self).__init__(api_key, product='suivi', entity='Suivi') | ||
|
||
def get(self, resource, params={}): | ||
response = self._get(resource, params) | ||
|
||
if response['code'] == 'BAD_REQUEST': | ||
raise Exception(response['message']) | ||
|
||
if response['code'] == 'RESOURCE_NOT_FOUND': | ||
raise Exception(response['message']) | ||
|
||
if self.entity is None: | ||
return response | ||
|
||
return self.create_object(response, self.entity) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.apis.apibase import ApiBase | ||
|
||
|
||
class ApiTarifEnvoi(ApiBase): | ||
def __init__(self, api_key): | ||
super(ApiTarifEnvoi, self).__init__(api_key, product='tarifenvoi', entity='TarifEnvoi') | ||
|
||
def get(self, type, weight, channels=[], products=[]): | ||
params = {'type': type, | ||
'poids': weight} | ||
|
||
response = self._get('', params) | ||
response_objects = [self.create_object(r, self.entity) for r in response] | ||
|
||
if len(channels) > 0: | ||
response_objects = [response_object for response_object in response_objects if response_object.channel in [channel.value for channel in channels]] | ||
|
||
if len(products) > 0: | ||
response_objects = [response_object for response_object in response_objects if response_object.product in [product.value for product in products]] | ||
|
||
return response_objects |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from enum import Enum | ||
|
||
|
||
class TarifEnvoiTypes(Enum): | ||
letter = 'lettre' | ||
colissimo = 'colis' | ||
chronopost = 'chronopost' | ||
|
||
|
||
class TarifEnvoiProducts(Enum): | ||
green_mail = 'Lettre verte' | ||
first_class_mail = 'Lettre prioritaire' | ||
ecopli = 'Ecopli' | ||
colissimo = 'Colissimo France (« avec Signature » en option)' | ||
chronopost_10 = 'Affranchissement Chronopost Chrono 10' | ||
chronopost_13 = 'Affranchissement Chronopost Chrono 13' | ||
|
||
|
||
class TarifEnvoiChannels(Enum): | ||
post_office = 'bureau' | ||
online = 'en ligne' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#__all__ = ['adresse', 'suivi'] | ||
# -*- coding:utf-8 -*- | ||
# __all__ = ['adresse', 'suivi', 'tarifenvoi'] | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.entities.adresse import Adresse | ||
from lapostesdk.entities.suivi import Suivi | ||
from lapostesdk.entities.tarifenvoi import TarifEnvoi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.entities.base import BaseEntity | ||
|
||
|
||
class TarifEnvoi(BaseEntity): | ||
def __init__(self): | ||
self.channel = None | ||
self.currency = None | ||
self.price = None | ||
self.product = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
from lapostesdk.apis import apisuivi, apicontroladresse | ||
# -*- coding:utf-8 -*- | ||
|
||
# Standard library imports | ||
from __future__ import unicode_literals | ||
|
||
from lapostesdk.apis import apisuivi, apicontroladresse, apitarifenvoi | ||
|
||
|
||
class LaPosteApi(object): | ||
def __init__(self, api_key): | ||
self.api_key = api_key | ||
|
||
self.suivi = apisuivi.ApiSuivi(self.api_key) | ||
self.controladresse = apicontroladresse.ApiControlAdresse(self.api_key) | ||
self.tarifenvoi = apitarifenvoi.ApiTarifEnvoi(self.api_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters