Skip to content

Commit 4aede94

Browse files
Manuel HuezManuel Huez
authored andcommitted
Add InvoiceDetail and CardInformation
1 parent df2139a commit 4aede94

File tree

11 files changed

+409
-40
lines changed

11 files changed

+409
-40
lines changed

processout/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from processout.activity import Activity
66
from processout.authorizationrequest import AuthorizationRequest
77
from processout.card import Card
8+
from processout.cardinformation import CardInformation
89
from processout.coupon import Coupon
910
from processout.customer import Customer
1011
from processout.token import Token
@@ -13,6 +14,7 @@
1314
from processout.gateway import Gateway
1415
from processout.gatewayconfiguration import GatewayConfiguration
1516
from processout.invoice import Invoice
17+
from processout.invoicedetail import InvoiceDetail
1618
from processout.customeraction import CustomerAction
1719
from processout.plan import Plan
1820
from processout.product import Product

processout/card.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, client, prefill = None):
2020
self._type = None
2121
self._bank_name = None
2222
self._brand = None
23+
self._country = None
2324
self._iin = None
2425
self._last_4_digits = None
2526
self._exp_month = None
@@ -114,6 +115,19 @@ def brand(self, val):
114115
self._brand = val
115116
return self
116117

118+
@property
119+
def country(self):
120+
"""Get country"""
121+
return self._country
122+
123+
@country.setter
124+
def country(self, val):
125+
"""Set country
126+
Keyword argument:
127+
val -- New country value"""
128+
self._country = val
129+
return self
130+
117131
@property
118132
def iin(self):
119133
"""Get iin"""
@@ -222,6 +236,8 @@ def fill_with_data(self, data):
222236
self.bank_name = data["bank_name"]
223237
if "brand" in data.keys():
224238
self.brand = data["brand"]
239+
if "country" in data.keys():
240+
self.country = data["country"]
225241
if "iin" in data.keys():
226242
self.iin = data["iin"]
227243
if "last_4_digits" in data.keys():
@@ -239,4 +255,60 @@ def fill_with_data(self, data):
239255

240256
return self
241257

258+
def all(self, options = {}):
259+
"""Get all the cards.
260+
Keyword argument:
261+
262+
options -- Options for the request"""
263+
self.fill_with_data(options)
264+
265+
request = Request(self._client)
266+
path = "/cards"
267+
data = {
268+
269+
}
270+
271+
response = Response(request.get(path, data, options))
272+
return_values = []
273+
274+
a = []
275+
body = response.body
276+
for v in body['cards']:
277+
tmp = processout.Card(self._client)
278+
tmp.fill_with_data(v)
279+
a.append(tmp)
280+
281+
return_values.append(a)
282+
283+
284+
285+
return return_values[0]
286+
287+
def find(self, card_id, options = {}):
288+
"""Find a card by its ID.
289+
Keyword argument:
290+
card_id -- ID of the card
291+
options -- Options for the request"""
292+
self.fill_with_data(options)
293+
294+
request = Request(self._client)
295+
path = "/cards/" + quote_plus(card_id) + ""
296+
data = {
297+
298+
}
299+
300+
response = Response(request.get(path, data, options))
301+
return_values = []
302+
303+
body = response.body
304+
body = body["card_information"]
305+
306+
307+
obj = processout.Card(self._client)
308+
return_values.append(obj.fill_with_data(body))
309+
310+
311+
312+
return return_values[0]
313+
242314

processout/cardinformation.py

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
try:
2+
from urllib.parse import quote_plus
3+
except ImportError:
4+
from urllib import quote_plus
5+
6+
import processout
7+
8+
from processout.networking.request import Request
9+
from processout.networking.response import Response
10+
11+
# The content of this file was automatically generated
12+
13+
class CardInformation(object):
14+
def __init__(self, client, prefill = None):
15+
self._client = client
16+
17+
self._iin = None
18+
self._scheme = None
19+
self._type = None
20+
self._bank_name = None
21+
self._brand = None
22+
self._country = None
23+
if prefill != None:
24+
self.fill_with_data(prefill)
25+
26+
27+
@property
28+
def iin(self):
29+
"""Get iin"""
30+
return self._iin
31+
32+
@iin.setter
33+
def iin(self, val):
34+
"""Set iin
35+
Keyword argument:
36+
val -- New iin value"""
37+
self._iin = val
38+
return self
39+
40+
@property
41+
def scheme(self):
42+
"""Get scheme"""
43+
return self._scheme
44+
45+
@scheme.setter
46+
def scheme(self, val):
47+
"""Set scheme
48+
Keyword argument:
49+
val -- New scheme value"""
50+
self._scheme = val
51+
return self
52+
53+
@property
54+
def type(self):
55+
"""Get type"""
56+
return self._type
57+
58+
@type.setter
59+
def type(self, val):
60+
"""Set type
61+
Keyword argument:
62+
val -- New type value"""
63+
self._type = val
64+
return self
65+
66+
@property
67+
def bank_name(self):
68+
"""Get bank_name"""
69+
return self._bank_name
70+
71+
@bank_name.setter
72+
def bank_name(self, val):
73+
"""Set bank_name
74+
Keyword argument:
75+
val -- New bank_name value"""
76+
self._bank_name = val
77+
return self
78+
79+
@property
80+
def brand(self):
81+
"""Get brand"""
82+
return self._brand
83+
84+
@brand.setter
85+
def brand(self, val):
86+
"""Set brand
87+
Keyword argument:
88+
val -- New brand value"""
89+
self._brand = val
90+
return self
91+
92+
@property
93+
def country(self):
94+
"""Get country"""
95+
return self._country
96+
97+
@country.setter
98+
def country(self, val):
99+
"""Set country
100+
Keyword argument:
101+
val -- New country value"""
102+
self._country = val
103+
return self
104+
105+
106+
def fill_with_data(self, data):
107+
"""Fill the current object with the new values pulled from data
108+
Keyword argument:
109+
data -- The data from which to pull the new values"""
110+
if "iin" in data.keys():
111+
self.iin = data["iin"]
112+
if "scheme" in data.keys():
113+
self.scheme = data["scheme"]
114+
if "type" in data.keys():
115+
self.type = data["type"]
116+
if "bank_name" in data.keys():
117+
self.bank_name = data["bank_name"]
118+
if "brand" in data.keys():
119+
self.brand = data["brand"]
120+
if "country" in data.keys():
121+
self.country = data["country"]
122+
123+
return self
124+
125+
def fetch(self, iin, options = {}):
126+
"""Fetch card information from the IIN.
127+
Keyword argument:
128+
iin -- IIN of the card (first 6 digits)
129+
options -- Options for the request"""
130+
self.fill_with_data(options)
131+
132+
request = Request(self._client)
133+
path = "/iins/" + quote_plus(iin) + ""
134+
data = {
135+
136+
}
137+
138+
response = Response(request.get(path, data, options))
139+
return_values = []
140+
141+
body = response.body
142+
body = body["coupon"]
143+
144+
145+
obj = processout.CardInformation(self._client)
146+
return_values.append(obj.fill_with_data(body))
147+
148+
149+
150+
return return_values[0]
151+
152+

processout/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def new_card(self, prefill = None):
4949
prefill -- Data used to prefill the object (optional)"""
5050
return processout.Card(self, prefill)
5151

52+
def new_card_information(self, prefill = None):
53+
"""Create a new CardInformation instance
54+
Keyword argument:
55+
prefill -- Data used to prefill the object (optional)"""
56+
return processout.CardInformation(self, prefill)
57+
5258
def new_coupon(self, prefill = None):
5359
"""Create a new Coupon instance
5460
Keyword argument:
@@ -97,6 +103,12 @@ def new_invoice(self, prefill = None):
97103
prefill -- Data used to prefill the object (optional)"""
98104
return processout.Invoice(self, prefill)
99105

106+
def new_invoice_detail(self, prefill = None):
107+
"""Create a new InvoiceDetail instance
108+
Keyword argument:
109+
prefill -- Data used to prefill the object (optional)"""
110+
return processout.InvoiceDetail(self, prefill)
111+
100112
def new_customer_action(self, prefill = None):
101113
"""Create a new CustomerAction instance
102114
Keyword argument:

processout/discount.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def __init__(self, client, prefill = None):
1919
self._subscription = None
2020
self._coupon = None
2121
self._amount = None
22+
self._percent = None
2223
self._expires_at = None
2324
self._metadata = None
2425
self._sandbox = None
@@ -107,6 +108,19 @@ def amount(self, val):
107108
self._amount = val
108109
return self
109110

111+
@property
112+
def percent(self):
113+
"""Get percent"""
114+
return self._percent
115+
116+
@percent.setter
117+
def percent(self, val):
118+
"""Set percent
119+
Keyword argument:
120+
val -- New percent value"""
121+
self._percent = val
122+
return self
123+
110124
@property
111125
def expires_at(self):
112126
"""Get expires_at"""
@@ -174,6 +188,8 @@ def fill_with_data(self, data):
174188
self.coupon = data["coupon"]
175189
if "amount" in data.keys():
176190
self.amount = data["amount"]
191+
if "percent" in data.keys():
192+
self.percent = data["percent"]
177193
if "expires_at" in data.keys():
178194
self.expires_at = data["expires_at"]
179195
if "metadata" in data.keys():

0 commit comments

Comments
 (0)