Skip to content

Commit

Permalink
Added DepartureComponents resource, upped version to 0.1.41
Browse files Browse the repository at this point in the history
New resource which provides detailed data about the components which make up a
purchased departure.

See official documentation for more details:
https://developers.gadventures.com/docs/departure_component.html
  • Loading branch information
bartek committed Apr 14, 2015
1 parent afc04fe commit b9fbf45
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
History
-------

0.1.41 (2015-04-14)
------------------

* Added `DepartureComponent` resource. See the [official G API documentation for details](https://developers.gadventures.com/docs/departure_component.html)

0.1.40 (2015-04-06)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion gapipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__version__ = '0.1.40'
__version__ = '0.1.41'
__title__ = 'gapipy'


Expand Down
2 changes: 2 additions & 0 deletions gapipy/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Activity,
OptionalActivity,
Departure,
DepartureComponent,
Duration,
Itinerary,
Promotion,
Expand Down Expand Up @@ -60,6 +61,7 @@
# Tour
'Accommodation', 'Activity', 'Departure', 'Itinerary', 'Promotion',
'SingleSupplement', 'Tour', 'TourCategory', 'TourDossier', 'Transport',
'DepartureComponent',

# Geographical
'Airport', 'Continent', 'Country', 'Feature', 'FeatureCategory', 'Place',
Expand Down
7 changes: 7 additions & 0 deletions gapipy/resources/booking/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from ..tour import (
Departure,
DepartureComponent,
Accommodation,
Activity,
Transport,
Expand Down Expand Up @@ -116,6 +117,12 @@ def _resource_fields(self):
('itinerary', 'Itinerary'),
])

@property
def _resource_collection_fields(self):
return super(DepartureService, self)._resource_collection_fields + [
('components', DepartureComponent),
]

@property
def _model_collection_fields(self):
return (super(DepartureService, self)._model_collection_fields + [
Expand Down
1 change: 1 addition & 0 deletions gapipy/resources/tour/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .accommodation import Accommodation
from .activity import Activity
from .departure import Departure
from .departure_component import DepartureComponent
from .itinerary import Itinerary, OptionalActivity, Duration
from .promotion import Promotion
from .single_supplement import SingleSupplement
Expand Down
32 changes: 32 additions & 0 deletions gapipy/resources/tour/departure_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import unicode_literals

from ...models.base import BaseModel
from ...utils import get_resource_class_from_resource_name
from ..base import Resource

class AssociatedDossier(BaseModel):
_as_is_fields = ["type"]
_model_fields = [
("dossier", object),
]

def _set_model_field(self, field, value):
resource_cls = get_resource_class_from_resource_name(self.type)
stub = resource_cls(value, stub=True)
setattr(self, field, stub)

class DepartureComponent(Resource):
_resource_name = 'departure_components'
_is_listable = True
_is_parent_resource = False

_as_is_fields = [
"id", "href", "name", "code", "type", "flags",
]

_date_fields = ["start_date"]
_date_time_fields_utc = ["date_created", "date_last_modified"]

_model_fields = [
("associated_dossier", AssociatedDossier),
]

0 comments on commit b9fbf45

Please sign in to comment.