From 2462860717a84e5b2b74db3173d9c3dab1a929d0 Mon Sep 17 00:00:00 2001 From: Mateusz Walesiak Date: Wed, 3 Apr 2024 17:19:28 +0200 Subject: [PATCH] feat: Add create/update card request fields; SFTPSettings (#16) Co-authored-by: ProcessOut Fountain --- processout/__init__.py | 1 + processout/cardcreaterequest.py | 21 ++++- processout/cardupdaterequest.py | 7 +- processout/client.py | 6 ++ processout/projectsftpsettingspublic.py | 106 ++++++++++++++++++++++++ setup.py | 4 +- 6 files changed, 137 insertions(+), 8 deletions(-) create mode 100755 processout/projectsftpsettingspublic.py diff --git a/processout/__init__.py b/processout/__init__.py index 54458a3..c08b9b1 100644 --- a/processout/__init__.py +++ b/processout/__init__.py @@ -41,6 +41,7 @@ from processout.product import Product from processout.project import Project from processout.projectsftpsettings import ProjectSFTPSettings +from processout.projectsftpsettingspublic import ProjectSFTPSettingsPublic from processout.refund import Refund from processout.subscription import Subscription from processout.transaction import Transaction diff --git a/processout/cardcreaterequest.py b/processout/cardcreaterequest.py index 683f076..0328942 100755 --- a/processout/cardcreaterequest.py +++ b/processout/cardcreaterequest.py @@ -356,7 +356,23 @@ def create(self, options={}): request = Request(self._client) path = "/cards" data = { - + 'device': self.device, + 'name': self.name, + 'number': self.number, + 'exp_day': self.exp_day, + 'exp_month': self.exp_month, + 'exp_year': self.exp_year, + 'cvc2': self.cvc2, + 'preferred_scheme': self.preferred_scheme, + 'metadata': self.metadata, + 'token_type': self.token_type, + 'eci': self.eci, + 'cryptogram': self.cryptogram, + 'applepay_response': self.applepay_response, + 'applepay_mid': self.applepay_mid, + 'payment_token': self.payment_token, + 'contact': self.contact, + 'shipping': self.shipping } response = Response(request.post(path, data, options)) @@ -365,7 +381,6 @@ def create(self, options={}): body = response.body body = body["card"] - obj = processout.CardCreateRequest(self._client) - return_values.append(obj.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/cardupdaterequest.py b/processout/cardupdaterequest.py index a47c7ac..d48fbe9 100755 --- a/processout/cardupdaterequest.py +++ b/processout/cardupdaterequest.py @@ -91,7 +91,9 @@ def update(self, card_id, options={}): request = Request(self._client) path = "/cards/" + quote_plus(card_id) + "" data = { - + 'update_type': self.update_type, + 'update_reason': self.update_reason, + 'preferred_scheme': self.preferred_scheme } response = Response(request.put(path, data, options)) @@ -100,7 +102,6 @@ def update(self, card_id, options={}): body = response.body body = body["card"] - obj = processout.CardUpdateRequest(self._client) - return_values.append(obj.fill_with_data(body)) + return_values.append(self.fill_with_data(body)) return return_values[0] diff --git a/processout/client.py b/processout/client.py index 6540044..35cded2 100644 --- a/processout/client.py +++ b/processout/client.py @@ -267,6 +267,12 @@ def new_project_sftp_settings(self, prefill=None): prefill -- Data used to prefill the object (optional)""" return processout.ProjectSFTPSettings(self, prefill) + def new_project_sftp_settings_public(self, prefill=None): + """Create a new ProjectSFTPSettingsPublic instance + Keyword argument: + prefill -- Data used to prefill the object (optional)""" + return processout.ProjectSFTPSettingsPublic(self, prefill) + def new_refund(self, prefill=None): """Create a new Refund instance Keyword argument: diff --git a/processout/projectsftpsettingspublic.py b/processout/projectsftpsettingspublic.py new file mode 100755 index 0000000..e1446d4 --- /dev/null +++ b/processout/projectsftpsettingspublic.py @@ -0,0 +1,106 @@ +try: + from urllib.parse import quote_plus +except ImportError: + from urllib import quote_plus + +import processout +import json + +from processout.networking.request import Request +from processout.networking.response import Response + +# The content of this file was automatically generated + + +class ProjectSFTPSettingsPublic(object): + def __init__(self, client, prefill=None): + self._client = client + + self._enabled = None + self._endpoint = None + self._username = None + if prefill is not None: + self.fill_with_data(prefill) + + @property + def enabled(self): + """Get enabled""" + return self._enabled + + @enabled.setter + def enabled(self, val): + """Set enabled + Keyword argument: + val -- New enabled value""" + self._enabled = val + return self + + @property + def endpoint(self): + """Get endpoint""" + return self._endpoint + + @endpoint.setter + def endpoint(self, val): + """Set endpoint + Keyword argument: + val -- New endpoint value""" + self._endpoint = val + return self + + @property + def username(self): + """Get username""" + return self._username + + @username.setter + def username(self, val): + """Set username + Keyword argument: + val -- New username value""" + self._username = val + return self + + def fill_with_data(self, data): + """Fill the current object with the new values pulled from data + Keyword argument: + data -- The data from which to pull the new values""" + if "enabled" in data.keys(): + self.enabled = data["enabled"] + if "endpoint" in data.keys(): + self.endpoint = data["endpoint"] + if "username" in data.keys(): + self.username = data["username"] + + return self + + def to_json(self): + return { + "enabled": self.enabled, + "endpoint": self.endpoint, + "username": self.username, + } + + def fetch_sftp_settings(self, id, options={}): + """Fetch the SFTP settings for the project. + Keyword argument: + id -- ID of the project + options -- Options for the request""" + self.fill_with_data(options) + + request = Request(self._client) + path = "/projects/" + quote_plus(id) + "/sftp-settings" + data = { + + } + + response = Response(request.get(path, data, options)) + return_values = [] + + body = response.body + body = body["sftp_settings"] + + obj = processout.ProjectSFTPSettingsPublic(self._client) + return_values.append(obj.fill_with_data(body)) + + return return_values[0] diff --git a/setup.py b/setup.py index 25cb3bd..2495380 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setup( name = 'processout', packages = ['processout', 'processout.errors', 'processout.networking'], - version = '6.33.0', + version = '6.34.0', description = 'ProcessOut API bindings.', author = 'ProcessOut', author_email = 'hi@processout.com', url = 'https://github.com/processout/processout-python', - download_url = 'https://github.com/processout/processout-python/tarball/6.33.0', + download_url = 'https://github.com/processout/processout-python/tarball/6.34.0', keywords = ['ProcessOut', 'api', 'bindings'], classifiers = [], )