Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions iyzipay/iyzipay_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import string

import iyzipay

from iyzipay.iyzipay_response import IyzipayResponse

class IyzipayResource:
RANDOM_STRING_SIZE = 8
RE_SEARCH_V2 = r'/v2/'
header = {
"Accept": "application/json",
"Accept": "application/json",
"Content-type": "application/json",
'x-iyzi-client-version': 'iyzipay-python-1.0.40'
}
Expand All @@ -27,7 +27,11 @@ def connect(self, method, url, options, request_body_dict=None, pki=None):
body_str = json.dumps(request_body_dict)
header = self.get_http_header(url, options, body_str, pki)
connection.request(method, url, body_str, header)
return connection.getresponse()
response = connection.getresponse()
return IyzipayResponse(
response.status,
json.loads(response.read().decode('utf-8')),
)

def get_http_header(self, url, options=None, body_str=None, pki_string=None):
random_str = self.generate_random_string(self.RANDOM_STRING_SIZE)
Expand Down Expand Up @@ -866,7 +870,7 @@ def encode(file_path):
class IyziLinkProduct(IyzipayResource):
def create(self, request, options):
return self.connect('POST', '/v2/iyzilink/products/', options, request)

def retrieve(self, request, options):
if request.get('token') is None:
raise Exception('token must be in request')
Expand All @@ -883,7 +887,7 @@ def update(self, request, options):
raise Exception('token must be in request')
token = str(request.get('token'))
return self.connect('PUT', '/v2/iyzilink/products/' + token, options, request)

def delete(self, request, options):
if request.get('token') is None:
raise Exception('token must be in request')
Expand Down
3 changes: 3 additions & 0 deletions iyzipay/iyzipay_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from collections import namedtuple

IyzipayResponse = namedtuple('IyzipayResponse', ('status', 'body'))
2 changes: 1 addition & 1 deletion samples/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

api_test = iyzipay.ApiTest().retrieve(options)

print(api_test.read().decode('utf-8'))
print(api_test.body)
2 changes: 1 addition & 1 deletion samples/approve.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

approval = iyzipay.Approval().create(request, options)

print(approval.read().decode('utf-8'))
print(approval.body)
2 changes: 1 addition & 1 deletion samples/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

cancel = iyzipay.Cancel().create(request, options)

print(cancel.read().decode('utf-8'))
print(cancel.body)
2 changes: 1 addition & 1 deletion samples/create_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

card = iyzipay.Card().create(request, options)

print(card.read().decode('utf-8'))
print(card.body)
2 changes: 1 addition & 1 deletion samples/create_limited_company_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

sub_merchant = iyzipay.SubMerchant().create(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/create_marketplace_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@

payment = iyzipay.Payment().create(request, options)

print(payment.read().decode('utf-8'))
print(payment.body)
2 changes: 1 addition & 1 deletion samples/create_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@

payment = iyzipay.Payment().create(request, options)

print(payment.read().decode('utf-8'))
print(payment.body)
2 changes: 1 addition & 1 deletion samples/create_payment_with_registered_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@

payment = iyzipay.Payment().create(request, options)

print(payment.read().decode('utf-8'))
print(payment.body)
2 changes: 1 addition & 1 deletion samples/create_pecco_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

pecco_payment = iyzipay.PeccoPayment().create(request, options)

print(pecco_payment.read().decode('utf-8'))
print(pecco_payment.body)
2 changes: 1 addition & 1 deletion samples/create_personal_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

sub_merchant = iyzipay.SubMerchant().create(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/create_private_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

sub_merchant = iyzipay.SubMerchant().create(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/create_threeds_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

threeds_payment = iyzipay.ThreedsPayment().create(request, options)

print(threeds_payment.read().decode('utf-8'))
print(threeds_payment.body)
2 changes: 1 addition & 1 deletion samples/create_user_and_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

card = iyzipay.Card().create(request, options)

print(card.read().decode('utf-8'))
print(card.body)
2 changes: 1 addition & 1 deletion samples/delete_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

card = iyzipay.Card().delete(request, options)

print(card.read().decode('utf-8'))
print(card.body)
2 changes: 1 addition & 1 deletion samples/disapprove.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

disapproval = iyzipay.Disapproval().create(request, options)

print(disapproval.read().decode('utf-8'))
print(disapproval.body)
2 changes: 1 addition & 1 deletion samples/initialize_bkm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@

bkm_initialize = iyzipay.BkmInitialize().create(request, options)

print(bkm_initialize.read().decode('utf-8'))
print(bkm_initialize.body)
2 changes: 1 addition & 1 deletion samples/initialize_checkout_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@

checkout_form_initialize = iyzipay.CheckoutFormInitialize().create(request, options)

print(checkout_form_initialize.read().decode('utf-8'))
print(checkout_form_initialize.body)
2 changes: 1 addition & 1 deletion samples/initialize_pecco.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@

pecco_initialize = iyzipay.PeccoInitialize().create(request, options)

print(pecco_initialize.read().decode('utf-8'))
print(pecco_initialize.body)
2 changes: 1 addition & 1 deletion samples/initialize_threeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@

threeds_initialize = iyzipay.ThreedsInitialize().create(request, options)

print(threeds_initialize.read().decode('utf-8'))
print(threeds_initialize.body)
2 changes: 1 addition & 1 deletion samples/refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

refund = iyzipay.Refund().create(request, options)

print(refund.read().decode('utf-8'))
print(refund.body)
2 changes: 1 addition & 1 deletion samples/retrieve_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

bin_number = iyzipay.BinNumber().retrieve(request, options)

print(bin_number.read().decode('utf-8'))
print(bin_number.body)
2 changes: 1 addition & 1 deletion samples/retrieve_bkm_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

bkm = iyzipay.Bkm().retrieve(request, options)

print(bkm.read().decode('utf-8'))
print(bkm.body)
2 changes: 1 addition & 1 deletion samples/retrieve_bounced_bank_transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

bounced_bank_transfer_list = iyzipay.BouncedBankTransferList().retrieve(request, options)

print(bounced_bank_transfer_list.read().decode('utf-8'))
print(bounced_bank_transfer_list.body)
2 changes: 1 addition & 1 deletion samples/retrieve_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

card_list = iyzipay.CardList().retrieve(request, options)

print(card_list.read().decode('utf-8'))
print(card_list.body)
2 changes: 1 addition & 1 deletion samples/retrieve_checkout_form_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

checkout_form_result = iyzipay.CheckoutForm().retrieve(request, options)

print(checkout_form_result.read().decode('utf-8'))
print(checkout_form_result.body)
2 changes: 1 addition & 1 deletion samples/retrieve_installments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

installment_info = iyzipay.InstallmentInfo().retrieve(request, options)

print(installment_info.read().decode('utf-8'))
print(installment_info.body)
2 changes: 1 addition & 1 deletion samples/retrieve_payment_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

payment = iyzipay.Payment().retrieve(request, options)

print(payment.read().decode('utf-8'))
print(payment.body)
2 changes: 1 addition & 1 deletion samples/retrieve_payout_completed_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

payout_completed_transaction_list = iyzipay.PayoutCompletedTransactionList().retrieve(request, options)

print(payout_completed_transaction_list.read().decode('utf-8'))
print(payout_completed_transaction_list.body)
2 changes: 1 addition & 1 deletion samples/retrieve_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

sub_merchant = iyzipay.SubMerchant().retrieve(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/update_limited_company_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

sub_merchant = iyzipay.SubMerchant().update(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/update_personal_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

sub_merchant = iyzipay.SubMerchant().update(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)
2 changes: 1 addition & 1 deletion samples/update_private_sub_merchant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

sub_merchant = iyzipay.SubMerchant().update(request, options)

print(sub_merchant.read().decode('utf-8'))
print(sub_merchant.body)