class App(BaseObject): """ """ __config = { "3de9977e-ee9d-4239-a27d-8d37e79accd9": OperationConfig("/labs/proxy/chain/api/v1/network/app/{id}", "read", [], []), "b2b655f5-8553-4842-81ed-ea157dfe2b57": OperationConfig("/labs/proxy/chain/api/v1/network/app/{id}", "update", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def read(cls, id, criteria=None): """ Returns objects of type App by id and optional criteria @param str id @param dict criteria @return instance of App @raise ApiException: raised an exception from the response status """ mapObj = RequestMap() if id: mapObj.set("id", id) if criteria: if (isinstance(criteria, RequestMap)): mapObj.setAll(criteria.getObject()) else: mapObj.setAll(criteria) return BaseObject.execute("3de9977e-ee9d-4239-a27d-8d37e79accd9", App(mapObj)) def update(self): """ Updates an object of type App @return App object representing the response. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("b2b655f5-8553-4842-81ed-ea157dfe2b57", self)
class Encoding(BaseObject): """ """ __config = { "4a6c5efd-f877-41cb-985f-cb8796c39368": OperationConfig("/labs/proxy/chain/api/v1/network/support/encoding", "create", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def create(cls, mapObj): """ Creates object of type Encoding @param Dict mapObj, containing the required parameters to create a new object @return Encoding of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("4a6c5efd-f877-41cb-985f-cb8796c39368", Encoding(mapObj))
class Authorize(BaseObject): """ """ __config = { "b83eeed4-1e3a-406e-bae8-5eaeb84496c9": OperationConfig("/labs/proxy/chain/api/v1/network/authorize", "create", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def create(cls, mapObj): """ Creates object of type Authorize @param Dict mapObj, containing the required parameters to create a new object @return Authorize of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("b83eeed4-1e3a-406e-bae8-5eaeb84496c9", Authorize(mapObj))
class Settle(BaseObject): """ """ __config = { "cae44157-b9e3-4c58-8514-878675a96c10": OperationConfig("/labs/proxy/chain/api/v1/network/settle", "create", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def create(cls, mapObj): """ Creates object of type Settle @param Dict mapObj, containing the required parameters to create a new object @return Settle of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("cae44157-b9e3-4c58-8514-878675a96c10", Settle(mapObj))
class TerminationInquiryRequest(BaseObject): """ """ __config = { "e3d40dd9-b110-4add-b328-929f05f88dd9" : OperationConfig("/fraud/merchant/v3/termination-inquiry", "create", [], ["PageOffset","PageLength"]), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls,mapObj): """ Creates object of type TerminationInquiryRequest @param Dict mapObj, containing the required parameters to create a new object @return TerminationInquiryRequest of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("e3d40dd9-b110-4add-b328-929f05f88dd9", TerminationInquiryRequest(mapObj))
class RetroactiveInquiryRequest(BaseObject): """ """ __config = { "ea56ec58-772c-4411-9b72-65019e6d0c77" : OperationConfig("/fraud/merchant/v3/retro/retro-list", "create", [], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls,mapObj): """ Creates object of type RetroactiveInquiryRequest @param Dict mapObj, containing the required parameters to create a new object @return RetroactiveInquiryRequest of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("ea56ec58-772c-4411-9b72-65019e6d0c77", RetroactiveInquiryRequest(mapObj))
class UserPostPath(BaseObject): """ """ __config = { "40ebb906-ebe3-4f49-8c82-e69df5a5c287" : OperationConfig("/mock_crud_server/users/{user_id}/posts", "list", [], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "http://localhost:8081") @classmethod def listByCriteria(cls,criteria=None): """ List objects of type UserPostPath @param Dict criteria @return Array of UserPostPath object matching the criteria. """ if not criteria : return BaseObject.execute("40ebb906-ebe3-4f49-8c82-e69df5a5c287", UserPostPath()) else: return BaseObject.execute("40ebb906-ebe3-4f49-8c82-e69df5a5c287", UserPostPath(criteria))
class UserPostHeader(BaseObject): """ """ __config = { "1e5446b1-24d6-4841-867c-83105e47a3b3" : OperationConfig("/mock_crud_server/users/posts", "list", ["user_id"], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "http://localhost:8081") @classmethod def listByCriteria(cls,criteria=None): """ List objects of type UserPostHeader @param Dict criteria @return Array of UserPostHeader object matching the criteria. """ if not criteria : return BaseObject.execute("1e5446b1-24d6-4841-867c-83105e47a3b3", UserPostHeader()) else: return BaseObject.execute("1e5446b1-24d6-4841-867c-83105e47a3b3", UserPostHeader(criteria))
class AcquirerContactRequest(BaseObject): """ """ __config = { "3f23a81f-ab1e-4c0e-a727-e75ad475efe6" : OperationConfig("/fraud/merchant/v3/common/contact-details", "create", [], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls,mapObj): """ Creates object of type AcquirerContactRequest @param Dict mapObj, containing the required parameters to create a new object @return AcquirerContactRequest of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("3f23a81f-ab1e-4c0e-a727-e75ad475efe6", AcquirerContactRequest(mapObj))
class RPPSPaymentValidatorAPI(BaseObject): """ """ __config = { "e32f6e1e-82fb-4628-a642-22adf19c5435": OperationConfig("/billpayAPI/v1/isRoutingValid", "create", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls, mapObj): """ Creates object of type RPPSPaymentValidatorAPI @param Dict mapObj, containing the required parameters to create a new object @return RPPSPaymentValidatorAPI of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("e32f6e1e-82fb-4628-a642-22adf19c5435", RPPSPaymentValidatorAPI(mapObj))
class AddTerminatedMerchant(BaseObject): """ """ __config = { "901c7eab-cb8b-45db-a66c-3fb0a2b00361": OperationConfig("/fraud/merchant/v3/add-merchant", "create", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls, mapObj): """ Creates object of type AddTerminatedMerchant @param Dict mapObj, containing the required parameters to create a new object @return AddTerminatedMerchant of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("901c7eab-cb8b-45db-a66c-3fb0a2b00361", AddTerminatedMerchant(mapObj))
class Sign(BaseObject): """ """ __config = { "00742795-7084-4c3e-8c80-315cb72c7d66" : OperationConfig("/labs/proxy/chain/api/v1/network/sign", "create", [], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def create(cls,mapObj): """ Creates object of type Sign @param Dict mapObj, containing the required parameters to create a new object @return Sign of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("00742795-7084-4c3e-8c80-315cb72c7d66", Sign(mapObj))
def test_execute(self): inputMap = { "Content-Type": "application/json", "a": 1, "b": "naman aggarwal %20", "id": 3 } config = OperationConfig("/user/{a}", "list", ["Content-Type"], []) metadata = OperationMetadata("0.0.1", "https://sandbox.api.mastercard.com") with patch('mastercardapicore.core.controller.Config') as mock_config: #Set Authentication to None mock_config.getAuthentication.return_value = None with self.assertRaises(APIException): content = self.controller.execute(config, metadata, inputMap) #Set Authentication to some other object mock_config.getAuthentication.return_value = "stringobject" with self.assertRaises(APIException): content = self.controller.execute(config, metadata, inputMap) with patch( 'mastercardapicore.core.controller.Session') as mock_session: response = Mock() response.content = "Some Content" response.status_code = 200 mock_session().send.return_value = response content = self.controller.execute(config, metadata, inputMap)
class RetroactiveInquiryDetailsRequest(BaseObject): """ """ __config = { "513069ab-b5e5-4fb0-9ff2-d84300f61989": OperationConfig("/fraud/merchant/v3/retro/retro-inquiry-details", "create", [], ["AcquirerId"]), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def create(cls, mapObj): """ Creates object of type RetroactiveInquiryDetailsRequest @param Dict mapObj, containing the required parameters to create a new object @return RetroactiveInquiryDetailsRequest of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("513069ab-b5e5-4fb0-9ff2-d84300f61989", RetroactiveInquiryDetailsRequest(mapObj))
class TerminationInquiryHistoryRequest(BaseObject): """ """ __config = { "fcae4efd-1761-4c7a-8058-a4cf809e12c2": OperationConfig("/fraud/merchant/v3/termination-inquiry/{IRN}", "read", [], ["PageOffset", "PageLength", "AcquirerId"]), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext()) @classmethod def read(cls, id, criteria=None): """ Returns objects of type TerminationInquiryHistoryRequest by id and optional criteria @param str id @param dict criteria @return instance of TerminationInquiryHistoryRequest @raise ApiException: raised an exception from the response status """ mapObj = RequestMap() if id: mapObj.set("id", id) if criteria: if (isinstance(criteria, RequestMap)): mapObj.setAll(criteria.getObject()) else: mapObj.setAll(criteria) return BaseObject.execute("fcae4efd-1761-4c7a-8058-a4cf809e12c2", TerminationInquiryHistoryRequest(mapObj))
class Insights(BaseObject): __config = { "query": OperationConfig("/sectorinsights/v1/sectins.svc/insights", "query", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "https://sandbox.api.mastercard.com") @staticmethod def query(criteria): return BaseObject.execute("query", Insights(criteria))
class AccountInquiry(BaseObject): __config = { "update": OperationConfig("/fraud/loststolen/v1/account-inquiry", "update", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "https://sandbox.api.mastercard.com") @staticmethod def update(criteria): return BaseObject.execute("update", AccountInquiry(criteria))
class Status(BaseObject): """ """ __config = { "ebfaec38-a69e-48c0-a366-bd8b3887cde2" : OperationConfig("/labs/proxy/chain/api/v1/network/status", "query", [], []), } def getOperationConfig(self,operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: "+operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def query(cls,criteria): """ Query objects of type Status by id and optional criteria @param type criteria @return Status object representing the response. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("ebfaec38-a69e-48c0-a366-bd8b3887cde2", Status(criteria))
class Block(BaseObject): """ """ __config = { "71bb7550-8f4d-40d6-9ec8-42c98f704d8d": OperationConfig("/labs/proxy/chain/api/v1/network/block", "list", [], ["from", "to"]), "e2929737-7620-429a-bf0d-bd3a6483a4a5": OperationConfig("/labs/proxy/chain/api/v1/network/block/{id}", "read", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def listByCriteria(cls, criteria=None): """ List objects of type Block @param Dict criteria @return Array of Block object matching the criteria. @raise ApiException: raised an exception from the response status """ if not criteria: return BaseObject.execute("71bb7550-8f4d-40d6-9ec8-42c98f704d8d", Block()) else: return BaseObject.execute("71bb7550-8f4d-40d6-9ec8-42c98f704d8d", Block(criteria)) @classmethod def read(cls, id, criteria=None): """ Returns objects of type Block by id and optional criteria @param str id @param dict criteria @return instance of Block @raise ApiException: raised an exception from the response status """ mapObj = RequestMap() if id: mapObj.set("id", id) if criteria: if (isinstance(criteria, RequestMap)): mapObj.setAll(criteria.getObject()) else: mapObj.setAll(criteria) return BaseObject.execute("e2929737-7620-429a-bf0d-bd3a6483a4a5", Block(mapObj))
class MultiplePathUserPost(BaseObject): """ """ __config = { "96c94c4d-fe46-4a70-96d2-ee0227a4690f": OperationConfig("/mock_crud_server/users/{user_id}/post/{post_id}", "list", [], []), "1f153175-4a49-4cd2-bfb2-a949351dab10": OperationConfig("/mock_crud_server/users/{user_id}/post/{post_id}", "update", [], ["testQuery"]), "7d0317ff-5d7d-427b-abd2-9df62d5becb7": OperationConfig("/mock_crud_server/users/{user_id}/post/{post_id}", "delete", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "http://localhost:8081") @classmethod def listByCriteria(cls, criteria=None): """ List objects of type MultiplePathUserPost @param Dict criteria @return Array of MultiplePathUserPost object matching the criteria. """ if not criteria: return BaseObject.execute("96c94c4d-fe46-4a70-96d2-ee0227a4690f", MultiplePathUserPost()) else: return BaseObject.execute("96c94c4d-fe46-4a70-96d2-ee0227a4690f", MultiplePathUserPost(criteria)) def update(self): """ Updates an object of type MultiplePathUserPost @return MultiplePathUserPost object representing the response. """ return BaseObject.execute("1f153175-4a49-4cd2-bfb2-a949351dab10", self) @classmethod def deleteById(cls, id, map=None): """ Delete object of type MultiplePathUserPost by id @param str id @return MultiplePathUserPost of the response of the deleted instance. """ mapObj = RequestMap() if id: mapObj.set("id", id) if map: if (isinstance(map, RequestMap)): mapObj.setAll(map.getObject()) else: mapObj.setAll(map) return BaseObject.execute("7d0317ff-5d7d-427b-abd2-9df62d5becb7", MultiplePathUserPost(mapObj)) def delete(self): """ Delete object of type MultiplePathUserPost @return MultiplePathUserPost of the response of the deleted instance. """ return BaseObject.execute("7d0317ff-5d7d-427b-abd2-9df62d5becb7", self)
class Node(BaseObject): """ """ __config = { "394e8410-1b43-45c4-a9cc-8af33c48c93e": OperationConfig("/labs/proxy/chain/api/v1/network/create", "create", [], []), "59f70f71-1980-4492-bc29-d9d3c60f5685": OperationConfig("/labs/proxy/chain/api/v1/network/invite", "create", [], []), "bcebcf67-188a-44d0-9ff0-f08718ecabae": OperationConfig("/labs/proxy/chain/api/v1/network/join", "create", [], []), "7257dc46-3f6c-4ff3-a119-da1135d4bc96": OperationConfig("/labs/proxy/chain/api/v1/network/node/{address}", "read", [], []), "fca24c6e-de8c-49e3-9cfb-166571bb8550": OperationConfig("/labs/proxy/chain/api/v1/network/node", "query", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUID) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative()) @classmethod def provision(cls, mapObj): """ Creates object of type Node @param Dict mapObj, containing the required parameters to create a new object @return Node of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("394e8410-1b43-45c4-a9cc-8af33c48c93e", Node(mapObj)) @classmethod def invite(cls, mapObj): """ Creates object of type Node @param Dict mapObj, containing the required parameters to create a new object @return Node of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("59f70f71-1980-4492-bc29-d9d3c60f5685", Node(mapObj)) @classmethod def join(cls, mapObj): """ Creates object of type Node @param Dict mapObj, containing the required parameters to create a new object @return Node of the response of created instance. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("bcebcf67-188a-44d0-9ff0-f08718ecabae", Node(mapObj)) @classmethod def read(cls, id, criteria=None): """ Returns objects of type Node by id and optional criteria @param str id @param dict criteria @return instance of Node @raise ApiException: raised an exception from the response status """ mapObj = RequestMap() if id: mapObj.set("id", id) if criteria: if (isinstance(criteria, RequestMap)): mapObj.setAll(criteria.getObject()) else: mapObj.setAll(criteria) return BaseObject.execute("7257dc46-3f6c-4ff3-a119-da1135d4bc96", Node(mapObj)) @classmethod def query(cls, criteria): """ Query objects of type Node by id and optional criteria @param type criteria @return Node object representing the response. @raise ApiException: raised an exception from the response status """ return BaseObject.execute("fca24c6e-de8c-49e3-9cfb-166571bb8550", Node(criteria))
class User(BaseObject): """ """ __config = { "3d1d0857-7e73-4534-99be-52134515f40a": OperationConfig("/mock_crud_server/users", "list", [], []), "25cf4d3e-3606-433c-8fcc-1df3813d28d5": OperationConfig("/mock_crud_server/users", "create", [], []), "7bd54cb3-740a-46a8-ba73-a7116d7fbfa5": OperationConfig("/mock_crud_server/users/{id}", "read", [], []), "fe79f3e0-b05d-44e9-a8e4-6f08dbb99964": OperationConfig("/mock_crud_server/users/{id}", "update", [], []), "32f3baaa-9757-4f56-9ed1-241756206274": OperationConfig("/mock_crud_server/users/{id}", "delete", [], []), "ff6f7de7-08fe-4dc2-8185-1f838dc96197": OperationConfig("/mock_crud_server/users200/{id}", "delete", [], []), "7223cecd-203a-47b7-85cb-3ddbf9027f33": OperationConfig("/mock_crud_server/users204/{id}", "delete", [], []), } def getOperationConfig(self, operationUUID): if operationUUID not in self.__config: raise Exception("Invalid operationUUID: " + operationUUI) return self.__config[operationUUID] def getOperationMetadata(self): return OperationMetadata("0.0.1", "http://localhost:8081") @classmethod def listByCriteria(cls, criteria=None): """ List objects of type User @param Dict criteria @return Array of User object matching the criteria. """ if not criteria: return BaseObject.execute("3d1d0857-7e73-4534-99be-52134515f40a", User()) else: return BaseObject.execute("3d1d0857-7e73-4534-99be-52134515f40a", User(criteria)) @classmethod def create(cls, mapObj): """ Creates object of type User @param Dict mapObj, containing the required parameters to create a new object @return User of the response of created instance. """ return BaseObject.execute("25cf4d3e-3606-433c-8fcc-1df3813d28d5", User(mapObj)) @classmethod def read(cls, id, criteria=None): """ Returns objects of type User by id and optional criteria @param str id @param dict criteria @return instance of User """ mapObj = RequestMap() if id: mapObj.set("id", id) if criteria: if (isinstance(criteria, RequestMap)): mapObj.setAll(criteria.getObject()) else: mapObj.setAll(criteria) return BaseObject.execute("7bd54cb3-740a-46a8-ba73-a7116d7fbfa5", User(mapObj)) def update(self): """ Updates an object of type User @return User object representing the response. """ return BaseObject.execute("fe79f3e0-b05d-44e9-a8e4-6f08dbb99964", self) @classmethod def deleteById(cls, id, map=None): """ Delete object of type User by id @param str id @return User of the response of the deleted instance. """ mapObj = RequestMap() if id: mapObj.set("id", id) if map: if (isinstance(map, RequestMap)): mapObj.setAll(map.getObject()) else: mapObj.setAll(map) return BaseObject.execute("32f3baaa-9757-4f56-9ed1-241756206274", User(mapObj)) def delete(self): """ Delete object of type User @return User of the response of the deleted instance. """ return BaseObject.execute("32f3baaa-9757-4f56-9ed1-241756206274", self) @classmethod def delete200ById(cls, id, map=None): """ Delete object of type User by id @param str id @return User of the response of the deleted instance. """ mapObj = RequestMap() if id: mapObj.set("id", id) if map: if (isinstance(map, RequestMap)): mapObj.setAll(map.getObject()) else: mapObj.setAll(map) return BaseObject.execute("ff6f7de7-08fe-4dc2-8185-1f838dc96197", User(mapObj)) def delete200(self): """ Delete object of type User @return User of the response of the deleted instance. """ return BaseObject.execute("ff6f7de7-08fe-4dc2-8185-1f838dc96197", self) @classmethod def delete204ById(cls, id, map=None): """ Delete object of type User by id @param str id @return User of the response of the deleted instance. """ mapObj = RequestMap() if id: mapObj.set("id", id) if map: if (isinstance(map, RequestMap)): mapObj.setAll(map.getObject()) else: mapObj.setAll(map) return BaseObject.execute("7223cecd-203a-47b7-85cb-3ddbf9027f33", User(mapObj)) def delete204(self): """ Delete object of type User @return User of the response of the deleted instance. """ return BaseObject.execute("7223cecd-203a-47b7-85cb-3ddbf9027f33", self)
def test_getURL(self): inputMap = { 'api': 'lostandstolen', 'version': 1, 'three': 3, 'four': 4, 'five': 5 } resourceConfig = ResourceConfig() config = OperationConfig("/fraud/{api}/v{version}/account-inquiry", "create", [], []) metadata = OperationMetadata("0.0.1", "https://sandbox.api.mastercard.com") url = self.controller.getURL(config, metadata, inputMap) #Normal URL self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/lostandstolen/v1/account-inquiry" ) self.assertEqual(3, len(inputMap)) inputMap = { 'api': 'lostandstolen', 'version': 1, 'three': 3, 'four': 4, 'five': 5 } #URL with trailing / config = OperationConfig("/fraud/{api}/v{version}/account-inquiry/", "create", [], []) url = self.controller.getURL(config, metadata, inputMap) self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/lostandstolen/v1/account-inquiry" ) self.assertEqual(3, len(inputMap)) inputMap = {'api': 'lostandstolen', 'version': 1, 'three': 3, 'id': 1} #URL with id and action delete config = OperationConfig( "/fraud/{api}/v{version}/account-inquiry/{id}", "delete", [], []) url = self.controller.getURL(config, metadata, inputMap) self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/lostandstolen/v1/account-inquiry/1" ) self.assertEqual(1, len(inputMap)) inputMap = {'api': 'lostandstolen', 'version': 1, 'three': 3, 'id': 1} #URL with id in inputMap but not in url config = OperationConfig("/fraud/{api}/v{version}/account-inquiry", "delete", [], []) url = self.controller.getURL(config, metadata, inputMap) self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/lostandstolen/v1/account-inquiry/1" ) self.assertEqual(1, len(inputMap)) inputMap = {'api': 'lostandstolen', 'version': 1, 'three': 3, 'id': 1} #URL with id in inputMap but not in url and method create config = OperationConfig("/fraud/{api}/v{version}/account-inquiry", "create", [], []) url = self.controller.getURL(config, metadata, inputMap) self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/lostandstolen/v1/account-inquiry" ) self.assertEqual(2, len(inputMap)) #Now that the key api and version are not there in map #This should raise a key error with self.assertRaises(KeyError): config = OperationConfig("/fraud/{api}/v{version}/account-inquiry", "create", [], []) url = self.controller.getURL(config, metadata, inputMap) print(url)
def test_environment(self): inputMap = [] Config.setEnvironment(Environment.SANDBOX) resourceConfig = ResourceConfig() config = OperationConfig("/fraud/#env/v1/account-inquiry", "create", [], []) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) #dafault metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) url = self.controller.getURL(config, metadata, inputMap) self.assertEqual( url, "https://sandbox.api.mastercard.com/fraud/v1/account-inquiry") #dafault Config.setEnvironment(Environment.PRODUCTION_MTF) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual( self.controller.getURL(config, metadata, inputMap), "https://api.mastercard.com/fraud/mtf/v1/account-inquiry") Config.setEnvironment(Environment.PRODUCTION_ITF) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual( self.controller.getURL(config, metadata, inputMap), "https://api.mastercard.com/fraud/itf/v1/account-inquiry") Config.setEnvironment(Environment.STAGE) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual( self.controller.getURL(config, metadata, inputMap), "https://stage.api.mastercard.com/fraud/v1/account-inquiry") Config.setEnvironment("") metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual( self.controller.getURL(config, metadata, inputMap), "https://stage.api.mastercard.com/fraud/v1/account-inquiry") Config.setEnvironment(None) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual( self.controller.getURL(config, metadata, inputMap), "https://stage.api.mastercard.com/fraud/v1/account-inquiry") Config.setEnvironment(Environment.LOCALHOST) metadata = OperationMetadata("0.0.1", resourceConfig.getHost(), resourceConfig.getContext()) self.assertEqual(self.controller.getURL(config, metadata, inputMap), "http://localhost:8081/fraud/v1/account-inquiry") Config.clearResourceConfig()
def test_getRequestObject(self): defaultHeaders = { APIController.KEY_ACCEPT: APIController.APPLICATION_JSON, APIController.KEY_CONTENT_TYPE: APIController.APPLICATION_JSON, APIController.KEY_USER_AGENT: APIController.PYTHON_SDK + "/0.0.1" } inputMap = { "param1": 1, "param2": 2, "a": "1", APIController.KEY_ACCEPT: APIController.APPLICATION_JSON, APIController.KEY_CONTENT_TYPE: APIController.APPLICATION_JSON, APIController.KEY_USER_AGENT: APIController.PYTHON_SDK + "/0.0.1" } config = OperationConfig("/fraud/api/v1/account-inquiry", "create", ['Accept', 'Content-Type', 'User-Agent'], ["a"]) metadata = OperationMetadata("0.0.1", "https://sandbox.api.mastercard.com") url = "https://sandbox.api.mastercard.com/fraud/api/v1/account-inquiry" Config.setAuthentication(None) #Create Request with inputMap request = self.controller.getRequestObject(config, metadata, inputMap) self.assertEqual(request.url, url) self.assertEqual(request.params, { APIController.KEY_FORMAT: APIController.JSON, "a": "1" }) self.assertEqual(json.loads(request.data), inputMap) self.assertEqual(request.headers, defaultHeaders) inputMap = {"param1": 1, "param2": 2, "a": "1", "b": 2} config = OperationConfig("/fraud/api/v1/account-inquiry", "list", ['Accept', 'Content-Type', 'User-Agent'], ["a", "b"]) #List Request with inputMap request = self.controller.getRequestObject(config, metadata, inputMap) self.assertEqual(request.params, { "param1": 1, "param2": 2, "a": "1", "b": 2, "Format": "JSON" }) self.assertEqual(request.data, []) self.assertEqual(request.headers, defaultHeaders) self.assertEqual(request.url, url) inputMap = {"a": "1", "b": 2} #List Request with no inputMap request = self.controller.getRequestObject(config, metadata, inputMap) self.assertEqual(request.params, {"a": "1", "b": 2, "Format": "JSON"}) self.assertEqual(request.data, []) self.assertEqual(request.headers, defaultHeaders) self.assertEqual(request.url, url)