-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DE-801] Fix invoice events structure (#40)
- Remove default collection method value - Reorganize `Invoice Event` structure: - Invoice Event is now union type - Invoice Event Data is no longer union type. Each Invoice Event has it's own invoice_data with a concrete type - Remove some redundant models
- Loading branch information
1 parent
5a03c89
commit 18f20f0
Showing
151 changed files
with
3,921 additions
and
4,161 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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
advanced_billing | ||
This file was automatically generated for Maxio by APIMATIC v3.0 ( | ||
https://www.apimatic.io ). | ||
""" | ||
from advancedbilling.api_helper import APIHelper | ||
from advancedbilling.models.apply_credit_note_event_data import ApplyCreditNoteEventData | ||
from advancedbilling.models.invoice import Invoice | ||
from advancedbilling.models.invoice_event_type import InvoiceEventType | ||
|
||
|
||
class ApplyCreditNoteEvent(object): | ||
|
||
"""Implementation of the 'Apply Credit Note Event' model. | ||
TODO: type model description here. | ||
Attributes: | ||
id (long|int): TODO: type description here. | ||
timestamp (datetime): TODO: type description here. | ||
invoice (Invoice): TODO: type description here. | ||
event_type (InvoiceEventType): TODO: type description here. | ||
event_data (ApplyCreditNoteEventData): Example schema for an | ||
`apply_credit_note` event | ||
""" | ||
|
||
# Create a mapping from Model property names to API property names | ||
_names = { | ||
"id": 'id', | ||
"timestamp": 'timestamp', | ||
"invoice": 'invoice', | ||
"event_type": 'event_type', | ||
"event_data": 'event_data' | ||
} | ||
|
||
def __init__(self, | ||
id=None, | ||
timestamp=None, | ||
invoice=None, | ||
event_type='apply_credit_note', | ||
event_data=None, | ||
additional_properties={}): | ||
"""Constructor for the ApplyCreditNoteEvent class""" | ||
|
||
# Initialize members of the class | ||
self.id = id | ||
self.timestamp = APIHelper.apply_datetime_converter(timestamp, APIHelper.RFC3339DateTime) if timestamp else None | ||
self.invoice = invoice | ||
self.event_type = event_type | ||
self.event_data = event_data | ||
|
||
# Add additional model properties to the instance | ||
self.additional_properties = additional_properties | ||
|
||
@classmethod | ||
def from_dictionary(cls, | ||
dictionary): | ||
"""Creates an instance of this model from a dictionary | ||
Args: | ||
dictionary (dictionary): A dictionary representation of the object | ||
as obtained from the deserialization of the server's response. The | ||
keys MUST match property names in the API description. | ||
Returns: | ||
object: An instance of this structure class. | ||
""" | ||
|
||
if dictionary is None: | ||
return None | ||
|
||
# Extract variables from the dictionary | ||
id = dictionary.get("id") if dictionary.get("id") else None | ||
timestamp = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestamp")).datetime if dictionary.get("timestamp") else None | ||
invoice = Invoice.from_dictionary(dictionary.get('invoice')) if dictionary.get('invoice') else None | ||
event_type = dictionary.get("event_type") if dictionary.get("event_type") else 'apply_credit_note' | ||
event_data = ApplyCreditNoteEventData.from_dictionary(dictionary.get('event_data')) if dictionary.get('event_data') else None | ||
# Clean out expected properties from dictionary | ||
for key in cls._names.values(): | ||
if key in dictionary: | ||
del dictionary[key] | ||
# Return an object of this model | ||
return cls(id, | ||
timestamp, | ||
invoice, | ||
event_type, | ||
event_data, | ||
dictionary) | ||
|
||
@classmethod | ||
def validate(cls, dictionary): | ||
"""Validates dictionary against class required properties | ||
Args: | ||
dictionary (dictionary): A dictionary representation of the object | ||
as obtained from the deserialization of the server's response. The | ||
keys MUST match property names in the API description. | ||
Returns: | ||
boolean : if dictionary is valid contains required properties. | ||
""" | ||
|
||
if isinstance(dictionary, cls): | ||
return APIHelper.is_valid_type(value=dictionary.id, | ||
type_callable=lambda value: isinstance(value, int)) \ | ||
and APIHelper.is_valid_type(value=dictionary.timestamp, | ||
type_callable=lambda value: isinstance(value, APIHelper.RFC3339DateTime)) \ | ||
and APIHelper.is_valid_type(value=dictionary.invoice, | ||
type_callable=lambda value: Invoice.validate(value), | ||
is_model_dict=True) \ | ||
and APIHelper.is_valid_type(value=dictionary.event_type, | ||
type_callable=lambda value: InvoiceEventType.validate(value)) \ | ||
and APIHelper.is_valid_type(value=dictionary.event_data, | ||
type_callable=lambda value: ApplyCreditNoteEventData.validate(value), | ||
is_model_dict=True) | ||
|
||
if not isinstance(dictionary, dict): | ||
return False | ||
|
||
return APIHelper.is_valid_type(value=dictionary.get('id'), | ||
type_callable=lambda value: isinstance(value, int)) \ | ||
and APIHelper.is_valid_type(value=dictionary.get('timestamp'), | ||
type_callable=lambda value: isinstance(value, str)) \ | ||
and APIHelper.is_valid_type(value=dictionary.get('invoice'), | ||
type_callable=lambda value: Invoice.validate(value), | ||
is_model_dict=True) \ | ||
and APIHelper.is_valid_type(value=dictionary.get('event_type'), | ||
type_callable=lambda value: InvoiceEventType.validate(value)) \ | ||
and APIHelper.is_valid_type(value=dictionary.get('event_data'), | ||
type_callable=lambda value: ApplyCreditNoteEventData.validate(value), | ||
is_model_dict=True) |
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
Oops, something went wrong.