"""Project post request.""" from project_manager.constant.header_const import \ (GRASS_ACCOUNT_TYPE_SUBACCOUNT, GRASS_ACCOUNT_TYPE_VENDOR) class ProjectPostRequest: """Encapsulate a POST request for a project. # subaccount_id is a non-nullable subaccount_id # to enforce uniqueness. We use 0 to represent NULL. """ SUBACCOUNT_ID_NULL = 0 def __init__( self, project_code, project_name, artist_id, subaccount_id, grass_account_type, grass_account_id, correlation_id, description=None, vendor_id=None, user=None, ): """Project Post Request init method.""" self.project_code = project_code self.project_name = project_name self.artist_id = int(artist_id) self.vendor_id = None self.subaccount_id = self.SUBACCOUNT_ID_NULL self.grass_account_id = None self.grass_account_type = grass_account_type self.correlation_id = correlation_id self.description = description if subaccount_id is not None: self.subaccount_id = int(subaccount_id) if grass_account_id: self.grass_account_id = int(grass_account_id) if not self.grass_account_type: self.vendor_id = vendor_id elif self.grass_account_type == GRASS_ACCOUNT_TYPE_VENDOR: self.vendor_id = self.grass_account_id elif self.grass_account_type == GRASS_ACCOUNT_TYPE_SUBACCOUNT: self.subaccount_id = self.grass_account_id self.user = user