{ "info": { "author": "Inspetor Dev Team", "author_email": "dev@useinspetor.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "\n

\n \"Inspetor \n

\n\n# Inspetor Antifraud\nInspetor Antifraud library for Python.\n\n## Description\nThis README file should help you to integrate the Inspetor Python library into your product.\n\n## Setup Guide\nThis is the step-by-step Inspetor integration:\n\n### PyPI\nPyPI is the largest Python package repository there is and it's common to install python libraries with the \"pip install\" command. To install our library, you need to use the following command:\n```\npip install inspetor\n```\nIf you get no errors, you'll be able to see the Inspetor version installed using the \"pip freeze\" command (which will show every library you've installed in your environment). \n\n### Library setup\nNow, you're almost able to call the library from inside your code. But first, you need to set some **configuration** values (app id, tracker name, and dev env):\n```\n inspetor_config = {\n \"APP_ID\": \"123\",\n \"TRACKER_NAME\": \"123\",\n \"DEV_ENV\": True\n }\n```\n\nThe ***APP_ID*** is a unique identifier that the Inspetor Team will provide you when you start the paid integration with us. The ***TRACKER_NAME*** is a name that will help us find your data in our database and we'll provide you a couple of them. Lastly, ***DEV_ENV*** is a boolean statement that you set to inform if you want to use the development or production environment. It's false by default. \n\nWe **strongly** recommend you to create an Inspetor class in your code to start our library. That's where you're going to insert the Inspetor config you wrote and, with that, retrieve our client. Confusing? Relax, we're kind enough to show you how to do it.\n\n```\nimport inspetor\n\n\nclass InspetorClass:\n\n def __init__(self):\n \"\"\"\n Let's instantiate the library!\n \"\"\"\n self.inspetor = inspetor.InspetorClient(inspetor_config)\n\n def get_client(self):\n \"\"\"\n return object of type InspetorClient\n \"\"\"\n return self.inspetor\n ...\n```\n\nNow, wherever you need to call some Inspetor function, you just need to import this Class and _voil\u00e0_.\n\n*P.S.: you can place your inspetor_config dictionary wherever you think is better - it could be just before instantiating InspetorClient or into a config file that you include in this class.*\n\n### Library Calls\n\nIf you've already read the [general Inspetor documentation](https://inspetor.github.io/docs-backend/#introduction), you should be aware of all of Inspetor requests and trackers, so our intention here is just to show you how to use the Python version of some of them.\n\nLet's imagine that you want to put a tracker in your *\"create transaction\"* flow to send data to Inspetor. First, you need to create an `InspetorSale` object (you can find more about Inspetor objects [here](https://inspetor.github.io/docs-backend/#models)) and then pass this object as an argument to the function `track_inspetor_sale_creation`.\n\nHere is the snippet of the example above:\n\n```\nfrom niceCompany.inspetor.inspetor_class import InspetorClass;\n\n\nclass Sale:\n ...\n\n def some_company_function(self):\n \"\"\"\n company_sale is an example object you might have in your code, which contains sale data\n \"\"\"\n inspetor_sale = self.inspetor_sale_builder(company_sale)\n\n self.inspetor = InspetorClass()\n\n if inspetor_sale is not None:\n inspetor.get_client.track_sale_creation(inspetor_sale)\n\n def inspetor_sale_builder(self, company_sale):\n\n model = inspetor.get_client.get_inspetor_sale()\n\n model.id(company_sale.get_id());\n model.account_id(company_sale.user_id)\n model.status(company_sale.sale_status);\n model.is_fraud(company_sale.fraud);\n model....\n\n return model\n ...\n```\n\nFollowing this code and assuming you've built your model with all the required parameters (find out each Model's required parameters [here](https://inspetor.github.io/docs-backend/#models)), whenever `some_company_function` runs, the Inspetor code inside will send the information about the transaction to Inspetor.\n\nWe're using an auxiliary function `inspetor_sale_builder` to build the *Sale Model object* but you could do it differently and place it where it suits your needs better. You could set this `inspetor_sale_builder` inside your `InspetorClass` that we talked about some lines above, for example. There are some more tips in the [Best Practices & Tips](#best-practices-&-tips) section.\n\n### Models\n\nThe last snippet was a simple example to show how you should call our library and use our models. But now we're gonna talk about all of our Models, hoping you understand that some of them are not tracked themselves but they're needed inside others. Take a look!\n\n\n***Principal models***:\n- **Auth**: model you fill with ***login*** or ***logout*** data.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_auth = self.inspetor.get_inspetor_auth()\n\n \"\"\"\n Filling model with auth data\n \"\"\"\n inspetor_auth.account_email = \"test@email.com\"\n inspetor_auth.account_id = \"123\" # you need only to pass the account_id if the login is successful\n inspetor_auth.timestamp = datetime.timestamp(datetime.now())\n```\n\n- **Account**: model you fill with your ***user*** data. Account has `address` and `billing_address` as two non-required values and both are built with an object of the `InspetorAddress` Model type.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_account = self.inspetor.get_inspetor_account();\n\n \"\"\"\n Filling model with account data\n \"\"\"\n inspetor_account.id = \"123\"\n inspetor_account.name = \"Test\"\n inspetor_account.email = \"test@email.com\"\n inspetor_account.document = \"12312312312\"\n inspetor_account.phoneNumber = \"112345678\"\n inspetor_account.address = inspetor_account_address\n inspetor_account.timestamp = datetime.timestamp(datetime.now())\n```\n\n- **Event**: model you fill with your ***event*** data (e.g. a party or forum info). The `address` is required here, so you **must** instantiate an `InspetorAddress` Model object for an Event.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_event = self.inspetor.get_inspetor_event()\n\n \"\"\"\n Filling the model with event data\n \"\"\"\n inspetor_event.id = \"123\"\n inspetor_event.name = \"Name Test\"\n inspetor_event.description = \"Description Test\"\n inspetor_event.sessions = [\n inspetor_event_session1,\n inspetor_event_session1\n ]\n inspetor_event.status = inspetor_event.PRIVATE_STATUS\n inspetor_event.slug = \"slug-test\"\n inspetor_event.creator_id = \"124\"\n inspetor_event.is_physical = True\n inspetor_event.categories = [\n inspetor_event_category1,\n inspetor_event_category2\n ]\n inspetor_event.address = inspetor_event_address\n inspetor_event.admins_id = [\"123\"]\n inspetor_event.seating_options = [\"Seating Option\"]\n inspetor_event.timestamp = datetime.timestamp(datetime.now())\n```\n\n- **PassRecovery**: model that must contain data from a ***password recovery*** or ***password reset*** request in your API.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_pass = self.inspetor.get_inspetor_pass_recovery()\n\n \"\"\"\n Filling model with password recovery data\n \"\"\"\n inspetor_pass.recovery_email = \"test@email.com\"\n inspetor_pass.timestamp = datetime.timestamp(datetime.now())\n```\n\n- **Sale**: model that should be filled with ***sale*** data. The sale status has a fixed list of allowed values :\n - \"accepted\" but you can use the Sale const like `Sale.ACCEPTED_STATUS`\n - \"rejected\" but you can use the Sale const like `Sale.REJECTED_STATUS`\n - \"pending\" but you can use the Sale const like `Sale.PENDING_STATUS`\n - \"refunded\" but you can use the Sale const like `Sale.REFUNDED_STATUS`\n - \"manual_analysis\" but you can use the Sale const like `Sale.MANUAL_ANALYSIS_STATUS`\n```\n\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_sale = self.inspetor.get_inspetor_sale()\n\n \"\"\"\n Filling model with sale data\n \"\"\"\n inspetor_sale.id = \"123\"\n inspetor_sale.account_id = \"456\"\n inspetor_sale.total_value = \"123,00\"\n inspetor_sale.status = inspetor_sale.PENDING_STATUS\n inspetor_sale.timestamp = datetime.timestamp(datetime.now())\n inspetor_sale.items = [\n self.get_default_item()\n ]\n inspetor_sale.payment = inspetor_payment\n```\n\n- **Transfer**: model you fill with the ***transference*** data of an item (e.g. transfer of a ticket). The transfer status has fixed allowed values:\n - \"accepted\" but you can use the Transfer const like `Transfer.ACCEPTED_STATUS`\n - \"rejected\" but you can use the Transfer const like `Transfer.REJECTED_STATUS`\n - \"pending\" but you can use the Transfer const like `Transfer.PENDING_STATUS`\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_transfer = self.inspetor.get_inspetor_transfer()\n\n \"\"\"\n Filling model with transfer data\n \"\"\"\n inspetor_transfer.id = \"123\"\n inspetor_transfer.timestamp = datetime.timestamp(datetime.now())\n inspetor_transfer.item_id = \"123\"\n inspetor_transfer.sender_account_id = \"123\"\n inspetor_transfer.receiver_email = \"test@email.com\"\n inspetor_transfer.status = inspetor_transfer.PENDING_STATUS \n```\n\n***Auxiliar models***:\n- **Address**: this model appears inside `InspetorAccount` and `InspetorEvent` models and should be filled with data for a ***user***, a ***credit card*** or an ***event***.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_address = self.inspetor.get_inspetor_address()\n\n \"\"\"\n Filling model with address data\n \"\"\"\n inspetor_address.street = \"Test Street\"\n inspetor_address.number = \"123\"\n inspetor_address.zip_code = \"123456\"\n inspetor_address.city = \"Test City\"\n inspetor_address.state = \"Test State\"\n inspetor_address.country = \"Test Country\"\n inspetor_address.latitude = \"123\"\n inspetor_address.longitude = \"123\"\n```\n- **CreditCard**: when your API processes a payment done with a credit card, this model will be used. It should be filled with the ***buyer's creditcard*** secure data. \n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_cc = self.inspetor.get_inspetor_card()\n\n \"\"\"\n Filling model with credit card data\n \"\"\"\n credit_card.first_six_digits = \"123456\"\n credit_card.last_four_digits = \"1234\"\n credit_card.holder_name = \"Holder Name Test\"\n credit_card.holder_cpf = \"Holder CPF Test\"\n credit_card.billing_address = inspetor_billing_address\n```\n\n- **Item**: when someone buys a ***ticket***, for instance, this Model will be instantiated and filled with that ticket data.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_item = self.inspetor.get_inspetor_item()\n\n \"\"\"\n Filling model with item data\n \"\"\"\n inspetor_item.id = \"123\"\n inspetor_item.event_id = \"123\"\n inspetor_item.session_id = \"123\"\n inspetor_item.seating_option = \"Seating Option Test\"\n inspetor_item.price = \"10\"\n inspetor_item.quantity = \"123\"\n```\n\n- **Payment**: this Model holds the ***transaction*** data (e.g. payment method or installments). The payment status has fixed allowed values:\n - \"credit_card\" but you can use the Payment const like `Payment.CREDIT_CARD`\n - \"boleto\" but you can use the Payment const like `Payment.BOLETO`\n - \"other\" but you can use the Payment const like `Payment.OTHER_METHOD`\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_payment = self.inspetor.get_inspetor_payment()\n\n \"\"\"\n Filling model with payment data\n \"\"\"\n inspetor_payment.id = \"123\"\n inspetor_payment.method = inspetor_payment.CREDIT_CARD\n inspetor_payment.installments = \"1\"\n inspetor_payment.credit_card = inspetor_credit_card\n```\n\n - **Session**: model you fill with ***event date session*** data.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_session = self.inspetor.get_inspetor_session()\n\n \"\"\"\n Filling model with session data\n \"\"\"\n inspetor_session.id = \"123\"\n inspetor_session.datetime = int(1562934682) # it's the date of that event session in unix timestamp format\n```\n\n - **Category**: model you fill with ***event category*** data. In an event context it could be, for instance, \"Show\", \"Lecture\", \"Art Exposition\", etc.\n```\n \"\"\"\n Calling an instance of Model\n \"\"\"\n inspetor_category = self.inspetor.get_inspetor_category()\n\n \"\"\"\n Filling model with category data\n \"\"\"\n inspetor_category.id = \"123\"\n inspetor_category.name = \"Cooltegory\"\n```\n\n### What you should notice\nNot all of the Model's attributes are required but we deeply recommend you try to pass them all. On the other hand, some of them are **super important** and you should pass it correctly. Let's talk about some of them.\n - Sale:\n - ***is_fraud***: it's an attribute that you **must** pass to indicate if a sale is fraudulent or not, even if it's something that we're providing to you (as part of postback process).\n - Event:\n - ***sessions***: it's an attribute that you **must** pass even if you don't use the session's context. If that is the case, you just need to replicate some of your Event attributes, such as *event_id* and *event_date*, for example.\n - Address:\n - ***almost all fields***: address is **only required** when you try to track an Event, but exists in the Account model as well. \n - CreditCard:\n - ***all fields***: all of them are requested if you set the `payment_method` as \"credit_card\", so pay attention to that.\n - Common requests:\n - ***timestamp***: some Models have setters and getters for this, as you can see in the general files, and you must provide us a UTC Unix timestamp.\n\n### Best Practices & Tips\nIn this part, we decided to share some nice practices we've discovered during development time and should help you with a cleaner integration.\n\n - **InspetorClass**: we already told you about that but we think it's important for a cleaner integration. With this class, you don't need to pass your config every time and it creates a layer between our application and yours, where you can, for instance, create functions as *model builders* (we've already talked about that too) to keep all builders in one place. Here's a snippet of an `InspetorClass` with an example of *builder*.\n```\nimport inspetor\n\nclass InspetorClass:\n\n def __init__(self):\n \"\"\"\n Let's instantiate this awesome library!\n \"\"\"\n self.inspetor = InspetorClient(inspetor_config)\n\n def get_client(self):\n \"\"\"\n return object of type InspetorClient\n \"\"\"\n return self.inspetor\n\n def inspetor_auth_builder(self, auth_data) {\n \"\"\"\n param array auth_data\n return object of type Inspetor.Model.Auth\n \"\"\"\n inspetor_auth = self.get_client.get_inspetor_auth()\n inspetor_auth.account_email = auth_data.user_email\n inspetor_auth.account_id = auth_data.account_id_login\n inspetor_auth.timestamp = datetime.timestamp(datetime.now())\n\n return inspetor_auth\n ...\n```\n\n### Conclusion\nWOW! It was lovely to work with you, my friend. We truly hope that our instructions were clear and effective. If you have any suggestions or find any bugs please feel free to contact us [here](mailto:dev@useinspetor.com).\n\nNow you're invited to join our army against fraud 'cause ***STEALING IS BULLSHIT***!\n\n*DPCL (dope cool)*\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pypa/sampleproject", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "inspetor", "package_url": "https://pypi.org/project/inspetor/", "platform": "", "project_url": "https://pypi.org/project/inspetor/", "project_urls": { "Homepage": "https://github.com/pypa/sampleproject" }, "release_url": "https://pypi.org/project/inspetor/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Inspetor Antifraud library for Python.", "version": "0.0.3" }, "last_serial": 5787675, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "9d355ca32bb963abd518dfcb9d3221e0", "sha256": "5179c34e73ac33843171b8513b231427111f1f9c8d8ef2dd82179f85f3bd44a5" }, "downloads": -1, "filename": "inspetor-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9d355ca32bb963abd518dfcb9d3221e0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 31403, "upload_time": "2019-08-06T23:30:49", "url": "https://files.pythonhosted.org/packages/5a/6c/735864f3ef867daed544597b255f0f8247f27faa813ebeb294a73630aa6d/inspetor-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "974e7cdca0497e459a3f671e1dff4a78", "sha256": "383a57c28a6c8c8059b43a5f15a83e1c4abe4c7956e20b3b192265bc6aa5025a" }, "downloads": -1, "filename": "inspetor-0.0.2.tar.gz", "has_sig": false, "md5_digest": "974e7cdca0497e459a3f671e1dff4a78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12773, "upload_time": "2019-08-06T23:30:50", "url": "https://files.pythonhosted.org/packages/7e/99/36517089da25385f7a60f3ca41f14ee8e03768bd489cace5c3e2d5ec097b/inspetor-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "241c549f59ac5065f34fa0a12029f2b3", "sha256": "9aef171f662e2fee97e7a739de08859cb6fc94f305343f6be3e78b4c6bbf20e6" }, "downloads": -1, "filename": "inspetor-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "241c549f59ac5065f34fa0a12029f2b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 42777, "upload_time": "2019-09-05T17:41:55", "url": "https://files.pythonhosted.org/packages/54/a9/a08b3e743b8d3b9c9795c5b5e5e161c12b84f4210b0f531a2189f1095648/inspetor-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01e17fde9e09df491ff783d8a1478a50", "sha256": "51a818439d3606c3c9ecfc66fb25d4af352ec50d3aa120292dec48202043ef89" }, "downloads": -1, "filename": "inspetor-0.0.3.tar.gz", "has_sig": false, "md5_digest": "01e17fde9e09df491ff783d8a1478a50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21658, "upload_time": "2019-09-05T17:41:56", "url": "https://files.pythonhosted.org/packages/62/c3/1fb3f3e827f65d64a840333c0e3d86d3497f497d43290b60af65842e30db/inspetor-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "241c549f59ac5065f34fa0a12029f2b3", "sha256": "9aef171f662e2fee97e7a739de08859cb6fc94f305343f6be3e78b4c6bbf20e6" }, "downloads": -1, "filename": "inspetor-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "241c549f59ac5065f34fa0a12029f2b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 42777, "upload_time": "2019-09-05T17:41:55", "url": "https://files.pythonhosted.org/packages/54/a9/a08b3e743b8d3b9c9795c5b5e5e161c12b84f4210b0f531a2189f1095648/inspetor-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01e17fde9e09df491ff783d8a1478a50", "sha256": "51a818439d3606c3c9ecfc66fb25d4af352ec50d3aa120292dec48202043ef89" }, "downloads": -1, "filename": "inspetor-0.0.3.tar.gz", "has_sig": false, "md5_digest": "01e17fde9e09df491ff783d8a1478a50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21658, "upload_time": "2019-09-05T17:41:56", "url": "https://files.pythonhosted.org/packages/62/c3/1fb3f3e827f65d64a840333c0e3d86d3497f497d43290b60af65842e30db/inspetor-0.0.3.tar.gz" } ] }