From 2ccc838b1193db78e153766968122011bd9666f5 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 29 Jul 2025 13:23:34 +0330 Subject: [PATCH 01/38] fallah --- apps/pg/admin.py | 10 +++++---- apps/pg/models.py | 34 ++++++++++++++++++++++++++++++ main/settings.py | 6 +++--- utils/exceptions.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ utils/i18n.py | 14 +++++++++++++ 5 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 utils/exceptions.py create mode 100644 utils/i18n.py diff --git a/apps/pg/admin.py b/apps/pg/admin.py index cf2eea9..dbde3ff 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -3,13 +3,15 @@ from .models import PaymentRequest, PNA, Fake class PNAAdmin(admin.ModelAdmin): - list_display = ['pna_status_code', 'pna_status_message', 'created_at', 'payment_request'] + list_display = ['pna_status_code', 'pna_status_message', 'jajali_datetime', 'payment_request'] + list_filter = ['pna_status'] + search_fields = ['pna_status_code', 'pna_status_message'] class PaymentRequestAdmin(admin.ModelAdmin): - list_display = ['state', 'uuid', 'amount', 'user_id', 'created_at', 'application', 'gateway'] - search_fields = ['application__uuid','application__client_id', 'amount'] - list_filter = ['application', 'state'] + list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'application', 'gateway'] + search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] + list_filter = ['application', 'state', 'gateway'] class FakeAdmin(admin.ModelAdmin): diff --git a/apps/pg/models.py b/apps/pg/models.py index 040e488..8530291 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -1,6 +1,7 @@ import urllib.parse from mimetypes import guess_all_extensions +import jdatetime from django.conf import settings from django.contrib import messages from django.db import models @@ -43,6 +44,28 @@ class PaymentRequest(models.Model): created_at = models.DateTimeField(auto_now_add=True, db_index=True) updated_at = models.DateTimeField(auto_now=True, db_index=True) + @property + def splited_amount(self): + def amount_split_3digit(value): + text = str(value)[::-1] + return ','.join([l[::-1] for l in [text[i:i + 3] for i in range(0, len(text), 3)][::-1]]) + + if self.amount: + amount_str = amount_split_3digit(str(self.amount)) + return amount_str + return + + @property + def jajali_datetime(self): + def to_jalali(value): + if value: + return jdatetime.datetime.fromgregorian(date=value, locale='fa_IR').strftime("%Y/%m/%d-%H:%M:%S") + else: + return value + + return to_jalali(self.created_at) + + def get_gateway_tools(self): if self.gateway == GatewayChoise.PNA: return PNA.objects.get(payment_request=self) @@ -155,6 +178,17 @@ class PNA(BasePGModel): client = PNAClient() + @property + def jajali_datetime(self): + def to_jalali(value): + if value: + return jdatetime.datetime.fromgregorian(date=value, locale='fa_IR').strftime("%Y/%m/%d-%H:%M:%S") + else: + return value + + return to_jalali(self.created_at) + + def make_request(self): self.payment_request.change_state(StateChoices.CREATED, StateChoices.IPG_PENDING, 'can not change state') amount = self.payment_request.amount diff --git a/main/settings.py b/main/settings.py index fa0e768..d49bd35 100644 --- a/main/settings.py +++ b/main/settings.py @@ -61,13 +61,14 @@ MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', - # 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'utils.i18n.ForceAdminLanguageMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'oauth2_provider.middleware.OAuth2TokenMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - + 'utils.exceptions.ErrorMiddleware', ] OAUTH2_PROVIDER_APPLICATION_MODEL = "gooyal_oauth2.Application" @@ -144,7 +145,6 @@ DATABASES = { 'HOST': config('DB_HOST', '127.0.0.1'), 'PORT': config('DB_PORT', ''), } - } # Password validation diff --git a/utils/exceptions.py b/utils/exceptions.py new file mode 100644 index 0000000..28a4f95 --- /dev/null +++ b/utils/exceptions.py @@ -0,0 +1,50 @@ +import logging + +from rest_framework.exceptions import APIException +from rest_framework.views import exception_handler as drf_exception_handler + +logger = logging.getLogger(__name__) +def exception_handler(exc, context): + # پاسخ پیش‌فرض DRF را دریافت می‌کنیم + response = drf_exception_handler(exc, context) + + if response is not None: + # ساختار دلخواه خود را تعریف می‌کنیم + response_data = { + 'success': False, + 'status_code': response.status_code, + 'message': 'An error occurred', + 'details': {} + } + + if isinstance(exc, APIException): + response_data['message'] = exc.detail if isinstance(exc.detail, str) else "Validation error" + response_data['details'] = exc.detail if isinstance(exc.detail, dict) else {} + + response.data = response_data + + return response + + +# در فایل middleware.py +from django.http import JsonResponse + +class ErrorMiddleware: + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + response = self.get_response(request) + return response + + def process_exception(self, request, exception): + logger.exception(exception) + return JsonResponse( + { + "success": False, + "status_code": 500, + "message": "Internal server error", + "details": str(exception) # فقط در حالت توسعه! در تولید بهتر است لاگ شود. + }, + status=500 + ) \ No newline at end of file diff --git a/utils/i18n.py b/utils/i18n.py new file mode 100644 index 0000000..fe38f0d --- /dev/null +++ b/utils/i18n.py @@ -0,0 +1,14 @@ +from django.utils import translation + +class ForceAdminLanguageMiddleware: + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + if request.path.startswith('/admin/'): + translation.activate('fa') + request.LANGUAGE_CODE = 'fa' + else: + translation.activate('fa') + request.LANGUAGE_CODE = 'fa' + return self.get_response(request) \ No newline at end of file From b410078649ab14da738f8c39727eb1a2662a76d1 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sat, 9 Aug 2025 12:29:50 +0330 Subject: [PATCH 02/38] new templates --- apps/pg/models.py | 14 +- apps/pg/views.py | 8 +- main/settings.py | 6 +- static/css/datetimepicker.css | 34 +++ static/js/datetimepicker.js | 396 ++++++++++++++++++++++++++++++ templates/admin/input_filter.html | 15 ++ templates/pg/payment_failure.html | 179 ++++++++++++++ templates/pg/payment_success.html | 175 +++++++++++++ 8 files changed, 821 insertions(+), 6 deletions(-) create mode 100644 static/css/datetimepicker.css create mode 100644 static/js/datetimepicker.js create mode 100644 templates/admin/input_filter.html create mode 100644 templates/pg/payment_failure.html create mode 100644 templates/pg/payment_success.html diff --git a/apps/pg/models.py b/apps/pg/models.py index 8530291..b7f9615 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -91,6 +91,15 @@ class PaymentRequest(models.Model): self.save() + @property + def reference_number(self): + pna = PNA.objects.filter(payment_request=self).first() + if pna: + return pna.pk + + else: + return '00000000' + # TODO: complete and use this def change_state(self, from_state, to_state, error_message=None, **data): if self.state == from_state: @@ -222,7 +231,7 @@ class PNA(BasePGModel): def confirm_request(self, request=None): if self.payment_request.state not in [StateChoices.IPG_PENDING]: messages.error(request, "وضعیت تراکنش در حالت مناسبی نیست.") - return + return False, "وضعیت تراکنش در حالت مناسبی نیست." print(dict(request.POST)) post_dict = dict(request.POST) @@ -246,13 +255,16 @@ class PNA(BasePGModel): self.payment_request.charge_wallet_balance() messages.success(request, 'شارژ انجام شد') + return True, 'شارژ انجام شد' except Exception as e: print(e) messages.error(request, str(e)) + return False, "خطایی رخ داده است." else: print(request.POST) messages.error(request, "نتیجه تراکنش از سمت درگاه دریافت نشد.") + return False, "نتیجه تراکنش از سمت درگاه دریافت نشد." def reverse_request(self): raise NotImplementedError() diff --git a/apps/pg/views.py b/apps/pg/views.py index 4816098..79d51e5 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -83,7 +83,8 @@ class PaymentRequestView(UpdateView): @method_decorator(csrf_exempt, name='dispatch') class PaymentConfirmView(UpdateView): - template_name = 'pg/payment-confirm.html' + template_name = 'pg/payment_failure.html' + # template_name = 'pg/payment_success.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' slug_field = 'uuid' @@ -118,8 +119,11 @@ class PaymentConfirmView(UpdateView): return response tool = self.object.get_gateway_tools() - tool.confirm_request(request) + state, message = tool.confirm_request(request) + if state: + self.template_name = 'pg/payment_success.html' context = self.get_context_data(object=self.object) + context['message'] = message return self.render_to_response(context) diff --git a/main/settings.py b/main/settings.py index d49bd35..edd86e3 100644 --- a/main/settings.py +++ b/main/settings.py @@ -244,6 +244,6 @@ CACHES = { } } -PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') -WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') -IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') +PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') +WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') +IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') diff --git a/static/css/datetimepicker.css b/static/css/datetimepicker.css new file mode 100644 index 0000000..ea9cf87 --- /dev/null +++ b/static/css/datetimepicker.css @@ -0,0 +1,34 @@ +.cursorily{ cursor: pointer;} +.hov:hover{ color: #000;} +.ico-size{font-size: 16px;} +.ico-size-month{font-size: 26px!important; line-height: 26px!important;} +.ico-size-large{ font-size: 40px!important; line-height: 30px;} +.dtp_main{ border: solid 1px #eee; border-radius: 3px; background-color: #fff; padding: 8px 0 8px 8px;} +.dtp_main span, .dtp_main i{ display: inline-block; padding-right: 8px;} +.dtp_modal-win{position: fixed;left: 0; top: 0; width: 100%; height: 100%; + z-index: 999; background-color: #eeeeee; opacity: 0.6;} +.dtp_modal-content{ background-color: #fff; border-radius: 10px; width: 624px; + position: absolute; z-index: 1000; top: 100px; left: 100px; font-size: 16px;font-weight: normal;} +.dtp_modal-content-no-time{ background-color: #fff; border-radius: 10px; width: 312px; + position: absolute; z-index: 1000; top: 100px; left: 100px; font-size: 16px;font-weight: normal;} +.dtp_modal-title{ border-bottom: solid 3px #54646b; padding: 16px 36px; margin-bottom: 16px; font-size: 22px; } +.dtp_modal-cell-date{ width: 312px; float: right; margin-bottom: 22px; margin-top: 6px;} +.dtp_modal-cell-time{width: 311px; float: left; direction: ltr; border-right: solid 1px #000;} +.dtp_modal-months{ color: #7d7d7d; text-align: center; font-size: 20px; padding: 0 20px;} +.dtp_modal-months span{ display: inline-block; padding: 10px 20px; width: 182px;} +.dtp_modal-calendar{ width: 266px; margin-left: 22px; } +.dtp_modal-calendar-cell{ width: 38px; padding: 7px 0; display: inline-block; text-align: center;} +.dtp_modal-colored{ color: #54646b; } +.dtp_modal-grey{ color: #7d7d7d; } +.dtp_modal-cell-selected{ background-color: #54646b; border-radius: 48%; transition: background-color 1s ease-out;} +.dtp_modal-time-block{ height: 212px; width: 310px; } +.dpt_modal-button{ background-color: #54646b; color: #fff; font-size: 24px; padding: 8px 40px; float: left; + text-align: center; display: inline-block; margin-left: 22px; cursor: pointer; border: solid 1px #fff; +border-radius: 3px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);} +.dtp_modal-time-line{ text-align: center; color: #7d7d7d; font-size: 20px; padding-top: 15px; } +.dtp_modal-time-mechanic{ padding-top: 16px;} +.dtp_modal-append{ color: #7d7d7d; padding-left: 108px; font-weight: normal; } +.dtp_modal-midle{ display: inline-block; width: 40px; } +.dtp_modal-midle-dig{display: inline-block; width: 16px; text-align: center; } +.dtp_modal-digits{ font-size: 50px; padding-left: 96px;} +.dtp_modal-digit{ } diff --git a/static/js/datetimepicker.js b/static/js/datetimepicker.js new file mode 100644 index 0000000..adb871e --- /dev/null +++ b/static/js/datetimepicker.js @@ -0,0 +1,396 @@ +(function ($) { + 'use strict'; + $.fn.dateTimePicker = function (options) { + + var settings = $.extend({ + selectData: "now", + dateFormat: "YYYY-MM-DD HH:mm", + showTime: true, + locale: 'en', + positionShift: { top: 20, left: 0}, + title: "Select Date and Time", + buttonTitle: "Select", + allowBackwards: false + }, options); + moment.locale(settings.locale); + var elem = this; + var limitation = {"hour": 23, "minute": 59}; + var mousedown = false; + var timeout = 800; + var selectDate = settings.selectData == "now" ? moment() : moment(settings.selectData, settings.dateFormat); + if (selectDate < moment() && (settings.allowBackwards == false)) { + selectDate = moment(); + } + var startDate = copyDate(moment()); + var lastSelected = copyDate(selectDate); + return this.each(function () { + if (lastSelected != selectDate) { + selectDate = copyDate(lastSelected); + } + elem.addClass("dtp_main"); + updateMainElemGlobal(); + // elem.text(selectDate.format(settings.dateFormat)); + function updateMainElemGlobal() { + var arrF = settings.dateFormat.split(' '); + if (settings.showTime && arrF.length != 2) { + arrF.length = 2; + arrF[0] = 'DD/MM/YY'; + arrF[1] = 'HH:mm'; + } + var $s = $(''); + $s.text(lastSelected.format(arrF[0])); + elem.empty(); + elem.append($s); + $s = $(''); + $s.addClass('fa fa-calendar ico-size'); + elem.append($s); + if (settings.showTime) { + $s = $(''); + $s.text(lastSelected.format(arrF[1])); + elem.append($s); + $s = $(''); + $s.addClass('fa fa-clock-o ico-size'); + elem.append($s); + } + } + elem.on('click', function () { + var $win = $('
'); + $win.addClass("dtp_modal-win"); + var $body = $('body'); + $body.append($win); + var $content = createContent(); + $body.append($content); + var offset = elem.offset(); + $content.css({top: (offset.top + settings.positionShift.top) + "px", left: (offset.left + settings.positionShift.left) + "px"}); + feelDates(selectDate); + $win.on('click', function () { + $content.remove(); + $win.remove(); + }) + if (settings.showTime) { + attachChangeTime(); + var $fieldTime = $('#field-time'); + var $hour = $fieldTime.find('#d-hh'); + var $minute = $fieldTime.find('#d-mm'); + } + + function feelDates(selectM) { + var $fDate = $content.find('#field-data'); + $fDate.empty(); + $fDate.append(createMonthPanel(selectM)); + $fDate.append(createCalendar(selectM)); + } + + function createCalendar(selectedMonth) { + var $c = $('
'); + $c.addClass('dtp_modal-calendar'); + for (var i = 0; i < 7; i++) { + var $e = $('
'); + $e.addClass('dtp_modal-calendar-cell dtp_modal-colored'); + $e.text(moment().weekday(i).format('ddd')); + $c.append($e); + } + var m = copyDate(selectedMonth); + m.date(1); + // console.log(m.format('DD--MM--YYYY')); + // console.log(selectData.format('DD--MM--YYYY')); + // console.log(m.weekday()); + var flagStart = totalMonths(selectedMonth) === totalMonths(startDate); + var flagSelect = totalMonths(lastSelected) === totalMonths(selectedMonth); + var cerDay = parseInt(selectedMonth.format('D')); + var dayNow = parseInt(startDate.format('D')); + for (var i = 0; i < 6; i++) { + for (var j = 0; j < 7; j++) { + var $b = $('
'); + $b.html(' '); + $b.addClass('dtp_modal-calendar-cell'); + if (m.month() == selectedMonth.month() && m.weekday() == j) { + var day = parseInt(m.format('D')); + $b.text(day); + if (flagStart && day < dayNow) { + + if (settings.allowBackwards == false) { + $b.addClass('dtp_modal-grey'); + } else { + $b.addClass('cursorily'); + $b.bind('click', changeDate); + } + + } + else if (flagSelect && day == cerDay) { + $b.addClass('dtp_modal-cell-selected'); + } + else { + $b.addClass('cursorily'); + $b.bind('click', changeDate); + } + m.add(1, 'days'); + } + $c.append($b); + } + } + return $c; + } + + function changeDate() { + + var $div = $(this); + selectDate.date($div.text()); + lastSelected = copyDate(selectDate); + updateDate(); + var $fDate = $content.find('#field-data'); + var old = $fDate.find('.dtp_modal-cell-selected'); + old.removeClass('dtp_modal-cell-selected'); + old.addClass('cursorily'); + $div.addClass('dtp_modal-cell-selected'); + $div.removeClass('cursorily'); + old.bind('click', changeDate); + $div.unbind('click'); + // console.log(selectDate.format('DD-MM-YYYY')); + } + + function createMonthPanel(selectMonth) { + var $d = $('
'); + $d.addClass('dtp_modal-months'); + var $s = $(''); + $s.addClass('fa fa-angle-left cursorily ico-size-month hov'); + //$s.attr('data-fa-mask', 'fas fa-circle'); + $s.bind('click', prevMonth); + $d.append($s); + $s = $(''); + $s.text(selectMonth.format("MMMM YYYY")); + $d.append($s); + $s = $(''); + $s.addClass('fa fa-angle-right cursorily ico-size-month hov'); + $s.bind('click', nextMonth); + $d.append($s); + return $d; + } + + function close() { + if (settings.showTime) { + lastSelected.hour(parseInt($hour.text())); + lastSelected.minute(parseInt($minute.text())); + selectDate.hour(parseInt($hour.text())); + selectDate.minute(parseInt($minute.text())); + } + updateDate(); + $content.remove(); + $win.remove(); + } + + function nextMonth() { + selectDate.add(1, 'month'); + feelDates(selectDate); + } + + function prevMonth() { + if (totalMonths(selectDate) > totalMonths(startDate) || settings.allowBackwards == true) { + selectDate.add(-1, 'month'); + feelDates(selectDate); + } + } + + function attachChangeTime() { + var $angles = $($content).find('i[id^="angle-"]'); + // $angles.bind('click', changeTime); + $angles.bind('mouseup', function () { + mousedown = false; + timeout = 800; + }); + $angles.bind('mousedown', function () { + mousedown = true; + changeTime(this); + }); + } + + function changeTime(el) { + var $el = this || el; + $el = $($el); + ///angle-up-hour angle-up-minute angle-down-hour angle-down-minute + var arr = $el.attr('id').split('-'); + var increment = 1; + if (arr[1] == 'down') { + increment = -1; + } + appendIncrement(arr[2], increment); + setTimeout(function () { + autoIncrement($el); + }, timeout); + } + + function autoIncrement(el) { + if (mousedown) { + if (timeout > 200) { + timeout -= 200; + } + changeTime(el); + } + } + + function appendIncrement(typeDigits, increment) { + + var $i = typeDigits == "hour" ? $hour : $minute; + var val = parseInt($i.text()) + increment; + if (val < 0) { + val = limitation[typeDigits]; + } + else if (val > limitation[typeDigits]) { + val = 0; + } + $i.text(formatDigits(val)); + } + + function formatDigits(val) { + + if (val < 10) { + return '0' + val; + } + return val; + } + + function createTimer() { + var $div = $('
'); + $div.addClass('dtp_modal-time-mechanic'); + var $panel = $('
'); + $panel.addClass('dtp_modal-append'); + var $i = $(''); + $i.attr('id', 'angle-up-hour'); + $i.addClass('fa fa-angle-up ico-size-large cursorily hov'); + $panel.append($i); + var $m = $(''); + $m.addClass('dtp_modal-midle'); + $panel.append($m); + $i = $(''); + $i.attr('id', 'angle-up-minute'); + $i.addClass('fa fa-angle-up ico-size-large cursorily hov'); + $panel.append($i); + $div.append($panel); + + $panel = $('
'); + $panel.addClass('dtp_modal-digits'); + var $d = $(''); + $d.addClass('dtp_modal-digit'); + $d.attr('id', 'd-hh'); + $d.text(lastSelected.format('HH')); + $panel.append($d); + $m = $(''); + $m.addClass('dtp_modal-midle-dig'); + $m.html(':'); + $panel.append($m); + $d = $(''); + $d.addClass('dtp_modal-digit'); + $d.attr('id', 'd-mm'); + $d.text(lastSelected.format('mm')); + $panel.append($d); + $div.append($panel); + + $panel = $('
'); + $panel.addClass('dtp_modal-append'); + $i = $(''); + $i.attr('id', 'angle-down-hour'); + $i.addClass('fa fa-angle-down ico-size-large cursorily hov'); + $panel.append($i); + $m = $(''); + $m.addClass('dtp_modal-midle'); + $panel.append($m); + $i = $(''); + $i.attr('id', 'angle-down-minute'); + $i.addClass('fa fa-angle-down ico-size-large cursorily hov'); + $panel.append($i); + $div.append($panel); + return $div; + } + + function createContent() { + var $c = $('
'); + if (settings.showTime) { + $c.addClass("dtp_modal-content"); + } + else { + $c.addClass("dtp_modal-content-no-time"); + } + var $el = $('
'); + $el.addClass("dtp_modal-title"); + $el.text(settings.title); + $c.append($el); + $el = $('
'); + $el.addClass('dtp_modal-cell-date'); + $el.attr('id', 'field-data'); + $c.append($el); + if (settings.showTime) { + $el = $('
'); + $el.addClass('dtp_modal-cell-time'); + var $a = $('
'); + $a.addClass('dtp_modal-time-block'); + $a.attr('id', 'field-time'); + $el.append($a); + var $line = $('
'); + $line.attr('id', 'time-line'); + $line.addClass('dtp_modal-time-line'); + $line.text(lastSelected.format(settings.dateFormat)); + + $a.append($line); + $a.append(createTimer()); + var $but = $('
'); + $but.addClass('dpt_modal-button'); + $but.text(settings.buttonTitle); + $but.bind('click', close); + $el.append($but); + $c.append($el); + } + return $c; + } + function updateDate() { + if (settings.showTime) { + $('#time-line').text(lastSelected.format(settings.dateFormat)); + } + updateMainElem(); + elem.next().val(selectDate.format(settings.dateFormat)); + if (!settings.showTime) { + $content.remove(); + $win.remove(); + } + } + + function updateMainElem() { + var arrF = settings.dateFormat.split(' '); + if (settings.showTime && arrF.length != 2) { + arrF.length = 2; + arrF[0] = 'DD/MM/YY'; + arrF[1] = 'HH:mm'; + } + var $s = $(''); + $s.text(lastSelected.format(arrF[0])); + elem.empty(); + elem.append($s); + $s = $(''); + $s.addClass('fa fa-calendar ico-size'); + elem.append($s); + if (settings.showTime) { + $s = $(''); + $s.text(lastSelected.format(arrF[1])); + elem.append($s); + $s = $(''); + $s.addClass('fa fa-clock-o ico-size'); + elem.append($s); + } + } + + }); + + }); + + }; + + function copyDate(d) { + return moment(d.toDate()); + } + + function totalMonths(m) { + var r = m.format('YYYY') * 12 + parseInt(m.format('MM')); + return r; + } + +}(jQuery)); +// fa-caret-down \ No newline at end of file diff --git a/templates/admin/input_filter.html b/templates/admin/input_filter.html new file mode 100644 index 0000000..168713b --- /dev/null +++ b/templates/admin/input_filter.html @@ -0,0 +1,15 @@ + + +{% load i18n %} + +

{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}

+
    +
  • +
    + +
    +
  • +
\ No newline at end of file diff --git a/templates/pg/payment_failure.html b/templates/pg/payment_failure.html new file mode 100644 index 0000000..8c6b976 --- /dev/null +++ b/templates/pg/payment_failure.html @@ -0,0 +1,179 @@ +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + + + + + + + + Payment Unsuccessful + + + + + + + + + +
+
+ +
+
!
+ {% if message %} +

{{ message }}

+ {% else %} +

پرداخت شما ناموفق بود

+ {% endif %} +
+
+

کد پیگیری تراکنش شما: {{ object.reference_number }}

+

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

+
+ addwin +
+ +
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
+
+ + + \ No newline at end of file diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html new file mode 100644 index 0000000..b6dd263 --- /dev/null +++ b/templates/pg/payment_success.html @@ -0,0 +1,175 @@ +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + + + + + + + Payment Successful + + + + + + + + + +
+
+ +
+
✓
+

پرداخت موفق

+

پرداخت با موفقیت انجام شد.

+
+
+ مقدار پرداخت شده: + {{ object.amount }} تومان +
+ addwin +
+ +
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+ +
+
+ + + \ No newline at end of file From 24f18e3f8d3824099ce4dabb87df063865d3631a Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sat, 9 Aug 2025 17:03:17 +0330 Subject: [PATCH 03/38] new templates --- templates/pg/payment_failure.html | 2 +- templates/pg/payment_success.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/pg/payment_failure.html b/templates/pg/payment_failure.html index 8c6b976..97c49d3 100644 --- a/templates/pg/payment_failure.html +++ b/templates/pg/payment_failure.html @@ -169,7 +169,7 @@
{% csrf_token %} {{ form|crispy }} - +
diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index b6dd263..cc32a2d 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -164,7 +164,7 @@
{% csrf_token %} {{ form|crispy }} - +
From 92849481d137b3eb7def565d0e56003675aeb142 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sat, 9 Aug 2025 17:33:21 +0330 Subject: [PATCH 04/38] better html --- templates/pg/payment_failure.html | 4 ++-- templates/pg/payment_success.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/pg/payment_failure.html b/templates/pg/payment_failure.html index 97c49d3..bd19088 100644 --- a/templates/pg/payment_failure.html +++ b/templates/pg/payment_failure.html @@ -27,8 +27,8 @@ .mobile-frame { - width: 390px; - height: 844px; + width: 100vh; + height: 100vh; background-color: #ffffff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); padding: 30px; diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index cc32a2d..81cac7d 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -26,8 +26,8 @@ .mobile-frame { - width: 390px; - height: 844px; + width: 100vh; + height: 100vh; background-color: #ffffff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); padding: 30px; From 9462e25de2c82b5f223e39c8ed0d56ff779e861a Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 12 Aug 2025 16:55:25 +0330 Subject: [PATCH 05/38] sum in admin list view --- apps/pg/admin.py | 13 +++++++++++++ templates/admin/pg/paymentrequest/change_list.html | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 templates/admin/pg/paymentrequest/change_list.html diff --git a/apps/pg/admin.py b/apps/pg/admin.py index dbde3ff..8f48238 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -1,4 +1,6 @@ from django.contrib import admin +from django.db.models import Sum + from .models import PaymentRequest, PNA, Fake @@ -13,6 +15,17 @@ class PaymentRequestAdmin(admin.ModelAdmin): search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] + def changelist_view(self, request, extra_context=None): + extra_context = extra_context or {} + + cl = self.get_changelist_instance(request) + queryset = cl.result_list + totals = queryset.aggregate( + total_amount=Sum('amount'), + ) + extra_context['totals'] = totals + return super().changelist_view(request, extra_context=extra_context) + class FakeAdmin(admin.ModelAdmin): list_display = [ 'created_at'] diff --git a/templates/admin/pg/paymentrequest/change_list.html b/templates/admin/pg/paymentrequest/change_list.html new file mode 100644 index 0000000..dab27a4 --- /dev/null +++ b/templates/admin/pg/paymentrequest/change_list.html @@ -0,0 +1,11 @@ +{% extends "admin/change_list.html" %} +{% load tags %} +{% block result_list %} + {{ block.super }} +
+

جمع کل:

+

+

{{ totals.total_amount|default:"0"|amount_split_3digit }}

+

+
+{% endblock %} \ No newline at end of file From 91fed410365f42e07b158581d5772d47d2abb736 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 12 Aug 2025 17:24:37 +0330 Subject: [PATCH 06/38] sum in admin list view --- apps/pg/admin.py | 43 +++++++++++++++++++++++++++++++++++++++++++ requirements.in | 4 +++- requirements.txt | 4 ++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 8f48238..609c0b9 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -1,5 +1,11 @@ +import io + +import jdatetime +import xlsxwriter from django.contrib import admin from django.db.models import Sum +from django.http import HttpResponse +from django.utils import timezone from .models import PaymentRequest, PNA, Fake @@ -10,10 +16,47 @@ class PNAAdmin(admin.ModelAdmin): search_fields = ['pna_status_code', 'pna_status_message'] +@admin.action(description="export exel") +def export_exel(modeladmin, request, queryset): + output = io.BytesIO() + workbook = xlsxwriter.Workbook(output, options={"remove_timezone": True}) + worksheet = workbook.add_worksheet() + + for col, header in enumerate([]): + worksheet.write(0, col, header) + + for row, payment_request in enumerate(queryset, 1): + worksheet.write(row, 0, payment_request.amount) + worksheet.write(row, 1, str(payment_request.pk)) + worksheet.write(row, 2, str(payment_request.user.pk)) + worksheet.write(row, 3, payment_request.jajali_datetime) + worksheet.write(row, 4, payment_request.gateway) + worksheet.write(row, 5, payment_request.get_state_display()) + + workbook.close() + + # create a response + response = HttpResponse(content_type='application/vnd.ms-excel') + + # tell the browser what the file is named + file_name = jdatetime.date.fromgregorian(date=timezone.now(), locale='fa_IR').strftime("%Y/%m/%d") + response['Content-Disposition'] = f'attachment;filename="{file_name}.xlsx"' + + # put the spreadsheet data into the response + response.write(output.getvalue()) + + # return the response + return response + + + + class PaymentRequestAdmin(admin.ModelAdmin): list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] + actions = [export_exel] + def changelist_view(self, request, extra_context=None): extra_context = extra_context or {} diff --git a/requirements.in b/requirements.in index 47bd1bb..fcd0ee8 100644 --- a/requirements.in +++ b/requirements.in @@ -16,4 +16,6 @@ django-oauth-toolkit redis celery httpx -django-redis \ No newline at end of file +django-redis +xlsxwriter +xlrd \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fb0e1f6..f156612 100644 --- a/requirements.txt +++ b/requirements.txt @@ -175,6 +175,10 @@ vine==5.1.0 # kombu wcwidth==0.2.13 # via prompt-toolkit +xlrd==2.0.2 + # via -r requirements.in +xlsxwriter==3.2.5 + # via -r requirements.in zope-event==5.0 # via gevent zope-interface==7.2 From cfe7db6dc99cb798acfd393361ed404c070edfbb Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 17 Aug 2025 14:54:49 +0330 Subject: [PATCH 07/38] local time instead of utc --- apps/pg/admin.py | 2 +- main/settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 609c0b9..fa96731 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -52,7 +52,7 @@ def export_exel(modeladmin, request, queryset): class PaymentRequestAdmin(admin.ModelAdmin): - list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'application', 'gateway'] + list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] actions = [export_exel] diff --git a/main/settings.py b/main/settings.py index edd86e3..67c8799 100644 --- a/main/settings.py +++ b/main/settings.py @@ -170,13 +170,13 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Tehran' USE_I18N = True USE_L10N = True -USE_TZ = True +USE_TZ = False LOCALE_PATHS = [ BASE_DIR / 'locale', From 336baa51eb559d71e3dd4d202a839c3dd6691039 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 31 Aug 2025 16:20:31 +0330 Subject: [PATCH 08/38] local time instead of utc --- apps/pg/views.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/pg/views.py b/apps/pg/views.py index 79d51e5..92e9ed5 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -55,6 +55,24 @@ class PaymentRequestView(UpdateView): slug_field = 'uuid' slug_url_kwarg = 'uuid' + # TODO: remove it in future + def get(self, request, *args, **kwargs): + charge_request: PaymentRequest = self.get_object() + charge_request.set_gateway({'pna': True}) + tool = charge_request.get_gateway_tools() + tool.make_request() + redirect_url = tool.get_pg_page_url() + return HttpResponseRedirect(redirect_url) + + # TODO: remove it in future + def post(self, request, *args, **kwargs): + charge_request: PaymentRequest = self.get_object() + charge_request.set_gateway({'pna': True}) + tool = charge_request.get_gateway_tools() + tool.make_request() + redirect_url = tool.get_pg_page_url() + return HttpResponseRedirect(redirect_url) + def get_queryset(self): # return ChargeRequest.objects.all() # return Charge.objects.filter(state__in=[StateChoices.CREATED.value, StateChoices.SUCCESS.value]) From 011b1f2a722a58d0875bdc1c60b45373972e8e17 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 9 Sep 2025 14:08:48 +0330 Subject: [PATCH 09/38] i18n --- apps/pg/models.py | 2 +- locale/ar/LC_MESSAGES/django.mo | Bin 0 -> 463 bytes locale/ar/LC_MESSAGES/django.po | 120 ++++++++++++++++++++++++++++++++ locale/en/LC_MESSAGES/django.mo | Bin 0 -> 380 bytes locale/en/LC_MESSAGES/django.po | 119 +++++++++++++++++++++++++++++++ locale/fa/LC_MESSAGES/django.mo | Bin 0 -> 647 bytes locale/fa/LC_MESSAGES/django.po | 119 +++++++++++++++++++++++++++++++ locale/tr/LC_MESSAGES/django.mo | Bin 0 -> 379 bytes locale/tr/LC_MESSAGES/django.po | 119 +++++++++++++++++++++++++++++++ main/settings.py | 11 ++- 10 files changed, 488 insertions(+), 2 deletions(-) create mode 100644 locale/ar/LC_MESSAGES/django.mo create mode 100644 locale/ar/LC_MESSAGES/django.po create mode 100644 locale/en/LC_MESSAGES/django.mo create mode 100644 locale/en/LC_MESSAGES/django.po create mode 100644 locale/fa/LC_MESSAGES/django.mo create mode 100644 locale/fa/LC_MESSAGES/django.po create mode 100644 locale/tr/LC_MESSAGES/django.mo create mode 100644 locale/tr/LC_MESSAGES/django.po diff --git a/apps/pg/models.py b/apps/pg/models.py index b7f9615..2560397 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -130,7 +130,7 @@ class PaymentRequest(models.Model): "payee_type": 1, "amount": self.amount, "details": { - 'description': "charge via IPG", + 'description': _("charge via ipg"), 'reference_id': str(self.uuid), 'application_details_url': '' }, diff --git a/locale/ar/LC_MESSAGES/django.mo b/locale/ar/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..74dbaf67ca1b1ef110318ec24bc2175e757fa49b GIT binary patch literal 463 zcmYk0%}&BV6ooaq>e97~yHGYd*n%1;3{qjh#{Q-JB)S`6tTknZOb4S6!t41g-by0g zJn8=3$;bFjc=9tn?$R3u`tA6lDW`juA~czH+b~M z4CXAI_;F;VVy(0xVVUJia=*z+GF2{ENla4lkykrp$c=E}iFqjrV>0yMA$CLm;yI3( z74XuKsphgQxKY}L(JTlc@pJ zb)~a?1{;Ka$o93Jx@`@VG(zIJuQm2D;?rEM3!cjkEZ(>-g`u(s@AK}gvo_k z<}!1k^^zMaDK?rHWTf<}bV06vza_oxzz(UT)P_5-0bNQRL}!N$#72eZj&1j76Kb^` Xcd1itH20q4{4?8aG_TRT=~xFpfMj~p literal 0 HcmV?d00001 diff --git a/locale/ar/LC_MESSAGES/django.po b/locale/ar/LC_MESSAGES/django.po new file mode 100644 index 0000000..c3dc886 --- /dev/null +++ b/locale/ar/LC_MESSAGES/django.po @@ -0,0 +1,120 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-09 14:04+0330\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" +#: apps/pg/constans.py:6 +msgid "created" +msgstr "" + +#: apps/pg/constans.py:7 +msgid "ipg pending" +msgstr "" + +#: apps/pg/constans.py:8 +msgid "ipg success" +msgstr "" + +#: apps/pg/constans.py:10 +msgid "wallet submit pending" +msgstr "" + +#: apps/pg/constans.py:11 +msgid "wallet submit success" +msgstr "" + +#: apps/pg/constans.py:13 +msgid "failed" +msgstr "" + +#: apps/pg/constans.py:14 +msgid "expected failure" +msgstr "" + +#: apps/pg/constans.py:15 +msgid "success" +msgstr "" + +#: apps/pg/constans.py:19 +msgid "user" +msgstr "" + +#: apps/pg/constans.py:20 +msgid "application" +msgstr "" + +#: apps/pg/models.py:24 +msgid "fake" +msgstr "" + +#: apps/pg/models.py:25 +msgid "pna" +msgstr "" + +#: apps/pg/models.py:133 +msgid "charge via ipg" +msgstr "" + +#: apps/users/models.py:49 +msgid "password" +msgstr "" + +#: apps/users/models.py:52 +msgid "username" +msgstr "" + +#: apps/users/models.py:55 +msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." +msgstr "" + +#: apps/users/models.py:58 +msgid "A user with that username already exists." +msgstr "" + +#: apps/users/models.py:64 +msgid "last update" +msgstr "" + +#: apps/users/models.py:65 +msgid "last login" +msgstr "" + +#: apps/users/models.py:66 +msgid "date joined" +msgstr "" + +#: main/settings.py:184 +msgid "English" +msgstr "" + +#: main/settings.py:185 +msgid "Persian" +msgstr "" + +#: main/settings.py:186 +msgid "Arabic" +msgstr "" + +#: main/settings.py:187 +msgid "Turkish" +msgstr "" + +#: templates/admin/input_filter.html:5 +#, python-format +msgid " By %(filter_title)s " +msgstr "" diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..71cbdf3e9d8d54be31066ec4ad8628bc2c1f2845 GIT binary patch literal 380 zcmYL@K~KUk7=|%=+R?Lz&%}d9i{c3jGZa>EvE7z2Nc2{r&Y96JZ6W$Y{CoZuJ5A(G zp7i_Dx9RhJeDu}vIq;l#&OC>nD^HugXY4QU{MmN?lNtRkR}RH%w3NnHT4Bh@vF%H^(V-=Ii1iQ$Qo9Pt!I1Rhe%oml#`f^NEGFCKEL->Rc=KoQ6a?!10%_7(V7ey8`V`;n{war z20Z3;uifk31QV^CRQ|iq#``$=;jWunRB8aLH({)F;i8zL{=V00y-I_qTIqGAN(}v% i$^}`yHKImSZ8jEzYJOK6-VWez49^vuhS0kh1f3tbb!oc* literal 0 HcmV?d00001 diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000..584b9ba --- /dev/null +++ b/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,119 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-09 14:04+0330\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: apps/pg/constans.py:6 +msgid "created" +msgstr "" + +#: apps/pg/constans.py:7 +msgid "ipg pending" +msgstr "" + +#: apps/pg/constans.py:8 +msgid "ipg success" +msgstr "" + +#: apps/pg/constans.py:10 +msgid "wallet submit pending" +msgstr "" + +#: apps/pg/constans.py:11 +msgid "wallet submit success" +msgstr "" + +#: apps/pg/constans.py:13 +msgid "failed" +msgstr "" + +#: apps/pg/constans.py:14 +msgid "expected failure" +msgstr "" + +#: apps/pg/constans.py:15 +msgid "success" +msgstr "" + +#: apps/pg/constans.py:19 +msgid "user" +msgstr "" + +#: apps/pg/constans.py:20 +msgid "application" +msgstr "" + +#: apps/pg/models.py:24 +msgid "fake" +msgstr "" + +#: apps/pg/models.py:25 +msgid "pna" +msgstr "" + +#: apps/pg/models.py:133 +msgid "charge via ipg" +msgstr "" + +#: apps/users/models.py:49 +msgid "password" +msgstr "" + +#: apps/users/models.py:52 +msgid "username" +msgstr "" + +#: apps/users/models.py:55 +msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." +msgstr "" + +#: apps/users/models.py:58 +msgid "A user with that username already exists." +msgstr "" + +#: apps/users/models.py:64 +msgid "last update" +msgstr "" + +#: apps/users/models.py:65 +msgid "last login" +msgstr "" + +#: apps/users/models.py:66 +msgid "date joined" +msgstr "" + +#: main/settings.py:184 +msgid "English" +msgstr "" + +#: main/settings.py:185 +msgid "Persian" +msgstr "" + +#: main/settings.py:186 +msgid "Arabic" +msgstr "" + +#: main/settings.py:187 +msgid "Turkish" +msgstr "" + +#: templates/admin/input_filter.html:5 +#, python-format +msgid " By %(filter_title)s " +msgstr "" diff --git a/locale/fa/LC_MESSAGES/django.mo b/locale/fa/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..2e8cd0d52d86e2c9e10b19efa640104f892d9e53 GIT binary patch literal 647 zcmYL^&u-H|5XKFZKQa;rZb%$PoIq#`;Z!+ERnu%rgq=i=QweU{WO28+>uBv%AaN-w z5r&Ha3`8%onkw1jos87FWZO6s=|I!n zeClpd*rq|N)~MS7? zv(^i)2$h|rD`e!r+K$NVX53dSCe=jkrw+*8tW3*~iZD;hcO|St;a<_U^iMs}$J3#u zNBQ7anvf6NE@kr~Pd)_*}8%1;0Q literal 0 HcmV?d00001 diff --git a/locale/fa/LC_MESSAGES/django.po b/locale/fa/LC_MESSAGES/django.po new file mode 100644 index 0000000..6252a0f --- /dev/null +++ b/locale/fa/LC_MESSAGES/django.po @@ -0,0 +1,119 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-09 14:03+0330\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +#: apps/pg/constans.py:6 +msgid "created" +msgstr "" + +#: apps/pg/constans.py:7 +msgid "ipg pending" +msgstr "" + +#: apps/pg/constans.py:8 +msgid "ipg success" +msgstr "" + +#: apps/pg/constans.py:10 +msgid "wallet submit pending" +msgstr "" + +#: apps/pg/constans.py:11 +msgid "wallet submit success" +msgstr "" + +#: apps/pg/constans.py:13 +msgid "failed" +msgstr "" + +#: apps/pg/constans.py:14 +msgid "expected failure" +msgstr "" + +#: apps/pg/constans.py:15 +msgid "success" +msgstr "" + +#: apps/pg/constans.py:19 +msgid "user" +msgstr "" + +#: apps/pg/constans.py:20 +msgid "application" +msgstr "" + +#: apps/pg/models.py:24 +msgid "fake" +msgstr "" + +#: apps/pg/models.py:25 +msgid "pna" +msgstr "" + +#: apps/pg/models.py:133 +msgid "charge via ipg" +msgstr "افزایش موجودی از طریق پرداخت آنلاین" + +#: apps/users/models.py:49 +msgid "password" +msgstr "" + +#: apps/users/models.py:52 +msgid "username" +msgstr "" + +#: apps/users/models.py:55 +msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." +msgstr "" + +#: apps/users/models.py:58 +msgid "A user with that username already exists." +msgstr "" + +#: apps/users/models.py:64 +msgid "last update" +msgstr "" + +#: apps/users/models.py:65 +msgid "last login" +msgstr "" + +#: apps/users/models.py:66 +msgid "date joined" +msgstr "" + +#: main/settings.py:184 +msgid "English" +msgstr "انگلیسی" + +#: main/settings.py:185 +msgid "Persian" +msgstr "فارسی" + +#: main/settings.py:186 +msgid "Arabic" +msgstr "عربی" + +#: main/settings.py:187 +msgid "Turkish" +msgstr "ترکی" + +#: templates/admin/input_filter.html:5 +#, python-format +msgid " By %(filter_title)s " +msgstr "" diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..2c90dd0c81aca562856271a6885816b565885734 GIT binary patch literal 379 zcmYL@y-ve06h@0+%E-)c2L=$hP^RMksHSmCgq=ibS_wAOnqZXLk?kUQ5MGaG!2yYW z(vk0#Kg;L)_~@$>au7HPoCXd9mw`6@01213;cPqq$*p;lYmbr*T1o4a(HL?veIRoR zD_Sg)ER71;80!&tmD-@YUFA?|FhqHV3i+e|LVdy_A hALaGViW<#~-8u}q`CZ-UW&nTV=uE>Hdgp_v^8-$QX_^24 literal 0 HcmV?d00001 diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po new file mode 100644 index 0000000..dd60a8c --- /dev/null +++ b/locale/tr/LC_MESSAGES/django.po @@ -0,0 +1,119 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-09 14:04+0330\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +#: apps/pg/constans.py:6 +msgid "created" +msgstr "" + +#: apps/pg/constans.py:7 +msgid "ipg pending" +msgstr "" + +#: apps/pg/constans.py:8 +msgid "ipg success" +msgstr "" + +#: apps/pg/constans.py:10 +msgid "wallet submit pending" +msgstr "" + +#: apps/pg/constans.py:11 +msgid "wallet submit success" +msgstr "" + +#: apps/pg/constans.py:13 +msgid "failed" +msgstr "" + +#: apps/pg/constans.py:14 +msgid "expected failure" +msgstr "" + +#: apps/pg/constans.py:15 +msgid "success" +msgstr "" + +#: apps/pg/constans.py:19 +msgid "user" +msgstr "" + +#: apps/pg/constans.py:20 +msgid "application" +msgstr "" + +#: apps/pg/models.py:24 +msgid "fake" +msgstr "" + +#: apps/pg/models.py:25 +msgid "pna" +msgstr "" + +#: apps/pg/models.py:133 +msgid "charge via ipg" +msgstr "" + +#: apps/users/models.py:49 +msgid "password" +msgstr "" + +#: apps/users/models.py:52 +msgid "username" +msgstr "" + +#: apps/users/models.py:55 +msgid "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." +msgstr "" + +#: apps/users/models.py:58 +msgid "A user with that username already exists." +msgstr "" + +#: apps/users/models.py:64 +msgid "last update" +msgstr "" + +#: apps/users/models.py:65 +msgid "last login" +msgstr "" + +#: apps/users/models.py:66 +msgid "date joined" +msgstr "" + +#: main/settings.py:184 +msgid "English" +msgstr "" + +#: main/settings.py:185 +msgid "Persian" +msgstr "" + +#: main/settings.py:186 +msgid "Arabic" +msgstr "" + +#: main/settings.py:187 +msgid "Turkish" +msgstr "" + +#: templates/admin/input_filter.html:5 +#, python-format +msgid " By %(filter_title)s " +msgstr "" diff --git a/main/settings.py b/main/settings.py index 67c8799..4a5e9a1 100644 --- a/main/settings.py +++ b/main/settings.py @@ -100,13 +100,15 @@ REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.TokenAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), - 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 200, "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", + 'EXCEPTION_HANDLER': 'utils.exceptions.exception_handler', } ROOT_URLCONF = 'main.urls' @@ -178,6 +180,13 @@ USE_L10N = True USE_TZ = False +LANGUAGES = [ + ('en', _('English')), + ('fa', _('Persian')), + ('ar', _('Arabic')), + ('tr', _('Turkish')), +] + LOCALE_PATHS = [ BASE_DIR / 'locale', ] From 218a86ab7cbab2b4f3efcb28e23d99f37e1103ef Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 9 Sep 2025 14:09:12 +0330 Subject: [PATCH 10/38] i18n --- apps/pg/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index 2560397..68589c6 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -130,7 +130,7 @@ class PaymentRequest(models.Model): "payee_type": 1, "amount": self.amount, "details": { - 'description': _("charge via ipg"), + 'description': str(_("charge via ipg")), 'reference_id': str(self.uuid), 'application_details_url': '' }, From 42815873966a654f5a78a946252a45056ca596eb Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 7 Oct 2025 13:19:48 +0330 Subject: [PATCH 11/38] state in callback --- apps/pg/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pg/views.py b/apps/pg/views.py index 92e9ed5..9f58a73 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -133,7 +133,7 @@ class PaymentConfirmView(UpdateView): if 'redirect-to-app' in request.POST: response = HttpResponse(status=302) - response['Location'] = self.object.callback_url + response['Location'] = self.object.callback_url + f'?state={self.object.state}' return response tool = self.object.get_gateway_tools() From fe1f535ee623cc0848a58893bdbd6bc885157c64 Mon Sep 17 00:00:00 2001 From: hgh Date: Mon, 13 Oct 2025 15:49:53 +0330 Subject: [PATCH 12/38] FEATURE(pg):batch change payments to success/failed batch change payments to success/failed --- apps/pg/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index fa96731..00a1d9d 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -7,6 +7,7 @@ from django.db.models import Sum from django.http import HttpResponse from django.utils import timezone +from .constans import StateChoices from .models import PaymentRequest, PNA, Fake @@ -48,14 +49,22 @@ def export_exel(modeladmin, request, queryset): # return the response return response +@admin.action(description="change to success") +def change_to_success(model_admin, request, queryset): + for obj in queryset: + obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.SUCCESS, 'change to success by admin') +@admin.action(description="change to failed") +def change_to_failed(model_admin, request, queryset): + for obj in queryset: + obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.FAILED, 'change to failed by admin') class PaymentRequestAdmin(admin.ModelAdmin): list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] - actions = [export_exel] + actions = [export_exel, change_to_success, change_to_failed] def changelist_view(self, request, extra_context=None): From 8ceb818edc0767c99fbb587bdc5f8742cce9d8be Mon Sep 17 00:00:00 2001 From: hgh Date: Tue, 14 Oct 2025 11:48:14 +0330 Subject: [PATCH 13/38] FEATURE(pg):adding is registered field to payment request and batch mark as registered adding is registered field to payment request and batch mark as registered --- apps/pg/admin.py | 10 ++++++++-- .../0006_paymentrequest_is_registered.py | 18 ++++++++++++++++++ apps/pg/models.py | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 apps/pg/migrations/0006_paymentrequest_is_registered.py diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 00a1d9d..c555afa 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -59,12 +59,18 @@ def change_to_failed(model_admin, request, queryset): for obj in queryset: obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.FAILED, 'change to failed by admin') +@admin.action(description="mark as registered") +def mark_as_registered(model_admin, request, queryset): + for obj in queryset: + obj.is_registered = True + obj.save(update_fields=['is_registered']) + class PaymentRequestAdmin(admin.ModelAdmin): - list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] + list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'is_registered', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] - actions = [export_exel, change_to_success, change_to_failed] + actions = [export_exel, change_to_success, change_to_failed, mark_as_registered] def changelist_view(self, request, extra_context=None): diff --git a/apps/pg/migrations/0006_paymentrequest_is_registered.py b/apps/pg/migrations/0006_paymentrequest_is_registered.py new file mode 100644 index 0000000..1ce1a07 --- /dev/null +++ b/apps/pg/migrations/0006_paymentrequest_is_registered.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-10-14 11:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pg', '0005_fake'), + ] + + operations = [ + migrations.AddField( + model_name='paymentrequest', + name='is_registered', + field=models.BooleanField(default=False), + ), + ] diff --git a/apps/pg/models.py b/apps/pg/models.py index 68589c6..af26d87 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -41,6 +41,8 @@ class PaymentRequest(models.Model): phone_number = models.CharField(max_length=255, null=True, blank=True) callback_url = models.CharField(max_length=255, null=True, blank=True) + is_registered = models.BooleanField(default=False) + created_at = models.DateTimeField(auto_now_add=True, db_index=True) updated_at = models.DateTimeField(auto_now=True, db_index=True) From 64368eb18811853562fa881b1e170b4d61156da9 Mon Sep 17 00:00:00 2001 From: hgh Date: Wed, 15 Oct 2025 17:53:22 +0330 Subject: [PATCH 14/38] FEATURE(pg):check success again check success again --- apps/pg/admin.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 00a1d9d..650555c 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -2,10 +2,14 @@ import io import jdatetime import xlsxwriter -from django.contrib import admin +from django.contrib import admin, messages from django.db.models import Sum from django.http import HttpResponse from django.utils import timezone +from django.utils.html import format_html +from django.shortcuts import redirect +from django.urls import path +from utils.wallet_client import deposit_to_user_wallet_verify from .constans import StateChoices from .models import PaymentRequest, PNA, Fake @@ -61,7 +65,7 @@ def change_to_failed(model_admin, request, queryset): class PaymentRequestAdmin(admin.ModelAdmin): - list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] + list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] actions = [export_exel, change_to_success, change_to_failed] @@ -78,6 +82,43 @@ class PaymentRequestAdmin(admin.ModelAdmin): extra_context['totals'] = totals return super().changelist_view(request, extra_context=extra_context) + def check_success_again(self, obj): + if obj.state == StateChoices.WALLET_SUBMIT_SUCCESS: + return format_html( + 'بررسی دوباره موفقیت', + f'{obj.uuid}/check_success_again/' + ) + return '' + + def get_urls(self): + urls = super().get_urls() + custom_urls = [ + path('/check_success_again/', self.admin_site.admin_view(self.check_success_again_view)) + ] + return custom_urls + urls + + def check_success_again_view(self, request, payment_request_uuid): + verify_response = deposit_to_user_wallet_verify(payment_request_uuid) + if not verify_response: + self.message_user(request, "خطای استعلام", level=messages.ERROR) + else: + if not verify_response.uuid or verify_response.state != 5: + to_pay_failed = PaymentRequest.objects.filter( + pk=payment_request_uuid, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.FAILED.value, + ) + else: + to_pay_success = PaymentRequest.objects.filter( + pk=payment_request_uuid, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.SUCCESS.value, + ) + self.message_user(request, f"درخواست {payment_request_uuid} بررسی شد ✅") + return redirect(request.META.get("HTTP_REFERER", "..")) + class FakeAdmin(admin.ModelAdmin): list_display = [ 'created_at'] From c8939de18fec536b49f3d23a30318e7092788d70 Mon Sep 17 00:00:00 2001 From: hgh Date: Sun, 19 Oct 2025 16:43:27 +0330 Subject: [PATCH 15/38] FEATURE(pg): update wallet client update wallet client --- gooyal_wallet_client/api/api/__init__.py | 1 + .../api/api/api_charge_create_create.py | 151 +++++++++++++ gooyal_wallet_client/api/wallet/__init__.py | 1 + ...wallet_api_application_balance_retrieve.py | 1 + ...llet_api_application_balance_retrieve_2.py | 151 +++++++++++++ .../wallet_api_application_deposit_create.py | 4 +- ...wallet_api_application_deposit_create_2.py | 168 +++++++++++++++ ...api_application_deposit_verify_retrieve.py | 1 + ...i_application_deposit_verify_retrieve_2.py | 160 ++++++++++++++ .../api/wallet/wallet_api_application_list.py | 44 ++-- .../wallet/wallet_api_application_list_2.py | 183 ++++++++++++++++ .../wallet/wallet_api_application_retrieve.py | 16 +- .../wallet_api_application_retrieve_2.py | 147 +++++++++++++ ...t_api_application_user_balance_retrieve.py | 147 +++++++++++++ ...api_application_user_balance_retrieve_2.py | 160 ++++++++++++++ .../wallet_api_application_withdraw_create.py | 4 +- ...allet_api_application_withdraw_create_2.py | 168 +++++++++++++++ ...pi_application_withdraw_verify_retrieve.py | 1 + ..._application_withdraw_verify_retrieve_2.py | 160 ++++++++++++++ .../wallet/wallet_api_transactions_list.py | 44 ++-- .../wallet_api_user_balance_retrieve.py | 147 +++++++++++++ .../wallet_api_user_transactions_list.py | 203 ++++++++++++++++++ .../wallet_api_wallet_balance_retrieve.py | 1 + gooyal_wallet_client/models/__init__.py | 6 +- .../models/application_balance.py | 5 +- .../models/application_deposit.py | 165 ++++---------- .../models/application_transaction.py | 134 +++--------- .../models/application_withdraw.py | 193 +++++------------ gooyal_wallet_client/models/charge.py | 150 +++++++++++++ gooyal_wallet_client/models/my_wallet.py | 5 +- .../paginated_application_transaction_list.py | 9 +- .../models/paginated_user_transaction_list.py | 9 +- .../models/payee_type_enum.py | 9 - .../models/payer_type_enum.py | 9 - .../models/user_transaction.py | 134 +++--------- gooyal_wallet_client/types.py | 18 +- 36 files changed, 2361 insertions(+), 548 deletions(-) create mode 100644 gooyal_wallet_client/api/api/__init__.py create mode 100644 gooyal_wallet_client/api/api/api_charge_create_create.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py create mode 100644 gooyal_wallet_client/models/charge.py delete mode 100644 gooyal_wallet_client/models/payee_type_enum.py delete mode 100644 gooyal_wallet_client/models/payer_type_enum.py diff --git a/gooyal_wallet_client/api/api/__init__.py b/gooyal_wallet_client/api/api/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/gooyal_wallet_client/api/api/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/gooyal_wallet_client/api/api/api_charge_create_create.py b/gooyal_wallet_client/api/api/api_charge_create_create.py new file mode 100644 index 0000000..d85ea99 --- /dev/null +++ b/gooyal_wallet_client/api/api/api_charge_create_create.py @@ -0,0 +1,151 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.charge import Charge +from ...types import Response + + +def _get_kwargs( + *, + body: Charge, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/api/charge_create", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Charge]: + if response.status_code == 201: + response_201 = Charge.from_dict(response.json()) + + return response_201 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Charge]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + body: Charge, +) -> Response[Charge]: + """ + Args: + body (Charge): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Charge] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: Charge, +) -> Optional[Charge]: + """ + Args: + body (Charge): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Charge + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: Charge, +) -> Response[Charge]: + """ + Args: + body (Charge): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Charge] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: Charge, +) -> Optional[Charge]: + """ + Args: + body (Charge): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Charge + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/__init__.py b/gooyal_wallet_client/api/wallet/__init__.py index e69de29..2d7c0b2 100644 --- a/gooyal_wallet_client/api/wallet/__init__.py +++ b/gooyal_wallet_client/api/wallet/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py index 6e39db6..f896c6c 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py @@ -25,6 +25,7 @@ def _parse_response( response_200 = ApplicationBalance.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py new file mode 100644 index 0000000..6c10de8 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py @@ -0,0 +1,151 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_balance import ApplicationBalance +from ...types import Response + + +def _get_kwargs( + category_uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/balance", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationBalance]: + if response.status_code == 200: + response_200 = ApplicationBalance.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationBalance]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationBalance] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationBalance + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationBalance] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationBalance + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py index 0612c2d..12f96d7 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py @@ -20,9 +20,8 @@ def _get_kwargs( "url": "/wallet/api/application/deposit/", } - _body = body.to_dict() + _kwargs["json"] = body.to_dict() - _kwargs["json"] = _body headers["Content-Type"] = "application/json" _kwargs["headers"] = headers @@ -36,6 +35,7 @@ def _parse_response( response_201 = ApplicationDeposit.from_dict(response.json()) return response_201 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py new file mode 100644 index 0000000..ef013a5 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py @@ -0,0 +1,168 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_deposit import ApplicationDeposit +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + *, + body: ApplicationDeposit, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/wallet/api/application/{category_uuid}/deposit/", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationDeposit]: + if response.status_code == 201: + response_201 = ApplicationDeposit.from_dict(response.json()) + + return response_201 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationDeposit]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (str): + body (ApplicationDeposit): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationDeposit] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (str): + body (ApplicationDeposit): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationDeposit + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (str): + body (ApplicationDeposit): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationDeposit] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (str): + body (ApplicationDeposit): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationDeposit + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py index e5b7c34..fde4421 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py @@ -27,6 +27,7 @@ def _parse_response( response_200 = ApplicationDeposit.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py new file mode 100644 index 0000000..e21cbdb --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_deposit import ApplicationDeposit +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/deposit/{uuid}/verify", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationDeposit]: + if response.status_code == 200: + response_200 = ApplicationDeposit.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationDeposit]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationDeposit] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationDeposit + """ + + return sync_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationDeposit] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationDeposit + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_list.py index 8c65444..b3c7624 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_list.py @@ -11,11 +11,14 @@ from ...types import UNSET, Response, Unset def _get_kwargs( *, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} - params["page"] = page + params["limit"] = limit + + params["offset"] = offset params = {k: v for k, v in params.items() if v is not UNSET and v is not None} @@ -35,6 +38,7 @@ def _parse_response( response_200 = PaginatedApplicationTransactionList.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,11 +59,13 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -70,7 +76,8 @@ def sync_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = client.get_httpx_client().request( @@ -83,11 +90,13 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -99,18 +108,21 @@ def sync( return sync_detailed( client=client, - page=page, + limit=limit, + offset=offset, ).parsed async def asyncio_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -121,7 +133,8 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -132,11 +145,13 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -149,6 +164,7 @@ async def asyncio( return ( await asyncio_detailed( client=client, - page=page, + limit=limit, + offset=offset, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py new file mode 100644 index 0000000..84cbf49 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py @@ -0,0 +1,183 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.paginated_application_transaction_list import PaginatedApplicationTransactionList +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + category_uuid: str, + *, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PaginatedApplicationTransactionList]: + if response.status_code == 200: + response_200 = PaginatedApplicationTransactionList.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PaginatedApplicationTransactionList]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedApplicationTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedApplicationTransactionList + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedApplicationTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedApplicationTransactionList + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py index bbb4146..9ef9349 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py @@ -10,11 +10,12 @@ from ...types import Response def _get_kwargs( + category_uuid: str, uuid: str, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/{uuid}/", + "url": f"/wallet/api/application/{category_uuid}/{uuid}/", } return _kwargs @@ -27,6 +28,7 @@ def _parse_response( response_200 = ApplicationTransaction.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -45,12 +47,14 @@ def _build_response( def sync_detailed( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -62,6 +66,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + category_uuid=category_uuid, uuid=uuid, ) @@ -73,12 +78,14 @@ def sync_detailed( def sync( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -90,18 +97,21 @@ def sync( """ return sync_detailed( + category_uuid=category_uuid, uuid=uuid, client=client, ).parsed async def asyncio_detailed( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -113,6 +123,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + category_uuid=category_uuid, uuid=uuid, ) @@ -122,12 +133,14 @@ async def asyncio_detailed( async def asyncio( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -140,6 +153,7 @@ async def asyncio( return ( await asyncio_detailed( + category_uuid=category_uuid, uuid=uuid, client=client, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py new file mode 100644 index 0000000..50d6347 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_transaction import ApplicationTransaction +from ...types import Response + + +def _get_kwargs( + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{uuid}/", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationTransaction]: + if response.status_code == 200: + response_200 = ApplicationTransaction.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationTransaction]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationTransaction] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationTransaction + """ + + return sync_detailed( + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationTransaction] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationTransaction + """ + + return ( + await asyncio_detailed( + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py new file mode 100644 index 0000000..2062248 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/user_balance/{uuid}", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return sync_detailed( + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return ( + await asyncio_detailed( + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py new file mode 100644 index 0000000..f77f03f --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/user/{uuid}/balance", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return sync_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py index 731ae3c..3853436 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py @@ -20,9 +20,8 @@ def _get_kwargs( "url": "/wallet/api/application/withdraw/", } - _body = body.to_dict() + _kwargs["json"] = body.to_dict() - _kwargs["json"] = _body headers["Content-Type"] = "application/json" _kwargs["headers"] = headers @@ -36,6 +35,7 @@ def _parse_response( response_201 = ApplicationWithdraw.from_dict(response.json()) return response_201 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py new file mode 100644 index 0000000..f4b42ac --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py @@ -0,0 +1,168 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_withdraw import ApplicationWithdraw +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + *, + body: ApplicationWithdraw, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/wallet/api/application/{category_uuid}/withdraw/", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationWithdraw]: + if response.status_code == 201: + response_201 = ApplicationWithdraw.from_dict(response.json()) + + return response_201 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationWithdraw]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + body (ApplicationWithdraw): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationWithdraw] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + body (ApplicationWithdraw): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationWithdraw + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + body (ApplicationWithdraw): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationWithdraw] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + body (ApplicationWithdraw): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationWithdraw + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py index 0e0d0db..dd57a27 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py @@ -27,6 +27,7 @@ def _parse_response( response_200 = ApplicationWithdraw.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py new file mode 100644 index 0000000..651a764 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_withdraw import ApplicationWithdraw +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/withdraw/{uuid}/verify", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationWithdraw]: + if response.status_code == 200: + response_200 = ApplicationWithdraw.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationWithdraw]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationWithdraw] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationWithdraw + """ + + return sync_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationWithdraw] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (str): + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationWithdraw + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py index 4009fe1..7880004 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py @@ -11,11 +11,14 @@ from ...types import UNSET, Response, Unset def _get_kwargs( *, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} - params["page"] = page + params["limit"] = limit + + params["offset"] = offset params = {k: v for k, v in params.items() if v is not UNSET and v is not None} @@ -35,6 +38,7 @@ def _parse_response( response_200 = PaginatedUserTransactionList.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,7 +59,8 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -64,7 +69,8 @@ def sync_detailed( - user: authenticated user Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -75,7 +81,8 @@ def sync_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = client.get_httpx_client().request( @@ -88,7 +95,8 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -97,7 +105,8 @@ def sync( - user: authenticated user Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -109,14 +118,16 @@ def sync( return sync_detailed( client=client, - page=page, + limit=limit, + offset=offset, ).parsed async def asyncio_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -125,7 +136,8 @@ async def asyncio_detailed( - user: authenticated user Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -136,7 +148,8 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -147,7 +160,8 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -156,7 +170,8 @@ async def asyncio( - user: authenticated user Args: - page (Union[Unset, int]): + limit (Union[Unset, int]): + offset (Union[Unset, int]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -169,6 +184,7 @@ async def asyncio( return ( await asyncio_detailed( client=client, - page=page, + limit=limit, + offset=offset, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py new file mode 100644 index 0000000..2928286 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + category_uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/user/{category_uuid}/balance", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py new file mode 100644 index 0000000..50cbc86 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.paginated_user_transaction_list import PaginatedUserTransactionList +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + category_uuid: str, + *, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/user/{category_uuid}/transactions/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PaginatedUserTransactionList]: + if response.status_code == 200: + response_200 = PaginatedUserTransactionList.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PaginatedUserTransactionList]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedUserTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedUserTransactionList + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedUserTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + limit (Union[Unset, int]): + offset (Union[Unset, int]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedUserTransactionList + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py index a05375e..5a5e38d 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py @@ -23,6 +23,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt response_200 = MyWallet.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/models/__init__.py b/gooyal_wallet_client/models/__init__.py index 30db318..06a7b4a 100644 --- a/gooyal_wallet_client/models/__init__.py +++ b/gooyal_wallet_client/models/__init__.py @@ -4,11 +4,10 @@ from .application_balance import ApplicationBalance from .application_deposit import ApplicationDeposit from .application_transaction import ApplicationTransaction from .application_withdraw import ApplicationWithdraw +from .charge import Charge from .my_wallet import MyWallet from .paginated_application_transaction_list import PaginatedApplicationTransactionList from .paginated_user_transaction_list import PaginatedUserTransactionList -from .payee_type_enum import PayeeTypeEnum -from .payer_type_enum import PayerTypeEnum from .state_enum import StateEnum from .user_transaction import UserTransaction @@ -17,11 +16,10 @@ __all__ = ( "ApplicationDeposit", "ApplicationTransaction", "ApplicationWithdraw", + "Charge", "MyWallet", "PaginatedApplicationTransactionList", "PaginatedUserTransactionList", - "PayeeTypeEnum", - "PayerTypeEnum", "StateEnum", "UserTransaction", ) diff --git a/gooyal_wallet_client/models/application_balance.py b/gooyal_wallet_client/models/application_balance.py index c094cc5..3ae824e 100644 --- a/gooyal_wallet_client/models/application_balance.py +++ b/gooyal_wallet_client/models/application_balance.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -30,8 +31,8 @@ class ApplicationBalance: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) balance = d.pop("balance", UNSET) application_balance = cls( diff --git a/gooyal_wallet_client/models/application_deposit.py b/gooyal_wallet_client/models/application_deposit.py index 267dc45..9d1772f 100644 --- a/gooyal_wallet_client/models/application_deposit.py +++ b/gooyal_wallet_client/models/application_deposit.py @@ -1,13 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +from collections.abc import Mapping +from typing import Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from dateutil.parser import isoparse -from ..models.payee_type_enum import PayeeTypeEnum -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,11 +17,11 @@ T = TypeVar("T", bound="ApplicationDeposit") class ApplicationDeposit: """ Attributes: - uuid (UUID): - payer_id (Union[None, UUID]): - payer_type (Union[None, PayerTypeEnum]): + payer_id (str): + payer_type (str): payee_id (UUID): - created_at (Union[None, datetime.datetime]): + payee_type (int): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -31,63 +30,43 @@ class ApplicationDeposit: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): - payee_type (Union[None, PayeeTypeEnum, Unset]): + updated_at (datetime.datetime): + uuid (Union[Unset, UUID]): details (Union[Unset, Any]): """ - uuid: UUID - payer_id: Union[None, UUID] - payer_type: Union[None, PayerTypeEnum] + payer_id: str + payer_type: str payee_id: UUID - created_at: Union[None, datetime.datetime] + payee_type: int + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] - payee_type: Union[None, PayeeTypeEnum, Unset] = UNSET + updated_at: datetime.datetime + uuid: Union[Unset, UUID] = UNSET details: Union[Unset, Any] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) + payer_id = self.payer_id - payer_id: Union[None, str] - if isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, int] - if isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type + payer_type = self.payer_type payee_id = str(self.payee_id) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + payee_type = self.payee_type + + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() - payee_type: Union[None, Unset, int] - if isinstance(self.payee_type, Unset): - payee_type = UNSET - elif isinstance(self.payee_type, PayeeTypeEnum): - payee_type = self.payee_type.value - else: - payee_type = self.payee_type + uuid: Union[Unset, str] = UNSET + if not isinstance(self.uuid, Unset): + uuid = str(self.uuid) details = self.details @@ -95,123 +74,61 @@ class ApplicationDeposit: field_dict.update(self.additional_properties) field_dict.update( { - "uuid": uuid, "payer_id": payer_id, "payer_type": payer_type, "payee_id": payee_id, + "payee_type": payee_type, "created_at": created_at, "state": state, "amount": amount, "updated_at": updated_at, } ) - if payee_type is not UNSET: - field_dict["payee_type"] = payee_type + if uuid is not UNSET: + field_dict["uuid"] = uuid if details is not UNSET: field_dict["details"] = details return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - uuid = UUID(d.pop("uuid")) + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + payer_id = d.pop("payer_id") - def _parse_payer_id(data: object) -> Union[None, UUID]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID], data) - - payer_id = _parse_payer_id(d.pop("payer_id")) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum]: - if data is None: - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum], data) - - payer_type = _parse_payer_type(d.pop("payer_type")) + payer_type = d.pop("payer_type") payee_id = UUID(d.pop("payee_id")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) + payee_type = d.pop("payee_type") - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) + updated_at = isoparse(d.pop("updated_at")) - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) - - def _parse_payee_type(data: object) -> Union[None, PayeeTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payee_type_type_0 = PayeeTypeEnum(data) - - return payee_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayeeTypeEnum, Unset], data) - - payee_type = _parse_payee_type(d.pop("payee_type", UNSET)) + _uuid = d.pop("uuid", UNSET) + uuid: Union[Unset, UUID] + if isinstance(_uuid, Unset): + uuid = UNSET + else: + uuid = UUID(_uuid) details = d.pop("details", UNSET) application_deposit = cls( - uuid=uuid, payer_id=payer_id, payer_type=payer_type, payee_id=payee_id, + payee_type=payee_type, created_at=created_at, state=state, amount=amount, updated_at=updated_at, - payee_type=payee_type, + uuid=uuid, details=details, ) diff --git a/gooyal_wallet_client/models/application_transaction.py b/gooyal_wallet_client/models/application_transaction.py index 0bd6ab3..f504cbc 100644 --- a/gooyal_wallet_client/models/application_transaction.py +++ b/gooyal_wallet_client/models/application_transaction.py @@ -1,12 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +from collections.abc import Mapping +from typing import Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from dateutil.parser import isoparse -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,9 +18,11 @@ class ApplicationTransaction: """ Attributes: uuid (UUID): + payer_id (str): + payer_type (str): payee_id (UUID): payee_type (UUID): - created_at (Union[None, datetime.datetime]): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -29,71 +31,49 @@ class ApplicationTransaction: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): + updated_at (datetime.datetime): details (Any): role (str): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): delay (Union[Unset, int]): """ uuid: UUID + payer_id: str + payer_type: str payee_id: UUID payee_type: UUID - created_at: Union[None, datetime.datetime] + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] + updated_at: datetime.datetime details: Any role: str - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET delay: Union[Unset, int] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: uuid = str(self.uuid) + payer_id = self.payer_id + + payer_type = self.payer_type + payee_id = str(self.payee_id) payee_type = str(self.payee_type) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() details = self.details role = self.role - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - delay = self.delay field_dict: dict[str, Any] = {} @@ -101,6 +81,8 @@ class ApplicationTransaction: field_dict.update( { "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, @@ -111,100 +93,42 @@ class ApplicationTransaction: "role": role, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type if delay is not UNSET: field_dict["delay"] = delay return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) uuid = UUID(d.pop("uuid")) + payer_id = d.pop("payer_id") + + payer_type = d.pop("payer_type") + payee_id = UUID(d.pop("payee_id")) payee_type = UUID(d.pop("payee_type")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) - - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) + updated_at = isoparse(d.pop("updated_at")) details = d.pop("details") role = d.pop("role") - def _parse_payer_id(data: object) -> Union[None, UUID, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, str): - raise TypeError() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) - delay = d.pop("delay", UNSET) application_transaction = cls( uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, @@ -213,8 +137,6 @@ class ApplicationTransaction: updated_at=updated_at, details=details, role=role, - payer_id=payer_id, - payer_type=payer_type, delay=delay, ) diff --git a/gooyal_wallet_client/models/application_withdraw.py b/gooyal_wallet_client/models/application_withdraw.py index cd473a2..3470f5a 100644 --- a/gooyal_wallet_client/models/application_withdraw.py +++ b/gooyal_wallet_client/models/application_withdraw.py @@ -1,13 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +from collections.abc import Mapping +from typing import Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from dateutil.parser import isoparse -from ..models.payee_type_enum import PayeeTypeEnum -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,10 +17,11 @@ T = TypeVar("T", bound="ApplicationWithdraw") class ApplicationWithdraw: """ Attributes: - uuid (UUID): - payee_id (UUID): - payee_type (Union[None, PayeeTypeEnum]): - created_at (Union[None, datetime.datetime]): + payer_id (UUID): + payer_type (int): + payee_id (str): + payee_type (str): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -30,193 +30,106 @@ class ApplicationWithdraw: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): - details (Any): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): + updated_at (datetime.datetime): + uuid (Union[Unset, UUID]): + details (Union[Unset, Any]): """ - uuid: UUID - payee_id: UUID - payee_type: Union[None, PayeeTypeEnum] - created_at: Union[None, datetime.datetime] + payer_id: UUID + payer_type: int + payee_id: str + payee_type: str + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] - details: Any - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET + updated_at: datetime.datetime + uuid: Union[Unset, UUID] = UNSET + details: Union[Unset, Any] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) + payer_id = str(self.payer_id) - payee_id = str(self.payee_id) + payer_type = self.payer_type - payee_type: Union[None, int] - if isinstance(self.payee_type, PayeeTypeEnum): - payee_type = self.payee_type.value - else: - payee_type = self.payee_type + payee_id = self.payee_id - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + payee_type = self.payee_type + + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() + + uuid: Union[Unset, str] = UNSET + if not isinstance(self.uuid, Unset): + uuid = str(self.uuid) details = self.details - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, "state": state, "amount": amount, "updated_at": updated_at, - "details": details, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type + if uuid is not UNSET: + field_dict["uuid"] = uuid + if details is not UNSET: + field_dict["details"] = details return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() - uuid = UUID(d.pop("uuid")) + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + payer_id = UUID(d.pop("payer_id")) - payee_id = UUID(d.pop("payee_id")) + payer_type = d.pop("payer_type") - def _parse_payee_type(data: object) -> Union[None, PayeeTypeEnum]: - if data is None: - return data - try: - if not isinstance(data, int): - raise TypeError() - payee_type_type_0 = PayeeTypeEnum(data) + payee_id = d.pop("payee_id") - return payee_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayeeTypeEnum], data) + payee_type = d.pop("payee_type") - payee_type = _parse_payee_type(d.pop("payee_type")) - - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) + updated_at = isoparse(d.pop("updated_at")) - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) + _uuid = d.pop("uuid", UNSET) + uuid: Union[Unset, UUID] + if isinstance(_uuid, Unset): + uuid = UNSET + else: + uuid = UUID(_uuid) - updated_at = _parse_updated_at(d.pop("updated_at")) - - details = d.pop("details") - - def _parse_payer_id(data: object) -> Union[None, UUID, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, str): - raise TypeError() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) + details = d.pop("details", UNSET) application_withdraw = cls( - uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, state=state, amount=amount, updated_at=updated_at, + uuid=uuid, details=details, - payer_id=payer_id, - payer_type=payer_type, ) application_withdraw.additional_properties = d diff --git a/gooyal_wallet_client/models/charge.py b/gooyal_wallet_client/models/charge.py new file mode 100644 index 0000000..25301fb --- /dev/null +++ b/gooyal_wallet_client/models/charge.py @@ -0,0 +1,150 @@ +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar, Union, cast +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.state_enum import StateEnum + +T = TypeVar("T", bound="Charge") + + +@_attrs_define +class Charge: + """ + Attributes: + uuid (UUID): + user (UUID): + created_at (Union[None, datetime.datetime]): + state (StateEnum): * `1` - created + * `2` - delayed + * `3` - pending + * `4` - incomplete + * `5` - success + * `6` - failed + * `7` - expected_failure + amount (Union[None, int]): + updated_at (Union[None, datetime.datetime]): + """ + + uuid: UUID + user: UUID + created_at: Union[None, datetime.datetime] + state: StateEnum + amount: Union[None, int] + updated_at: Union[None, datetime.datetime] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + uuid = str(self.uuid) + + user = str(self.user) + + created_at: Union[None, str] + if isinstance(self.created_at, datetime.datetime): + created_at = self.created_at.isoformat() + else: + created_at = self.created_at + + state = self.state.value + + amount: Union[None, int] + amount = self.amount + + updated_at: Union[None, str] + if isinstance(self.updated_at, datetime.datetime): + updated_at = self.updated_at.isoformat() + else: + updated_at = self.updated_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "uuid": uuid, + "user": user, + "created_at": created_at, + "state": state, + "amount": amount, + "updated_at": updated_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + uuid = UUID(d.pop("uuid")) + + user = UUID(d.pop("user")) + + def _parse_created_at(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + created_at_type_0 = isoparse(data) + + return created_at_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + created_at = _parse_created_at(d.pop("created_at")) + + state = StateEnum(d.pop("state")) + + def _parse_amount(data: object) -> Union[None, int]: + if data is None: + return data + return cast(Union[None, int], data) + + amount = _parse_amount(d.pop("amount")) + + def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + updated_at_type_0 = isoparse(data) + + return updated_at_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + updated_at = _parse_updated_at(d.pop("updated_at")) + + charge = cls( + uuid=uuid, + user=user, + created_at=created_at, + state=state, + amount=amount, + updated_at=updated_at, + ) + + charge.additional_properties = d + return charge + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/gooyal_wallet_client/models/my_wallet.py b/gooyal_wallet_client/models/my_wallet.py index 16f9ade..e76505d 100644 --- a/gooyal_wallet_client/models/my_wallet.py +++ b/gooyal_wallet_client/models/my_wallet.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -30,8 +31,8 @@ class MyWallet: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) balance = d.pop("balance", UNSET) my_wallet = cls( diff --git a/gooyal_wallet_client/models/paginated_application_transaction_list.py b/gooyal_wallet_client/models/paginated_application_transaction_list.py index 2854f85..f72973d 100644 --- a/gooyal_wallet_client/models/paginated_application_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_application_transaction_list.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define @@ -18,8 +19,8 @@ class PaginatedApplicationTransactionList: Attributes: count (int): Example: 123. results (list['ApplicationTransaction']): - next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4. - previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2. + next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100. + previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100. """ count: int @@ -64,10 +65,10 @@ class PaginatedApplicationTransactionList: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.application_transaction import ApplicationTransaction - d = src_dict.copy() + d = dict(src_dict) count = d.pop("count") results = [] diff --git a/gooyal_wallet_client/models/paginated_user_transaction_list.py b/gooyal_wallet_client/models/paginated_user_transaction_list.py index 631893f..fb90457 100644 --- a/gooyal_wallet_client/models/paginated_user_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_user_transaction_list.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define @@ -18,8 +19,8 @@ class PaginatedUserTransactionList: Attributes: count (int): Example: 123. results (list['UserTransaction']): - next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4. - previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2. + next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100. + previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100. """ count: int @@ -64,10 +65,10 @@ class PaginatedUserTransactionList: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.user_transaction import UserTransaction - d = src_dict.copy() + d = dict(src_dict) count = d.pop("count") results = [] diff --git a/gooyal_wallet_client/models/payee_type_enum.py b/gooyal_wallet_client/models/payee_type_enum.py deleted file mode 100644 index 2d56dd5..0000000 --- a/gooyal_wallet_client/models/payee_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class PayeeTypeEnum(IntEnum): - VALUE_1 = 1 - VALUE_2 = 2 - - def __str__(self) -> str: - return str(self.value) diff --git a/gooyal_wallet_client/models/payer_type_enum.py b/gooyal_wallet_client/models/payer_type_enum.py deleted file mode 100644 index f49196c..0000000 --- a/gooyal_wallet_client/models/payer_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class PayerTypeEnum(IntEnum): - VALUE_1 = 1 - VALUE_2 = 2 - - def __str__(self) -> str: - return str(self.value) diff --git a/gooyal_wallet_client/models/user_transaction.py b/gooyal_wallet_client/models/user_transaction.py index fcc64cf..5b2a0a1 100644 --- a/gooyal_wallet_client/models/user_transaction.py +++ b/gooyal_wallet_client/models/user_transaction.py @@ -1,12 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +from collections.abc import Mapping +from typing import Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from dateutil.parser import isoparse -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,9 +18,11 @@ class UserTransaction: """ Attributes: uuid (UUID): + payer_id (str): + payer_type (str): payee_id (UUID): payee_type (UUID): - created_at (Union[None, datetime.datetime]): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -29,71 +31,49 @@ class UserTransaction: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): + updated_at (datetime.datetime): details (Any): role (int): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): delay (Union[Unset, int]): """ uuid: UUID + payer_id: str + payer_type: str payee_id: UUID payee_type: UUID - created_at: Union[None, datetime.datetime] + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] + updated_at: datetime.datetime details: Any role: int - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET delay: Union[Unset, int] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: uuid = str(self.uuid) + payer_id = self.payer_id + + payer_type = self.payer_type + payee_id = str(self.payee_id) payee_type = str(self.payee_type) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() details = self.details role = self.role - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - delay = self.delay field_dict: dict[str, Any] = {} @@ -101,6 +81,8 @@ class UserTransaction: field_dict.update( { "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, @@ -111,100 +93,42 @@ class UserTransaction: "role": role, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type if delay is not UNSET: field_dict["delay"] = delay return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) uuid = UUID(d.pop("uuid")) + payer_id = d.pop("payer_id") + + payer_type = d.pop("payer_type") + payee_id = UUID(d.pop("payee_id")) payee_type = UUID(d.pop("payee_type")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) - - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) + updated_at = isoparse(d.pop("updated_at")) details = d.pop("details") role = d.pop("role") - def _parse_payer_id(data: object) -> Union[None, UUID, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, str): - raise TypeError() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) - delay = d.pop("delay", UNSET) user_transaction = cls( uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, @@ -213,8 +137,6 @@ class UserTransaction: updated_at=updated_at, details=details, role=role, - payer_id=payer_id, - payer_type=payer_type, delay=delay, ) diff --git a/gooyal_wallet_client/types.py b/gooyal_wallet_client/types.py index b9ed58b..1b96ca4 100644 --- a/gooyal_wallet_client/types.py +++ b/gooyal_wallet_client/types.py @@ -1,8 +1,8 @@ """Contains some shared types for properties""" -from collections.abc import MutableMapping +from collections.abc import Mapping, MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, Optional, TypeVar +from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union from attrs import define @@ -14,7 +14,15 @@ class Unset: UNSET: Unset = Unset() -FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = Union[IO[bytes], bytes, str] +FileTypes = Union[ + # (filename, file (or bytes), content_type) + tuple[Optional[str], FileContent, Optional[str]], + # (filename, file (or bytes), content_type, headers) + tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], +] +RequestFiles = list[tuple[str, FileTypes]] @define @@ -25,7 +33,7 @@ class File: file_name: Optional[str] = None mime_type: Optional[str] = None - def to_tuple(self) -> FileJsonType: + def to_tuple(self) -> FileTypes: """Return a tuple representation that httpx will accept for multipart/form-data""" return self.file_name, self.payload, self.mime_type @@ -43,4 +51,4 @@ class Response(Generic[T]): parsed: Optional[T] -__all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"] +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] From fe31f41362f7e0d404f5c651a790dd75beea0122 Mon Sep 17 00:00:00 2001 From: hgh Date: Mon, 20 Oct 2025 13:39:03 +0330 Subject: [PATCH 16/38] FEATURE(pg): check payment request success and add logger check payment request success and add logger --- apps/pg/admin.py | 39 ++++++-------- apps/pg/models.py | 120 ++++++++++++++++++++++++----------------- main/settings.py | 1 + utils/wallet_client.py | 14 ++--- 4 files changed, 96 insertions(+), 78 deletions(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index 650555c..1af6777 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -1,3 +1,4 @@ +import logging import io import jdatetime @@ -7,13 +8,13 @@ from django.db.models import Sum from django.http import HttpResponse from django.utils import timezone from django.utils.html import format_html -from django.shortcuts import redirect +from django.shortcuts import redirect, get_object_or_404 from django.urls import path -from utils.wallet_client import deposit_to_user_wallet_verify from .constans import StateChoices from .models import PaymentRequest, PNA, Fake +logger = logging.getLogger(__name__) class PNAAdmin(admin.ModelAdmin): list_display = ['pna_status_code', 'pna_status_message', 'jajali_datetime', 'payment_request'] @@ -83,7 +84,7 @@ class PaymentRequestAdmin(admin.ModelAdmin): return super().changelist_view(request, extra_context=extra_context) def check_success_again(self, obj): - if obj.state == StateChoices.WALLET_SUBMIT_SUCCESS: + if obj.state in [StateChoices.IPG_SUCCESS, StateChoices.WALLET_SUBMIT_PENDING, StateChoices.WALLET_SUBMIT_SUCCESS]: return format_html( 'بررسی دوباره موفقیت', f'{obj.uuid}/check_success_again/' @@ -96,27 +97,19 @@ class PaymentRequestAdmin(admin.ModelAdmin): path('/check_success_again/', self.admin_site.admin_view(self.check_success_again_view)) ] return custom_urls + urls - def check_success_again_view(self, request, payment_request_uuid): - verify_response = deposit_to_user_wallet_verify(payment_request_uuid) - if not verify_response: - self.message_user(request, "خطای استعلام", level=messages.ERROR) - else: - if not verify_response.uuid or verify_response.state != 5: - to_pay_failed = PaymentRequest.objects.filter( - pk=payment_request_uuid, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.FAILED.value, - ) - else: - to_pay_success = PaymentRequest.objects.filter( - pk=payment_request_uuid, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.SUCCESS.value, - ) - self.message_user(request, f"درخواست {payment_request_uuid} بررسی شد ✅") + logger.info(f"[Admin panel] Check success again for payment_request_uuid={payment_request_uuid}") + payment_request: PaymentRequest = get_object_or_404(PaymentRequest, uuid=payment_request_uuid) + logger.info(f"[Admin panel] initial payment_request state={payment_request.state}") + if payment_request.state == StateChoices.IPG_SUCCESS: + payment_request.charge_wallet_balance() + elif payment_request.state == StateChoices.WALLET_SUBMIT_PENDING: + payment_request.deposit_submit() + elif payment_request.state == StateChoices.WALLET_SUBMIT_SUCCESS: + payment_request.deposit_verify() + payment_request.refresh_from_db() + logger.info(f"[Admin panel] final payment_request state={payment_request.state}") + self.message_user(request, f"درخواست {payment_request_uuid} بررسی شد ✅") return redirect(request.META.get("HTTP_REFERER", "..")) diff --git a/apps/pg/models.py b/apps/pg/models.py index 68589c6..76f2e3f 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -1,5 +1,6 @@ +import logging + import urllib.parse -from mimetypes import guess_all_extensions import jdatetime from django.conf import settings @@ -18,7 +19,7 @@ from utils.wallet_client import deposit_to_user_wallet_submit, withdraw_from_use from utils.pna import PNAClient from django.utils.translation import gettext_lazy as _ - +logger = logging.getLogger(__name__) class GatewayChoise(TextChoices): FAKE = "fake", _("fake") @@ -114,7 +115,67 @@ class PaymentRequest(models.Model): else: raise Exception(error_message) + def deposit_submit(self): + data = { + "uuid": str(self.uuid), + "payee_id": str(self.user.uuid), + "payee_type": 1, + "amount": self.amount, + "details": { + 'description': str(_("charge via ipg")), + 'reference_id': str(self.uuid), + 'application_details_url': '' + }, + } + submit_response = deposit_to_user_wallet_submit(settings.WALLET_CATEGORY_UUID, data) + + if not submit_response or not submit_response.uuid: + logger.error(f"[Deposit Submit] Wallet submission failed | payment_id={self.pk}") + raise Exception('Failed to submit payment in wallet') + + to_success = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_PENDING.value, + ).update( + state=StateChoices.WALLET_SUBMIT_SUCCESS.value) + + if not to_success: + logger.error(f"[Deposit Submit] Failed to update state to WALLET_SUBMIT_SUCCESS | payment_id={self.pk}") + raise Exception('Cannot charge balance because state') + return to_success + + def deposit_verify(self): + verify_response = deposit_to_user_wallet_verify(settings.WALLET_CATEGORY_UUID, self.uuid) + + if not verify_response: + logger.error(f"[Deposit Verify] Failed to get response from wallet service | payment_id={self.pk}") + raise Exception('Failed to get response from wallet service') + + if not verify_response.uuid or verify_response.state != 5: + logger.error(f"[Deposit Verify] Wallet verification failed | payment_id={self.pk}, response={verify_response}") + to_pay_failed = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.FAILED.value, + ) + raise Exception('Failed to verify payment in wallet') + + to_pay_success = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.SUCCESS.value, + ) + + if not to_pay_success: + logger.error(f"[Deposit Verify] Failed to update state to SUCCESS | payment_id={self.pk}") + raise Exception('Failed to update state payment') + + return to_pay_success + def charge_wallet_balance(self): + logger.info(f"[Charge Wallet] Starting wallet charge process | payment_id={self.pk}") if self.state in [StateChoices.IPG_SUCCESS]: to_pending = PaymentRequest.objects.filter( pk=self.pk, @@ -122,54 +183,15 @@ class PaymentRequest(models.Model): ).update( state=StateChoices.WALLET_SUBMIT_PENDING.value) if not to_pending: + logger.error(f"[Charge Wallet] Failed to update state to WALLET_SUBMIT_PENDING | payment_id={self.pk}") raise Exception('Cannot charge balance because state') - - data = { - "uuid": str(self.uuid), - "payee_id": str(self.user.uuid), - "payee_type": 1, - "amount": self.amount, - "details": { - 'description': str(_("charge via ipg")), - 'reference_id': str(self.uuid), - 'application_details_url': '' - }, - } - submit_response = deposit_to_user_wallet_submit(data) - - if not submit_response.uuid: - raise Exception('Failed to submit payment in wallet') - - to_success = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_PENDING.value, - ).update( - state=StateChoices.WALLET_SUBMIT_SUCCESS.value) - - if not to_success: - raise Exception('Cannot charge balance because state') - - verify_response = deposit_to_user_wallet_verify(self.uuid) - - if not verify_response.uuid or verify_response.state != 5: - to_pay_failed = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.FAILED.value, - ) - raise Exception('Failed to verify payment in wallet') - - to_pay_success = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.SUCCESS.value, - ) - - if not to_pay_success: - raise Exception('Failed to update state payment') - + logger.info(f"[Charge Wallet] State updated to WALLET_SUBMIT_PENDING | payment_id={self.pk}") + self.deposit_submit() + to_pay_success = self.deposit_verify() + if to_pay_success: + logger.info(f"[Charge Wallet] Wallet charged successfully | payment_id={self.pk}") + else: + logger.warning(f"[Charge Wallet] Wallet charge verification failed | payment_id={self.pk}") return bool(to_pay_success) diff --git a/main/settings.py b/main/settings.py index 4a5e9a1..16c1f02 100644 --- a/main/settings.py +++ b/main/settings.py @@ -255,4 +255,5 @@ CACHES = { PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') +WALLET_CATEGORY_UUID = config('WALLET_CATEGORY_UUID') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') diff --git a/utils/wallet_client.py b/utils/wallet_client.py index 0762eaa..729ae4b 100644 --- a/utils/wallet_client.py +++ b/utils/wallet_client.py @@ -8,8 +8,8 @@ from httpx import Request from gooyal_wallet_client import AuthenticatedClient from gooyal_wallet_client.models import MyWallet, UserTransaction, ApplicationDeposit, ApplicationWithdraw -from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create, - wallet_api_application_deposit_verify_retrieve, +from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create_2, + wallet_api_application_deposit_verify_retrieve_2, wallet_api_application_withdraw_create, wallet_api_application_withdraw_verify_retrieve) from gooyal_wallet_client.types import Response @@ -73,22 +73,24 @@ def get_client(): return client -def deposit_to_user_wallet_submit(data): +def deposit_to_user_wallet_submit(category_uuid, data): class Tmp(): def to_dict(self): return data deposit_data = Tmp() client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_create.sync(client=client, body=deposit_data) + response: ApplicationDeposit = wallet_api_application_deposit_create_2.sync(category_uuid= category_uuid, + client=client, + body=deposit_data) print(response) return response -def deposit_to_user_wallet_verify(uuid): +def deposit_to_user_wallet_verify(category_uuid, uuid): client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve.sync(uuid=uuid, client=client) + response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) print(response) return response From ed77a069843d30f55a021a8090ead30a74a9f09b Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 25 Oct 2025 16:38:10 +0330 Subject: [PATCH 17/38] fix(pg): fix payment request admin list display fix payment request admin list display --- apps/pg/admin.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/apps/pg/admin.py b/apps/pg/admin.py index fcc83d2..1dc9b08 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -54,16 +54,6 @@ def export_exel(modeladmin, request, queryset): # return the response return response -@admin.action(description="change to success") -def change_to_success(model_admin, request, queryset): - for obj in queryset: - obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.SUCCESS, 'change to success by admin') - -@admin.action(description="change to failed") -def change_to_failed(model_admin, request, queryset): - for obj in queryset: - obj.change_state(StateChoices.WALLET_SUBMIT_SUCCESS, StateChoices.FAILED, 'change to failed by admin') - @admin.action(description="mark as registered") def mark_as_registered(model_admin, request, queryset): for obj in queryset: @@ -72,11 +62,10 @@ def mark_as_registered(model_admin, request, queryset): class PaymentRequestAdmin(admin.ModelAdmin): - list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'is_registered', 'created_at', 'application', 'gateway'] - list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] + list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'is_registered', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] - actions = [export_exel, change_to_success, change_to_failed, mark_as_registered] + actions = [export_exel, mark_as_registered] def changelist_view(self, request, extra_context=None): From 1084ed0b5c5893032366767c2b2fd07ef6caf8b0 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 25 Oct 2025 17:14:28 +0330 Subject: [PATCH 18/38] fix(pg): new wallet client to handle category uuid new wallet client to handle category uuid notice: add WALLET_RIAL_CATEGORY to .env --- apps/pg/models.py | 6 +++--- main/settings.py | 2 +- utils/wallet_client.py | 16 ++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index 025567e..6396b24 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -14,7 +14,7 @@ from apps.core.models import BaseModel, BasePGModel from apps.pg.constans import StateChoices import uuid -from utils.wallet_client import deposit_to_user_wallet_submit, withdraw_from_user_wallet_verify, \ +from utils.wallet_client import deposit_to_user_wallet_submit, \ deposit_to_user_wallet_verify from utils.pna import PNAClient @@ -129,7 +129,7 @@ class PaymentRequest(models.Model): 'application_details_url': '' }, } - submit_response = deposit_to_user_wallet_submit(settings.WALLET_CATEGORY_UUID, data) + submit_response = deposit_to_user_wallet_submit(settings.WALLET_RIAL_CATEGORY, data) if not submit_response or not submit_response.uuid: logger.error(f"[Deposit Submit] Wallet submission failed | payment_id={self.pk}") @@ -147,7 +147,7 @@ class PaymentRequest(models.Model): return to_success def deposit_verify(self): - verify_response = deposit_to_user_wallet_verify(settings.WALLET_CATEGORY_UUID, self.uuid) + verify_response = deposit_to_user_wallet_verify(settings.WALLET_RIAL_CATEGORY, self.uuid) if not verify_response: logger.error(f"[Deposit Verify] Failed to get response from wallet service | payment_id={self.pk}") diff --git a/main/settings.py b/main/settings.py index 16c1f02..d528c2d 100644 --- a/main/settings.py +++ b/main/settings.py @@ -255,5 +255,5 @@ CACHES = { PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') -WALLET_CATEGORY_UUID = config('WALLET_CATEGORY_UUID') +WALLET_RIAL_CATEGORY = config('WALLET_RIAL_CATEGORY') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') diff --git a/utils/wallet_client.py b/utils/wallet_client.py index 729ae4b..08ba00f 100644 --- a/utils/wallet_client.py +++ b/utils/wallet_client.py @@ -10,8 +10,8 @@ from gooyal_wallet_client import AuthenticatedClient from gooyal_wallet_client.models import MyWallet, UserTransaction, ApplicationDeposit, ApplicationWithdraw from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create_2, wallet_api_application_deposit_verify_retrieve_2, - wallet_api_application_withdraw_create, - wallet_api_application_withdraw_verify_retrieve) + wallet_api_application_withdraw_create_2, + wallet_api_application_withdraw_verify_retrieve_2) from gooyal_wallet_client.types import Response from django.conf import Settings @@ -84,7 +84,6 @@ def deposit_to_user_wallet_submit(category_uuid, data): client=client, body=deposit_data) print(response) - return response @@ -92,28 +91,25 @@ def deposit_to_user_wallet_verify(category_uuid, uuid): client = get_client() response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) print(response) - return response -def withdraw_from_user_wallet_submit(data): +def withdraw_from_user_wallet_submit(category_uuid, data): class Tmp(): def to_dict(self): return data withdraw_data = Tmp() client = get_client() - response: ApplicationWithdraw = wallet_api_application_withdraw_create.sync(client=client, body=withdraw_data) + response: ApplicationWithdraw = wallet_api_application_withdraw_create_2.sync(category_uuid=category_uuid, client=client, body=withdraw_data) print(response) - return response -def withdraw_from_user_wallet_verify(uuid): +def withdraw_from_user_wallet_verify(category_uuid, uuid): client = get_client() - response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve.sync(uuid=uuid, client=client) + response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) print(response) - return response From 91ba2a7edf4c74e4f57190262ca4bbe99aa87f0e Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Wed, 29 Oct 2025 11:31:00 +0330 Subject: [PATCH 19/38] fix(pg): new wallet api new wallet api --- gooyal_wallet_client/api/api/__init__.py | 1 - .../api/api/api_charge_create_create.py | 151 ------------ ...wallet_api_application_balance_retrieve.py | 127 ---------- ...llet_api_application_balance_retrieve_2.py | 151 ------------ .../wallet_api_application_deposit_create.py | 15 +- ...wallet_api_application_deposit_create_2.py | 168 ------------- ...api_application_deposit_verify_retrieve.py | 15 +- ...i_application_deposit_verify_retrieve_2.py | 160 ------------ .../wallet/wallet_api_application_retrieve.py | 160 ------------ .../wallet_api_application_retrieve_2.py | 147 ------------ ...allet_api_application_transactions_list.py | 227 ++++++++++++++++++ ..._api_application_transactions_retrieve.py} | 57 +++-- ...api_application_user_balance_retrieve_2.py | 160 ------------ ...=> wallet_api_application_wallets_list.py} | 38 +-- ...llet_api_application_wallets_user_list.py} | 97 ++++---- .../wallet_api_application_withdraw_create.py | 15 +- ...allet_api_application_withdraw_create_2.py | 168 ------------- ...pi_application_withdraw_verify_retrieve.py | 15 +- ..._application_withdraw_verify_retrieve_2.py | 160 ------------ .../wallet/wallet_api_transactions_list.py | 81 ++++++- .../wallet_api_user_balance_retrieve.py | 147 ------------ .../wallet_api_wallet_balance_retrieve.py | 123 ---------- ...n_list_2.py => wallet_api_wallets_list.py} | 72 +++--- gooyal_wallet_client/models/__init__.py | 22 +- .../{application_balance.py => account.py} | 43 +++- .../models/application_deposit.py | 40 ++- .../models/application_transaction.py | 160 ------------ .../models/application_withdraw.py | 40 ++- gooyal_wallet_client/models/charge.py | 150 ------------ gooyal_wallet_client/models/my_wallet.py | 59 ----- ...tion_list.py => paginated_account_list.py} | 20 +- ..._list.py => paginated_transaction_list.py} | 20 +- .../{user_transaction.py => transaction.py} | 58 +++-- 33 files changed, 651 insertions(+), 2416 deletions(-) delete mode 100644 gooyal_wallet_client/api/api/__init__.py delete mode 100644 gooyal_wallet_client/api/api/api_charge_create_create.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py create mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py rename gooyal_wallet_client/api/wallet/{wallet_api_application_user_balance_retrieve.py => wallet_api_application_transactions_retrieve.py} (75%) delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py rename gooyal_wallet_client/api/wallet/{wallet_api_application_list.py => wallet_api_application_wallets_list.py} (82%) rename gooyal_wallet_client/api/wallet/{wallet_api_user_transactions_list.py => wallet_api_application_wallets_user_list.py} (64%) delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py delete mode 100644 gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py rename gooyal_wallet_client/api/wallet/{wallet_api_application_list_2.py => wallet_api_wallets_list.py} (74%) rename gooyal_wallet_client/models/{application_balance.py => account.py} (53%) delete mode 100644 gooyal_wallet_client/models/application_transaction.py delete mode 100644 gooyal_wallet_client/models/charge.py delete mode 100644 gooyal_wallet_client/models/my_wallet.py rename gooyal_wallet_client/models/{paginated_user_transaction_list.py => paginated_account_list.py} (85%) rename gooyal_wallet_client/models/{paginated_application_transaction_list.py => paginated_transaction_list.py} (84%) rename gooyal_wallet_client/models/{user_transaction.py => transaction.py} (76%) diff --git a/gooyal_wallet_client/api/api/__init__.py b/gooyal_wallet_client/api/api/__init__.py deleted file mode 100644 index 2d7c0b2..0000000 --- a/gooyal_wallet_client/api/api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Contains endpoint functions for accessing the API""" diff --git a/gooyal_wallet_client/api/api/api_charge_create_create.py b/gooyal_wallet_client/api/api/api_charge_create_create.py deleted file mode 100644 index d85ea99..0000000 --- a/gooyal_wallet_client/api/api/api_charge_create_create.py +++ /dev/null @@ -1,151 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.charge import Charge -from ...types import Response - - -def _get_kwargs( - *, - body: Charge, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": "/api/charge_create", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Charge]: - if response.status_code == 201: - response_201 = Charge.from_dict(response.json()) - - return response_201 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Charge]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: AuthenticatedClient, - body: Charge, -) -> Response[Charge]: - """ - Args: - body (Charge): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Charge] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: AuthenticatedClient, - body: Charge, -) -> Optional[Charge]: - """ - Args: - body (Charge): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Charge - """ - - return sync_detailed( - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - *, - client: AuthenticatedClient, - body: Charge, -) -> Response[Charge]: - """ - Args: - body (Charge): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[Charge] - """ - - kwargs = _get_kwargs( - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: AuthenticatedClient, - body: Charge, -) -> Optional[Charge]: - """ - Args: - body (Charge): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Charge - """ - - return ( - await asyncio_detailed( - client=client, - body=body, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py deleted file mode 100644 index f896c6c..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py +++ /dev/null @@ -1,127 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_balance import ApplicationBalance -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/wallet/api/application/balance", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationBalance]: - if response.status_code == 200: - response_200 = ApplicationBalance.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationBalance]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: AuthenticatedClient, -) -> Response[ApplicationBalance]: - """API for getting specified user or application balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationBalance] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: AuthenticatedClient, -) -> Optional[ApplicationBalance]: - """API for getting specified user or application balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationBalance - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: AuthenticatedClient, -) -> Response[ApplicationBalance]: - """API for getting specified user or application balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationBalance] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: AuthenticatedClient, -) -> Optional[ApplicationBalance]: - """API for getting specified user or application balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationBalance - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py deleted file mode 100644 index 6c10de8..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py +++ /dev/null @@ -1,151 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_balance import ApplicationBalance -from ...types import Response - - -def _get_kwargs( - category_uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{category_uuid}/balance", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationBalance]: - if response.status_code == 200: - response_200 = ApplicationBalance.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationBalance]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationBalance]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationBalance] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationBalance]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationBalance - """ - - return sync_detailed( - category_uuid=category_uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationBalance]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationBalance] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationBalance]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationBalance - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py index 12f96d7..c4f8fa1 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py @@ -10,6 +10,7 @@ from ...types import Response def _get_kwargs( + payer_wallet: str, *, body: ApplicationDeposit, ) -> dict[str, Any]: @@ -17,7 +18,7 @@ def _get_kwargs( _kwargs: dict[str, Any] = { "method": "post", - "url": "/wallet/api/application/deposit/", + "url": f"/wallet/api/application/{payer_wallet}/deposit/", } _kwargs["json"] = body.to_dict() @@ -54,12 +55,14 @@ def _build_response( def sync_detailed( + payer_wallet: str, *, client: AuthenticatedClient, body: ApplicationDeposit, ) -> Response[ApplicationDeposit]: """ Args: + payer_wallet (str): body (ApplicationDeposit): Raises: @@ -71,6 +74,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + payer_wallet=payer_wallet, body=body, ) @@ -82,12 +86,14 @@ def sync_detailed( def sync( + payer_wallet: str, *, client: AuthenticatedClient, body: ApplicationDeposit, ) -> Optional[ApplicationDeposit]: """ Args: + payer_wallet (str): body (ApplicationDeposit): Raises: @@ -99,18 +105,21 @@ def sync( """ return sync_detailed( + payer_wallet=payer_wallet, client=client, body=body, ).parsed async def asyncio_detailed( + payer_wallet: str, *, client: AuthenticatedClient, body: ApplicationDeposit, ) -> Response[ApplicationDeposit]: """ Args: + payer_wallet (str): body (ApplicationDeposit): Raises: @@ -122,6 +131,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + payer_wallet=payer_wallet, body=body, ) @@ -131,12 +141,14 @@ async def asyncio_detailed( async def asyncio( + payer_wallet: str, *, client: AuthenticatedClient, body: ApplicationDeposit, ) -> Optional[ApplicationDeposit]: """ Args: + payer_wallet (str): body (ApplicationDeposit): Raises: @@ -149,6 +161,7 @@ async def asyncio( return ( await asyncio_detailed( + payer_wallet=payer_wallet, client=client, body=body, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py deleted file mode 100644 index ef013a5..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_deposit import ApplicationDeposit -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - *, - body: ApplicationDeposit, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": f"/wallet/api/application/{category_uuid}/deposit/", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationDeposit]: - if response.status_code == 201: - response_201 = ApplicationDeposit.from_dict(response.json()) - - return response_201 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationDeposit]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationDeposit, -) -> Response[ApplicationDeposit]: - """ - Args: - category_uuid (str): - body (ApplicationDeposit): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationDeposit] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationDeposit, -) -> Optional[ApplicationDeposit]: - """ - Args: - category_uuid (str): - body (ApplicationDeposit): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationDeposit - """ - - return sync_detailed( - category_uuid=category_uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationDeposit, -) -> Response[ApplicationDeposit]: - """ - Args: - category_uuid (str): - body (ApplicationDeposit): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationDeposit] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationDeposit, -) -> Optional[ApplicationDeposit]: - """ - Args: - category_uuid (str): - body (ApplicationDeposit): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationDeposit - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - client=client, - body=body, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py index fde4421..29042f3 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py @@ -10,11 +10,12 @@ from ...types import Response def _get_kwargs( + payer_wallet: str, uuid: str, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/deposit/{uuid}/verify", + "url": f"/wallet/api/application/{payer_wallet}/deposit/{uuid}/verify", } return _kwargs @@ -46,12 +47,14 @@ def _build_response( def sync_detailed( + payer_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationDeposit]: """ Args: + payer_wallet (str): uuid (str): Raises: @@ -63,6 +66,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + payer_wallet=payer_wallet, uuid=uuid, ) @@ -74,12 +78,14 @@ def sync_detailed( def sync( + payer_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationDeposit]: """ Args: + payer_wallet (str): uuid (str): Raises: @@ -91,18 +97,21 @@ def sync( """ return sync_detailed( + payer_wallet=payer_wallet, uuid=uuid, client=client, ).parsed async def asyncio_detailed( + payer_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationDeposit]: """ Args: + payer_wallet (str): uuid (str): Raises: @@ -114,6 +123,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + payer_wallet=payer_wallet, uuid=uuid, ) @@ -123,12 +133,14 @@ async def asyncio_detailed( async def asyncio( + payer_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationDeposit]: """ Args: + payer_wallet (str): uuid (str): Raises: @@ -141,6 +153,7 @@ async def asyncio( return ( await asyncio_detailed( + payer_wallet=payer_wallet, uuid=uuid, client=client, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py deleted file mode 100644 index e21cbdb..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py +++ /dev/null @@ -1,160 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_deposit import ApplicationDeposit -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{category_uuid}/deposit/{uuid}/verify", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationDeposit]: - if response.status_code == 200: - response_200 = ApplicationDeposit.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationDeposit]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationDeposit]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationDeposit] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationDeposit]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationDeposit - """ - - return sync_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationDeposit]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationDeposit] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationDeposit]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationDeposit - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py deleted file mode 100644 index 9ef9349..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py +++ /dev/null @@ -1,160 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_transaction import ApplicationTransaction -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{category_uuid}/{uuid}/", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationTransaction]: - if response.status_code == 200: - response_200 = ApplicationTransaction.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationTransaction]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationTransaction]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationTransaction] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationTransaction]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationTransaction - """ - - return sync_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationTransaction]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationTransaction] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationTransaction]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationTransaction - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py deleted file mode 100644 index 50d6347..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py +++ /dev/null @@ -1,147 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_transaction import ApplicationTransaction -from ...types import Response - - -def _get_kwargs( - uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{uuid}/", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationTransaction]: - if response.status_code == 200: - response_200 = ApplicationTransaction.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationTransaction]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationTransaction]: - """ - Args: - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationTransaction] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationTransaction]: - """ - Args: - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationTransaction - """ - - return sync_detailed( - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationTransaction]: - """ - Args: - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationTransaction] - """ - - kwargs = _get_kwargs( - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationTransaction]: - """ - Args: - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationTransaction - """ - - return ( - await asyncio_detailed( - uuid=uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py new file mode 100644 index 0000000..e808f0e --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py @@ -0,0 +1,227 @@ +from http import HTTPStatus +from typing import Any, Optional, Union +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.paginated_transaction_list import PaginatedTransactionList +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + json_payee: Union[Unset, str] = UNSET + if not isinstance(payee, Unset): + json_payee = str(payee) + params["payee"] = json_payee + + json_payer: Union[Unset, str] = UNSET + if not isinstance(payer, Unset): + json_payer = str(payer) + params["payer"] = json_payer + + json_wallets = [] + for wallets_item_data in wallets: + wallets_item = str(wallets_item_data) + json_wallets.append(wallets_item) + + params["wallets"] = json_wallets + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/wallet/api/application/transactions/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PaginatedTransactionList]: + if response.status_code == 200: + response_200 = PaginatedTransactionList.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[PaginatedTransactionList]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Response[PaginatedTransactionList]: + """ + Args: + limit (Union[Unset, int]): + offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedTransactionList] + """ + + kwargs = _get_kwargs( + limit=limit, + offset=offset, + payee=payee, + payer=payer, + wallets=wallets, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Optional[PaginatedTransactionList]: + """ + Args: + limit (Union[Unset, int]): + offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedTransactionList + """ + + return sync_detailed( + client=client, + limit=limit, + offset=offset, + payee=payee, + payer=payer, + wallets=wallets, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Response[PaginatedTransactionList]: + """ + Args: + limit (Union[Unset, int]): + offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PaginatedTransactionList] + """ + + kwargs = _get_kwargs( + limit=limit, + offset=offset, + payee=payee, + payer=payer, + wallets=wallets, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Optional[PaginatedTransactionList]: + """ + Args: + limit (Union[Unset, int]): + offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PaginatedTransactionList + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + offset=offset, + payee=payee, + payer=payer, + wallets=wallets, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py similarity index 75% rename from gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py rename to gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py index 2062248..1939f25 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py @@ -1,28 +1,29 @@ from http import HTTPStatus from typing import Any, Optional, Union +from uuid import UUID import httpx from ... import errors from ...client import AuthenticatedClient, Client -from ...models.my_wallet import MyWallet +from ...models.transaction import Transaction from ...types import Response def _get_kwargs( - uuid: str, + uuid: UUID, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/user_balance/{uuid}", + "url": f"/wallet/api/application/transactions/{uuid}/", } return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Transaction]: if response.status_code == 200: - response_200 = MyWallet.from_dict(response.json()) + response_200 = Transaction.from_dict(response.json()) return response_200 @@ -32,7 +33,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Transaction]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -42,21 +43,20 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( - uuid: str, + uuid: UUID, *, client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting specified user or application balance. - +) -> Response[Transaction]: + """ Args: - uuid (str): + uuid (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[MyWallet] + Response[Transaction] """ kwargs = _get_kwargs( @@ -71,21 +71,20 @@ def sync_detailed( def sync( - uuid: str, + uuid: UUID, *, client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting specified user or application balance. - +) -> Optional[Transaction]: + """ Args: - uuid (str): + uuid (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - MyWallet + Transaction """ return sync_detailed( @@ -95,21 +94,20 @@ def sync( async def asyncio_detailed( - uuid: str, + uuid: UUID, *, client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting specified user or application balance. - +) -> Response[Transaction]: + """ Args: - uuid (str): + uuid (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[MyWallet] + Response[Transaction] """ kwargs = _get_kwargs( @@ -122,21 +120,20 @@ async def asyncio_detailed( async def asyncio( - uuid: str, + uuid: UUID, *, client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting specified user or application balance. - +) -> Optional[Transaction]: + """ Args: - uuid (str): + uuid (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - MyWallet + Transaction """ return ( diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py deleted file mode 100644 index f77f03f..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py +++ /dev/null @@ -1,160 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.my_wallet import MyWallet -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{category_uuid}/user/{uuid}/balance", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: - if response.status_code == 200: - response_200 = MyWallet.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return sync_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting specified user or application balance. - - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py similarity index 82% rename from gooyal_wallet_client/api/wallet/wallet_api_application_list.py rename to gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py index b3c7624..9d5a57b 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py @@ -5,7 +5,7 @@ import httpx from ... import errors from ...client import AuthenticatedClient, Client -from ...models.paginated_application_transaction_list import PaginatedApplicationTransactionList +from ...models.paginated_account_list import PaginatedAccountList from ...types import UNSET, Response, Unset @@ -24,7 +24,7 @@ def _get_kwargs( _kwargs: dict[str, Any] = { "method": "get", - "url": "/wallet/api/application/", + "url": "/wallet/api/application/wallets/", "params": params, } @@ -33,9 +33,9 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PaginatedApplicationTransactionList]: +) -> Optional[PaginatedAccountList]: if response.status_code == 200: - response_200 = PaginatedApplicationTransactionList.from_dict(response.json()) + response_200 = PaginatedAccountList.from_dict(response.json()) return response_200 @@ -47,7 +47,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PaginatedApplicationTransactionList]: +) -> Response[PaginatedAccountList]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,8 +61,9 @@ def sync_detailed( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedApplicationTransactionList]: - """ +) -> Response[PaginatedAccountList]: + """API for getting specified user or application balance. + Args: limit (Union[Unset, int]): offset (Union[Unset, int]): @@ -72,7 +73,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedApplicationTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( @@ -92,8 +93,9 @@ def sync( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedApplicationTransactionList]: - """ +) -> Optional[PaginatedAccountList]: + """API for getting specified user or application balance. + Args: limit (Union[Unset, int]): offset (Union[Unset, int]): @@ -103,7 +105,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedApplicationTransactionList + PaginatedAccountList """ return sync_detailed( @@ -118,8 +120,9 @@ async def asyncio_detailed( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedApplicationTransactionList]: - """ +) -> Response[PaginatedAccountList]: + """API for getting specified user or application balance. + Args: limit (Union[Unset, int]): offset (Union[Unset, int]): @@ -129,7 +132,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedApplicationTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( @@ -147,8 +150,9 @@ async def asyncio( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedApplicationTransactionList]: - """ +) -> Optional[PaginatedAccountList]: + """API for getting specified user or application balance. + Args: limit (Union[Unset, int]): offset (Union[Unset, int]): @@ -158,7 +162,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedApplicationTransactionList + PaginatedAccountList """ return ( diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py similarity index 64% rename from gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py rename to gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py index 50cbc86..54d843e 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py @@ -1,19 +1,21 @@ from http import HTTPStatus from typing import Any, Optional, Union +from uuid import UUID import httpx from ... import errors from ...client import AuthenticatedClient, Client -from ...models.paginated_user_transaction_list import PaginatedUserTransactionList +from ...models.paginated_account_list import PaginatedAccountList from ...types import UNSET, Response, Unset def _get_kwargs( - category_uuid: str, + owner: str, *, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, + wallet: list[UUID], ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -21,11 +23,18 @@ def _get_kwargs( params["offset"] = offset + json_wallet = [] + for wallet_item_data in wallet: + wallet_item = str(wallet_item_data) + json_wallet.append(wallet_item) + + params["wallet"] = json_wallet + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/user/{category_uuid}/transactions/", + "url": f"/wallet/api/application/wallets/user/{owner}/", "params": params, } @@ -34,9 +43,9 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PaginatedUserTransactionList]: +) -> Optional[PaginatedAccountList]: if response.status_code == 200: - response_200 = PaginatedUserTransactionList.from_dict(response.json()) + response_200 = PaginatedAccountList.from_dict(response.json()) return response_200 @@ -48,7 +57,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PaginatedUserTransactionList]: +) -> Response[PaginatedAccountList]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -58,35 +67,34 @@ def _build_response( def sync_detailed( - category_uuid: str, + owner: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedUserTransactionList]: - """GET: API for getting list of transactions for authenticated user - POST: API for creating transaction for transferring funds from authenticated user to application - owner. (deprecated) - args: - - user: authenticated user + wallet: list[UUID], +) -> Response[PaginatedAccountList]: + """API for getting specified user wallet. Args: - category_uuid (str): + owner (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedUserTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( - category_uuid=category_uuid, + owner=owner, limit=limit, offset=offset, + wallet=wallet, ) response = client.get_httpx_client().request( @@ -97,69 +105,67 @@ def sync_detailed( def sync( - category_uuid: str, + owner: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedUserTransactionList]: - """GET: API for getting list of transactions for authenticated user - POST: API for creating transaction for transferring funds from authenticated user to application - owner. (deprecated) - args: - - user: authenticated user + wallet: list[UUID], +) -> Optional[PaginatedAccountList]: + """API for getting specified user wallet. Args: - category_uuid (str): + owner (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedUserTransactionList + PaginatedAccountList """ return sync_detailed( - category_uuid=category_uuid, + owner=owner, client=client, limit=limit, offset=offset, + wallet=wallet, ).parsed async def asyncio_detailed( - category_uuid: str, + owner: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedUserTransactionList]: - """GET: API for getting list of transactions for authenticated user - POST: API for creating transaction for transferring funds from authenticated user to application - owner. (deprecated) - args: - - user: authenticated user + wallet: list[UUID], +) -> Response[PaginatedAccountList]: + """API for getting specified user wallet. Args: - category_uuid (str): + owner (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedUserTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( - category_uuid=category_uuid, + owner=owner, limit=limit, offset=offset, + wallet=wallet, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -168,36 +174,35 @@ async def asyncio_detailed( async def asyncio( - category_uuid: str, + owner: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedUserTransactionList]: - """GET: API for getting list of transactions for authenticated user - POST: API for creating transaction for transferring funds from authenticated user to application - owner. (deprecated) - args: - - user: authenticated user + wallet: list[UUID], +) -> Optional[PaginatedAccountList]: + """API for getting specified user wallet. Args: - category_uuid (str): + owner (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedUserTransactionList + PaginatedAccountList """ return ( await asyncio_detailed( - category_uuid=category_uuid, + owner=owner, client=client, limit=limit, offset=offset, + wallet=wallet, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py index 3853436..74d6944 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py @@ -10,6 +10,7 @@ from ...types import Response def _get_kwargs( + payee_wallet: str, *, body: ApplicationWithdraw, ) -> dict[str, Any]: @@ -17,7 +18,7 @@ def _get_kwargs( _kwargs: dict[str, Any] = { "method": "post", - "url": "/wallet/api/application/withdraw/", + "url": f"/wallet/api/application/{payee_wallet}/withdraw/", } _kwargs["json"] = body.to_dict() @@ -54,12 +55,14 @@ def _build_response( def sync_detailed( + payee_wallet: str, *, client: AuthenticatedClient, body: ApplicationWithdraw, ) -> Response[ApplicationWithdraw]: """ Args: + payee_wallet (str): body (ApplicationWithdraw): Raises: @@ -71,6 +74,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + payee_wallet=payee_wallet, body=body, ) @@ -82,12 +86,14 @@ def sync_detailed( def sync( + payee_wallet: str, *, client: AuthenticatedClient, body: ApplicationWithdraw, ) -> Optional[ApplicationWithdraw]: """ Args: + payee_wallet (str): body (ApplicationWithdraw): Raises: @@ -99,18 +105,21 @@ def sync( """ return sync_detailed( + payee_wallet=payee_wallet, client=client, body=body, ).parsed async def asyncio_detailed( + payee_wallet: str, *, client: AuthenticatedClient, body: ApplicationWithdraw, ) -> Response[ApplicationWithdraw]: """ Args: + payee_wallet (str): body (ApplicationWithdraw): Raises: @@ -122,6 +131,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + payee_wallet=payee_wallet, body=body, ) @@ -131,12 +141,14 @@ async def asyncio_detailed( async def asyncio( + payee_wallet: str, *, client: AuthenticatedClient, body: ApplicationWithdraw, ) -> Optional[ApplicationWithdraw]: """ Args: + payee_wallet (str): body (ApplicationWithdraw): Raises: @@ -149,6 +161,7 @@ async def asyncio( return ( await asyncio_detailed( + payee_wallet=payee_wallet, client=client, body=body, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py deleted file mode 100644 index f4b42ac..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py +++ /dev/null @@ -1,168 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_withdraw import ApplicationWithdraw -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - *, - body: ApplicationWithdraw, -) -> dict[str, Any]: - headers: dict[str, Any] = {} - - _kwargs: dict[str, Any] = { - "method": "post", - "url": f"/wallet/api/application/{category_uuid}/withdraw/", - } - - _kwargs["json"] = body.to_dict() - - headers["Content-Type"] = "application/json" - - _kwargs["headers"] = headers - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationWithdraw]: - if response.status_code == 201: - response_201 = ApplicationWithdraw.from_dict(response.json()) - - return response_201 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationWithdraw]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationWithdraw, -) -> Response[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - body (ApplicationWithdraw): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationWithdraw] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - body=body, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationWithdraw, -) -> Optional[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - body (ApplicationWithdraw): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationWithdraw - """ - - return sync_detailed( - category_uuid=category_uuid, - client=client, - body=body, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationWithdraw, -) -> Response[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - body (ApplicationWithdraw): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationWithdraw] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - body=body, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - *, - client: AuthenticatedClient, - body: ApplicationWithdraw, -) -> Optional[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - body (ApplicationWithdraw): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationWithdraw - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - client=client, - body=body, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py index dd57a27..757b597 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py @@ -10,11 +10,12 @@ from ...types import Response def _get_kwargs( + payee_wallet: str, uuid: str, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/withdraw/{uuid}/verify", + "url": f"/wallet/api/application/{payee_wallet}/withdraw/{uuid}/verify", } return _kwargs @@ -46,12 +47,14 @@ def _build_response( def sync_detailed( + payee_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationWithdraw]: """ Args: + payee_wallet (str): uuid (str): Raises: @@ -63,6 +66,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + payee_wallet=payee_wallet, uuid=uuid, ) @@ -74,12 +78,14 @@ def sync_detailed( def sync( + payee_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationWithdraw]: """ Args: + payee_wallet (str): uuid (str): Raises: @@ -91,18 +97,21 @@ def sync( """ return sync_detailed( + payee_wallet=payee_wallet, uuid=uuid, client=client, ).parsed async def asyncio_detailed( + payee_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationWithdraw]: """ Args: + payee_wallet (str): uuid (str): Raises: @@ -114,6 +123,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + payee_wallet=payee_wallet, uuid=uuid, ) @@ -123,12 +133,14 @@ async def asyncio_detailed( async def asyncio( + payee_wallet: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationWithdraw]: """ Args: + payee_wallet (str): uuid (str): Raises: @@ -141,6 +153,7 @@ async def asyncio( return ( await asyncio_detailed( + payee_wallet=payee_wallet, uuid=uuid, client=client, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py deleted file mode 100644 index 651a764..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py +++ /dev/null @@ -1,160 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.application_withdraw import ApplicationWithdraw -from ...types import Response - - -def _get_kwargs( - category_uuid: str, - uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/application/{category_uuid}/withdraw/{uuid}/verify", - } - - return _kwargs - - -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[ApplicationWithdraw]: - if response.status_code == 200: - response_200 = ApplicationWithdraw.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[ApplicationWithdraw]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationWithdraw] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationWithdraw - """ - - return sync_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Response[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[ApplicationWithdraw] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - uuid=uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[ApplicationWithdraw]: - """ - Args: - category_uuid (str): - uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - ApplicationWithdraw - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - uuid=uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py index 7880004..328df18 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py @@ -1,11 +1,12 @@ from http import HTTPStatus from typing import Any, Optional, Union +from uuid import UUID import httpx from ... import errors from ...client import AuthenticatedClient, Client -from ...models.paginated_user_transaction_list import PaginatedUserTransactionList +from ...models.paginated_transaction_list import PaginatedTransactionList from ...types import UNSET, Response, Unset @@ -13,6 +14,9 @@ def _get_kwargs( *, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -20,6 +24,23 @@ def _get_kwargs( params["offset"] = offset + json_payee: Union[Unset, str] = UNSET + if not isinstance(payee, Unset): + json_payee = str(payee) + params["payee"] = json_payee + + json_payer: Union[Unset, str] = UNSET + if not isinstance(payer, Unset): + json_payer = str(payer) + params["payer"] = json_payer + + json_wallets = [] + for wallets_item_data in wallets: + wallets_item = str(wallets_item_data) + json_wallets.append(wallets_item) + + params["wallets"] = json_wallets + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} _kwargs: dict[str, Any] = { @@ -33,9 +54,9 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PaginatedUserTransactionList]: +) -> Optional[PaginatedTransactionList]: if response.status_code == 200: - response_200 = PaginatedUserTransactionList.from_dict(response.json()) + response_200 = PaginatedTransactionList.from_dict(response.json()) return response_200 @@ -47,7 +68,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PaginatedUserTransactionList]: +) -> Response[PaginatedTransactionList]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,7 +82,10 @@ def sync_detailed( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedUserTransactionList]: + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Response[PaginatedTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated) @@ -71,18 +95,24 @@ def sync_detailed( Args: limit (Union[Unset, int]): offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedUserTransactionList] + Response[PaginatedTransactionList] """ kwargs = _get_kwargs( limit=limit, offset=offset, + payee=payee, + payer=payer, + wallets=wallets, ) response = client.get_httpx_client().request( @@ -97,7 +127,10 @@ def sync( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedUserTransactionList]: + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Optional[PaginatedTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated) @@ -107,19 +140,25 @@ def sync( Args: limit (Union[Unset, int]): offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedUserTransactionList + PaginatedTransactionList """ return sync_detailed( client=client, limit=limit, offset=offset, + payee=payee, + payer=payer, + wallets=wallets, ).parsed @@ -128,7 +167,10 @@ async def asyncio_detailed( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedUserTransactionList]: + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Response[PaginatedTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated) @@ -138,18 +180,24 @@ async def asyncio_detailed( Args: limit (Union[Unset, int]): offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedUserTransactionList] + Response[PaginatedTransactionList] """ kwargs = _get_kwargs( limit=limit, offset=offset, + payee=payee, + payer=payer, + wallets=wallets, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -162,7 +210,10 @@ async def asyncio( client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedUserTransactionList]: + payee: Union[Unset, UUID] = UNSET, + payer: Union[Unset, UUID] = UNSET, + wallets: list[UUID], +) -> Optional[PaginatedTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated) @@ -172,13 +223,16 @@ async def asyncio( Args: limit (Union[Unset, int]): offset (Union[Unset, int]): + payee (Union[Unset, UUID]): + payer (Union[Unset, UUID]): + wallets (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedUserTransactionList + PaginatedTransactionList """ return ( @@ -186,5 +240,8 @@ async def asyncio( client=client, limit=limit, offset=offset, + payee=payee, + payer=payer, + wallets=wallets, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py deleted file mode 100644 index 2928286..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py +++ /dev/null @@ -1,147 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.my_wallet import MyWallet -from ...types import Response - - -def _get_kwargs( - category_uuid: str, -) -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": f"/wallet/api/user/{category_uuid}/balance", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: - if response.status_code == 200: - response_200 = MyWallet.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting authenticated user balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - ) - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting authenticated user balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return sync_detailed( - category_uuid=category_uuid, - client=client, - ).parsed - - -async def asyncio_detailed( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting authenticated user balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs( - category_uuid=category_uuid, - ) - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - category_uuid: str, - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting authenticated user balance. - - Args: - category_uuid (str): - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return ( - await asyncio_detailed( - category_uuid=category_uuid, - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py deleted file mode 100644 index 5a5e38d..0000000 --- a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py +++ /dev/null @@ -1,123 +0,0 @@ -from http import HTTPStatus -from typing import Any, Optional, Union - -import httpx - -from ... import errors -from ...client import AuthenticatedClient, Client -from ...models.my_wallet import MyWallet -from ...types import Response - - -def _get_kwargs() -> dict[str, Any]: - _kwargs: dict[str, Any] = { - "method": "get", - "url": "/wallet/api/wallet/balance", - } - - return _kwargs - - -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: - if response.status_code == 200: - response_200 = MyWallet.from_dict(response.json()) - - return response_200 - - if client.raise_on_unexpected_status: - raise errors.UnexpectedStatus(response.status_code, response.content) - else: - return None - - -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[MyWallet]: - return Response( - status_code=HTTPStatus(response.status_code), - content=response.content, - headers=response.headers, - parsed=_parse_response(client=client, response=response), - ) - - -def sync_detailed( - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting authenticated user balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs() - - response = client.get_httpx_client().request( - **kwargs, - ) - - return _build_response(client=client, response=response) - - -def sync( - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting authenticated user balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return sync_detailed( - client=client, - ).parsed - - -async def asyncio_detailed( - *, - client: AuthenticatedClient, -) -> Response[MyWallet]: - """API for getting authenticated user balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - Response[MyWallet] - """ - - kwargs = _get_kwargs() - - response = await client.get_async_httpx_client().request(**kwargs) - - return _build_response(client=client, response=response) - - -async def asyncio( - *, - client: AuthenticatedClient, -) -> Optional[MyWallet]: - """API for getting authenticated user balance. - - Raises: - errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. - httpx.TimeoutException: If the request takes longer than Client.timeout. - - Returns: - MyWallet - """ - - return ( - await asyncio_detailed( - client=client, - ) - ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py b/gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py similarity index 74% rename from gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py rename to gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py index 84cbf49..f406ae8 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py @@ -1,19 +1,20 @@ from http import HTTPStatus from typing import Any, Optional, Union +from uuid import UUID import httpx from ... import errors from ...client import AuthenticatedClient, Client -from ...models.paginated_application_transaction_list import PaginatedApplicationTransactionList +from ...models.paginated_account_list import PaginatedAccountList from ...types import UNSET, Response, Unset def _get_kwargs( - category_uuid: str, *, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, + wallet: list[UUID], ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -21,11 +22,18 @@ def _get_kwargs( params["offset"] = offset + json_wallet = [] + for wallet_item_data in wallet: + wallet_item = str(wallet_item_data) + json_wallet.append(wallet_item) + + params["wallet"] = json_wallet + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/{category_uuid}/", + "url": "/wallet/api/wallets/", "params": params, } @@ -34,9 +42,9 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[PaginatedApplicationTransactionList]: +) -> Optional[PaginatedAccountList]: if response.status_code == 200: - response_200 = PaginatedApplicationTransactionList.from_dict(response.json()) + response_200 = PaginatedAccountList.from_dict(response.json()) return response_200 @@ -48,7 +56,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[PaginatedApplicationTransactionList]: +) -> Response[PaginatedAccountList]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -58,30 +66,31 @@ def _build_response( def sync_detailed( - category_uuid: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedApplicationTransactionList]: - """ + wallet: list[UUID], +) -> Response[PaginatedAccountList]: + """API for getting authenticated user balance. + Args: - category_uuid (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedApplicationTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( - category_uuid=category_uuid, limit=limit, offset=offset, + wallet=wallet, ) response = client.get_httpx_client().request( @@ -92,59 +101,61 @@ def sync_detailed( def sync( - category_uuid: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedApplicationTransactionList]: - """ + wallet: list[UUID], +) -> Optional[PaginatedAccountList]: + """API for getting authenticated user balance. + Args: - category_uuid (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedApplicationTransactionList + PaginatedAccountList """ return sync_detailed( - category_uuid=category_uuid, client=client, limit=limit, offset=offset, + wallet=wallet, ).parsed async def asyncio_detailed( - category_uuid: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Response[PaginatedApplicationTransactionList]: - """ + wallet: list[UUID], +) -> Response[PaginatedAccountList]: + """API for getting authenticated user balance. + Args: - category_uuid (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[PaginatedApplicationTransactionList] + Response[PaginatedAccountList] """ kwargs = _get_kwargs( - category_uuid=category_uuid, limit=limit, offset=offset, + wallet=wallet, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -153,31 +164,32 @@ async def asyncio_detailed( async def asyncio( - category_uuid: str, *, client: AuthenticatedClient, limit: Union[Unset, int] = UNSET, offset: Union[Unset, int] = UNSET, -) -> Optional[PaginatedApplicationTransactionList]: - """ + wallet: list[UUID], +) -> Optional[PaginatedAccountList]: + """API for getting authenticated user balance. + Args: - category_uuid (str): limit (Union[Unset, int]): offset (Union[Unset, int]): + wallet (list[UUID]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - PaginatedApplicationTransactionList + PaginatedAccountList """ return ( await asyncio_detailed( - category_uuid=category_uuid, client=client, limit=limit, offset=offset, + wallet=wallet, ) ).parsed diff --git a/gooyal_wallet_client/models/__init__.py b/gooyal_wallet_client/models/__init__.py index 06a7b4a..4d9841d 100644 --- a/gooyal_wallet_client/models/__init__.py +++ b/gooyal_wallet_client/models/__init__.py @@ -1,25 +1,19 @@ """Contains all the data models used in inputs/outputs""" -from .application_balance import ApplicationBalance +from .account import Account from .application_deposit import ApplicationDeposit -from .application_transaction import ApplicationTransaction from .application_withdraw import ApplicationWithdraw -from .charge import Charge -from .my_wallet import MyWallet -from .paginated_application_transaction_list import PaginatedApplicationTransactionList -from .paginated_user_transaction_list import PaginatedUserTransactionList +from .paginated_account_list import PaginatedAccountList +from .paginated_transaction_list import PaginatedTransactionList from .state_enum import StateEnum -from .user_transaction import UserTransaction +from .transaction import Transaction __all__ = ( - "ApplicationBalance", + "Account", "ApplicationDeposit", - "ApplicationTransaction", "ApplicationWithdraw", - "Charge", - "MyWallet", - "PaginatedApplicationTransactionList", - "PaginatedUserTransactionList", + "PaginatedAccountList", + "PaginatedTransactionList", "StateEnum", - "UserTransaction", + "Transaction", ) diff --git a/gooyal_wallet_client/models/application_balance.py b/gooyal_wallet_client/models/account.py similarity index 53% rename from gooyal_wallet_client/models/application_balance.py rename to gooyal_wallet_client/models/account.py index 3ae824e..25b08bb 100644 --- a/gooyal_wallet_client/models/application_balance.py +++ b/gooyal_wallet_client/models/account.py @@ -1,32 +1,45 @@ from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar, Union, cast +from uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field from ..types import UNSET, Unset -T = TypeVar("T", bound="ApplicationBalance") +T = TypeVar("T", bound="Account") @_attrs_define -class ApplicationBalance: +class Account: """ Attributes: balance (Union[Unset, int]): + wallet (Union[None, UUID, Unset]): """ balance: Union[Unset, int] = UNSET + wallet: Union[None, UUID, Unset] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: balance = self.balance + wallet: Union[None, Unset, str] + if isinstance(self.wallet, Unset): + wallet = UNSET + elif isinstance(self.wallet, UUID): + wallet = str(self.wallet) + else: + wallet = self.wallet + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if balance is not UNSET: field_dict["balance"] = balance + if wallet is not UNSET: + field_dict["wallet"] = wallet return field_dict @@ -35,12 +48,30 @@ class ApplicationBalance: d = dict(src_dict) balance = d.pop("balance", UNSET) - application_balance = cls( + def _parse_wallet(data: object) -> Union[None, UUID, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + wallet_type_0 = UUID(data) + + return wallet_type_0 + except: # noqa: E722 + pass + return cast(Union[None, UUID, Unset], data) + + wallet = _parse_wallet(d.pop("wallet", UNSET)) + + account = cls( balance=balance, + wallet=wallet, ) - application_balance.additional_properties = d - return application_balance + account.additional_properties = d + return account @property def additional_keys(self) -> list[str]: diff --git a/gooyal_wallet_client/models/application_deposit.py b/gooyal_wallet_client/models/application_deposit.py index 9d1772f..71fb885 100644 --- a/gooyal_wallet_client/models/application_deposit.py +++ b/gooyal_wallet_client/models/application_deposit.py @@ -17,10 +17,12 @@ T = TypeVar("T", bound="ApplicationDeposit") class ApplicationDeposit: """ Attributes: - payer_id (str): + payer (str): payer_type (str): - payee_id (UUID): + payer_wallet (UUID): + payee (UUID): payee_type (int): + payee_wallet (UUID): created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed @@ -35,10 +37,12 @@ class ApplicationDeposit: details (Union[Unset, Any]): """ - payer_id: str + payer: str payer_type: str - payee_id: UUID + payer_wallet: UUID + payee: UUID payee_type: int + payee_wallet: UUID created_at: datetime.datetime state: StateEnum amount: int @@ -48,14 +52,18 @@ class ApplicationDeposit: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - payer_id = self.payer_id + payer = self.payer payer_type = self.payer_type - payee_id = str(self.payee_id) + payer_wallet = str(self.payer_wallet) + + payee = str(self.payee) payee_type = self.payee_type + payee_wallet = str(self.payee_wallet) + created_at = self.created_at.isoformat() state = self.state.value @@ -74,10 +82,12 @@ class ApplicationDeposit: field_dict.update(self.additional_properties) field_dict.update( { - "payer_id": payer_id, + "payer": payer, "payer_type": payer_type, - "payee_id": payee_id, + "payer_wallet": payer_wallet, + "payee": payee, "payee_type": payee_type, + "payee_wallet": payee_wallet, "created_at": created_at, "state": state, "amount": amount, @@ -94,14 +104,18 @@ class ApplicationDeposit: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - payer_id = d.pop("payer_id") + payer = d.pop("payer") payer_type = d.pop("payer_type") - payee_id = UUID(d.pop("payee_id")) + payer_wallet = UUID(d.pop("payer_wallet")) + + payee = UUID(d.pop("payee")) payee_type = d.pop("payee_type") + payee_wallet = UUID(d.pop("payee_wallet")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) @@ -120,10 +134,12 @@ class ApplicationDeposit: details = d.pop("details", UNSET) application_deposit = cls( - payer_id=payer_id, + payer=payer, payer_type=payer_type, - payee_id=payee_id, + payer_wallet=payer_wallet, + payee=payee, payee_type=payee_type, + payee_wallet=payee_wallet, created_at=created_at, state=state, amount=amount, diff --git a/gooyal_wallet_client/models/application_transaction.py b/gooyal_wallet_client/models/application_transaction.py deleted file mode 100644 index f504cbc..0000000 --- a/gooyal_wallet_client/models/application_transaction.py +++ /dev/null @@ -1,160 +0,0 @@ -import datetime -from collections.abc import Mapping -from typing import Any, TypeVar, Union -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.state_enum import StateEnum -from ..types import UNSET, Unset - -T = TypeVar("T", bound="ApplicationTransaction") - - -@_attrs_define -class ApplicationTransaction: - """ - Attributes: - uuid (UUID): - payer_id (str): - payer_type (str): - payee_id (UUID): - payee_type (UUID): - created_at (datetime.datetime): - state (StateEnum): * `1` - created - * `2` - delayed - * `3` - pending - * `4` - incomplete - * `5` - success - * `6` - failed - * `7` - expected_failure - amount (int): - updated_at (datetime.datetime): - details (Any): - role (str): - delay (Union[Unset, int]): - """ - - uuid: UUID - payer_id: str - payer_type: str - payee_id: UUID - payee_type: UUID - created_at: datetime.datetime - state: StateEnum - amount: int - updated_at: datetime.datetime - details: Any - role: str - delay: Union[Unset, int] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) - - payer_id = self.payer_id - - payer_type = self.payer_type - - payee_id = str(self.payee_id) - - payee_type = str(self.payee_type) - - created_at = self.created_at.isoformat() - - state = self.state.value - - amount = self.amount - - updated_at = self.updated_at.isoformat() - - details = self.details - - role = self.role - - delay = self.delay - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "uuid": uuid, - "payer_id": payer_id, - "payer_type": payer_type, - "payee_id": payee_id, - "payee_type": payee_type, - "created_at": created_at, - "state": state, - "amount": amount, - "updated_at": updated_at, - "details": details, - "role": role, - } - ) - if delay is not UNSET: - field_dict["delay"] = delay - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - uuid = UUID(d.pop("uuid")) - - payer_id = d.pop("payer_id") - - payer_type = d.pop("payer_type") - - payee_id = UUID(d.pop("payee_id")) - - payee_type = UUID(d.pop("payee_type")) - - created_at = isoparse(d.pop("created_at")) - - state = StateEnum(d.pop("state")) - - amount = d.pop("amount") - - updated_at = isoparse(d.pop("updated_at")) - - details = d.pop("details") - - role = d.pop("role") - - delay = d.pop("delay", UNSET) - - application_transaction = cls( - uuid=uuid, - payer_id=payer_id, - payer_type=payer_type, - payee_id=payee_id, - payee_type=payee_type, - created_at=created_at, - state=state, - amount=amount, - updated_at=updated_at, - details=details, - role=role, - delay=delay, - ) - - application_transaction.additional_properties = d - return application_transaction - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/gooyal_wallet_client/models/application_withdraw.py b/gooyal_wallet_client/models/application_withdraw.py index 3470f5a..3ddd5b4 100644 --- a/gooyal_wallet_client/models/application_withdraw.py +++ b/gooyal_wallet_client/models/application_withdraw.py @@ -17,10 +17,12 @@ T = TypeVar("T", bound="ApplicationWithdraw") class ApplicationWithdraw: """ Attributes: - payer_id (UUID): + payer (UUID): payer_type (int): - payee_id (str): + payer_wallet (UUID): + payee (str): payee_type (str): + payee_wallet (UUID): created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed @@ -35,10 +37,12 @@ class ApplicationWithdraw: details (Union[Unset, Any]): """ - payer_id: UUID + payer: UUID payer_type: int - payee_id: str + payer_wallet: UUID + payee: str payee_type: str + payee_wallet: UUID created_at: datetime.datetime state: StateEnum amount: int @@ -48,14 +52,18 @@ class ApplicationWithdraw: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - payer_id = str(self.payer_id) + payer = str(self.payer) payer_type = self.payer_type - payee_id = self.payee_id + payer_wallet = str(self.payer_wallet) + + payee = self.payee payee_type = self.payee_type + payee_wallet = str(self.payee_wallet) + created_at = self.created_at.isoformat() state = self.state.value @@ -74,10 +82,12 @@ class ApplicationWithdraw: field_dict.update(self.additional_properties) field_dict.update( { - "payer_id": payer_id, + "payer": payer, "payer_type": payer_type, - "payee_id": payee_id, + "payer_wallet": payer_wallet, + "payee": payee, "payee_type": payee_type, + "payee_wallet": payee_wallet, "created_at": created_at, "state": state, "amount": amount, @@ -94,14 +104,18 @@ class ApplicationWithdraw: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - payer_id = UUID(d.pop("payer_id")) + payer = UUID(d.pop("payer")) payer_type = d.pop("payer_type") - payee_id = d.pop("payee_id") + payer_wallet = UUID(d.pop("payer_wallet")) + + payee = d.pop("payee") payee_type = d.pop("payee_type") + payee_wallet = UUID(d.pop("payee_wallet")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) @@ -120,10 +134,12 @@ class ApplicationWithdraw: details = d.pop("details", UNSET) application_withdraw = cls( - payer_id=payer_id, + payer=payer, payer_type=payer_type, - payee_id=payee_id, + payer_wallet=payer_wallet, + payee=payee, payee_type=payee_type, + payee_wallet=payee_wallet, created_at=created_at, state=state, amount=amount, diff --git a/gooyal_wallet_client/models/charge.py b/gooyal_wallet_client/models/charge.py deleted file mode 100644 index 25301fb..0000000 --- a/gooyal_wallet_client/models/charge.py +++ /dev/null @@ -1,150 +0,0 @@ -import datetime -from collections.abc import Mapping -from typing import Any, TypeVar, Union, cast -from uuid import UUID - -from attrs import define as _attrs_define -from attrs import field as _attrs_field -from dateutil.parser import isoparse - -from ..models.state_enum import StateEnum - -T = TypeVar("T", bound="Charge") - - -@_attrs_define -class Charge: - """ - Attributes: - uuid (UUID): - user (UUID): - created_at (Union[None, datetime.datetime]): - state (StateEnum): * `1` - created - * `2` - delayed - * `3` - pending - * `4` - incomplete - * `5` - success - * `6` - failed - * `7` - expected_failure - amount (Union[None, int]): - updated_at (Union[None, datetime.datetime]): - """ - - uuid: UUID - user: UUID - created_at: Union[None, datetime.datetime] - state: StateEnum - amount: Union[None, int] - updated_at: Union[None, datetime.datetime] - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - uuid = str(self.uuid) - - user = str(self.user) - - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at - - state = self.state.value - - amount: Union[None, int] - amount = self.amount - - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "uuid": uuid, - "user": user, - "created_at": created_at, - "state": state, - "amount": amount, - "updated_at": updated_at, - } - ) - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - uuid = UUID(d.pop("uuid")) - - user = UUID(d.pop("user")) - - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) - - state = StateEnum(d.pop("state")) - - def _parse_amount(data: object) -> Union[None, int]: - if data is None: - return data - return cast(Union[None, int], data) - - amount = _parse_amount(d.pop("amount")) - - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) - - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) - - charge = cls( - uuid=uuid, - user=user, - created_at=created_at, - state=state, - amount=amount, - updated_at=updated_at, - ) - - charge.additional_properties = d - return charge - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/gooyal_wallet_client/models/my_wallet.py b/gooyal_wallet_client/models/my_wallet.py deleted file mode 100644 index e76505d..0000000 --- a/gooyal_wallet_client/models/my_wallet.py +++ /dev/null @@ -1,59 +0,0 @@ -from collections.abc import Mapping -from typing import Any, TypeVar, Union - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -T = TypeVar("T", bound="MyWallet") - - -@_attrs_define -class MyWallet: - """ - Attributes: - balance (Union[Unset, int]): - """ - - balance: Union[Unset, int] = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - balance = self.balance - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if balance is not UNSET: - field_dict["balance"] = balance - - return field_dict - - @classmethod - def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - d = dict(src_dict) - balance = d.pop("balance", UNSET) - - my_wallet = cls( - balance=balance, - ) - - my_wallet.additional_properties = d - return my_wallet - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/gooyal_wallet_client/models/paginated_user_transaction_list.py b/gooyal_wallet_client/models/paginated_account_list.py similarity index 85% rename from gooyal_wallet_client/models/paginated_user_transaction_list.py rename to gooyal_wallet_client/models/paginated_account_list.py index fb90457..18aee85 100644 --- a/gooyal_wallet_client/models/paginated_user_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_account_list.py @@ -7,24 +7,24 @@ from attrs import field as _attrs_field from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.user_transaction import UserTransaction + from ..models.account import Account -T = TypeVar("T", bound="PaginatedUserTransactionList") +T = TypeVar("T", bound="PaginatedAccountList") @_attrs_define -class PaginatedUserTransactionList: +class PaginatedAccountList: """ Attributes: count (int): Example: 123. - results (list['UserTransaction']): + results (list['Account']): next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100. previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100. """ count: int - results: list["UserTransaction"] + results: list["Account"] next_: Union[None, Unset, str] = UNSET previous: Union[None, Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -66,7 +66,7 @@ class PaginatedUserTransactionList: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.user_transaction import UserTransaction + from ..models.account import Account d = dict(src_dict) count = d.pop("count") @@ -74,7 +74,7 @@ class PaginatedUserTransactionList: results = [] _results = d.pop("results") for results_item_data in _results: - results_item = UserTransaction.from_dict(results_item_data) + results_item = Account.from_dict(results_item_data) results.append(results_item) @@ -96,15 +96,15 @@ class PaginatedUserTransactionList: previous = _parse_previous(d.pop("previous", UNSET)) - paginated_user_transaction_list = cls( + paginated_account_list = cls( count=count, results=results, next_=next_, previous=previous, ) - paginated_user_transaction_list.additional_properties = d - return paginated_user_transaction_list + paginated_account_list.additional_properties = d + return paginated_account_list @property def additional_keys(self) -> list[str]: diff --git a/gooyal_wallet_client/models/paginated_application_transaction_list.py b/gooyal_wallet_client/models/paginated_transaction_list.py similarity index 84% rename from gooyal_wallet_client/models/paginated_application_transaction_list.py rename to gooyal_wallet_client/models/paginated_transaction_list.py index f72973d..71f2a07 100644 --- a/gooyal_wallet_client/models/paginated_application_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_transaction_list.py @@ -7,24 +7,24 @@ from attrs import field as _attrs_field from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.application_transaction import ApplicationTransaction + from ..models.transaction import Transaction -T = TypeVar("T", bound="PaginatedApplicationTransactionList") +T = TypeVar("T", bound="PaginatedTransactionList") @_attrs_define -class PaginatedApplicationTransactionList: +class PaginatedTransactionList: """ Attributes: count (int): Example: 123. - results (list['ApplicationTransaction']): + results (list['Transaction']): next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100. previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100. """ count: int - results: list["ApplicationTransaction"] + results: list["Transaction"] next_: Union[None, Unset, str] = UNSET previous: Union[None, Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -66,7 +66,7 @@ class PaginatedApplicationTransactionList: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.application_transaction import ApplicationTransaction + from ..models.transaction import Transaction d = dict(src_dict) count = d.pop("count") @@ -74,7 +74,7 @@ class PaginatedApplicationTransactionList: results = [] _results = d.pop("results") for results_item_data in _results: - results_item = ApplicationTransaction.from_dict(results_item_data) + results_item = Transaction.from_dict(results_item_data) results.append(results_item) @@ -96,15 +96,15 @@ class PaginatedApplicationTransactionList: previous = _parse_previous(d.pop("previous", UNSET)) - paginated_application_transaction_list = cls( + paginated_transaction_list = cls( count=count, results=results, next_=next_, previous=previous, ) - paginated_application_transaction_list.additional_properties = d - return paginated_application_transaction_list + paginated_transaction_list.additional_properties = d + return paginated_transaction_list @property def additional_keys(self) -> list[str]: diff --git a/gooyal_wallet_client/models/user_transaction.py b/gooyal_wallet_client/models/transaction.py similarity index 76% rename from gooyal_wallet_client/models/user_transaction.py rename to gooyal_wallet_client/models/transaction.py index 5b2a0a1..96e122a 100644 --- a/gooyal_wallet_client/models/user_transaction.py +++ b/gooyal_wallet_client/models/transaction.py @@ -10,18 +10,20 @@ from dateutil.parser import isoparse from ..models.state_enum import StateEnum from ..types import UNSET, Unset -T = TypeVar("T", bound="UserTransaction") +T = TypeVar("T", bound="Transaction") @_attrs_define -class UserTransaction: +class Transaction: """ Attributes: uuid (UUID): - payer_id (str): + payer (str): payer_type (str): - payee_id (UUID): - payee_type (UUID): + payer_wallet (str): + payee (UUID): + payee_type (int): + payee_wallet (str): created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed @@ -38,10 +40,12 @@ class UserTransaction: """ uuid: UUID - payer_id: str + payer: str payer_type: str - payee_id: UUID - payee_type: UUID + payer_wallet: str + payee: UUID + payee_type: int + payee_wallet: str created_at: datetime.datetime state: StateEnum amount: int @@ -54,13 +58,17 @@ class UserTransaction: def to_dict(self) -> dict[str, Any]: uuid = str(self.uuid) - payer_id = self.payer_id + payer = self.payer payer_type = self.payer_type - payee_id = str(self.payee_id) + payer_wallet = self.payer_wallet - payee_type = str(self.payee_type) + payee = str(self.payee) + + payee_type = self.payee_type + + payee_wallet = self.payee_wallet created_at = self.created_at.isoformat() @@ -81,10 +89,12 @@ class UserTransaction: field_dict.update( { "uuid": uuid, - "payer_id": payer_id, + "payer": payer, "payer_type": payer_type, - "payee_id": payee_id, + "payer_wallet": payer_wallet, + "payee": payee, "payee_type": payee_type, + "payee_wallet": payee_wallet, "created_at": created_at, "state": state, "amount": amount, @@ -103,13 +113,17 @@ class UserTransaction: d = dict(src_dict) uuid = UUID(d.pop("uuid")) - payer_id = d.pop("payer_id") + payer = d.pop("payer") payer_type = d.pop("payer_type") - payee_id = UUID(d.pop("payee_id")) + payer_wallet = d.pop("payer_wallet") - payee_type = UUID(d.pop("payee_type")) + payee = UUID(d.pop("payee")) + + payee_type = d.pop("payee_type") + + payee_wallet = d.pop("payee_wallet") created_at = isoparse(d.pop("created_at")) @@ -125,12 +139,14 @@ class UserTransaction: delay = d.pop("delay", UNSET) - user_transaction = cls( + transaction = cls( uuid=uuid, - payer_id=payer_id, + payer=payer, payer_type=payer_type, - payee_id=payee_id, + payer_wallet=payer_wallet, + payee=payee, payee_type=payee_type, + payee_wallet=payee_wallet, created_at=created_at, state=state, amount=amount, @@ -140,8 +156,8 @@ class UserTransaction: delay=delay, ) - user_transaction.additional_properties = d - return user_transaction + transaction.additional_properties = d + return transaction @property def additional_keys(self) -> list[str]: From 0c9dde033925117183c6588230d0208ed57ac9cd Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Wed, 29 Oct 2025 13:36:50 +0330 Subject: [PATCH 20/38] fix(pg): deposit verify process deposit verify process --- apps/pg/models.py | 7 ++++--- main/settings.py | 2 +- utils/wallet_client.py | 18 +++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index 6396b24..958a020 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -120,8 +120,9 @@ class PaymentRequest(models.Model): def deposit_submit(self): data = { "uuid": str(self.uuid), - "payee_id": str(self.user.uuid), + "payee": str(self.user.uuid), "payee_type": 1, + "payee_wallet": settings.WALLET_RIAL, "amount": self.amount, "details": { 'description': str(_("charge via ipg")), @@ -129,7 +130,7 @@ class PaymentRequest(models.Model): 'application_details_url': '' }, } - submit_response = deposit_to_user_wallet_submit(settings.WALLET_RIAL_CATEGORY, data) + submit_response = deposit_to_user_wallet_submit(settings.WALLET_RIAL, data) if not submit_response or not submit_response.uuid: logger.error(f"[Deposit Submit] Wallet submission failed | payment_id={self.pk}") @@ -147,7 +148,7 @@ class PaymentRequest(models.Model): return to_success def deposit_verify(self): - verify_response = deposit_to_user_wallet_verify(settings.WALLET_RIAL_CATEGORY, self.uuid) + verify_response = deposit_to_user_wallet_verify(settings.WALLET_RIAL, self.uuid) if not verify_response: logger.error(f"[Deposit Verify] Failed to get response from wallet service | payment_id={self.pk}") diff --git a/main/settings.py b/main/settings.py index d528c2d..1dfd128 100644 --- a/main/settings.py +++ b/main/settings.py @@ -255,5 +255,5 @@ CACHES = { PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') -WALLET_RIAL_CATEGORY = config('WALLET_RIAL_CATEGORY') +WALLET_RIAL = config('WALLET_RIAL') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') diff --git a/utils/wallet_client.py b/utils/wallet_client.py index 08ba00f..f923dbf 100644 --- a/utils/wallet_client.py +++ b/utils/wallet_client.py @@ -7,11 +7,11 @@ from django.db import models from httpx import Request from gooyal_wallet_client import AuthenticatedClient -from gooyal_wallet_client.models import MyWallet, UserTransaction, ApplicationDeposit, ApplicationWithdraw -from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create_2, - wallet_api_application_deposit_verify_retrieve_2, - wallet_api_application_withdraw_create_2, - wallet_api_application_withdraw_verify_retrieve_2) +from gooyal_wallet_client.models import Transaction, Account, ApplicationDeposit, ApplicationWithdraw +from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create, + wallet_api_application_deposit_verify_retrieve, + wallet_api_application_withdraw_create, + wallet_api_application_withdraw_verify_retrieve) from gooyal_wallet_client.types import Response from django.conf import Settings @@ -73,23 +73,23 @@ def get_client(): return client -def deposit_to_user_wallet_submit(category_uuid, data): +def deposit_to_user_wallet_submit(payer_wallet, data): class Tmp(): def to_dict(self): return data deposit_data = Tmp() client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_create_2.sync(category_uuid= category_uuid, + response: ApplicationDeposit = wallet_api_application_deposit_create.sync(payer_wallet=payer_wallet, client=client, body=deposit_data) print(response) return response -def deposit_to_user_wallet_verify(category_uuid, uuid): +def deposit_to_user_wallet_verify(payer_wallet, uuid): client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) + response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve.sync(payer_wallet=payer_wallet, uuid=uuid, client=client) print(response) return response From 50ddf47d21fd0920fe2427020c348efe8784801a Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Wed, 29 Oct 2025 15:11:44 +0330 Subject: [PATCH 21/38] fix(pg): withdraw verify process withdraw verify process --- utils/wallet_client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/wallet_client.py b/utils/wallet_client.py index f923dbf..b5247d3 100644 --- a/utils/wallet_client.py +++ b/utils/wallet_client.py @@ -94,21 +94,21 @@ def deposit_to_user_wallet_verify(payer_wallet, uuid): return response -def withdraw_from_user_wallet_submit(category_uuid, data): +def withdraw_from_user_wallet_submit(payee_wallet, data): class Tmp(): def to_dict(self): return data withdraw_data = Tmp() client = get_client() - response: ApplicationWithdraw = wallet_api_application_withdraw_create_2.sync(category_uuid=category_uuid, client=client, body=withdraw_data) + response: ApplicationWithdraw = wallet_api_application_withdraw_create.sync(payee_wallet=payee_wallet, client=client, body=withdraw_data) print(response) return response -def withdraw_from_user_wallet_verify(category_uuid, uuid): +def withdraw_from_user_wallet_verify(payee_wallet, uuid): client = get_client() - response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) + response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve.sync(payee_wallet=payee_wallet, uuid=uuid, client=client) print(response) return response From c732500c4461099c0c10fb5d69d8537c82123488 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Wed, 29 Oct 2025 18:18:59 +0330 Subject: [PATCH 22/38] fix(wallet): fix fix --- ...user_list.py => wallet_api_application_user_wallets_list.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename gooyal_wallet_client/api/wallet/{wallet_api_application_wallets_user_list.py => wallet_api_application_user_wallets_list.py} (98%) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py similarity index 98% rename from gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py rename to gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py index 54d843e..3317b1e 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_user_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py @@ -34,7 +34,7 @@ def _get_kwargs( _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/wallets/user/{owner}/", + "url": f"/wallet/api/application/user/wallets/{owner}/", "params": params, } From 9d79f30518e310abd689f43df137b76a72173e41 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Tue, 11 Nov 2025 13:16:15 +0330 Subject: [PATCH 23/38] FEAT(pg): ipg commission ipg commission --- .../0007_paymentrequest_commission.py | 18 ++++++++++++++++++ apps/pg/models.py | 11 ++++++++++- apps/pg/views.py | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 apps/pg/migrations/0007_paymentrequest_commission.py diff --git a/apps/pg/migrations/0007_paymentrequest_commission.py b/apps/pg/migrations/0007_paymentrequest_commission.py new file mode 100644 index 0000000..b7bb0cd --- /dev/null +++ b/apps/pg/migrations/0007_paymentrequest_commission.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-11-10 15:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pg', '0006_paymentrequest_is_registered'), + ] + + operations = [ + migrations.AddField( + model_name='paymentrequest', + name='commission', + field=models.PositiveBigIntegerField(null=True), + ), + ] diff --git a/apps/pg/models.py b/apps/pg/models.py index 958a020..d0ab3e1 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -39,6 +39,7 @@ class PaymentRequest(models.Model): state = models.IntegerField(choices=StateChoices.choices, default=StateChoices.CREATED) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT) amount = models.PositiveBigIntegerField(null=True, blank=True) + commission = models.PositiveBigIntegerField(null=True) phone_number = models.CharField(max_length=255, null=True, blank=True) callback_url = models.CharField(max_length=255, null=True, blank=True) @@ -68,6 +69,14 @@ class PaymentRequest(models.Model): return to_jalali(self.created_at) + def calculate_commission(self): + self.commission = 1200 + if 6000000 <= self.amount <= 400000000: + self.commission = 0.0002 * self.amount + elif 400000000 < self.amount: + self.commission = 80000 + self.save(update_fields=['commission']) + def get_gateway_tools(self): if self.gateway == GatewayChoise.PNA: @@ -225,7 +234,7 @@ class PNA(BasePGModel): def make_request(self): self.payment_request.change_state(StateChoices.CREATED, StateChoices.IPG_PENDING, 'can not change state') - amount = self.payment_request.amount + amount = self.payment_request.amount + self.payment_request.commission description = 'from addwin ipg' callback_url = urllib.parse.urljoin( settings.IPG_BASE_PUBLIC_URL, diff --git a/apps/pg/views.py b/apps/pg/views.py index 9f58a73..4fd4469 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -59,6 +59,7 @@ class PaymentRequestView(UpdateView): def get(self, request, *args, **kwargs): charge_request: PaymentRequest = self.get_object() charge_request.set_gateway({'pna': True}) + charge_request.calculate_commission() tool = charge_request.get_gateway_tools() tool.make_request() redirect_url = tool.get_pg_page_url() From fbff6b1336f077c7ef34cf5670fefb090e39cd21 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Tue, 11 Nov 2025 14:47:22 +0330 Subject: [PATCH 24/38] FEAT(pg): ipg commission ipg commission --- apps/pg/models.py | 14 +++++++------- main/settings.py | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index d0ab3e1..01358df 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -14,8 +14,8 @@ from apps.core.models import BaseModel, BasePGModel from apps.pg.constans import StateChoices import uuid -from utils.wallet_client import deposit_to_user_wallet_submit, \ - deposit_to_user_wallet_verify +from utils.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify +from main import settings from utils.pna import PNAClient from django.utils.translation import gettext_lazy as _ @@ -70,11 +70,11 @@ class PaymentRequest(models.Model): return to_jalali(self.created_at) def calculate_commission(self): - self.commission = 1200 - if 6000000 <= self.amount <= 400000000: - self.commission = 0.0002 * self.amount - elif 400000000 < self.amount: - self.commission = 80000 + self.commission = settings.COMMISSION_LEVEL1 + if settings.COMMISSION_LEVEL2_MIN_AMOUNT <= self.amount <= settings.COMMISSION_LEVEL2_MAX_AMOUNT: + self.commission = settings.COMMISSION_LEVEL2_RATE * self.amount + elif settings.COMMISSION_LEVEL2_MAX_AMOUNT < self.amount: + self.commission = settings.COMMISSION_LEVEL3 self.save(update_fields=['commission']) diff --git a/main/settings.py b/main/settings.py index 1dfd128..602da3a 100644 --- a/main/settings.py +++ b/main/settings.py @@ -257,3 +257,8 @@ PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') WALLET_RIAL = config('WALLET_RIAL') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') +COMMISSION_LEVEL1 = config('COMMISSION_LEVEL1', cast=int) +COMMISSION_LEVEL2_MIN_AMOUNT = config('COMMISSION_LEVEL2_MIN_AMOUNT', cast=int) +COMMISSION_LEVEL2_MAX_AMOUNT = config('COMMISSION_LEVEL2_MAX_AMOUNT', cast=int) +COMMISSION_LEVEL2_RATE = config('COMMISSION_LEVEL2_RATE', cast=float) +COMMISSION_LEVEL3 = config('COMMISSION_LEVEL3', cast=int) From 0bb1889f27e6ae6ac62703c86d8788397ce91706 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Tue, 11 Nov 2025 14:50:52 +0330 Subject: [PATCH 25/38] FEAT(pg): ipg commission COMMISSION_LEVEL1=1200 COMMISSION_LEVEL2_MIN_AMOUNT=6000000 COMMISSION_LEVEL2_MAX_AMOUNT=400000000 COMMISSION_LEVEL2_RATE=0.0002 COMMISSION_LEVEL3=80000 --- apps/pg/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index 01358df..605229c 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -77,7 +77,6 @@ class PaymentRequest(models.Model): self.commission = settings.COMMISSION_LEVEL3 self.save(update_fields=['commission']) - def get_gateway_tools(self): if self.gateway == GatewayChoise.PNA: return PNA.objects.get(payment_request=self) From 1a8e210e872f98d6246ffdc595a5bed499b02463 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Thu, 13 Nov 2025 16:20:19 +0330 Subject: [PATCH 26/38] cleanup --- apps/pg/models.py | 2 +- main/settings.py | 17 +++++++------- .../clients/gooyal_wallet_client}/__init__.py | 0 .../gooyal_wallet_client}/api/__init__.py | 0 .../api/wallet/__init__.py | 0 .../wallet_api_application_deposit_create.py | 0 ...api_application_deposit_verify_retrieve.py | 0 ...allet_api_application_transactions_list.py | 0 ...t_api_application_transactions_retrieve.py | 0 ...allet_api_application_user_wallets_list.py | 0 .../wallet_api_application_wallets_list.py | 0 .../wallet_api_application_withdraw_create.py | 0 ...pi_application_withdraw_verify_retrieve.py | 0 .../wallet/wallet_api_transactions_list.py | 0 .../api/wallet/wallet_api_wallets_list.py | 0 .../clients/gooyal_wallet_client}/client.py | 0 .../clients/gooyal_wallet_client}/errors.py | 0 .../gooyal_wallet_client}/models/__init__.py | 0 .../gooyal_wallet_client}/models/account.py | 0 .../models/application_deposit.py | 0 .../models/application_withdraw.py | 0 .../models/paginated_account_list.py | 0 .../models/paginated_transaction_list.py | 0 .../models/state_enum.py | 0 .../models/transaction.py | 0 .../clients/gooyal_wallet_client}/py.typed | 0 .../clients/gooyal_wallet_client}/types.py | 0 utils/{ => clients}/wallet_client.py | 23 ++++++------------- 28 files changed, 17 insertions(+), 25 deletions(-) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/__init__.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/__init__.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/__init__.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_deposit_create.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_deposit_verify_retrieve.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_transactions_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_transactions_retrieve.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_user_wallets_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_wallets_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_withdraw_create.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_application_withdraw_verify_retrieve.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_transactions_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/api/wallet/wallet_api_wallets_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/client.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/errors.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/__init__.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/account.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/application_deposit.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/application_withdraw.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/paginated_account_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/paginated_transaction_list.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/state_enum.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/models/transaction.py (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/py.typed (100%) rename {gooyal_wallet_client => utils/clients/gooyal_wallet_client}/types.py (100%) rename utils/{ => clients}/wallet_client.py (84%) diff --git a/apps/pg/models.py b/apps/pg/models.py index 605229c..eacf45d 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -14,7 +14,7 @@ from apps.core.models import BaseModel, BasePGModel from apps.pg.constans import StateChoices import uuid -from utils.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify +from utils.clients.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify from main import settings from utils.pna import PNAClient diff --git a/main/settings.py b/main/settings.py index 602da3a..303f9e3 100644 --- a/main/settings.py +++ b/main/settings.py @@ -77,12 +77,12 @@ OAUTH2_PROVIDER_ID_TOKEN_MODEL = "gooyal_oauth2.IDToken" OAUTH2_PROVIDER_GRANT_MODEL = "gooyal_oauth2.Grant" OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = "gooyal_oauth2.RefreshToken" -BASE_OAUTH2_PROVIDER_PUBLIC_URL = config("BASE_OAUTH2_PROVIDER_PUBLIC_URL") -BASE_OAUTH2_PROVIDER_PRIVATE_URL = config("BASE_OAUTH2_PROVIDER_PRIVATE_URL") +OAUTH2_PROVIDER_BASE_PUBLIC_URL = config("OAUTH2_PROVIDER_BASE_PUBLIC_URL") +OAUTH2_PROVIDER_BASE_PRIVATE_URL = config("OAUTH2_PROVIDER_BASE_PRIVATE_URL") -CLIENT_ID = config('CLIENT_ID') -CLIENT_SECRET = config('CLIENT_SECRET') -SCOPES = config('SCOPES', default='') +OAUTH2_PROVIDER_CLIENT_ID = config('OAUTH2_PROVIDER_CLIENT_ID') +OAUTH2_PROVIDER_CLIENT_SECRET = config('OAUTH2_PROVIDER_CLIENT_SECRET') +OAUTH2_PROVIDER_SCOPES = config('OAUTH2_PROVIDER_SCOPES', default='') OAUTH2_PROVIDER = { # this is the list of available scopes # 'SCOPES_BACKEND_CLASS': 'apps.gooyal_oauth2.scopes.Scopes', @@ -91,9 +91,9 @@ OAUTH2_PROVIDER = { # 'groups': 'Access to your groups', # 'introspection': 'Introspect token scope'}, 'OAUTH2_VALIDATOR_CLASS': 'apps.gooyal_oauth2.validators.OAuth2Validator', - 'RESOURCE_SERVER_INTROSPECTION_URL': BASE_OAUTH2_PROVIDER_PRIVATE_URL + '/introspect/', + 'RESOURCE_SERVER_INTROSPECTION_URL': OAUTH2_PROVIDER_BASE_PRIVATE_URL + '/introspect/', # 'RESOURCE_SERVER_AUTH_TOKEN': '3yUqsWtwKYKHnfivFcJu', # OR this but not both: - 'RESOURCE_SERVER_INTROSPECTION_CREDENTIALS': (CLIENT_ID, CLIENT_SECRET), + 'RESOURCE_SERVER_INTROSPECTION_CREDENTIALS': (OAUTH2_PROVIDER_CLIENT_ID, OAUTH2_PROVIDER_CLIENT_SECRET), } REST_FRAMEWORK = { @@ -246,7 +246,7 @@ JALALI_DATE_DEFAULTS = { CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": config('BASE_REDIS_URL'), + "LOCATION": config('REDIS_BASE_URL'), "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", } @@ -257,6 +257,7 @@ PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') WALLET_RIAL = config('WALLET_RIAL') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') + COMMISSION_LEVEL1 = config('COMMISSION_LEVEL1', cast=int) COMMISSION_LEVEL2_MIN_AMOUNT = config('COMMISSION_LEVEL2_MIN_AMOUNT', cast=int) COMMISSION_LEVEL2_MAX_AMOUNT = config('COMMISSION_LEVEL2_MAX_AMOUNT', cast=int) diff --git a/gooyal_wallet_client/__init__.py b/utils/clients/gooyal_wallet_client/__init__.py similarity index 100% rename from gooyal_wallet_client/__init__.py rename to utils/clients/gooyal_wallet_client/__init__.py diff --git a/gooyal_wallet_client/api/__init__.py b/utils/clients/gooyal_wallet_client/api/__init__.py similarity index 100% rename from gooyal_wallet_client/api/__init__.py rename to utils/clients/gooyal_wallet_client/api/__init__.py diff --git a/gooyal_wallet_client/api/wallet/__init__.py b/utils/clients/gooyal_wallet_client/api/wallet/__init__.py similarity index 100% rename from gooyal_wallet_client/api/wallet/__init__.py rename to utils/clients/gooyal_wallet_client/api/wallet/__init__.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_list.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_transactions_retrieve.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_user_wallets_list.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_wallets_list.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py diff --git a/gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py b/utils/clients/gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py similarity index 100% rename from gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py rename to utils/clients/gooyal_wallet_client/api/wallet/wallet_api_wallets_list.py diff --git a/gooyal_wallet_client/client.py b/utils/clients/gooyal_wallet_client/client.py similarity index 100% rename from gooyal_wallet_client/client.py rename to utils/clients/gooyal_wallet_client/client.py diff --git a/gooyal_wallet_client/errors.py b/utils/clients/gooyal_wallet_client/errors.py similarity index 100% rename from gooyal_wallet_client/errors.py rename to utils/clients/gooyal_wallet_client/errors.py diff --git a/gooyal_wallet_client/models/__init__.py b/utils/clients/gooyal_wallet_client/models/__init__.py similarity index 100% rename from gooyal_wallet_client/models/__init__.py rename to utils/clients/gooyal_wallet_client/models/__init__.py diff --git a/gooyal_wallet_client/models/account.py b/utils/clients/gooyal_wallet_client/models/account.py similarity index 100% rename from gooyal_wallet_client/models/account.py rename to utils/clients/gooyal_wallet_client/models/account.py diff --git a/gooyal_wallet_client/models/application_deposit.py b/utils/clients/gooyal_wallet_client/models/application_deposit.py similarity index 100% rename from gooyal_wallet_client/models/application_deposit.py rename to utils/clients/gooyal_wallet_client/models/application_deposit.py diff --git a/gooyal_wallet_client/models/application_withdraw.py b/utils/clients/gooyal_wallet_client/models/application_withdraw.py similarity index 100% rename from gooyal_wallet_client/models/application_withdraw.py rename to utils/clients/gooyal_wallet_client/models/application_withdraw.py diff --git a/gooyal_wallet_client/models/paginated_account_list.py b/utils/clients/gooyal_wallet_client/models/paginated_account_list.py similarity index 100% rename from gooyal_wallet_client/models/paginated_account_list.py rename to utils/clients/gooyal_wallet_client/models/paginated_account_list.py diff --git a/gooyal_wallet_client/models/paginated_transaction_list.py b/utils/clients/gooyal_wallet_client/models/paginated_transaction_list.py similarity index 100% rename from gooyal_wallet_client/models/paginated_transaction_list.py rename to utils/clients/gooyal_wallet_client/models/paginated_transaction_list.py diff --git a/gooyal_wallet_client/models/state_enum.py b/utils/clients/gooyal_wallet_client/models/state_enum.py similarity index 100% rename from gooyal_wallet_client/models/state_enum.py rename to utils/clients/gooyal_wallet_client/models/state_enum.py diff --git a/gooyal_wallet_client/models/transaction.py b/utils/clients/gooyal_wallet_client/models/transaction.py similarity index 100% rename from gooyal_wallet_client/models/transaction.py rename to utils/clients/gooyal_wallet_client/models/transaction.py diff --git a/gooyal_wallet_client/py.typed b/utils/clients/gooyal_wallet_client/py.typed similarity index 100% rename from gooyal_wallet_client/py.typed rename to utils/clients/gooyal_wallet_client/py.typed diff --git a/gooyal_wallet_client/types.py b/utils/clients/gooyal_wallet_client/types.py similarity index 100% rename from gooyal_wallet_client/types.py rename to utils/clients/gooyal_wallet_client/types.py diff --git a/utils/wallet_client.py b/utils/clients/wallet_client.py similarity index 84% rename from utils/wallet_client.py rename to utils/clients/wallet_client.py index b5247d3..49f6dcd 100644 --- a/utils/wallet_client.py +++ b/utils/clients/wallet_client.py @@ -6,13 +6,13 @@ from django.core.cache import cache from django.db import models from httpx import Request -from gooyal_wallet_client import AuthenticatedClient -from gooyal_wallet_client.models import Transaction, Account, ApplicationDeposit, ApplicationWithdraw -from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create, +from utils.clients.gooyal_wallet_client import AuthenticatedClient +from utils.clients.gooyal_wallet_client.models import Transaction, Account, ApplicationDeposit, ApplicationWithdraw +from utils.clients.gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create, wallet_api_application_deposit_verify_retrieve, wallet_api_application_withdraw_create, wallet_api_application_withdraw_verify_retrieve) -from gooyal_wallet_client.types import Response +from utils.clients.gooyal_wallet_client.types import Response from django.conf import Settings @@ -37,11 +37,11 @@ def login_as_client_credentials(): data = { "grant_type": 'client_credentials', - "scope": settings.SCOPES, + "scope": settings.OAUTH2_PROVIDER_SCOPES, } - auth = (settings.CLIENT_ID, settings.CLIENT_SECRET) + auth = (settings.OAUTH2_PROVIDER_CLIENT_ID, settings.OAUTH2_PROVIDER_CLIENT_SECRET) - response = requests.post(f'{settings.BASE_OAUTH2_PROVIDER_PUBLIC_URL}/token/', + response = requests.post(f'{settings.OAUTH2_PROVIDER_BASE_PUBLIC_URL}/token/', data=data, auth=auth) print(response.content) @@ -111,12 +111,3 @@ def withdraw_from_user_wallet_verify(payee_wallet, uuid): response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve.sync(payee_wallet=payee_wallet, uuid=uuid, client=client) print(response) return response - - -sample_data = { - "uuid": "3fa85f64-5717-4562-b3fc-2c963f66afb1", - "payee_id": "5d66d02e-6087-4b0a-bb0c-291d5c11755a", - "payee_type": 1, - "amount": 2000, - "details": "string", -} From 6aceb7518575747c7320c5d7e45b68dc77c575b0 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 15 Nov 2025 14:15:54 +0330 Subject: [PATCH 27/38] FEAT(pg): ipg commission calculation api/calculate_commission/?amount=300000 --- apps/pg/models.py | 9 +++------ apps/pg/serializers.py | 4 ++++ apps/pg/urls.py | 3 ++- apps/pg/views.py | 28 ++++++++++++++++++++-------- utils/commons.py | 9 +++++++++ 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 utils/commons.py diff --git a/apps/pg/models.py b/apps/pg/models.py index 605229c..339e65f 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -14,6 +14,7 @@ from apps.core.models import BaseModel, BasePGModel from apps.pg.constans import StateChoices import uuid +from utils.commons import calculate_pna_commission from utils.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify from main import settings @@ -69,12 +70,8 @@ class PaymentRequest(models.Model): return to_jalali(self.created_at) - def calculate_commission(self): - self.commission = settings.COMMISSION_LEVEL1 - if settings.COMMISSION_LEVEL2_MIN_AMOUNT <= self.amount <= settings.COMMISSION_LEVEL2_MAX_AMOUNT: - self.commission = settings.COMMISSION_LEVEL2_RATE * self.amount - elif settings.COMMISSION_LEVEL2_MAX_AMOUNT < self.amount: - self.commission = settings.COMMISSION_LEVEL3 + def save_commission(self): + self.commission = calculate_pna_commission(self.amount) self.save(update_fields=['commission']) def get_gateway_tools(self): diff --git a/apps/pg/serializers.py b/apps/pg/serializers.py index 1f5f18f..3be3ace 100644 --- a/apps/pg/serializers.py +++ b/apps/pg/serializers.py @@ -39,3 +39,7 @@ class ApplicationPaymentRequestSerializer(serializers.ModelSerializer): read_only_fields = ['uuid', 'updated_at', 'state', 'created_at'] + +class CommissionSerializer(serializers.Serializer): + amount = serializers.IntegerField() + commission = serializers.IntegerField(read_only=True) \ No newline at end of file diff --git a/apps/pg/urls.py b/apps/pg/urls.py index 4d3320d..6fa5c3f 100644 --- a/apps/pg/urls.py +++ b/apps/pg/urls.py @@ -1,6 +1,6 @@ from django.urls import path, include from .views import PaymentRequestView, PaymentRequestCreateApiView, PaymentConfirmView, \ - ApplicationPaymentRequestCreateApiView + ApplicationPaymentRequestCreateApiView, CalculateCommissionView app_name = "pg" @@ -9,4 +9,5 @@ urlpatterns = [ path('page/pna_callback//', PaymentConfirmView.as_view(), name='payment-confirm-view'), path('api/charge_create/', PaymentRequestCreateApiView.as_view(), name='charge-request-create-api-view'), path('api/application/charge_create/', ApplicationPaymentRequestCreateApiView.as_view(), name='application-user-charge-request-create-api-view'), + path('api/calculate_commission/', CalculateCommissionView.as_view(), name='calculate-commission-view'), ] diff --git a/apps/pg/views.py b/apps/pg/views.py index 4fd4469..50759bf 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -1,23 +1,35 @@ from django.contrib import messages -from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect, HttpResponse -from django.shortcuts import render from django.urls import reverse from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.views.generic import UpdateView, DetailView -from oauth2_provider.contrib.rest_framework import TokenHasScope, IsAuthenticatedOrTokenHasScope +from django.views.generic import UpdateView +from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope from rest_framework import generics +from rest_framework.response import Response from rest_framework.views import APIView -from .forms import PaymentRequestForm -from .models import PaymentRequest, GatewayChoise -from .serializers import PaymentRequestSerializer, ApplicationPaymentRequestSerializer +from utils.commons import calculate_pna_commission from .constans import StateChoices +from .forms import PaymentRequestForm +from .models import PaymentRequest +from .serializers import PaymentRequestSerializer, CommissionSerializer from ..gooyal_oauth2.utils import get_application from ..users.models import User +class CalculateCommissionView(APIView): + def get(self, request): + serializer = CommissionSerializer(data=request.query_params) + serializer.is_valid(raise_exception=True) + amount = serializer.validated_data['amount'] + commission = calculate_pna_commission(amount) + serializer = CommissionSerializer({ + "amount": amount, + "commission": commission + }) + return Response(serializer.data) + class PaymentRequestCreateApiView(generics.CreateAPIView): permission_classes = [IsAuthenticatedOrTokenHasScope] serializer_class = PaymentRequestSerializer @@ -59,7 +71,7 @@ class PaymentRequestView(UpdateView): def get(self, request, *args, **kwargs): charge_request: PaymentRequest = self.get_object() charge_request.set_gateway({'pna': True}) - charge_request.calculate_commission() + charge_request.save_commission() tool = charge_request.get_gateway_tools() tool.make_request() redirect_url = tool.get_pg_page_url() diff --git a/utils/commons.py b/utils/commons.py new file mode 100644 index 0000000..f48babd --- /dev/null +++ b/utils/commons.py @@ -0,0 +1,9 @@ +from main import settings + +def calculate_pna_commission(amount: int) -> int: + commission = settings.COMMISSION_LEVEL1 + if settings.COMMISSION_LEVEL2_MIN_AMOUNT <= amount <= settings.COMMISSION_LEVEL2_MAX_AMOUNT: + commission = settings.COMMISSION_LEVEL2_RATE * amount + elif settings.COMMISSION_LEVEL2_MAX_AMOUNT < amount: + commission = settings.COMMISSION_LEVEL3 + return commission \ No newline at end of file From 89133022b1c1e0eba876126d7d818081c990f4ad Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 15 Nov 2025 14:38:47 +0330 Subject: [PATCH 28/38] FEAT(pg): ipg commission calculation api/calculate_commission/?amount=300000 --- apps/pg/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/pg/models.py b/apps/pg/models.py index 913f0d7..792b4ae 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -16,7 +16,6 @@ import uuid from utils.clients.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify from utils.commons import calculate_pna_commission -from utils.wallet_client import deposit_to_user_wallet_submit, deposit_to_user_wallet_verify from main import settings from utils.pna import PNAClient From 179677756aad1e72554d0bd7ee825d98c3b8a87b Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 15 Nov 2025 14:52:32 +0330 Subject: [PATCH 29/38] FEAT(pg): ipg commission calculation ipg commission calculation api/calculate_commission/?amount=300000 --- apps/pg/views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/pg/views.py b/apps/pg/views.py index 50759bf..c58ce1e 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -8,6 +8,7 @@ from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScop from rest_framework import generics from rest_framework.response import Response from rest_framework.views import APIView +from drf_spectacular.utils import extend_schema, OpenApiParameter from utils.commons import calculate_pna_commission from .constans import StateChoices @@ -19,6 +20,18 @@ from ..users.models import User class CalculateCommissionView(APIView): + @extend_schema( + parameters=[ + OpenApiParameter( + name='amount', + required=True, + type=float, + location=OpenApiParameter.QUERY, + description='مبلغ' + ) + ], + responses=CommissionSerializer + ) def get(self, request): serializer = CommissionSerializer(data=request.query_params) serializer.is_valid(raise_exception=True) From d0e8b24321fb19ab2208be8de8c5738921df9fdb Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 15 Nov 2025 14:59:15 +0330 Subject: [PATCH 30/38] FEAT(pg): ipg commission calculation ipg commission calculation api/calculate_commission/?amount=300000 --- apps/pg/views.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/apps/pg/views.py b/apps/pg/views.py index c58ce1e..5022bc1 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -8,7 +8,7 @@ from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScop from rest_framework import generics from rest_framework.response import Response from rest_framework.views import APIView -from drf_spectacular.utils import extend_schema, OpenApiParameter +from drf_spectacular.utils import extend_schema from utils.commons import calculate_pna_commission from .constans import StateChoices @@ -21,19 +21,11 @@ from ..users.models import User class CalculateCommissionView(APIView): @extend_schema( - parameters=[ - OpenApiParameter( - name='amount', - required=True, - type=float, - location=OpenApiParameter.QUERY, - description='مبلغ' - ) - ], + request=CommissionSerializer, responses=CommissionSerializer ) - def get(self, request): - serializer = CommissionSerializer(data=request.query_params) + def post(self, request): + serializer = CommissionSerializer(data=request.data) serializer.is_valid(raise_exception=True) amount = serializer.validated_data['amount'] commission = calculate_pna_commission(amount) From f851de4dde06a7943eb6697e7aeb095d5548d85b Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sat, 15 Nov 2025 18:03:27 +0330 Subject: [PATCH 31/38] cleanup --- main/settings.py | 1 + requirements.in | 3 ++- requirements.txt | 9 ++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main/settings.py b/main/settings.py index 303f9e3..2555941 100644 --- a/main/settings.py +++ b/main/settings.py @@ -48,6 +48,7 @@ INSTALLED_APPS = [ 'crispy_bootstrap5', 'django_filters', 'jalali_date', + 'django_admin_logs', # local apps 'apps.core', diff --git a/requirements.in b/requirements.in index fcd0ee8..c6a14d0 100644 --- a/requirements.in +++ b/requirements.in @@ -18,4 +18,5 @@ celery httpx django-redis xlsxwriter -xlrd \ No newline at end of file +xlrd +django_admin_logs \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f156612..65e6719 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.13 # by the following command: # # pip-compile @@ -12,8 +12,6 @@ asgiref==3.8.1 # via # django # django-cors-headers -async-timeout==5.0.1 - # via redis attrs==24.3.0 # via # jsonschema @@ -51,6 +49,7 @@ django==5.1.4 # via # -r requirements.in # crispy-bootstrap5 + # django-admin-logs # django-cors-headers # django-crispy-forms # django-filter @@ -59,6 +58,8 @@ django==5.1.4 # django-redis # djangorestframework # drf-spectacular +django-admin-logs==1.4.0 + # via -r requirements.in django-cors-headers==4.6.0 # via -r requirements.in django-crispy-forms==2.3 @@ -156,9 +157,7 @@ sqlparse==0.5.3 # via django typing-extensions==4.12.2 # via - # anyio # jwcrypto - # psycopg # psycopg-pool tzdata==2024.2 # via From c6cd842b727476ff8706d6b4e8c48f20915dd7ab Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Thu, 4 Dec 2025 15:06:16 +0330 Subject: [PATCH 32/38] cleanup --- apps/pg/urls.py | 2 +- apps/pg/views.py | 39 +- templates/pg/payment-confirm.html | 33 -- ...ment_failure.html => payment_confirm.html} | 356 +++++++++--------- templates/pg/payment_success.html | 5 +- 5 files changed, 190 insertions(+), 245 deletions(-) delete mode 100644 templates/pg/payment-confirm.html rename templates/pg/{payment_failure.html => payment_confirm.html} (94%) diff --git a/apps/pg/urls.py b/apps/pg/urls.py index 6fa5c3f..5eb12ad 100644 --- a/apps/pg/urls.py +++ b/apps/pg/urls.py @@ -6,7 +6,7 @@ app_name = "pg" urlpatterns = [ path('page/charge//', PaymentRequestView.as_view(), name='payment-request-view'), - path('page/pna_callback//', PaymentConfirmView.as_view(), name='payment-confirm-view'), + path('page/confirm//', PaymentConfirmView.as_view(), name='payment-confirm-view'), path('api/charge_create/', PaymentRequestCreateApiView.as_view(), name='charge-request-create-api-view'), path('api/application/charge_create/', ApplicationPaymentRequestCreateApiView.as_view(), name='application-user-charge-request-create-api-view'), path('api/calculate_commission/', CalculateCommissionView.as_view(), name='calculate-commission-view'), diff --git a/apps/pg/views.py b/apps/pg/views.py index 5022bc1..1451db6 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -119,7 +119,7 @@ class PaymentRequestView(UpdateView): @method_decorator(csrf_exempt, name='dispatch') class PaymentConfirmView(UpdateView): - template_name = 'pg/payment_failure.html' + template_name = 'pg/payment_confirm.html' # template_name = 'pg/payment_success.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' @@ -131,13 +131,19 @@ class PaymentConfirmView(UpdateView): # return Charge.objects.filter(state__in=[StateChoices.CREATED.value, StateChoices.SUCCESS.value]) def get(self, request, *args, **kwargs): - print('get') print(args) print(kwargs) self.object = self.get_object() tool = self.object.get_gateway_tools() - tool.confirm_request(request) + # state, message = tool.confirm_request(request) + # if state: + # self.template_name = 'pg/payment_success.html' + # + # + # # TODO: + # context = self.get_context_data(object=self.object) + # context['message'] = message context = self.get_context_data() return self.render_to_response(context) @@ -161,30 +167,3 @@ class PaymentConfirmView(UpdateView): context = self.get_context_data(object=self.object) context['message'] = message return self.render_to_response(context) - - - # def form_valid(self, form): - # self.object = form.save() - # charge_request: ChargeRequest = self.get_object() - # try: - # - # # transaction = Transaction.objects.create( - # # uuid=charge.uuid, - # # payee_id=charge.user.pk, - # # payee_type=1, - # # payer_id=payer_pk, - # # payer_type=2, - # # amount=amount, - # # details={'description': 'شارژ مجازی کیف پول'} - # # ) - # # transaction.submit() - # # transaction.verify() - # # charge.change_state(from_state=StateChoices.PENDING.value, to_state=StateChoices.SUCCESS.value) - # - # except Exception as e: - # print(e) - # messages.error(self.request, 'خطایی رخ داده است') - # charge_request.change_state(from_state=StateChoices.PENDING.value, to_state=StateChoices.EXPECTED_FAILURE.value) - # - # return HttpResponseRedirect(self.get_success_url()) - diff --git a/templates/pg/payment-confirm.html b/templates/pg/payment-confirm.html deleted file mode 100644 index 3e87bfc..0000000 --- a/templates/pg/payment-confirm.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "base.html" %} -{% load static %} -{% load crispy_forms_tags %} -{% load jalali_tags %} - -{% block title %}بازگشت{% endblock %} -{% block page_title %}بازگشت{% endblock %} - - -{% block content %} - مبلغ {{ object.amount }} ریال با وضعیت {{ object.get_state_display }}
-
- {% csrf_token %} -
-
- {#
#} - {#
#} - {{ form|crispy }} - {#
#} - {#
#} -
-
بازگشت به برنامه
-
-
- -
-
-
-
- -{% endblock %} \ No newline at end of file diff --git a/templates/pg/payment_failure.html b/templates/pg/payment_confirm.html similarity index 94% rename from templates/pg/payment_failure.html rename to templates/pg/payment_confirm.html index bd19088..926cfab 100644 --- a/templates/pg/payment_failure.html +++ b/templates/pg/payment_confirm.html @@ -1,179 +1,179 @@ -{% load static %} -{% load crispy_forms_tags %} -{% load jalali_tags %} - - - - - - - - Payment Unsuccessful - - - - - - - - - -
-
- -
-
!
- {% if message %} -

{{ message }}

- {% else %} -

پرداخت شما ناموفق بود

- {% endif %} -
-
-

کد پیگیری تراکنش شما: {{ object.reference_number }}

-

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

-
- addwin -
- -
-
- {% csrf_token %} - {{ form|crispy }} - -
-
-
-
- - +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + + + + + + + + Payment Unsuccessful + + + + + + + + + +
+
+ +
+
!
+ {% if message %} +

{{ message }}

+ {% else %} +

پرداخت شما ناموفق بود

+ {% endif %} +
+
+

کد پیگیری تراکنش شما: {{ object.reference_number }}

+

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

+
+ وینسو +
+ +
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
+
+ + \ No newline at end of file diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index 81cac7d..fa011f1 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -155,9 +155,9 @@
مقدار پرداخت شده: - {{ object.amount }} تومان + {{ object.amount }} ریال
- addwin + وینسو
@@ -167,7 +167,6 @@
-
From ae4794626519f58b53c090752a956087af6d7611 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 9 Dec 2025 10:38:15 +0330 Subject: [PATCH 33/38] logger --- main/settings.py | 38 ++++++++++++++++++++ utils/exceptions.py | 1 + utils/logs/__init__.py | 4 +++ utils/logs/formatters.py | 77 ++++++++++++++++++++++++++++++++++++++++ utils/logs/handlers.py | 57 +++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 utils/logs/__init__.py create mode 100644 utils/logs/formatters.py create mode 100644 utils/logs/handlers.py diff --git a/main/settings.py b/main/settings.py index 2555941..2b1db7f 100644 --- a/main/settings.py +++ b/main/settings.py @@ -254,6 +254,44 @@ CACHES = { } } +LOKI_BASE_PUBLIC_URL = config('LOKI_BASE_PUBLIC_URL', default=None, cast=str) + + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'loki': { + 'class': 'utils.logs.LokiFormatter', # required + }, + }, + + 'handlers': { + 'loki': { + 'level': 'DEBUG', # Log level. Required + 'class': 'utils.logs.LokiHandler', # Required + 'formatter': 'loki', # Loki formatter. Required + 'timeout': 2, # Post request timeout, default is 0.5. Optional + 'url': f'{LOKI_BASE_PUBLIC_URL}/loki/api/v1/push', # Loki url. Defaults to localhost. Optional. + # 'auth': ("user", "password"), # Basic auth to authenticate with loki. Default is None (i.e. no auth). Optional + 'tags': {"app": "ipg"}, # Tags / Labels to attach to the log. Optional, but strongly encoraged to use. + 'mode': 'thread', # Push mode. Can be 'sync' or 'thread'. Sync is blocking, thread is non-blocking. Defaults to sync. Optional. + }, + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + # 'formatter': 'verbose', + }, + }, + 'loggers': { + '': { + 'handlers': ['console', 'loki'], + 'level': 'INFO', + 'propagate': True, + }, + }, +} + PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') WALLET_RIAL = config('WALLET_RIAL') diff --git a/utils/exceptions.py b/utils/exceptions.py index 28a4f95..1fb3b04 100644 --- a/utils/exceptions.py +++ b/utils/exceptions.py @@ -5,6 +5,7 @@ from rest_framework.views import exception_handler as drf_exception_handler logger = logging.getLogger(__name__) def exception_handler(exc, context): + logger.exception(exc) # پاسخ پیش‌فرض DRF را دریافت می‌کنیم response = drf_exception_handler(exc, context) diff --git a/utils/logs/__init__.py b/utils/logs/__init__.py new file mode 100644 index 0000000..5afab06 --- /dev/null +++ b/utils/logs/__init__.py @@ -0,0 +1,4 @@ +from .formatters import LokiFormatter +from .handlers import LokiHandler + +__all__ = ['LokiHandler', 'LokiFormatter'] \ No newline at end of file diff --git a/utils/logs/formatters.py b/utils/logs/formatters.py new file mode 100644 index 0000000..def86d5 --- /dev/null +++ b/utils/logs/formatters.py @@ -0,0 +1,77 @@ +import logging +import socket +from datetime import datetime +from logging import BASIC_FORMAT + + +class LokiFormatter(logging.Formatter): + asctime_search = "%(asctime)" + tz = "UTC" + source = "Loki" + src_host = "localhost" + tags = {} + + def __init__(self, fmt, dfmt, style, fqdn=False): + super(LokiFormatter, self).__init__() + + self.fmt = fmt or BASIC_FORMAT + self.dfmt = dfmt or "%Y-%m-%d %H:%M:%S" + self.style = style + + if fqdn: + self.host = socket.getfqdn() + else: + self.host = socket.gethostname() + + def format_timestamp(self, time): + return str(int(time * 10**9)) + + def usesTime(self): + return self.fmt.find(self.asctime_search) >= 0 + + def formatMessage(self, record): + try: + return self.fmt % record.__dict__ + except KeyError as e: + raise ValueError("Formatting field not found in record: %s" % e) + + def format(self, record): + record.message = record.getMessage() + + if self.usesTime(): + record.asctime = self.formatTime(record, self.dfmt) + + message = self.formatMessage(record) + + if record.exc_info: + if not record.exc_text: + record.exc_text = self.formatException(record.exc_info) + + if record.exc_text: + if message[-1:] != "\n": + message = message + "\n" + message = message + record.exc_text + + if record.stack_info: + if message[-1:] != "\n": + message = message + "\n" + + message = message + self.formatStack(record.stack_info) + + message = { + "streams": [ + { + "stream": { + **self.tags, + }, + "values": [ + [ + self.format_timestamp(record.created), + message, + ] + ], + } + ] + } + + return message diff --git a/utils/logs/handlers.py b/utils/logs/handlers.py new file mode 100644 index 0000000..284e6a4 --- /dev/null +++ b/utils/logs/handlers.py @@ -0,0 +1,57 @@ +import logging +import sys +from threading import Thread + +import requests + + +class LokiHandler(logging.Handler): + def __init__( + self, + timeout=0.5, + url="http://localhost:3100/loki/api/v1/push", + auth=None, + tags={}, + mode="sync", + ): + super(LokiHandler, self).__init__() + + self._url = url + self._timeout = timeout + self._auth = auth + self._tags = tags + + self._mode = mode + + def emit(self, record): + try: + payload = self.formatter.format(record) + + self._push_message( + self._url, json=payload, timeout=self._timeout, auth=self._auth + ) + except requests.exceptions.ReadTimeout: + sys.stderr.write("Loki connection timed out\n") + except Exception as e: + sys.stderr.write(f"Loki connection failed with: {e}\n") + + def setFormatter(self, fmt): + fmt.tags = self._tags + + self.formatter = fmt + + def _push_message(self, *args, **kwargs): + if self._mode == "sync": + return _push_message(*args, **kwargs) + + if self._mode == "thread": + return Thread(target=_push_message, args=args, kwargs=kwargs).start() + + +def _push_message(*args, **kwargs): + response = requests.post(*args, **kwargs) + + if response.status_code != 204: + sys.stderr.write( + f"Got status {response.status_code} from loki with message: {response.text}\n" + ) From 09799c028cfeb3d1bebbe7ab16cc3e7b41a3210c Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sun, 14 Dec 2025 14:05:48 +0330 Subject: [PATCH 34/38] feat(ipg): fix failed request and change html files fix failed request and change html files --- apps/pg/models.py | 18 +- apps/pg/views.py | 11 + static/image/pg/fail.png | Bin 0 -> 2690 bytes static/image/pg/tik.png | Bin 0 -> 2703 bytes templates/pg/payment-confirm.html | 33 ++ ...ment_confirm.html => payment_failure.html} | 345 +++++++++--------- templates/pg/payment_success.html | 30 +- 7 files changed, 231 insertions(+), 206 deletions(-) create mode 100644 static/image/pg/fail.png create mode 100644 static/image/pg/tik.png create mode 100644 templates/pg/payment-confirm.html rename templates/pg/{payment_confirm.html => payment_failure.html} (88%) diff --git a/apps/pg/models.py b/apps/pg/models.py index 792b4ae..4c196b7 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -159,14 +159,18 @@ class PaymentRequest(models.Model): logger.error(f"[Deposit Verify] Failed to get response from wallet service | payment_id={self.pk}") raise Exception('Failed to get response from wallet service') - if not verify_response.uuid or verify_response.state != 5: + if not verify_response.uuid: + logger.error(f"[Deposit Verify] Failed to get response uuid from wallet service | payment_id={self.pk}") + raise Exception('Failed to get response uuid from wallet service') + + if verify_response.state != 5: logger.error(f"[Deposit Verify] Wallet verification failed | payment_id={self.pk}, response={verify_response}") - to_pay_failed = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.FAILED.value, - ) + # to_pay_failed = PaymentRequest.objects.filter( + # pk=self.pk, + # state=StateChoices.WALLET_SUBMIT_SUCCESS.value + # ).update( + # state=StateChoices.FAILED.value, + # ) raise Exception('Failed to verify payment in wallet') to_pay_success = PaymentRequest.objects.filter( diff --git a/apps/pg/views.py b/apps/pg/views.py index 1451db6..c2c2a26 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -9,6 +9,7 @@ from rest_framework import generics from rest_framework.response import Response from rest_framework.views import APIView from drf_spectacular.utils import extend_schema +from django.shortcuts import render from utils.commons import calculate_pna_commission from .constans import StateChoices @@ -79,6 +80,11 @@ class PaymentRequestView(UpdateView): charge_request.save_commission() tool = charge_request.get_gateway_tools() tool.make_request() + charge_request.refresh_from_db() + if charge_request.state == StateChoices.FAILED: + return render(request, 'pg/payment_failure.html', { + 'object': charge_request + }) redirect_url = tool.get_pg_page_url() return HttpResponseRedirect(redirect_url) @@ -88,6 +94,11 @@ class PaymentRequestView(UpdateView): charge_request.set_gateway({'pna': True}) tool = charge_request.get_gateway_tools() tool.make_request() + charge_request.refresh_from_db() + if charge_request.state == StateChoices.FAILED: + return render(request, 'pg/payment_failure.html', { + 'object': charge_request + }) redirect_url = tool.get_pg_page_url() return HttpResponseRedirect(redirect_url) diff --git a/static/image/pg/fail.png b/static/image/pg/fail.png new file mode 100644 index 0000000000000000000000000000000000000000..ec72d92d49c53e72f8d9b5d05fcfd388546f06b4 GIT binary patch literal 2690 zcmV-|3Vrp7P)3e@6IEIQ)39$_(bP;1v)5qNk3|>%T6CHZ* z01x{VLcmyl`V-@Y4P@wM9zy_#V^F{Eht$Eri2eE7?>8eYpF7U`(9j_gcOeFxVwK@T44P8id zyPi$_VW)j9T&KsGDrd?^x}s@Xdp&w z8+-V%4GzMA)(0_xsQ$B{n$t)bT3Z#@MAw`SerO7TsRQ^cEVaMr7?nz}$<{yE(&l&~4ka4PaG)OH`#$FMXBhr#lB!3p=P54lF~^ zn7!?CDuI_+xnflTcbQZIs)a+m$0N%Sv^`(4#AiyZ$rwp>$?b&3YTUg%?ZPL3(dxz} zveaV-D7BsyRc1@9R4;)8c>rjv;8OtxI$$$ql+e$>En-uH)d2>W>N{$BL=_U|UX|v3 zT&$9q{KEon5gUQvT?teHcUiA;Abo4XbPgF(`vI{j^Brz~%u;PZ2~e={Zw!r1&`}d8 zAMjI#M0o=D4+fmS#calH2)P{gnLVGB?YCvT#J^ zLY24!Q7bQ8wL`}_y7uNtypdSBVk31>GEvPv`jp%WO0G4vsiD+)@}ySDFRr818)Aic z!tH<;?i%`&7gxo)Ilv^XqZCQ60m z6}SEW;yncv39%8?-#Mt5J&5N8jdP=z0_3`q8ZufGS{?J-5`&rQSX+XvO&%8Bz1=6kt;R#v`lzn!%Z4?LP1hz zSPr?GExaPJ7Ry#wHPtzys;Ls;0WNtpmKgJ1aeMtq{N+oi7+(3*fGNkau$@DL_*H7b z2LhC(fePUp`-jfwmVqrRh@1{dV#nM70lKn_E1FPg3b~jS>~q_sQbTFY($L)03Q#sn z)dX_w+_c7~jdQfN@dmOLv9-Cj2tua*(st9lnLJ*zU0h)1>q_;8J74$W^v`L4pa;w# zyx`C4X{MOLBTQYE**(nlZfRB>L>fw|gIJ0VyD?zu&xPEwK~JP5%LOe%HT!-; ztdfV^4qQ99^TjB}SFRwRdQC1<0r_43_g5&0WJ*52-hrG`sdDauCO(a|K1f?YZ+c6U zMRfL&)YU4I)P`LA!9HljOV*v)E#*4WLJ|z9pKJbJKA4VVei3Te<-kn6aYeFTi_x{? zI+iU7c}`z$#H|CYK00H?os{$C=_-7JpjLa}3~h^%o|sWlH|N)QKEy^SDAnkK%4B^i4#D%C%S5_b)1_^U z%SuhT4I5H9&33uG3zAEcnl6FG1G$i@wFf!KB{m6l`Ph2~CE<9KDEp5RG}kxH7h61l z>)b|e1edD{W^gQn5caS%u@4^+QV+*&h|>iyT${0-i8UACwk{Q+^fIA!z&QUA`s7Y? zZ1tAU5?EeMaml(=ddp#`iB_7d8j@-L7*SO~D#1%)XGkTN9v_!%{CJ9P+cyna=F}|A z9?1hILQAZGSBO}G(YZpsbXIUd2Ol{>e`*n}{z>>aHac7h@GLddZ-FDygHy#VrNJyoY8h_OqPcl-^EZ1u`?L=4B}0*Vv;DgRFgA| zQ55IYkWyF4olq;W^GHdiTK%KsjdXzwk%^YX0F(6R0MW^^W-Ts_*hS2}<*0|1338o~ wXfrdteT($@*HH-=E6`Wcv@u14rcD3*1Ld8qrBMirrvLx|07*qoM6N<$f?+r5(EtDd literal 0 HcmV?d00001 diff --git a/static/image/pg/tik.png b/static/image/pg/tik.png new file mode 100644 index 0000000000000000000000000000000000000000..c6beb97cd1500983316f3ae83447bbd9b611c162 GIT binary patch literal 2703 zcmV;A3UKv_P)7itN#RFl`Nya-Rk~y`uyM93~GYjaI3xKLl+pdIp_Bz z$TogVuU7O*VjR6j^e%<`PDnQ3;%c<_-){#{12CuvMC7s%>%hH_@y{;YBrhw7@V@lr z+e;7nz0S!9DnO~k_J)sJO_)AHY3xEsX5o;)225PNo^pOxCds7``|SIzuGe5sp(HXj zIPj-k(A=N*eC8td1^S|Rh<7r)Ep5^F0gioW_VXfBhlAnPCf@1~z)g}z zQ;=)(sD{kM(k;lK@eb@I0tuD-PddfBI%#+|M1u-W26ZmOmWkNs=bt_RA&$U`R5tKI z>{dnSEQsI+uv5#sYz&+~{`}t8ufY+{#73mPvKUIY`Tpmfmq$=Tpo-|Big*Mz!om5b zE4fa@+LOu#QxF?f#p$+ivJsBtS`%xlQ_<2N@BRD4)kCNhk@P+_3>%})U9;7>R>V5| zvb%M?^-ZuP7rll1Hg}?t*f5&9_+TIve@(f&*C{UcE(4Kkc4`=gu2}QF$yMZF06G6A zNeyq2#U_cLVG0)h_uiWd+@{7CKw_rl+=esBr&Q2T?^fPx-kMdc{bc$ z*NsuC0vo-GhH4)TRS#|B+~Axh#? zB{p)cK7bk{wEi8q19(2%CLUH*+c8XEON%N~C6+_u4X8mb#~R!bFpwLdF=n2^MY};P z87zYeIIep{l_x&KYei$VuNl&%{KM>rH;Cn))=3`SX1%Jy7h%w&^nB8!wvqgUnAb@w z>XV0X3lP-gxLB3ITh!?BjWYdy_ueF z%q9GN1Qx(bu96E>Eg#4K4~UJ_fXWFTFLHv#hE(b+uq|v}dMjk;RAake{`BcR`cFWt z@YMx2{8FREtSf9tMU1Ff11u5z08+kHZRfv>jo_XBVO~&wPX(sYln1FZsElMm>Nrc8 z+h_1fwT-c$lk!@}c2xtX@V7oJ7^o}9qBa+lTCzlu)L;S%bs$-&XW7AU2NNz*m2l}} zvSp$20=Bg|A7JB2=VfL!hproaM>lPoX!14}e$bMhilCQjfj~yss^EzcHM4Ov(AYs>s|^2MRPf zg^ZW-7hZ%~mJ6wQX67znMd|m_j33U_CscSR;Jm1cR6-O`s5okKsg~Fg)EJcTz_i~R z3sR4Z${{l~u`SBSs))@jv2@W({$yPM8~dId6j5ZRES)Or6^9N^N8GoK+>`!NU9h~rQWLLwKCf9bs%DumJOT_CbSoWq4Q=|a&0qJ zVN#_uQkC|J>ns~M;t$+azEIVLSnd)T54&&t@wP*rP{4(xm(Ph4DkcC|9NhB3FJe#tDK^rG#!+(bK3(+>$+QMOSNN_@R zpF|SPAO2afd5q`w&p1HnD+aYZm}FK5F=ELDO=DSvc9}WVtnmDcu4)?^uJ`mF5$nHK z4Qv2cHgdRt$VKV5Ayp!S3*0cDtX&{vnkSpCgYwFaR zFM+MAwp~Vde?Y7uVhU1#kQ0d9AnW8nZjm`vS41<3RDyP$B26^KNu@f#6ksmuAPFMZ zFnJUc!pbAf&c~&kG_zepsU(GpkUK1O+ zRDIP>o_U^WCSWPLmr5>5>I9m#>LAx~fZo8{WCX~P8>3YyRPEr(sW*9mzMBi^V$?GB zfe-4|kL$_}n;oEQouTFI_B!9(hdYQD!|kEQ$G$P|?M4Mb*A7leljlEf*T#^Pg|Kp= znWB}#8A}_elUi_?vws^v;W*x@)HJBfy{665Os#ntCNZ>@u$~Wh2Ks(5TIne5^HgF3 zC9HAaNhN$0&Oo`ElNV#7JDVJrz>*SwL0S z4|SGay7j||Dt}T5P7)g{PvSp58Ivf60y2UKAO$97b5{>e|Rbn){fNbhniT{uc_5`BCPd>`K1 zKIJGZ%THSLR3(&3YWZ1>URlcZK?pzZRL~f?5laZ%7YRLJxm9&h&#@6^(`Kco4e5`g z%7pL%6U)1Kc7o?hYz*ohY*qU{^)>0iH#9eILWx>)=`rY zr9F$G6k=n9AtWtB6|9&vcNe22`qbq^4Jl<#Q7V<#B#30JLUhq^Q0HD3a(=WQbx=;B z+^5bZQ5mtbNId0eHR_foqT6727$yENBO$~&W<5sK=~tJ;&mX{HX=oaRgA)J%002ov JPDHLkV1flT2Pyyn literal 0 HcmV?d00001 diff --git a/templates/pg/payment-confirm.html b/templates/pg/payment-confirm.html new file mode 100644 index 0000000..3e87bfc --- /dev/null +++ b/templates/pg/payment-confirm.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + +{% block title %}بازگشت{% endblock %} +{% block page_title %}بازگشت{% endblock %} + + +{% block content %} + مبلغ {{ object.amount }} ریال با وضعیت {{ object.get_state_display }}
+
+ {% csrf_token %} +
+
+ {#
#} + {#
#} + {{ form|crispy }} + {#
#} + {#
#} +
+
بازگشت به برنامه
+
+
+ +
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/pg/payment_confirm.html b/templates/pg/payment_failure.html similarity index 88% rename from templates/pg/payment_confirm.html rename to templates/pg/payment_failure.html index 926cfab..1559144 100644 --- a/templates/pg/payment_confirm.html +++ b/templates/pg/payment_failure.html @@ -1,179 +1,168 @@ -{% load static %} -{% load crispy_forms_tags %} -{% load jalali_tags %} - - - - - - - - Payment Unsuccessful - - - - - - - - - -
-
- -
-
!
- {% if message %} -

{{ message }}

- {% else %} -

پرداخت شما ناموفق بود

- {% endif %} -
-
-

کد پیگیری تراکنش شما: {{ object.reference_number }}

-

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

-
- وینسو -
- -
-
- {% csrf_token %} - {{ form|crispy }} - -
-
-
-
- - +{% load static %} +{% load crispy_forms_tags %} +{% load jalali_tags %} + + + + + + + + Payment Unsuccessful + + + + + + + + + +
+
+ +
+
fail
+ {% if message %} +

{{ message }}

+ {% else %} +

پرداخت ناموفق

+ {% endif %} +
+
+

کد پیگیری تراکنش شما: {{ object.reference_number }}

+

در صورت کسر از موجودی، مبلغ پرداختی طی یک تا 72 ساعت آینده به حساب شما بازگردانده خواهد شد.

+
+ winsoo +
+ +
+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+
+
+ + \ No newline at end of file diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index fa011f1..fd9844e 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -24,18 +24,6 @@ min-height: 100vh; } - - .mobile-frame { - width: 100vh; - height: 100vh; - background-color: #ffffff; - box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); - padding: 30px; - box-sizing: border-box; - display: flex; - flex-direction: column; - } - .screen-content { flex-grow: 1; display: flex; @@ -125,7 +113,7 @@ width: 100%; padding: 15px; border: none; - border-radius: 20px; + border-radius: 8px; font-size: 1.1rem; font-weight: bold; font-family: 'Vazirmatn', sans-serif; @@ -134,12 +122,12 @@ } .btn-primary { - background-color: #6931c9; + background-color: #3B604B; color: #ffffff; } .btn-primary:hover { - background-color: #7745ce; + background-color: #3B604B; } @@ -149,24 +137,24 @@
-
✓
+
success

پرداخت موفق

-

پرداخت با موفقیت انجام شد.


- مقدار پرداخت شده: - {{ object.amount }} ریال + مبلغ شارژ + {{ object.amount }} تومان
- وینسو + winsoo
{% csrf_token %} {{ form|crispy }} - +
+
From 7c93636e8dc4eb56792c96c784c02279aa8eb17d Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 14 Dec 2025 15:08:02 +0330 Subject: [PATCH 35/38] template --- apps/pg/views.py | 2 +- templates/pg/{payment-confirm.html => payment_confirm.html} | 0 templates/pg/{payment-request.html => payment_request.html} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename templates/pg/{payment-confirm.html => payment_confirm.html} (100%) rename templates/pg/{payment-request.html => payment_request.html} (100%) diff --git a/apps/pg/views.py b/apps/pg/views.py index c2c2a26..cf82c92 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -67,7 +67,7 @@ class ApplicationPaymentRequestCreateApiView(generics.CreateAPIView): @method_decorator(csrf_exempt, name='dispatch') class PaymentRequestView(UpdateView): - template_name = 'pg/payment-request.html' + template_name = 'pg/payment_request.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' slug_field = 'uuid' diff --git a/templates/pg/payment-confirm.html b/templates/pg/payment_confirm.html similarity index 100% rename from templates/pg/payment-confirm.html rename to templates/pg/payment_confirm.html diff --git a/templates/pg/payment-request.html b/templates/pg/payment_request.html similarity index 100% rename from templates/pg/payment-request.html rename to templates/pg/payment_request.html From 4b2314879f973a8fb61a58462916d0c3fe7cd9f5 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 14 Dec 2025 15:14:31 +0330 Subject: [PATCH 36/38] template --- apps/pg/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/pg/views.py b/apps/pg/views.py index cf82c92..bf01c82 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -130,8 +130,8 @@ class PaymentRequestView(UpdateView): @method_decorator(csrf_exempt, name='dispatch') class PaymentConfirmView(UpdateView): - template_name = 'pg/payment_confirm.html' - # template_name = 'pg/payment_success.html' + # template_name = 'pg/payment_confirm.html' + template_name = 'pg/payment_success.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' slug_field = 'uuid' From 906866b8de36c9207b4553b9ec8ffd5bde840a1c Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Sun, 14 Dec 2025 15:17:26 +0330 Subject: [PATCH 37/38] template --- apps/pg/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pg/views.py b/apps/pg/views.py index bf01c82..4508743 100644 --- a/apps/pg/views.py +++ b/apps/pg/views.py @@ -131,7 +131,7 @@ class PaymentRequestView(UpdateView): @method_decorator(csrf_exempt, name='dispatch') class PaymentConfirmView(UpdateView): # template_name = 'pg/payment_confirm.html' - template_name = 'pg/payment_success.html' + template_name = 'pg/payment_failure.html' form_class = PaymentRequestForm # pk_url_kwarg = 'uuid' slug_field = 'uuid' From 31eabedfa68c53e973d0da9619978790b7f53335 Mon Sep 17 00:00:00 2001 From: Sayyid Hamid Mahdavi Date: Tue, 17 Feb 2026 11:20:54 +0330 Subject: [PATCH 38/38] use rial instead of toman --- templates/pg/payment_success.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pg/payment_success.html b/templates/pg/payment_success.html index fd9844e..e0e9d75 100644 --- a/templates/pg/payment_success.html +++ b/templates/pg/payment_success.html @@ -142,7 +142,7 @@
مبلغ شارژ - {{ object.amount }} تومان + {{ object.amount }} ریال
winsoo