def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: from_amount, to_amount = None, None if 'to_amount' in json_data.keys(): to_amount = Currency.serialize_from_json(json_data['to_amount'], response_type) if 'from_amount' in json_data.keys(): from_amount = Currency.serialize_from_json( json_data['from_amount'], response_type) return cls(from_amount, to_amount, json_data.get('exchange_rate'))
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: unit_amount, tax = None, None if 'unit_amount' in json_data.keys(): unit_amount = Money.serialize_from_json(json_data['unit_amount'], response_type) if 'tax' in json_data.keys(): tax = Money.serialize_from_json(json_data['tax'], response_type) return cls( json_data.get('name'), unit_amount, tax, json_data.get('quantity'), json_data.get('category'), json_data.get('description'), json_data.get('sku'), json_response= json_data, response_type = response_type )
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: payable_amount, converted_amount, exchange_rate = None, None, None if 'payable_amount' in json_data.keys(): payable_amount = Money.serialize_from_json(json_data['payable_amount', response_type]) if 'converted_amount' in json_data.keys(): converted_amount = Money.serialize_from_json(json_data['converted_amount', response_type]) if 'exchange_rate' in json_data.keys(): exchange_rate = ExchangeRate.serialize_from_json(json_data['exchange_rate', response_type]) return cls( payable_amount, converted_amount, exchange_rate, json_response = json_data, response_type = response_type )
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: amount, seller_protection, status_details = None, None, None if 'amount' in json_data.keys(): amount = Money.serialize_from_json(json_data['amount'], response_type) if 'seller_protection' in json_data.keys(): seller_protection = SellerProtection.serialize_from_json( json_data['seller_protection'], response_type) if 'status_details' in json_data.keys(): status_details = AuthStatusDetail.serialize_from_json( json_data['status_details'], response_type) return cls(json_data.get('id'), json_data.get('status'), amount, status_details, json_data.get('invoice_id'), json_data.get('custom_id'), seller_protection, json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: return cls(Money.serialize_from_json(json_data['tax_amount']), json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: amount = Money.serialize_from_json(json_data['amount_refunded']) return cls(json_data['outcome_code'], amount, json_response=json_data, response_type=response_type)
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: breakdown = { 'item_total': None, 'shipping': None, 'handling': None, 'tax_total': None, 'insurance': None, 'shipping_discount': None, 'discount': None } breakdown = { k : Money.serialize_from_json(json_data[k], response_type) if k in json_data.keys() else None for k in breakdown } return cls(**breakdown, json_response = json_data, response_type = response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: errors, amount, payout_item, payout_item_fee, currency_conversion, alternate_notification_method = None, None, None, None, None, None if 'errors' in json_data.keys(): errors = PayoutError.serialize_from_json(json_data['errors']) if 'amount' in json_data.keys(): amount = Currency.serialize_from_json(json_data['amount'], response_type) if 'payout_item' in json_data.keys(): payout_item = PayoutItemDetail.serialize_from_json( json_data['payout_item'], response_type) if 'payout_item_fee' in json_data.keys(): payout_item_fee = Currency.serialize_from_json( json_data['payout_item_fee'], response_type) if 'currency_conversion' in json_data.keys(): currency_conversion = CurrencyConversion.serialize_from_json( json_data['currency_conversion'], response_type) if 'alternate_notification_method' in json_data.keys(): alternate_notification_method = PaypalPhoneDetail.serialize_from_json( json_data['alternate_notification_method'], response_type) return cls(json_data.get('payout_item_id'), json_data.get('transaction_id'), json_data.get('activity_id'), json_data.get('transaction_status'), payout_item_fee, json_data.get('payout_batch_id'), json_data.get('sender_batch_id'), payout_item, currency_conversion, errors, json_data.get('recipient_type'), amount, json_data.get('note'), json_data.get('receiver'), json_data.get('sender_item_id'), json_data.get('recipient_wallet'), alternate_notification_method, json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: args = {**json_data} if 'incentive_amount' in json_data.keys(): args['incentive_amount'] = Money.serialize_from_json( json_data['incentive_amount']) return cls(**args, json_response=json_data, response_type=response_type)
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: platform_fees = [] gross_amount, paypal_fee, net_amount, receivable_amount, exchange_rate = None, None, None, None, None if 'gross_amount' in json_data.keys(): gross_amount = Money.serialize_from_json(json_data['gross_amount'], response_type) if 'paypal_fee' in json_data.keys(): paypal_fee = Money.serialize_from_json(json_data['paypal_fee'], response_type) if 'net_amount' in json_data.keys(): net_amount = Money.serialize_from_json(json_data['net_amount'], response_type) if 'receivable_amount' in json_data.keys(): receivable_amount = Money.serialize_from_json(json_data['receivable_amount'], response_type) if 'platform_fees' in json_data.keys(): platform_fees = [PlatformFee.serialize_from_json(x, response_type) for x in json_data['platform_fees']] return cls( gross_amount, paypal_fee, net_amount, receivable_amount, exchange_rate, platform_fees, json_response = json_data, response_type = response_type )
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: platform_fees, net_amount_breakdown = [], None gross_amount, paypal_fee, net_amount, total_refunded_amount = None, None, None, None if 'gross_amount' in json_data.keys(): gross_amount = Money.serialize_from_json(json_data['gross_amount'], response_type) if 'paypal_fee' in json_data.keys(): paypal_fee = Money.serialize_from_json(json_data['paypal_fee'], response_type) if 'net_amount' in json_data.keys(): net_amount = Money.serialize_from_json(json_data['net_amount'], response_type) if 'total_refunded_amount' in json_data.keys(): total_refunded_amount = Money.serialize_from_json(json_data['total_refunded_amount'], response_type) if 'net_amount_breakdown' in json_data.keys(): net_amount_breakdown = RefundNetAmtBreakdown.serialize_from_json(json_data['net_amount_breakdown'], response_type) if 'platform_fees' in json_data.keys(): platform_fees = [PlatformFee.serialize_from_json(x, response_type) for x in json_data['platform_fees']] return cls( gross_amount, paypal_fee, net_amount, total_refunded_amount, net_amount_breakdown, platform_fees, json_response = json_data, response_type = response_type )
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: args = { **json_data, **{ k: Money.serialize_from_json(v) for k, v in json_data.items() if k in cls._MONEY_TYPES } } return cls(**args, json_response=json_data, response_type=response_type)
def serialize_from_json(cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: amount, status_details, seller_breakdown = None, None, None if 'amount' in json_data.keys(): amount = Money.serialize_from_json(json_data['amount'], response_type) if 'status_details' in json_data.keys(): status_details = RefundStatusDetail.serialize_from_json(json_data['status_details'], response_type) if 'seller_breakdown' in json_data.keys(): seller_breakdown = SellerRefundBreakdown.serialize_from_json(json_data['seller_breakdown'], response_type) return cls( json_data.get('id'), json_data.get('status'), json_data.get('invoice_id'), amount, json_data.get('note_to_payer'), status_details, seller_breakdown, json_response = json_data, response_type = response_type )
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: amount, shipping = None, None if 'amount' in json_data.keys(): amount = Money.serialize_from_json(json_data['amount']) if 'shipping_info' in json_data.keys(): shipping = ShippingCost.serialize_from_json( json_data['shipping_info']) return cls(json_data['pd_type'], json_data['payment_id'], json_data['method'], amount, shipping, json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: paid_amount, transactions = None, list() if 'paid_amount' in json_data.keys(): paid_amount = Money.serialize_from_json(json_data['paid_amount'], response_type) if 'transactions' in json_data.keys(): transactions = [ PaymentDetail.serialize_from_json(x, response_type) for x in json_data['transactions'] ] return cls(paid_amount, transactions, json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: amount, recipient_name = None, None if 'amount' in json_data.keys(): amount = Currency.serialize_from_json(json_data['amount'], response_type) if 'recipient_name' in json_data.keys(): recipient_name = PaypalName.serialize_from_json( json_data['recipient_name'], response_type) return cls(json_data.get('recipient_type'), amount, json_data.get('note'), json_data.get('receiver'), json_data.get('sender_item_id'), recipient_name, json_data.get('recipient_wallet'), json_response=json_data, response_type=response_type)
def serialize_from_json( cls: Type[T], json_data: dict, response_type: ResponseType = ResponseType.MINIMAL) -> T: args = { # Regular (primitive) arguments **json_data, # Serialized Money arguments **{ k: Money.serialize_from_json(v) for k, v in json_data.items() if k in cls._MONEY_TYPES }, # Serialized array arguments **{ k: [ cls._PAYPAL_TYPE_ARRAYS[k].serialize_from_json(v) for v in json_data[k] ] for k in json_data.keys() if k in cls._PAYPAL_TYPE_ARRAYS } } return cls(**args, json_response=json_data, response_type=response_type)