From 2deb62416ba143223f977b1a7a91cf4b9ce86fad Mon Sep 17 00:00:00 2001 From: sophieleewu Date: Thu, 3 Sep 2026 15:46:45 +0000 Subject: [PATCH] Update Python SDK queries --- fragment/sdk/__init__.py | 16 ++- fragment/sdk/client.py | 48 ++++++++ fragment/sdk/create_payment.py | 40 ++++++ fragment/sdk/enums.py | 10 +- fragment/sdk/input_types.py | 17 ++- fragment/std_queries/queries.graphql | 34 ++++++ fragment/sync_sdk/__init__.py | 16 ++- fragment/sync_sdk/client.py | 48 ++++++++ fragment/sync_sdk/create_payment.py | 40 ++++++ fragment/sync_sdk/enums.py | 10 +- fragment/sync_sdk/input_types.py | 17 ++- .../001-marketing-schema/sdk/__init__.py | 16 ++- .../001-marketing-schema/sdk/client.py | 48 ++++++++ .../sdk/create_payment.py | 40 ++++++ .../001-marketing-schema/sdk/enums.py | 10 +- .../001-marketing-schema/sdk/input_types.py | 17 ++- tests/snapshots/schema.graphql | 115 ++++++++++++++++-- 17 files changed, 500 insertions(+), 42 deletions(-) create mode 100644 fragment/sdk/create_payment.py create mode 100644 fragment/sync_sdk/create_payment.py create mode 100644 tests/snapshots/001-marketing-schema/sdk/create_payment.py diff --git a/fragment/sdk/__init__.py b/fragment/sdk/__init__.py index bafdb82..e314561 100644 --- a/fragment/sdk/__init__.py +++ b/fragment/sdk/__init__.py @@ -55,6 +55,12 @@ CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema, CreateLedgerCreateLedgerInternalError, ) +from .create_payment import ( + CreatePayment, + CreatePaymentCreatePaymentBadRequestError, + CreatePaymentCreatePaymentInternalError, + CreatePaymentCreatePaymentPayment, +) from .delete_custom_txs import ( DeleteCustomTxs, DeleteCustomTxsDeleteCustomTxsBadRequestError, @@ -97,8 +103,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, StripeEnv, TxType, @@ -184,6 +190,7 @@ CreateLedgerAccountInput, CreateLedgerAccountsInput, CreateLedgerInput, + CreatePaymentInput, CurrencyFilter, CurrencyMatchInput, CustomAccountInput, @@ -462,6 +469,11 @@ "CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema", "CreateLedgerCreateLedgerInternalError", "CreateLedgerInput", + "CreatePayment", + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + "CreatePaymentInput", "CurrencyCode", "CurrencyFilter", "CurrencyMatchInput", @@ -707,12 +719,12 @@ "SchemaMatchInput", "SchemaPaymentAccountingInput", "SchemaPaymentEntryInput", - "SchemaPaymentEntryStatus", "SchemaPaymentInput", "SchemaPaymentLineInput", "SchemaPaymentTypeDetailsInput", "SchemaPaymentTypeDirection", "SchemaPaymentTypeInput", + "SchemaPaymentTypeStatus", "SchemaPaymentsInput", "SchemaRepeatedConfigInput", "SchemaSystemLineKind", diff --git a/fragment/sdk/client.py b/fragment/sdk/client.py index 1e5f7e7..147b1cf 100644 --- a/fragment/sdk/client.py +++ b/fragment/sdk/client.py @@ -10,6 +10,7 @@ from .create_custom_currency import CreateCustomCurrency from .create_custom_link import CreateCustomLink from .create_ledger import CreateLedger +from .create_payment import CreatePayment from .delete_custom_txs import DeleteCustomTxs from .delete_ledger import DeleteLedger from .delete_schema import DeleteSchema @@ -1786,3 +1787,50 @@ async def create_custom_currency( ) data = self.get_data(response) return CreateCustomCurrency.model_validate(data) + + async def create_payment( + self, + ik: Any, + ledger_ik: Any, + type_: Any, + type_version: Optional[int] = None, + parameters: Optional[Any] = None, + **kwargs: Any + ) -> CreatePayment: + query = gql(""" + mutation createPayment($ik: SafeString!, $ledgerIk: SafeString!, $type: SafeString!, $typeVersion: Int, $parameters: JSON) { + createPayment( + ik: $ik + ledger: {ik: $ledgerIk} + payment: {type: $type, typeVersion: $typeVersion, parameters: $parameters} + ) { + __typename + ... on Payment { + clientSecret + status + } + ... on BadRequestError { + code + message + retryable + } + ... on InternalError { + code + message + retryable + } + } + } + """) + variables: dict[str, object] = { + "ik": ik, + "ledgerIk": ledger_ik, + "type": type_, + "typeVersion": type_version, + "parameters": parameters, + } + response = await self.execute( + query=query, operation_name="createPayment", variables=variables, **kwargs + ) + data = self.get_data(response) + return CreatePayment.model_validate(data) diff --git a/fragment/sdk/create_payment.py b/fragment/sdk/create_payment.py new file mode 100644 index 0000000..67c0768 --- /dev/null +++ b/fragment/sdk/create_payment.py @@ -0,0 +1,40 @@ +# Generated by fragment (with the help of ariadne-codegen) +# Source: queries/ + +from typing import Literal, Union + +from pydantic import Field + +from .base_model import BaseModel +from .enums import PaymentStatus + + +class CreatePayment(BaseModel): + create_payment: Union[ + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + ] = Field(alias="createPayment", discriminator="typename__") + + +class CreatePaymentCreatePaymentBadRequestError(BaseModel): + typename__: Literal["BadRequestError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentInternalError(BaseModel): + typename__: Literal["InternalError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentPayment(BaseModel): + typename__: Literal["Payment"] = Field(alias="__typename") + client_secret: str = Field(alias="clientSecret") + status: PaymentStatus + + +CreatePayment.model_rebuild() diff --git a/fragment/sdk/enums.py b/fragment/sdk/enums.py index 26a6de2..9d36634 100644 --- a/fragment/sdk/enums.py +++ b/fragment/sdk/enums.py @@ -261,8 +261,8 @@ class LinkType(str, Enum): class PaymentStatus(str, Enum): + needs_payment_method = "needs_payment_method" processing = "processing" - requires_confirmation = "requires_confirmation" settled = "settled" @@ -299,15 +299,15 @@ class SchemaLedgerEntryStatus(str, Enum): disabled = "disabled" -class SchemaPaymentEntryStatus(str, Enum): - active = "active" - - class SchemaPaymentTypeDirection(str, Enum): payin = "payin" payout = "payout" +class SchemaPaymentTypeStatus(str, Enum): + active = "active" + + class SchemaSystemLineKind(str, Enum): payment_fee_line = "payment_fee_line" payment_settlement_line = "payment_settlement_line" diff --git a/fragment/sdk/input_types.py b/fragment/sdk/input_types.py index 62531a3..f5d93f7 100644 --- a/fragment/sdk/input_types.py +++ b/fragment/sdk/input_types.py @@ -21,8 +21,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, TxType, ) @@ -120,6 +120,17 @@ class CreateLedgerInput(BaseModel): type_: Optional[LedgerTypes] = Field(alias="type", default=None) +class CreatePaymentInput(BaseModel): + """EXPERIMENTAL: The Payment to create.""" + + parameters: Optional[Any] = None + "Parameters for the specific Payment Type. Must be a key-value pair of strings. Must be a flat object: nested objects and arrays are rejected." + type_: Any = Field(alias="type") + "The type of the Payment. Must be defined in the Schema linked to the Ledger." + type_version: Optional[int] = Field(alias="typeVersion", default=None) + "The version of the Payment Type. Defaults to the latest active version." + + class CurrencyFilter(BaseModel): equal_to: Optional["CurrencyMatchInput"] = Field(alias="equalTo", default=None) "Must match the value provided" @@ -895,7 +906,7 @@ class SchemaPaymentAccountingInput(BaseModel): """EXPERIMENTAL: The Ledger Entries a Payment Type posts as a payment moves through its lifecycle, keyed by lifecycle transition.""" - needs_confirmation_to_processing: Optional["SchemaPaymentEntryInput"] = None + needs_payment_method_to_processing: Optional["SchemaPaymentEntryInput"] = None "Posted when the payment enters processing. Optional." processing_to_settled: "SchemaPaymentEntryInput" "Posted when the payment settles. Every Payment Type must define it." @@ -950,7 +961,7 @@ class SchemaPaymentTypeInput(BaseModel): "The Ledger Entries posted as the payment moves through its lifecycle." payment: "SchemaPaymentTypeDetailsInput" "The payment this Payment Type creates." - status: SchemaPaymentEntryStatus + status: SchemaPaymentTypeStatus "The status of this Payment Type." type_: Any = Field(alias="type") "The type of this Payment Type. This is a stable, unique identifier for it.\nUniqueness is enforced at the Schema level." diff --git a/fragment/std_queries/queries.graphql b/fragment/std_queries/queries.graphql index 2ac3e79..33460e2 100644 --- a/fragment/std_queries/queries.graphql +++ b/fragment/std_queries/queries.graphql @@ -1241,3 +1241,37 @@ mutation createCustomCurrency( } } } + +mutation createPayment( + $ik: SafeString! + $ledgerIk: SafeString! + $type: SafeString! + $typeVersion: Int + $parameters: JSON +) { + createPayment( + ik: $ik + ledger: { ik: $ledgerIk } + payment: { + type: $type + typeVersion: $typeVersion + parameters: $parameters + } + ) { + __typename + ... on Payment { + clientSecret + status + } + ... on BadRequestError { + code + message + retryable + } + ... on InternalError { + code + message + retryable + } + } +} diff --git a/fragment/sync_sdk/__init__.py b/fragment/sync_sdk/__init__.py index 1c70f15..7334077 100644 --- a/fragment/sync_sdk/__init__.py +++ b/fragment/sync_sdk/__init__.py @@ -54,6 +54,12 @@ CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema, CreateLedgerCreateLedgerInternalError, ) +from .create_payment import ( + CreatePayment, + CreatePaymentCreatePaymentBadRequestError, + CreatePaymentCreatePaymentInternalError, + CreatePaymentCreatePaymentPayment, +) from .delete_custom_txs import ( DeleteCustomTxs, DeleteCustomTxsDeleteCustomTxsBadRequestError, @@ -96,8 +102,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, StripeEnv, TxType, @@ -183,6 +189,7 @@ CreateLedgerAccountInput, CreateLedgerAccountsInput, CreateLedgerInput, + CreatePaymentInput, CurrencyFilter, CurrencyMatchInput, CustomAccountInput, @@ -461,6 +468,11 @@ "CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema", "CreateLedgerCreateLedgerInternalError", "CreateLedgerInput", + "CreatePayment", + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + "CreatePaymentInput", "CurrencyCode", "CurrencyFilter", "CurrencyMatchInput", @@ -706,12 +718,12 @@ "SchemaMatchInput", "SchemaPaymentAccountingInput", "SchemaPaymentEntryInput", - "SchemaPaymentEntryStatus", "SchemaPaymentInput", "SchemaPaymentLineInput", "SchemaPaymentTypeDetailsInput", "SchemaPaymentTypeDirection", "SchemaPaymentTypeInput", + "SchemaPaymentTypeStatus", "SchemaPaymentsInput", "SchemaRepeatedConfigInput", "SchemaSystemLineKind", diff --git a/fragment/sync_sdk/client.py b/fragment/sync_sdk/client.py index 0013c85..0b55c8b 100644 --- a/fragment/sync_sdk/client.py +++ b/fragment/sync_sdk/client.py @@ -9,6 +9,7 @@ from .create_custom_currency import CreateCustomCurrency from .create_custom_link import CreateCustomLink from .create_ledger import CreateLedger +from .create_payment import CreatePayment from .delete_custom_txs import DeleteCustomTxs from .delete_ledger import DeleteLedger from .delete_schema import DeleteSchema @@ -1780,3 +1781,50 @@ def create_custom_currency( ) data = self.get_data(response) return CreateCustomCurrency.model_validate(data) + + def create_payment( + self, + ik: Any, + ledger_ik: Any, + type_: Any, + type_version: Optional[int] = None, + parameters: Optional[Any] = None, + **kwargs: Any + ) -> CreatePayment: + query = gql(""" + mutation createPayment($ik: SafeString!, $ledgerIk: SafeString!, $type: SafeString!, $typeVersion: Int, $parameters: JSON) { + createPayment( + ik: $ik + ledger: {ik: $ledgerIk} + payment: {type: $type, typeVersion: $typeVersion, parameters: $parameters} + ) { + __typename + ... on Payment { + clientSecret + status + } + ... on BadRequestError { + code + message + retryable + } + ... on InternalError { + code + message + retryable + } + } + } + """) + variables: dict[str, object] = { + "ik": ik, + "ledgerIk": ledger_ik, + "type": type_, + "typeVersion": type_version, + "parameters": parameters, + } + response = self.execute( + query=query, operation_name="createPayment", variables=variables, **kwargs + ) + data = self.get_data(response) + return CreatePayment.model_validate(data) diff --git a/fragment/sync_sdk/create_payment.py b/fragment/sync_sdk/create_payment.py new file mode 100644 index 0000000..67c0768 --- /dev/null +++ b/fragment/sync_sdk/create_payment.py @@ -0,0 +1,40 @@ +# Generated by fragment (with the help of ariadne-codegen) +# Source: queries/ + +from typing import Literal, Union + +from pydantic import Field + +from .base_model import BaseModel +from .enums import PaymentStatus + + +class CreatePayment(BaseModel): + create_payment: Union[ + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + ] = Field(alias="createPayment", discriminator="typename__") + + +class CreatePaymentCreatePaymentBadRequestError(BaseModel): + typename__: Literal["BadRequestError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentInternalError(BaseModel): + typename__: Literal["InternalError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentPayment(BaseModel): + typename__: Literal["Payment"] = Field(alias="__typename") + client_secret: str = Field(alias="clientSecret") + status: PaymentStatus + + +CreatePayment.model_rebuild() diff --git a/fragment/sync_sdk/enums.py b/fragment/sync_sdk/enums.py index 26a6de2..9d36634 100644 --- a/fragment/sync_sdk/enums.py +++ b/fragment/sync_sdk/enums.py @@ -261,8 +261,8 @@ class LinkType(str, Enum): class PaymentStatus(str, Enum): + needs_payment_method = "needs_payment_method" processing = "processing" - requires_confirmation = "requires_confirmation" settled = "settled" @@ -299,15 +299,15 @@ class SchemaLedgerEntryStatus(str, Enum): disabled = "disabled" -class SchemaPaymentEntryStatus(str, Enum): - active = "active" - - class SchemaPaymentTypeDirection(str, Enum): payin = "payin" payout = "payout" +class SchemaPaymentTypeStatus(str, Enum): + active = "active" + + class SchemaSystemLineKind(str, Enum): payment_fee_line = "payment_fee_line" payment_settlement_line = "payment_settlement_line" diff --git a/fragment/sync_sdk/input_types.py b/fragment/sync_sdk/input_types.py index 62531a3..f5d93f7 100644 --- a/fragment/sync_sdk/input_types.py +++ b/fragment/sync_sdk/input_types.py @@ -21,8 +21,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, TxType, ) @@ -120,6 +120,17 @@ class CreateLedgerInput(BaseModel): type_: Optional[LedgerTypes] = Field(alias="type", default=None) +class CreatePaymentInput(BaseModel): + """EXPERIMENTAL: The Payment to create.""" + + parameters: Optional[Any] = None + "Parameters for the specific Payment Type. Must be a key-value pair of strings. Must be a flat object: nested objects and arrays are rejected." + type_: Any = Field(alias="type") + "The type of the Payment. Must be defined in the Schema linked to the Ledger." + type_version: Optional[int] = Field(alias="typeVersion", default=None) + "The version of the Payment Type. Defaults to the latest active version." + + class CurrencyFilter(BaseModel): equal_to: Optional["CurrencyMatchInput"] = Field(alias="equalTo", default=None) "Must match the value provided" @@ -895,7 +906,7 @@ class SchemaPaymentAccountingInput(BaseModel): """EXPERIMENTAL: The Ledger Entries a Payment Type posts as a payment moves through its lifecycle, keyed by lifecycle transition.""" - needs_confirmation_to_processing: Optional["SchemaPaymentEntryInput"] = None + needs_payment_method_to_processing: Optional["SchemaPaymentEntryInput"] = None "Posted when the payment enters processing. Optional." processing_to_settled: "SchemaPaymentEntryInput" "Posted when the payment settles. Every Payment Type must define it." @@ -950,7 +961,7 @@ class SchemaPaymentTypeInput(BaseModel): "The Ledger Entries posted as the payment moves through its lifecycle." payment: "SchemaPaymentTypeDetailsInput" "The payment this Payment Type creates." - status: SchemaPaymentEntryStatus + status: SchemaPaymentTypeStatus "The status of this Payment Type." type_: Any = Field(alias="type") "The type of this Payment Type. This is a stable, unique identifier for it.\nUniqueness is enforced at the Schema level." diff --git a/tests/snapshots/001-marketing-schema/sdk/__init__.py b/tests/snapshots/001-marketing-schema/sdk/__init__.py index ab75f6f..40b34e9 100644 --- a/tests/snapshots/001-marketing-schema/sdk/__init__.py +++ b/tests/snapshots/001-marketing-schema/sdk/__init__.py @@ -55,6 +55,12 @@ CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema, CreateLedgerCreateLedgerInternalError, ) +from .create_payment import ( + CreatePayment, + CreatePaymentCreatePaymentBadRequestError, + CreatePaymentCreatePaymentInternalError, + CreatePaymentCreatePaymentPayment, +) from .delete_custom_txs import ( DeleteCustomTxs, DeleteCustomTxsDeleteCustomTxsBadRequestError, @@ -97,8 +103,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, StripeEnv, TxType, @@ -184,6 +190,7 @@ CreateLedgerAccountInput, CreateLedgerAccountsInput, CreateLedgerInput, + CreatePaymentInput, CurrencyFilter, CurrencyMatchInput, CustomAccountInput, @@ -579,6 +586,11 @@ "CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema", "CreateLedgerCreateLedgerInternalError", "CreateLedgerInput", + "CreatePayment", + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + "CreatePaymentInput", "CurrencyCode", "CurrencyFilter", "CurrencyMatchInput", @@ -923,12 +935,12 @@ "SchemaMatchInput", "SchemaPaymentAccountingInput", "SchemaPaymentEntryInput", - "SchemaPaymentEntryStatus", "SchemaPaymentInput", "SchemaPaymentLineInput", "SchemaPaymentTypeDetailsInput", "SchemaPaymentTypeDirection", "SchemaPaymentTypeInput", + "SchemaPaymentTypeStatus", "SchemaPaymentsInput", "SchemaRepeatedConfigInput", "SchemaSystemLineKind", diff --git a/tests/snapshots/001-marketing-schema/sdk/client.py b/tests/snapshots/001-marketing-schema/sdk/client.py index 72e01cd..27053fe 100644 --- a/tests/snapshots/001-marketing-schema/sdk/client.py +++ b/tests/snapshots/001-marketing-schema/sdk/client.py @@ -10,6 +10,7 @@ from .create_custom_currency import CreateCustomCurrency from .create_custom_link import CreateCustomLink from .create_ledger import CreateLedger +from .create_payment import CreatePayment from .delete_custom_txs import DeleteCustomTxs from .delete_ledger import DeleteLedger from .delete_schema import DeleteSchema @@ -2555,3 +2556,50 @@ async def create_custom_currency( ) data = self.get_data(response) return CreateCustomCurrency.model_validate(data) + + async def create_payment( + self, + ik: Any, + ledger_ik: Any, + type_: Any, + type_version: Optional[int] = None, + parameters: Optional[Any] = None, + **kwargs: Any + ) -> CreatePayment: + query = gql(""" + mutation createPayment($ik: SafeString!, $ledgerIk: SafeString!, $type: SafeString!, $typeVersion: Int, $parameters: JSON) { + createPayment( + ik: $ik + ledger: {ik: $ledgerIk} + payment: {type: $type, typeVersion: $typeVersion, parameters: $parameters} + ) { + __typename + ... on Payment { + clientSecret + status + } + ... on BadRequestError { + code + message + retryable + } + ... on InternalError { + code + message + retryable + } + } + } + """) + variables: dict[str, object] = { + "ik": ik, + "ledgerIk": ledger_ik, + "type": type_, + "typeVersion": type_version, + "parameters": parameters, + } + response = await self.execute( + query=query, operation_name="createPayment", variables=variables, **kwargs + ) + data = self.get_data(response) + return CreatePayment.model_validate(data) diff --git a/tests/snapshots/001-marketing-schema/sdk/create_payment.py b/tests/snapshots/001-marketing-schema/sdk/create_payment.py new file mode 100644 index 0000000..a83d27e --- /dev/null +++ b/tests/snapshots/001-marketing-schema/sdk/create_payment.py @@ -0,0 +1,40 @@ +# Generated by fragment (with the help of ariadne-codegen) +# Source: tests/snapshots/001-marketing-schema/ + +from typing import Literal, Union + +from pydantic import Field + +from .base_model import BaseModel +from .enums import PaymentStatus + + +class CreatePayment(BaseModel): + create_payment: Union[ + "CreatePaymentCreatePaymentBadRequestError", + "CreatePaymentCreatePaymentInternalError", + "CreatePaymentCreatePaymentPayment", + ] = Field(alias="createPayment", discriminator="typename__") + + +class CreatePaymentCreatePaymentBadRequestError(BaseModel): + typename__: Literal["BadRequestError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentInternalError(BaseModel): + typename__: Literal["InternalError"] = Field(alias="__typename") + code: str + message: str + retryable: bool + + +class CreatePaymentCreatePaymentPayment(BaseModel): + typename__: Literal["Payment"] = Field(alias="__typename") + client_secret: str = Field(alias="clientSecret") + status: PaymentStatus + + +CreatePayment.model_rebuild() diff --git a/tests/snapshots/001-marketing-schema/sdk/enums.py b/tests/snapshots/001-marketing-schema/sdk/enums.py index 26a6de2..9d36634 100644 --- a/tests/snapshots/001-marketing-schema/sdk/enums.py +++ b/tests/snapshots/001-marketing-schema/sdk/enums.py @@ -261,8 +261,8 @@ class LinkType(str, Enum): class PaymentStatus(str, Enum): + needs_payment_method = "needs_payment_method" processing = "processing" - requires_confirmation = "requires_confirmation" settled = "settled" @@ -299,15 +299,15 @@ class SchemaLedgerEntryStatus(str, Enum): disabled = "disabled" -class SchemaPaymentEntryStatus(str, Enum): - active = "active" - - class SchemaPaymentTypeDirection(str, Enum): payin = "payin" payout = "payout" +class SchemaPaymentTypeStatus(str, Enum): + active = "active" + + class SchemaSystemLineKind(str, Enum): payment_fee_line = "payment_fee_line" payment_settlement_line = "payment_settlement_line" diff --git a/tests/snapshots/001-marketing-schema/sdk/input_types.py b/tests/snapshots/001-marketing-schema/sdk/input_types.py index 62531a3..f5d93f7 100644 --- a/tests/snapshots/001-marketing-schema/sdk/input_types.py +++ b/tests/snapshots/001-marketing-schema/sdk/input_types.py @@ -21,8 +21,8 @@ SchemaConsistencyMode, SchemaLedgerAccountStatus, SchemaLedgerEntryStatus, - SchemaPaymentEntryStatus, SchemaPaymentTypeDirection, + SchemaPaymentTypeStatus, SchemaSystemLineKind, TxType, ) @@ -120,6 +120,17 @@ class CreateLedgerInput(BaseModel): type_: Optional[LedgerTypes] = Field(alias="type", default=None) +class CreatePaymentInput(BaseModel): + """EXPERIMENTAL: The Payment to create.""" + + parameters: Optional[Any] = None + "Parameters for the specific Payment Type. Must be a key-value pair of strings. Must be a flat object: nested objects and arrays are rejected." + type_: Any = Field(alias="type") + "The type of the Payment. Must be defined in the Schema linked to the Ledger." + type_version: Optional[int] = Field(alias="typeVersion", default=None) + "The version of the Payment Type. Defaults to the latest active version." + + class CurrencyFilter(BaseModel): equal_to: Optional["CurrencyMatchInput"] = Field(alias="equalTo", default=None) "Must match the value provided" @@ -895,7 +906,7 @@ class SchemaPaymentAccountingInput(BaseModel): """EXPERIMENTAL: The Ledger Entries a Payment Type posts as a payment moves through its lifecycle, keyed by lifecycle transition.""" - needs_confirmation_to_processing: Optional["SchemaPaymentEntryInput"] = None + needs_payment_method_to_processing: Optional["SchemaPaymentEntryInput"] = None "Posted when the payment enters processing. Optional." processing_to_settled: "SchemaPaymentEntryInput" "Posted when the payment settles. Every Payment Type must define it." @@ -950,7 +961,7 @@ class SchemaPaymentTypeInput(BaseModel): "The Ledger Entries posted as the payment moves through its lifecycle." payment: "SchemaPaymentTypeDetailsInput" "The payment this Payment Type creates." - status: SchemaPaymentEntryStatus + status: SchemaPaymentTypeStatus "The status of this Payment Type." type_: Any = Field(alias="type") "The type of this Payment Type. This is a stable, unique identifier for it.\nUniqueness is enforced at the Schema level." diff --git a/tests/snapshots/schema.graphql b/tests/snapshots/schema.graphql index 17d23b5..5b79c58 100644 --- a/tests/snapshots/schema.graphql +++ b/tests/snapshots/schema.graphql @@ -319,6 +319,24 @@ type CreateLedgerResult { ledger: Ledger! } +"""EXPERIMENTAL: The Payment to create.""" +input CreatePaymentInput { + """ + Parameters for the specific Payment Type. Must be a key-value pair of strings. Must be a flat object: nested objects and arrays are rejected. + """ + parameters: JSON + + """ + The type of the Payment. Must be defined in the Schema linked to the Ledger. + """ + type: SafeString! + + """ + The version of the Payment Type. Defaults to the latest active version. + """ + typeVersion: Int +} + union CreatePaymentResponse = BadRequestError | InternalError | Payment type Currency { @@ -3204,6 +3222,44 @@ enum LedgerMigrationStatus { started } +"""EXPERIMENTAL: A Payment posted to a Ledger.""" +type LedgerPayment { + """The amount of this Payment, in whole cents.""" + amount: Int96! + created: DateTime! + + """ + The [Idempotency Key](https://fragment.dev/api-reference/api-overview#idempotency) the Payment was created with. + """ + ik: SafeString! + + """The Ledger this Payment belongs to.""" + ledgerId: SafeString! + + """ + Parameters the Payment was created with. Only returned by the `ledgerPayment` query. + """ + parameters: JSON + + """The status of this Payment.""" + status: PaymentStatus! + + """The Payment Type in the Schema this Payment was created from.""" + type: SafeString! + + """The version of the Payment Type.""" + typeVersion: Int! +} + +"""EXPERIMENTAL: A paginated list of Payments.""" +type LedgerPaymentsConnection { + """The current page of results.""" + nodes: [LedgerPayment!]! + + """The pagination info for this list.""" + pageInfo: PageInfo! +} + input LedgerTypeFilter { equalTo: LedgerTypes @@ -3404,9 +3460,6 @@ type Mutation { Create a Payment. """ createPayment( - """The amount in cents, between 100 and 10000000 inclusive.""" - amount: Int96! - """ The [Idempotency Key](https://fragment.dev/api-reference/api-overview#idempotency) """ @@ -3414,6 +3467,9 @@ type Mutation { """The Ledger this Payment belongs to.""" ledger: LedgerMatchInput! + + """The Payment to create.""" + payment: CreatePaymentInput! ): CreatePaymentResponse! """ @@ -3571,8 +3627,8 @@ EXPERIMENTAL — subject to change. Status of a Payment. """ enum PaymentStatus { + needs_payment_method processing - requires_confirmation settled } @@ -3689,6 +3745,41 @@ type Query { ledgerLine: LedgerLineMatchInput! ): LedgerLine + """EXPERIMENTAL: Get a single Payment by its Idempotency Key.""" + ledgerPayment( + """The Idempotency Key the Payment was created with.""" + ik: SafeString! + + """The Ledger the Payment belongs to.""" + ledger: LedgerMatchInput! + ): LedgerPayment + + """EXPERIMENTAL: List the Payments on a Ledger, most recent first.""" + ledgerPayments( + """ + Where to start paginating from, when paginating forwards. Send endCursor from a response to get its next page. + """ + after: String + + """ + Where to start paginating from, when paginating backwards. Send startCursor from a response to get the previous page. + """ + before: String + + """ + The number of Payments to return per page, when paginating forwards. Defaults to 20, maximum is 200. + """ + first: Int + + """ + The number of Payments to return per page, when paginating backwards. Defaults to 20, maximum is 200. + """ + last: Int + + """The Ledger to list Payments for.""" + ledger: LedgerMatchInput! + ): LedgerPaymentsConnection! + """ Query Ledgers in workspace. Ledgers are paginated and returned in reverse-chronological order by their created date. """ @@ -4322,7 +4413,7 @@ through its lifecycle, keyed by lifecycle transition. """ input SchemaPaymentAccountingInput { """Posted when the payment enters processing. Optional.""" - needs_confirmation_to_processing: SchemaPaymentEntryInput + needs_payment_method_to_processing: SchemaPaymentEntryInput """Posted when the payment settles. Every Payment Type must define it.""" processing_to_settled: SchemaPaymentEntryInput! @@ -4339,12 +4430,6 @@ input SchemaPaymentEntryInput { lines: [SchemaPaymentLineInput!]! } -"""The status of a Payment Type.""" -enum SchemaPaymentEntryStatus { - """The Payment Type is active.""" - active -} - """EXPERIMENTAL: Marks a Ledger Account as a Payment Account.""" input SchemaPaymentInput { penguin: Boolean! @@ -4415,7 +4500,7 @@ input SchemaPaymentTypeInput { payment: SchemaPaymentTypeDetailsInput! """The status of this Payment Type.""" - status: SchemaPaymentEntryStatus! + status: SchemaPaymentTypeStatus! """ The type of this Payment Type. This is a stable, unique identifier for it. @@ -4427,6 +4512,12 @@ input SchemaPaymentTypeInput { typeVersion: Int! } +"""The status of a Payment Type.""" +enum SchemaPaymentTypeStatus { + """The Payment Type is active.""" + active +} + """EXPERIMENTAL: The Payment Types in your Schema.""" input SchemaPaymentsInput { """A list of Payment Type definitions."""