Skip to content

Commit

Permalink
Add semantic type and age range to discount (#115)
Browse files Browse the repository at this point in the history
* Add semantic type and age range to discount

* Fix syntax error

* Changelog and version update
  • Loading branch information
joegrimeringresso committed Aug 22, 2022
1 parent 7754fde commit 187aa97
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.12.0] - 2022-08-22
### Added
- Add semantic type to discounts

## [2.11.1] - 2022-07-15
### Added
- Added new media types
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -64,10 +64,10 @@
#
# The short X.Y version.

version = '2.11.1'
version = '2.12.0'

# The full version, including alpha/beta/rc tags.
release = '2.11.1'
release = '2.12.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyticketswitch/__init__.py
@@ -1,4 +1,4 @@
from pyticketswitch.client import Client # NOQA


__version__ = "2.11.1"
__version__ = "2.12.0"
12 changes: 12 additions & 0 deletions pyticketswitch/discount.py
Expand Up @@ -21,6 +21,9 @@ class Discount(SeatPricingMixin, JSONMixin, object):
predicted commission for the partner.
disallowed_seat_nos (list): a list of seat numbers, that this discount
code cannot be specified for.
semantic_type: a mapping of the code to a meaning e.g. standard (adult) or child
minimum_eligible_age: the youngest one can be to qualify for this ticket
maximum_eligible_age: the oldest one can be to qualify for this ticket
"""

def __init__(
Expand All @@ -36,6 +39,9 @@ def __init__(
user_commission=None,
disallowed_seat_nos=None,
tax_component=None,
semantic_type=None,
minimum_eligible_age=None,
maximum_eligible_age=None,
*args,
**kwargs
):
Expand All @@ -51,6 +57,9 @@ def __init__(
self.user_commission = user_commission
self.disallowed_seat_nos = disallowed_seat_nos
self.tax_component = tax_component
self.semantic_type = semantic_type
self.minimum_eligible_age = semantic_type
self.maximum_eligible_age = semantic_type

@classmethod
def from_api_data(cls, data):
Expand Down Expand Up @@ -89,6 +98,9 @@ def from_api_data(cls, data):
'absolute_saving': data.get('absolute_saving'),
'gross_commission': gross_commission,
'user_commission': user_commission,
'semantic_type': data.get('discount_semantic_type'),
'minimum_eligible_age': data.get('discount_minimum_eligible_age'),
'maximum_eligible_age': data.get('discount_maximum_eligible_age'),
}

tax_component = data.get('sale_combined_tax_component')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='pyticketswitch',
version='2.11.1',
version='2.12.0',
author='Ingresso',
author_email='systems@ingresso.co.uk',
url='https://github.com/ingresso-group/pyticketswitch/',
Expand Down
6 changes: 5 additions & 1 deletion tests/test_discount.py
Expand Up @@ -31,7 +31,10 @@ def test_from_api_data(self):
'number_available': 6,
'predicted_gross_commission': gross_commission_data,
'predicted_user_commission': user_commission_data,
'sale_combined_tax_component': 50
'sale_combined_tax_component': 50,
'discount_semantic_type': 'senior',
'discount_minimum_eligible_age': 60,
'discount_maximum_eligible_age': 80,
}

discount = Discount.from_api_data(data)
Expand All @@ -55,6 +58,7 @@ def test_from_api_data(self):
assert discount.user_commission.excluding_vat == user_commission_data['amount_excluding_vat']
assert discount.user_commission.currency_code == user_commission_data['commission_currency_code']
assert discount.tax_component == 50
assert discount.semantic_type == 'senior'

def test_from_api_data_without_commission(self):
data = {
Expand Down

0 comments on commit 187aa97

Please sign in to comment.