def __init__(self, payout_item_id: str, transaction_id: str, activity_id: str, transaction_status: str, payout_item_fee: Currency, payout_batch_id: str, sender_batch_id: str, payout_item: PayoutItemDetail, currency_conversion: CurrencyConversion, errors: PayoutError, recipient_type: str, amount: Currency, note: str, receiver: str, sender_item_id: str, recipient_wallet: str, alternate_notification_method: PaypalPhoneDetail, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.note = note self.errors = errors self.amount = amount self.receiver = receiver self.activity_id = activity_id self.payout_item = payout_item self.recipient_type = recipient_type self.payout_item_id = payout_item_id self.transaction_id = transaction_id self.sender_item_id = sender_item_id self.payout_item_fee = payout_item_fee self.payout_batch_id = payout_batch_id self.sender_batch_id = sender_batch_id self.recipient_wallet = recipient_wallet self.transaction_status = transaction_status self.currency_conversion = currency_conversion self.alternate_notification_method = alternate_notification_method self._time_created = self._json_response.get( 'time_created', kwargs.get('time_created')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, plan_id: str = None, product_id: str = None, name: str = None, status: str = None, description: str = None, billing_cycles: List[BillingCycle] = None, payment_preferences: PaymentPreferences = None, taxes: Taxes = None, quantity_supported: bool = None, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.name = name self.id = plan_id self.taxes = taxes self.status = status self.product_id = product_id self.description = description self.billing_cycles = billing_cycles self.quantity_supported = quantity_supported self.payment_preferences = payment_preferences self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def _page_from_link(self, link: ActionLink, element_key: str, element_class: Type[T]) -> PaypalPage[T]: """Performs an API call to get a page of elements Arguments: link {ActionLink} -- Page action link (HATEOAS) element_key {str} -- The key for the element lists inside the page json element_class {T} -- class reference of a PayPalEntity subclass Returns: PaypalPage[T] -- A page with the desired elements """ api_response = self._execute_action_link(link, None) if api_response.status_code != 200: return PaypalPage(True, api_response, 0, 0, [], []) json_response = api_response.json() total_items = json_response.get('total_items', 0) total_pages = json_response.get('total_pages', 0) elements = [ element_class.serialize_from_json(x) for x in json_response[element_key] ] links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in json_response['links'] ] return PaypalPage(False, api_response, total_items, total_pages, elements, links)
def __init__( self, payout_directive: PayoutDirective = None, referenced_payouts: List[ReferencedPayoutsItem] = [], **kwargs ): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.payout_directive = payout_directive self.referenced_payouts = referenced_payouts or [] self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__(self, field: str, issue: str, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.field = field self.issue = issue self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, batch_header: PayoutHeader, items: List[PayoutItem], **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.items = items self.batch_header = batch_header self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, intent: str, payer: Payer, purchase_units: List[PurchaseUnitRequest], application_context: OrderApplicationContext, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.intent = intent self.payer = payer self.purchase_units = purchase_units self.application_context = application_context self.status = self._json_response.get('status') self.id = self._json_response.get('id', kwargs.get('id')) self._create_time = self._json_response.get('create_time') self._update_time = self._json_response.get('update_time') self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__( self, default_template: bool, template_info: TemplateInfo, settings: TemplateSettings, unit_of_measure: str, name: str = None, **kwargs ): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.name = name self.settings = settings self.template_info = template_info self.unit_of_measure = unit_of_measure self.default_template = default_template self.id = self._json_response.get('id', kwargs.get('id')) self.standard_template = self._json_response.get('standard_template', kwargs.get('standard_template')) self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__(self, webhook_id: str = None, url: str = None, event_types: List[EventType] = [], **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.url = url self.webhook_id = webhook_id self.event_types = event_types or [] self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__( self, refund_id: str, status: str, invoice_id: str, amount: Money, note_to_payer: str, status_details: RefundStatusDetail, seller_breakdown: SellerRefundBreakdown, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.id = refund_id self.status = status self.invoice_id = invoice_id self.amount = amount self.note_to_payer = note_to_payer self.status_details = status_details self.seller_breakdown = seller_breakdown self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__(self, resource_id: str = None, state: str = None, amount: ResourceAmount = None, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.state = state self.amount = amount self.resource_id = resource_id self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def list_invoices(self, page: int = 1, page_size: int = 10, total_required: bool = True, fields: List[str] = []) -> PaypalPage[Invoice]: """Calls the paypal API to get an invoice page. Arguments: page {int} -- current page page_size {int} -- page size total_required {bool} -- total count required fields {List[str]} -- fields to be searched Returns: PaypalPage -- The paged elements in paypal API paged response """ query_params = { 'page': page, 'page_size': page_size, 'total_required': total_required } if fields: query_params['fields'] = ','.join(fields) response = self._session.get(parse_url(self._base_url, 'invoices'), query_params) if response.status_code != 200: return PaypalPage.error(response) json_response = response.json() items = [ Invoice.serialize_from_json(x) for x in json_response.get('items', []) ] links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in json_response.get('links', []) ] return PaypalPage.success(response, json_response.get('total_items'), json_response.get('total_pages'), items, links)
def __init__( self, cap_id: str, status: str, final_capture: bool, disbursement_mode: str, invoice_id: str, custom_id: str, amount: Money, seller_protection: SellerProtection, status_details: CaptureStatusDetail , seller_breakdown: SellerBreakdown, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.id = cap_id self.status = status self.final_capture = final_capture self.disbursement_mode = disbursement_mode self.invoice_id = invoice_id self.custom_id = custom_id self.amount = amount self.seller_protection = seller_protection self.status_details = status_details self.seller_receivable_breakdown = seller_breakdown self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def search_invoices(self, page: int, page_size: int, total_required: bool, search: InvoiceSearchRequest) -> PaypalPage[Invoice]: """Searches for and lists invoices that match search criteria. If you pass multiple criteria, the response lists invoices that match all criteria. Arguments: page {int} -- current page page_size {int} -- page size total_required {bool} -- total count required search {InvoiceSearchRequest} -- search criteria to be matched Returns: PaypalPage[Invoice] -- The paged elements in paypal API paged response """ query_params = { page: page, page_size: page_size, total_required: total_required } response = self._session.post(parse_url(self._base_url, 'search-invoices'), json.dumps(search.to_dict()), params=query_params) if response.status_code != 200: return PaypalPage.error(response) json_response = response.json() items = [ Invoice.serialize_from_json(x) for x in json_response['items'] ] links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in json_response['links'] ] return PaypalPage.success(response, json_response.get('total_items'), json_response.get('total_pages'), items, links)
def __init__( self, item_id: str = None, processing_state: str = None, reference_id: str = None, reference_type: str = None, payout_transaction_id: str = None, disbursement_transaction_id: str = None, external_merchant_id: str = None, payee_email: str = None, payout_amount: Money = None, payout_destination: str = None, invoice_id: str = None, custom: str = None, **kwargs ): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.custom = custom self.item_id = item_id self.invoice_id = invoice_id self.payee_email = payee_email self.reference_id = reference_id self.payout_amount = payout_amount self.reference_type = reference_type self.processing_state = processing_state self.payout_destination = payout_destination self.external_merchant_id = external_merchant_id self.payout_transaction_id = payout_transaction_id self.disbursement_transaction_id = disbursement_transaction_id self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__(self, account_number: str = None, transaction_details: List[TransactionDetails] = [], **kwargs): self.account_number = account_number self.transaction_details = transaction_details or [] self.page = self._json_response.get('page', kwargs.get('page')) self._end_date = self._json_response.get('end_date', kwargs.get('end_date')) self._start_date = self._json_response.get('start_date', kwargs.get('start_date')) self.total_pages = self._json_response.get('total_pages', kwargs.get('total_pages')) self.total_items = self._json_response.get('total_items', kwargs.get('total_items')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ] self._last_refreshed_datetime = self._json_response.get( 'last_refreshed_datetime', kwargs.get('last_refreshed_datetime'))
def __init__(self, name: str, product_type: ProductType, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.name = name self.product_type = product_type self.id = self._json_response.get('id', kwargs.get('id')) self.category = self._json_response.get('category', kwargs.get('category')) self.home_url = self._json_response.get('home_url', kwargs.get('home_url')) self.image_url = self._json_response.get('image_url', kwargs.get('image_url')) self.description = self._json_response.get('description', kwargs.get('description')) self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__( self, subscription_id: str = None, status: str = None, plan_id: str = None, status_change_note: str = None, quantity: str = None, subscriber: Subscriber = None, billing_info: BillingInfo = None, shipping_amount: Money = None, application_context: SubscriptionApplicationContext = None, **kwargs ): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.id = subscription_id self.status = status self.plan_id = plan_id self.quantity = quantity self.subscriber = subscriber self.billing_info = billing_info self.shipping_amount = shipping_amount self.status_change_note = status_change_note self.application_context = kwargs.get('application_context') self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self._start_time = self._json_response.get('_start_time', kwargs.get('_start_time')) self._status_update_time = self._json_response.get('_status_update_time', kwargs.get('_status_update_time')) self.links = [ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', [])]
def __init__(self, auth_id: str, status: str, amount: Money, status_details: AuthStatusDetail, invoice_id: str, custom_id: str, seller_protection: SellerProtection, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.id = auth_id self.status = status self.amount = amount self.status_details = status_details self.invoice_id = invoice_id self.custom_id = custom_id self.seller_protection = seller_protection self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._expiration_time = self._json_response.get( 'expiration_time', kwargs.get('expiration_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, event_id: str = None, resource_type: str = None, event_version: str = None, event_type: str = None, summary: str = None, resource_version: str = None, resource: Resource = None, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.summary = summary self.event_id = event_id self.resource = resource self.event_type = event_type self.resource_type = resource_type self.event_version = event_version self.resource_version = resource_version self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, dispute_id: str = None, reason: str = None, status: str = None, amount: Money = None, offer: Money = None, dispute_outcome: DisputeOutcome = None, messages: List[PaypalMessage] = [], disputed_transactions: List[DisputeTransaction] = [], dispute_channel: str = None, dispute_state: str = None, dispute_life_cycle_stage: str = None, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.offer = offer self.reason = reason self.status = status self.dispute_id = dispute_id self.dispute_amount = amount self.messages = messages or [] self.dispute_state = dispute_state self.dispute_channel = dispute_channel self.dispute_outcome = dispute_outcome self.disputed_transactions = disputed_transactions or [] self.dispute_life_cycle_stage = dispute_life_cycle_stage self.extensions = self._json_response.get('extensions', kwargs.get('extensions')) self._update_time = self._json_response.get('update_time', kwargs.get('update_time')) self._create_time = self._json_response.get('create_time', kwargs.get('create_time')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]
def __init__(self, **kwargs): super().__init__(kwargs.get('json_response', dict()), kwargs.get('response_type', ResponseType.MINIMAL)) self.id: str = kwargs.get('id', None) self.gratuity: Money = kwargs.get('gratuity', None) self.due_amount: Money = kwargs.get('due_amount', None) self.detail: InvoiceDetail = kwargs.get('detail', None) self.invoicer: InvoicerInfo = kwargs.get('invoicer', None) self.amount: AmountSummaryDetail = kwargs.get('amount', None) self.configuration: InvoiceConfiguration = kwargs.get( 'configuration', None) self.items: List[Item] = kwargs.get('items', []) self.refunds: List[Refund] = kwargs.get('refunds', []) self.templates: List[Template] = kwargs.get('templates', []) self.payments: List[InvoicePayment] = kwargs.get('payments', []) self.primary_recipients: List[RecipientInfo] = kwargs.get( 'primary_recipients', []) self.status = self._json_response.get('status', kwargs.get('status')) self.additional_recipients = self._json_response.get( 'additional_recipients', kwargs.get('additional_recipients')) self.links = [ ActionLink(x['href'], x['rel'], x.get('method', 'GET')) for x in self._json_response.get('links', []) ]