
"""
    This code was generated by Codezu.     

    Changes to this file may cause incorrect behavior and will be lost if
    the code is regenerated.
"""


from mozurestsdk.mozuclient import default as default_client
from mozurestsdk.mozuurl import MozuUrl;
from mozurestsdk.urllocation import UrlLocation
from mozurestsdk.apicontext import ApiContext;

class ExtendedProperty(object):
	def __init__(self, apiContext: ApiContext = None, mozuClient = None):
		self.client = mozuClient or default_client();
		if (apiContext is not None):
			self.client.withApiContext(apiContext);
		else:
			self.client.withApiContext(ApiContext());
	
	def getExtendedProperties(self,orderId, draft = False):
		""" Retrieves the extended property string associated with the order. 
		
		Args:
			| orderId (string) - Unique identifier of the order.
			| draft (bool) - If true, retrieve the draft version of the order, which might include uncommitted changes to the order or its components.
		
		Returns:
			| array of ExtendedProperty 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties?draft={draft}", "GET", UrlLocation.TenantPod, False);
		url.formatUrl("draft", draft);
		url.formatUrl("orderId", orderId);
		self.client.withResourceUrl(url).execute();
		return self.client.result();

	
		
	def addExtendedProperties(self,extendedProperties, orderId, updateMode = None, version = None):
		""" Creates an extended property for the order.
		
		Args:
			| extendedProperties(array|extendedProperties) - The details of the extended property.
			| orderId (string) - Unique identifier of the order.
			| updateMode (string) - Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
			| version (string) - Determines whether or not to check versioning of items for concurrency purposes.
		
		Returns:
			| array of ExtendedProperty 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties?updatemode={updateMode}&version={version}", "POST", UrlLocation.TenantPod, False);
		url.formatUrl("orderId", orderId);
		url.formatUrl("updateMode", updateMode);
		url.formatUrl("version", version);
		self.client.withResourceUrl(url).withBody(extendedProperties).execute();
		return self.client.result();

	
		
	def updateExtendedProperty(self,extendedProperty, orderId, key, updateMode = None, version = None, upsert = False, responseFields = None):
		""" Updates one ore more extended properties.
		
		Args:
			| extendedProperty(extendedProperty) - The details of the updated extended property.
			| orderId (string) - Unique identifier of the order.
			| key (string) - The extended property key.
			| updateMode (string) - Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
			| version (string) - Determines whether or not to check versioning of items for concurrency purposes.
			| upsert (bool) - Inserts and updates an extended property.
        
			| responseFields (string) - Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
		
		Returns:
			| ExtendedProperty 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}&upsert={upsert}&responseFields={responseFields}", "PUT", UrlLocation.TenantPod, False);
		url.formatUrl("key", key);
		url.formatUrl("orderId", orderId);
		url.formatUrl("responseFields", responseFields);
		url.formatUrl("updateMode", updateMode);
		url.formatUrl("upsert", upsert);
		url.formatUrl("version", version);
		self.client.withResourceUrl(url).withBody(extendedProperty).execute();
		return self.client.result();

	
		
	def updateExtendedProperties(self,extendedProperties, orderId, updateMode = None, version = None, upsert = False):
		""" Updates one or more extended properties.
		
		Args:
			| extendedProperties(array|extendedProperties) - The details of the updated extended properties.
			| orderId (string) - Unique identifier of the order.
			| updateMode (string) - Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
			| version (string) - Determines whether or not to check versioning of items for concurrency purposes.
			| upsert (bool) - Inserts and updates the extended property.
        
		
		Returns:
			| array of ExtendedProperty 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties?updatemode={updateMode}&version={version}&upsert={upsert}", "PUT", UrlLocation.TenantPod, False);
		url.formatUrl("orderId", orderId);
		url.formatUrl("updateMode", updateMode);
		url.formatUrl("upsert", upsert);
		url.formatUrl("version", version);
		self.client.withResourceUrl(url).withBody(extendedProperties).execute();
		return self.client.result();

	
		
	def deleteExtendedProperty(self,orderId, key, updateMode = None, version = None):
		""" Deletes one or more extended properties.
		
		Args:
			| orderId (string) - Unique identifier of the order.
			| key (string) - The extended property key.
			| updateMode (string) - Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
			| version (string) - Determines whether or not to check versioning of items for concurrency purposes.
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties/{key}?updatemode={updateMode}&version={version}", "DELETE", UrlLocation.TenantPod, False);
		url.formatUrl("key", key);
		url.formatUrl("orderId", orderId);
		url.formatUrl("updateMode", updateMode);
		url.formatUrl("version", version);
		self.client.withResourceUrl(url).execute();

	
		
	def deleteExtendedProperties(self,keys, orderId, updateMode = None, version = None):
		""" Deletes the extended property associated with the order. 
		
		Args:
			| keys(array|keys) - The extended property keys.
			| orderId (string) - Unique identifier of the order.
			| updateMode (string) - Specifies whether to update the original order, update the order in draft mode, or update the order in draft mode and then commit the changes to the original. Draft mode enables users to make incremental order changes before committing the changes to the original order. Valid values are "ApplyToOriginal," "ApplyToDraft," or "ApplyAndCommit."
			| version (string) - Determines whether or not to check versioning of items for concurrency purposes.
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/orders/{orderId}/extendedproperties?updatemode={updateMode}&version={version}", "DELETE", UrlLocation.TenantPod, False);
		url.formatUrl("orderId", orderId);
		url.formatUrl("updateMode", updateMode);
		url.formatUrl("version", version);
		self.client.withResourceUrl(url).withBody(keys).execute();

	
	
	