Skip to content

Commit

Permalink
feat: Add create/update card request fields; SFTPSettings (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: ProcessOut Fountain <internal@processout.com>
  • Loading branch information
mateusz-walesiak-cko and processout-machine committed Apr 3, 2024
1 parent 013f43e commit 2462860
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 8 deletions.
1 change: 1 addition & 0 deletions processout/__init__.py
Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions processout/cardcreaterequest.py
Expand Up @@ -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))
Expand All @@ -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]
7 changes: 4 additions & 3 deletions processout/cardupdaterequest.py
Expand Up @@ -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))
Expand All @@ -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]
6 changes: 6 additions & 0 deletions processout/client.py
Expand Up @@ -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:
Expand Down
106 changes: 106 additions & 0 deletions 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]
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -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 = [],
)

0 comments on commit 2462860

Please sign in to comment.