diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 61f33771..1c1eb30c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.16" + ".": "0.0.17" } diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c47cd1..9ce2bd49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.0.17](https://github.com/sumup/sumup-py/compare/v0.0.16...v0.0.17) (2025-12-19) + + +### Features + +* **sdk:** improve enum types ([a2d5cf6](https://github.com/sumup/sumup-py/commit/a2d5cf63397decf6c7ad58c880b383b8f7b07591)) + + +### Bug Fixes + +* transactions entry_mode enum ([05b0f5a](https://github.com/sumup/sumup-py/commit/05b0f5a1fb7543e3cd9948f7d3c7b117e7ccbef5)) + ## [0.0.16](https://github.com/sumup/sumup-py/compare/v0.0.15...v0.0.16) (2025-12-18) diff --git a/codegen/Makefile b/codegen/Makefile index 1fc921df..81fe416b 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -6,11 +6,15 @@ help: ## Show help .PHONY: fmt fmt: ## Format go files - golangci-lint fmt -v + golangci-lint fmt --verbose .PHONY: lint lint: ## Lint go files - golangci-lint run -v + golangci-lint run --verbose + +.PHONY: lint-fix +lint-fix: ## Lint go files and apply auto-fixes + golangci-lint run --verbose --fix .PHONY: test test: ## Run tests diff --git a/codegen/pkg/builder/builder.go b/codegen/pkg/builder/builder.go index 22eb40d3..eee0b8cc 100644 --- a/codegen/pkg/builder/builder.go +++ b/codegen/pkg/builder/builder.go @@ -35,6 +35,10 @@ type Builder struct { templates *template.Template start time.Time + + // currentTag is used to track which tag we're currently generating + // to determine if we need to add _shared. prefix + currentTag string } // Config is builder configuration which configures output options. @@ -90,6 +94,13 @@ func (b *Builder) Build() error { return fmt.Errorf("missing specs: call Load to load the specs first") } + // Generate shared schemas first if they exist + if sharedSchemas, ok := b.schemasByTag["_shared"]; ok && len(sharedSchemas) > 0 { + if err := b.generateSharedResource(sharedSchemas); err != nil { + return fmt.Errorf("generate shared resource: %w", err) + } + } + for tagName, paths := range b.pathsByTag { if err := b.generateResource(tagName, paths); err != nil { return err diff --git a/codegen/pkg/builder/collect.go b/codegen/pkg/builder/collect.go index c346fb72..1acfd2d7 100644 --- a/codegen/pkg/builder/collect.go +++ b/codegen/pkg/builder/collect.go @@ -49,6 +49,8 @@ func (b *Builder) collectPaths() { func (b *Builder) collectSchemas() { // Map of schemas grouped by tag schemasByTag := make(map[string][]*base.SchemaProxy) + // Track which tags reference each schema + schemaRefs := make(map[string][]string) for path, pathItem := range b.spec.Paths.PathItems.FromOldest() { for method, op := range pathItem.GetOperations().FromOldest() { @@ -78,11 +80,92 @@ func (b *Builder) collectSchemas() { }) { schemasByTag[tagLower] = append(schemasByTag[tagLower], schema) } + if !slices.Contains(schemaRefs[schema.GetReference()], tagLower) { + schemaRefs[schema.GetReference()] = append(schemaRefs[schema.GetReference()], tagLower) + } + } + } + } + } + + // Identify schemas that are referenced by multiple tags and move them to shared + for schemaRef, tags := range schemaRefs { + if len(tags) > 1 { + // Remove from individual tags + for _, tag := range tags { + tagLower := strings.ToLower(tag) + idx := slices.IndexFunc(schemasByTag[tagLower], func(sp *base.SchemaProxy) bool { + return sp.GetReference() == schemaRef + }) + if idx != -1 { + schemasByTag[tagLower] = append(schemasByTag[tagLower][:idx], schemasByTag[tagLower][idx+1:]...) + } + } + // Add to shared + if schemasByTag["_shared"] == nil { + schemasByTag["_shared"] = make([]*base.SchemaProxy, 0) + } + // Find the schema proxy to add + for _, schemas := range schemasByTag { + for _, sp := range schemas { + if sp.GetReference() == schemaRef { + if !slices.ContainsFunc(schemasByTag["_shared"], func(existing *base.SchemaProxy) bool { + return existing.GetReference() == schemaRef + }) { + schemasByTag["_shared"] = append(schemasByTag["_shared"], sp) + } + break + } } } } } + // Need to find schemas that were removed from other tags but not added yet + for schemaRef, tags := range schemaRefs { + if len(tags) > 1 { + // Try to find this schema in any tag's collection from the original data + var foundSchema *base.SchemaProxy + for _, pathItem := range b.spec.Paths.PathItems.FromOldest() { + for _, op := range pathItem.GetOperations().FromOldest() { + c := make(SchemaProxyCollection, 0, 100) + c.collectSchemasInResponse(op) + c.collectSchemasInParams(op) + c.collectSchemasInRequest(op) + + for _, schema := range c { + if schema.GetReference() == schemaRef { + foundSchema = schema + break + } + } + if foundSchema != nil { + break + } + } + if foundSchema != nil { + break + } + } + + if foundSchema != nil && !slices.ContainsFunc(schemasByTag["_shared"], func(sp *base.SchemaProxy) bool { + return sp.GetReference() == schemaRef + }) { + if schemasByTag["_shared"] == nil { + schemasByTag["_shared"] = make([]*base.SchemaProxy, 0) + } + schemasByTag["_shared"] = append(schemasByTag["_shared"], foundSchema) + } + } + } + + // Sort shared schemas to ensure deterministic order + if sharedSchemas, ok := schemasByTag["_shared"]; ok { + slices.SortFunc(sharedSchemas, func(a, b *base.SchemaProxy) int { + return strings.Compare(a.GetReference(), b.GetReference()) + }) + } + b.schemasByTag = schemasByTag } diff --git a/codegen/pkg/builder/methods.go b/codegen/pkg/builder/methods.go index ef8f583e..0c8907eb 100644 --- a/codegen/pkg/builder/methods.go +++ b/codegen/pkg/builder/methods.go @@ -375,11 +375,17 @@ func (b *Builder) convertToValidPyType(property string, r *base.SchemaProxy) str func (b *Builder) getReferenceSchema(v *base.SchemaProxy) string { if v.GoLow().IsReference() { ref := strings.TrimPrefix(v.GetReference(), "#/components/schemas/") + typeName := strcase.ToCamel(ref) if len(v.Schema().Enum) > 0 { - return strcase.ToCamel(stringx.MakeSingular(ref)) + typeName = strcase.ToCamel(stringx.MakeSingular(ref)) } - return strcase.ToCamel(ref) + // Check if this is a shared schema and we're not generating the shared file itself + if b.currentTag != "_shared" && b.isSharedSchema(v) { + typeName = "_shared." + typeName + } + + return typeName } return "" diff --git a/codegen/pkg/builder/out.go b/codegen/pkg/builder/out.go index 03a646de..140291df 100644 --- a/codegen/pkg/builder/out.go +++ b/codegen/pkg/builder/out.go @@ -16,20 +16,26 @@ import ( ) type typesTemplateData struct { - PackageName string - Types []Writable - UsesSecret bool + PackageName string + Types []Writable + UsesSecret bool + UsesShared bool + SharedImport string } func (b *Builder) generateResourceTypes(tag *base.Tag, schemas []*base.SchemaProxy) error { + b.currentTag = strings.ToLower(tag.Name) types := b.schemasToTypes(schemas) usesSecret := usesSecretType(types) + usesShared, sharedImport := b.usesSharedTypes(types, nil) typesBuf := bytes.NewBuffer(nil) if err := b.templates.ExecuteTemplate(typesBuf, "types.py.tmpl", typesTemplateData{ - PackageName: strcase.ToSnake(tag.Name), - Types: types, - UsesSecret: usesSecret, + PackageName: strcase.ToSnake(tag.Name), + Types: types, + UsesSecret: usesSecret, + UsesShared: usesShared, + SharedImport: sharedImport, }); err != nil { return err } @@ -96,16 +102,19 @@ func (b *Builder) generateResourceIndex(tagName string, resourceTypes []string) } type resourceTemplateData struct { - PackageName string - TypeNames []string - Params []Writable - Service string - Methods []*Method - UsesSecret bool + PackageName string + TypeNames []string + Params []Writable + Service string + Methods []*Method + UsesSecret bool + UsesShared bool + SharedImport string } func (b *Builder) generateResourceFile(tagName string, paths *v3.Paths) ([]string, error) { tag := b.tagByTagName(tagName) + b.currentTag = strings.ToLower(tag.Name) resolvedSchemas := b.schemasByTag[tagName] if err := b.generateResourceTypes(tag, b.schemasByTag[tagName]); err != nil { @@ -143,15 +152,18 @@ func (b *Builder) generateResourceFile(tagName string, paths *v3.Paths) ([]strin ) usesSecret := usesSecretType(innerTypes) + usesShared, sharedImport := b.usesSharedTypes(innerTypes, methods) serviceBuf := bytes.NewBuffer(nil) if err := b.templates.ExecuteTemplate(serviceBuf, "resource.py.tmpl", resourceTemplateData{ - PackageName: strcase.ToSnake(tag.Name), - TypeNames: typeNames, - Params: innerTypes, - Service: strcase.ToCamel(tag.Name), - Methods: methods, - UsesSecret: usesSecret, + PackageName: strcase.ToSnake(tag.Name), + TypeNames: typeNames, + Params: innerTypes, + Service: strcase.ToCamel(tag.Name), + Methods: methods, + UsesSecret: usesSecret, + UsesShared: usesShared, + SharedImport: sharedImport, }); err != nil { return nil, err } @@ -180,6 +192,40 @@ func (b *Builder) generateResourceFile(tagName string, paths *v3.Paths) ([]strin return resourceTypes, nil } +func (b *Builder) generateSharedResource(schemas []*base.SchemaProxy) error { + b.currentTag = "_shared" + types := b.schemasToTypes(schemas) + usesSecret := usesSecretType(types) + + slog.Info("generating shared schemas", + slog.Int("schema_count", len(schemas)), + ) + + typesBuf := bytes.NewBuffer(nil) + if err := b.templates.ExecuteTemplate(typesBuf, "types.py.tmpl", typesTemplateData{ + PackageName: "_shared", + Types: types, + UsesSecret: usesSecret, + }); err != nil { + return err + } + + sharedFileName := path.Join(b.cfg.Out, "_shared.py") + sharedFile, err := openGeneratedFile(sharedFileName) + if err != nil { + return err + } + defer func() { + _ = sharedFile.Close() + }() + + if _, err := sharedFile.Write(typesBuf.Bytes()); err != nil { + return err + } + + return nil +} + func (b *Builder) generateResource(tagName string, paths *v3.Paths) error { if tagName == "" { return fmt.Errorf("empty tag name") @@ -209,24 +255,60 @@ func (b *Builder) generateResource(tagName string, paths *v3.Paths) error { } func usesSecretType(writables []Writable) bool { - for _, w := range writables { - if writableUsesSecret(w) { + return slices.ContainsFunc(writables, writableUsesSecret) +} + +func writableUsesSecret(w Writable) bool { + switch typed := w.(type) { + case *ClassDeclaration: + for _, f := range typed.Fields { + if strings.Contains(f.Type, "Secret") { + return true + } + } + case *TypeAlias: + if strings.Contains(typed.Type, "Secret") { return true } } return false } -func writableUsesSecret(w Writable) bool { +// usesSharedTypes checks if any types or methods reference shared schemas +// Returns whether shared is used and the import statement if needed +func (b *Builder) usesSharedTypes(writables []Writable, methods []*Method) (bool, string) { + // Check if we have any shared schemas at all + if _, ok := b.schemasByTag["_shared"]; !ok { + return false, "" + } + + // Check writables for _shared references + if slices.ContainsFunc(writables, containsSharedRef) { + return true, "from .. import _shared" + } + + // Check methods for _shared references (only if methods are provided) + for _, m := range methods { + for _, r := range m.Responses { + if r.Type != "" && strings.Contains(r.Type, "_shared.") { + return true, "from .. import _shared" + } + } + } + + return false, "" +} + +func containsSharedRef(w Writable) bool { switch typed := w.(type) { case *ClassDeclaration: for _, f := range typed.Fields { - if strings.Contains(f.Type, "Secret") { + if strings.Contains(f.Type, "_shared.") { return true } } case *TypeAlias: - if strings.Contains(typed.Type, "Secret") { + if strings.Contains(typed.Type, "_shared.") { return true } } diff --git a/codegen/pkg/builder/transform.go b/codegen/pkg/builder/transform.go index 0e0c8404..78f49ee8 100644 --- a/codegen/pkg/builder/transform.go +++ b/codegen/pkg/builder/transform.go @@ -261,11 +261,21 @@ func (b *Builder) generateSchemaComponents(name string, spec *base.Schema) []Wri func (b *Builder) genSchema(sp *base.SchemaProxy, name string) (string, []Writable) { if sp.GetReference() != "" { ref := strings.TrimPrefix(sp.GetReference(), "#/components/schemas/") + typeName := strcase.ToCamel(ref) if len(sp.Schema().Enum) > 0 { - return strcase.ToCamel(stringx.MakeSingular(ref)), nil + typeName = strcase.ToCamel(stringx.MakeSingular(ref)) } - return strcase.ToCamel(ref), nil + // Check if this is a shared schema and we're not generating the shared file itself + if b.currentTag != "_shared" && b.isSharedSchema(sp) { + typeName = "_shared." + typeName + } else if b.currentTag == "_shared" && b.isSharedSchema(sp) { + // When generating _shared.py, use string forward reference for shared schemas + // to avoid ordering issues + typeName = "\"" + typeName + "\"" + } + + return typeName, nil } types := make([]Writable, 0) @@ -319,6 +329,18 @@ func (b *Builder) genSchema(sp *base.SchemaProxy, name string) (string, []Writab } } +// isSharedSchema checks if a schema is in the shared schemas collection +func (b *Builder) isSharedSchema(sp *base.SchemaProxy) bool { + if sharedSchemas, ok := b.schemasByTag["_shared"]; ok { + for _, shared := range sharedSchemas { + if shared.GetReference() == sp.GetReference() { + return true + } + } + } + return false +} + // createObject converts openapi schema into golang object. func (b *Builder) createObject(schema *base.Schema, name string) (Writable, []Writable) { if (schema.Properties == nil || schema.Properties.Len() == 0) && diff --git a/codegen/templates/resource.py.tmpl b/codegen/templates/resource.py.tmpl index f0e2e928..e3f44d6b 100644 --- a/codegen/templates/resource.py.tmpl +++ b/codegen/templates/resource.py.tmpl @@ -4,6 +4,9 @@ from .._exceptions import APIError {{- if .UsesSecret }} from .._secret import Secret {{- end }} +{{- if .UsesShared }} +{{ .SharedImport }} +{{- end }} {{- with .TypeNames }} from .types import {{ join ", " . }} {{- end }} diff --git a/codegen/templates/types.py.tmpl b/codegen/templates/types.py.tmpl index a52f0a91..a0fffad2 100644 --- a/codegen/templates/types.py.tmpl +++ b/codegen/templates/types.py.tmpl @@ -1,5 +1,10 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +{{- if ne .PackageName "_shared" }} from ._service import Service +{{- end }} +{{- if .UsesShared }} +{{ .SharedImport }} +{{- end }} import datetime import typing import pydantic diff --git a/openapi.json b/openapi.json index cad45cbd..e9d03f56 100755 --- a/openapi.json +++ b/openapi.json @@ -10041,6 +10041,7 @@ "type": "object", "properties": { "data": { + "type": "object", "properties": { "battery_level": { "description": "Battery level percentage", diff --git a/openapi.yaml b/openapi.yaml index feb217dc..d11c50c3 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7076,6 +7076,7 @@ components: type: object properties: data: + type: object properties: battery_level: description: Battery level percentage diff --git a/pyproject.toml b/pyproject.toml index 1a4741e7..9332a877 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "sumup" description = "Official Python SDK for the SumUp API." -version = "0.0.16" +version = "0.0.17" readme = "README.md" requires-python = ">=3.9" keywords = ["sdk", "sumup", "payments"] diff --git a/sumup/_shared.py b/sumup/_shared.py new file mode 100755 index 00000000..7c50e806 --- /dev/null +++ b/sumup/_shared.py @@ -0,0 +1,399 @@ +# Code generated by `py-sdk-gen`. DO NOT EDIT. +import datetime +import typing +import pydantic + + +class AddressLegacy(pydantic.BaseModel): + """ + Profile's personal address information. + """ + + city: typing.Optional[str] = None + """ + City name from the address. + """ + + country: typing.Optional[str] = None + """ + Two letter country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). + """ + + line_1: typing.Optional[str] = None + """ + First line of the address with details of the street name and number. + """ + + line_2: typing.Optional[str] = None + """ + Second line of the address with details of the building, unit, apartment, and floor numbers. + """ + + postal_code: typing.Optional[str] = None + """ + Postal code from the address. + """ + + state: typing.Optional[str] = None + """ + State name or abbreviation from the address. + """ + + +AmountEvent = float +""" +Amount of the event. +""" + +Attributes = dict[typing.Any, typing.Any] +""" +Object attributes that are modifiable only by SumUp applications. +""" + +CardType = typing.Literal[ + "AMEX", + "CUP", + "DINERS", + "DISCOVER", + "ELO", + "ELV", + "HIPERCARD", + "JCB", + "MAESTRO", + "MASTERCARD", + "UNKNOWN", + "VISA", + "VISA_ELECTRON", + "VISA_VPAY", +] + +Currency = typing.Literal[ + "BGN", + "BRL", + "CHF", + "CLP", + "CZK", + "DKK", + "EUR", + "GBP", + "HRK", + "HUF", + "NOK", + "PLN", + "RON", + "SEK", + "USD", +] + +EntryMode = typing.Literal[ + "APPLE_PAY", + "BANCONTACT", + "BLIK", + "BOLETO", + "CHIP", + "CONTACTLESS", + "CONTACTLESS_MAGSTRIPE", + "CUSTOMER_ENTRY", + "DIRECT_DEBIT", + "EPS", + "GIROPAY", + "GOOGLE_PAY", + "IDEAL", + "MAGSTRIPE", + "MAGSTRIPE_FALLBACK", + "MANUAL_ENTRY", + "MOTO", + "MYBANK", + "N/A", + "NONE", + "P24", + "PAYPAL", + "PIX", + "QR_CODE_PIX", + "SATISPAY", + "SOFORT", +] + + +class Error(pydantic.BaseModel): + """ + Error message structure. + """ + + error_code: typing.Optional[str] = None + """ + Platform code for the error. + """ + + message: typing.Optional[str] = None + """ + Short description of the error. + """ + + +class ErrorForbidden(pydantic.BaseModel): + """ + Error message for forbidden requests. + """ + + error_code: typing.Optional[str] = None + """ + Platform code for the error. + """ + + error_message: typing.Optional[str] = None + """ + Short description of the error. + """ + + status_code: typing.Optional[str] = None + """ + HTTP status code for the error. + """ + + +EventId = int +""" +Unique ID of the transaction event. +Format: int64 +""" + +EventStatus = typing.Literal["FAILED", "PAID_OUT", "PENDING", "REFUNDED", "SCHEDULED", "SUCCESSFUL"] + +EventType = typing.Literal["CHARGE_BACK", "PAYOUT", "PAYOUT_DEDUCTION", "REFUND"] + + +class Invite(pydantic.BaseModel): + """ + Pending invitation for membership. + """ + + email: str + """ + Email address of the invited user. + Format: email + """ + + expires_at: datetime.datetime + + +class MandateResponse(pydantic.BaseModel): + """ + Created mandate + """ + + merchant_code: typing.Optional[str] = None + """ + Merchant code which has the mandate + """ + + status: typing.Optional[str] = None + """ + Mandate status + """ + + type: typing.Optional[str] = None + """ + Indicates the mandate type + """ + + +MembershipStatus = typing.Literal["accepted", "disabled", "expired", "pending", "unknown"] + +Metadata = dict[typing.Any, typing.Any] +""" +Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. +Max properties: 64 +""" + +PaymentType = typing.Literal[ + "APM", + "BALANCE", + "BITCOIN", + "BOLETO", + "CASH", + "DIRECT_DEBIT", + "ECOM", + "MOTO", + "POS", + "RECURRING", + "UNKNOWN", +] + + +class PersonalDetails(pydantic.BaseModel): + """ + Personal details for the customer. + """ + + address: typing.Optional["AddressLegacy"] = None + """ + Profile's personal address information. + """ + + birth_date: typing.Optional[datetime.date] = None + """ + Date of birth of the customer. + Format: date + """ + + email: typing.Optional[str] = None + """ + Email address of the customer. + """ + + first_name: typing.Optional[str] = None + """ + First name of the customer. + """ + + last_name: typing.Optional[str] = None + """ + Last name of the customer. + """ + + phone: typing.Optional[str] = None + """ + Phone number of the customer. + """ + + tax_id: typing.Optional[str] = None + """ + An identification number user for tax purposes (e.g. CPF) + Max length: 255 + """ + + +class Problem(pydantic.BaseModel): + """ + A RFC 9457 problem details object. + + Additional properties specific to the problem type may be present. + """ + + type: str + """ + A URI reference that identifies the problem type. + Format: uri + """ + + detail: typing.Optional[str] = None + """ + A human-readable explanation specific to this occurrence of the problem. + """ + + instance: typing.Optional[str] = None + """ + A URI reference that identifies the specific occurrence of the problem. + Format: uri + """ + + status: typing.Optional[int] = None + """ + The HTTP status code generated by the origin server for this occurrence of the problem. + Min: 400 + Max: 600 + """ + + title: typing.Optional[str] = None + """ + A short, human-readable summary of the problem type. + """ + + +TimestampEvent = str +""" +Date and time of the transaction event. +""" + +TransactionBaseStatus = typing.Literal["CANCELLED", "FAILED", "PENDING", "SUCCESSFUL"] + + +class TransactionBase(pydantic.BaseModel): + """ + Details of the transaction. + """ + + amount: typing.Optional[float] = None + """ + Total amount of the transaction. + """ + + currency: typing.Optional["Currency"] = None + """ + Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. + """ + + id: typing.Optional[str] = None + """ + Unique ID of the transaction. + """ + + installments_count: typing.Optional[int] = None + """ + Current number of the installment for deferred payments. + Min: 1 + """ + + payment_type: typing.Optional["PaymentType"] = None + """ + Payment type used for the transaction. + """ + + status: typing.Optional[TransactionBaseStatus] = None + """ + Current status of the transaction. + """ + + timestamp: typing.Optional[datetime.datetime] = None + """ + Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + """ + + transaction_code: typing.Optional[str] = None + """ + Transaction code returned by the acquirer/processing entity after processing the transaction. + """ + + +class TransactionCheckoutInfo(pydantic.BaseModel): + """ + TransactionCheckoutInfo is a schema definition. + """ + + auth_code: typing.Optional[str] = None + """ + Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. + """ + + entry_mode: typing.Optional["EntryMode"] = None + """ + Entry mode of the payment details. + """ + + internal_id: typing.Optional[int] = None + """ + Internal unique ID of the transaction on the SumUp platform. + Format: int64 + """ + + merchant_code: typing.Optional[str] = None + """ + Unique code of the registered merchant to whom the payment is made. + """ + + tip_amount: typing.Optional[float] = None + """ + Amount of the tip (out of the total transaction amount). + """ + + vat_amount: typing.Optional[float] = None + """ + Amount of the applicable VAT (out of the total transaction amount). + """ + + +TransactionId = str +""" +Unique ID of the transaction. +""" diff --git a/sumup/_version.py b/sumup/_version.py index 3b3feec8..cec0601c 100644 --- a/sumup/_version.py +++ b/sumup/_version.py @@ -1 +1 @@ -__version__ = "0.0.16" # x-release-please-version +__version__ = "0.0.17" # x-release-please-version diff --git a/sumup/checkouts/__init__.py b/sumup/checkouts/__init__.py index 0575e2b0..2348e7c6 100755 --- a/sumup/checkouts/__init__.py +++ b/sumup/checkouts/__init__.py @@ -16,26 +16,15 @@ ProcessCheckoutResponse, ) from .types import ( - AddressLegacy, Card, - CardType, Checkout, CheckoutAccepted, CheckoutCreateRequest, CheckoutSuccess, - Currency, DetailsError, - EntryMode, - Error, ErrorExtended, - ErrorForbidden, MandatePayload, - MandateResponse, - PaymentType, - PersonalDetails, ProcessCheckout, - TransactionBase, - TransactionCheckoutInfo, ) @@ -54,24 +43,13 @@ "GetPaymentMethods200ResponseAvailablePaymentMethod", "GetPaymentMethods200Response", "ProcessCheckoutResponse", - "AddressLegacy", "Card", - "CardType", "Checkout", "CheckoutAccepted", "CheckoutCreateRequest", "CheckoutSuccess", - "Currency", "DetailsError", - "EntryMode", - "Error", "ErrorExtended", - "ErrorForbidden", "MandatePayload", - "MandateResponse", - "PaymentType", - "PersonalDetails", "ProcessCheckout", - "TransactionBase", - "TransactionCheckoutInfo", ] diff --git a/sumup/checkouts/resource.py b/sumup/checkouts/resource.py index 78b2d863..89335bcd 100755 --- a/sumup/checkouts/resource.py +++ b/sumup/checkouts/resource.py @@ -1,16 +1,13 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError +from .. import _shared from .types import ( Card, Checkout, CheckoutAccepted, CheckoutSuccess, - Currency, - EntryMode, MandatePayload, - PaymentType, - PersonalDetails, ) import datetime import httpx @@ -39,12 +36,12 @@ class CreateCheckoutBodyTransaction(pydantic.BaseModel): Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ - entry_mode: typing.Optional[EntryMode] = None + entry_mode: typing.Optional[_shared.EntryMode] = None """ Entry mode of the payment details. """ @@ -71,7 +68,7 @@ class CreateCheckoutBodyTransaction(pydantic.BaseModel): Unique code of the registered merchant to whom the payment is made. """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -118,7 +115,7 @@ class CreateCheckoutBody(pydantic.BaseModel): Max length: 90 """ - currency: Currency + currency: _shared.Currency """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ @@ -221,7 +218,7 @@ class ProcessCheckoutBody(pydantic.BaseModel): Mandate is passed when a card is to be tokenized """ - personal_details: typing.Optional[PersonalDetails] = None + personal_details: typing.Optional[_shared.PersonalDetails] = None """ Personal details for the customer. """ diff --git a/sumup/checkouts/types.py b/sumup/checkouts/types.py index 222899d8..b25322f1 100755 --- a/sumup/checkouts/types.py +++ b/sumup/checkouts/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -37,193 +38,6 @@ class DetailsError(pydantic.BaseModel): """ -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ - - -Currency = typing.Literal[ - "BGN", - "BRL", - "CHF", - "CLP", - "CZK", - "DKK", - "EUR", - "GBP", - "HRK", - "HUF", - "NOK", - "PLN", - "RON", - "SEK", - "USD", -] - - -class MandateResponse(pydantic.BaseModel): - """ - Created mandate - """ - - merchant_code: typing.Optional[str] = None - """ - Merchant code which has the mandate - """ - - status: typing.Optional[str] = None - """ - Mandate status - """ - - type: typing.Optional[str] = None - """ - Indicates the mandate type - """ - - -PaymentType = typing.Literal[ - "APM", - "BALANCE", - "BITCOIN", - "BOLETO", - "CASH", - "DIRECT_DEBIT", - "ECOM", - "MOTO", - "POS", - "RECURRING", - "UNKNOWN", -] - -TransactionBaseStatus = typing.Literal["CANCELLED", "FAILED", "PENDING", "SUCCESSFUL"] - - -class TransactionBase(pydantic.BaseModel): - """ - Details of the transaction. - """ - - amount: typing.Optional[float] = None - """ - Total amount of the transaction. - """ - - currency: typing.Optional[Currency] = None - """ - Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. - """ - - id: typing.Optional[str] = None - """ - Unique ID of the transaction. - """ - - installments_count: typing.Optional[int] = None - """ - Current number of the installment for deferred payments. - Min: 1 - """ - - payment_type: typing.Optional[PaymentType] = None - """ - Payment type used for the transaction. - """ - - status: typing.Optional[TransactionBaseStatus] = None - """ - Current status of the transaction. - """ - - timestamp: typing.Optional[datetime.datetime] = None - """ - Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. - """ - - transaction_code: typing.Optional[str] = None - """ - Transaction code returned by the acquirer/processing entity after processing the transaction. - """ - - -EntryMode = typing.Literal[ - "APPLE_PAY", - "BANCONTACT", - "BLIK", - "BOLETO", - "CHIP", - "CONTACTLESS", - "CONTACTLESS_MAGSTRIPE", - "CUSTOMER_ENTRY", - "DIRECT_DEBIT", - "EPS", - "GIROPAY", - "GOOGLE_PAY", - "IDEAL", - "MAGSTRIPE", - "MAGSTRIPE_FALLBACK", - "MANUAL_ENTRY", - "MOTO", - "MYBANK", - "N/A", - "NONE", - "P24", - "PAYPAL", - "PIX", - "QR_CODE_PIX", - "SATISPAY", - "SOFORT", -] - - -class TransactionCheckoutInfo(pydantic.BaseModel): - """ - TransactionCheckoutInfo is a schema definition. - """ - - auth_code: typing.Optional[str] = None - """ - Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. - """ - - entry_mode: typing.Optional[EntryMode] = None - """ - Entry mode of the payment details. - """ - - internal_id: typing.Optional[int] = None - """ - Internal unique ID of the transaction on the SumUp platform. - Format: int64 - """ - - merchant_code: typing.Optional[str] = None - """ - Unique code of the registered merchant to whom the payment is made. - """ - - tip_amount: typing.Optional[float] = None - """ - Amount of the tip (out of the total transaction amount). - """ - - vat_amount: typing.Optional[float] = None - """ - Amount of the applicable VAT (out of the total transaction amount). - """ - - CheckoutStatus = typing.Literal["EXPIRED", "FAILED", "PAID", "PENDING"] CheckoutTransactionStatus = typing.Literal["CANCELLED", "FAILED", "PENDING", "SUCCESSFUL"] @@ -244,12 +58,12 @@ class CheckoutTransaction(pydantic.BaseModel): Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ - entry_mode: typing.Optional[EntryMode] = None + entry_mode: typing.Optional[_shared.EntryMode] = None """ Entry mode of the payment details. """ @@ -276,7 +90,7 @@ class CheckoutTransaction(pydantic.BaseModel): Unique code of the registered merchant to whom the payment is made. """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -323,7 +137,7 @@ class Checkout(pydantic.BaseModel): Max length: 90 """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ @@ -349,7 +163,7 @@ class Checkout(pydantic.BaseModel): Read only """ - mandate: typing.Optional[MandateResponse] = None + mandate: typing.Optional[_shared.MandateResponse] = None """ Created mandate """ @@ -403,27 +217,6 @@ class ErrorExtended(pydantic.BaseModel): """ -class ErrorForbidden(pydantic.BaseModel): - """ - Error message for forbidden requests. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - error_message: typing.Optional[str] = None - """ - Short description of the error. - """ - - status_code: typing.Optional[str] = None - """ - HTTP status code for the error. - """ - - CheckoutCreateRequestPurpose = typing.Literal["CHECKOUT", "SETUP_RECURRING_PAYMENT"] CheckoutCreateRequestStatus = typing.Literal["FAILED", "PAID", "PENDING"] @@ -448,12 +241,12 @@ class CheckoutCreateRequestTransaction(pydantic.BaseModel): Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ - entry_mode: typing.Optional[EntryMode] = None + entry_mode: typing.Optional[_shared.EntryMode] = None """ Entry mode of the payment details. """ @@ -480,7 +273,7 @@ class CheckoutCreateRequestTransaction(pydantic.BaseModel): Unique code of the registered merchant to whom the payment is made. """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -527,7 +320,7 @@ class CheckoutCreateRequest(pydantic.BaseModel): Max length: 90 """ - currency: Currency + currency: _shared.Currency """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ @@ -615,12 +408,12 @@ class CheckoutSuccessTransaction(pydantic.BaseModel): Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ - entry_mode: typing.Optional[EntryMode] = None + entry_mode: typing.Optional[_shared.EntryMode] = None """ Entry mode of the payment details. """ @@ -647,7 +440,7 @@ class CheckoutSuccessTransaction(pydantic.BaseModel): Unique code of the registered merchant to whom the payment is made. """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -705,7 +498,7 @@ class CheckoutSuccess(pydantic.BaseModel): Max length: 90 """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ @@ -731,7 +524,7 @@ class CheckoutSuccess(pydantic.BaseModel): Read only """ - mandate: typing.Optional[MandateResponse] = None + mandate: typing.Optional[_shared.MandateResponse] = None """ Created mandate """ @@ -872,23 +665,6 @@ class MandatePayload(pydantic.BaseModel): """ -CardType = typing.Literal[ - "AMEX", - "CUP", - "DINERS", - "DISCOVER", - "ELO", - "ELV", - "HIPERCARD", - "JCB", - "MAESTRO", - "MASTERCARD", - "UNKNOWN", - "VISA", - "VISA_ELECTRON", - "VISA_VPAY", -] - CardExpiryMonth = typing.Literal[ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" ] @@ -941,7 +717,7 @@ class Card(pydantic.BaseModel): Write only """ - type: CardType + type: _shared.CardType """ Issuing card network of the payment card used for the transaction. """ @@ -955,85 +731,6 @@ class Card(pydantic.BaseModel): """ -class AddressLegacy(pydantic.BaseModel): - """ - Profile's personal address information. - """ - - city: typing.Optional[str] = None - """ - City name from the address. - """ - - country: typing.Optional[str] = None - """ - Two letter country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). - """ - - line_1: typing.Optional[str] = None - """ - First line of the address with details of the street name and number. - """ - - line_2: typing.Optional[str] = None - """ - Second line of the address with details of the building, unit, apartment, and floor numbers. - """ - - postal_code: typing.Optional[str] = None - """ - Postal code from the address. - """ - - state: typing.Optional[str] = None - """ - State name or abbreviation from the address. - """ - - -class PersonalDetails(pydantic.BaseModel): - """ - Personal details for the customer. - """ - - address: typing.Optional[AddressLegacy] = None - """ - Profile's personal address information. - """ - - birth_date: typing.Optional[datetime.date] = None - """ - Date of birth of the customer. - Format: date - """ - - email: typing.Optional[str] = None - """ - Email address of the customer. - """ - - first_name: typing.Optional[str] = None - """ - First name of the customer. - """ - - last_name: typing.Optional[str] = None - """ - Last name of the customer. - """ - - phone: typing.Optional[str] = None - """ - Phone number of the customer. - """ - - tax_id: typing.Optional[str] = None - """ - An identification number user for tax purposes (e.g. CPF) - Max length: 255 - """ - - ProcessCheckoutPaymentType = typing.Literal["bancontact", "blik", "boleto", "card", "ideal"] @@ -1069,7 +766,7 @@ class ProcessCheckout(pydantic.BaseModel): Mandate is passed when a card is to be tokenized """ - personal_details: typing.Optional[PersonalDetails] = None + personal_details: typing.Optional[_shared.PersonalDetails] = None """ Personal details for the customer. """ diff --git a/sumup/customers/__init__.py b/sumup/customers/__init__.py index c5ef6ad7..eee74273 100755 --- a/sumup/customers/__init__.py +++ b/sumup/customers/__init__.py @@ -6,14 +6,8 @@ UpdateCustomerBody, ) from .types import ( - AddressLegacy, - CardType, Customer, - Error, - ErrorForbidden, - MandateResponse, PaymentInstrumentResponse, - PersonalDetails, ) @@ -22,12 +16,6 @@ "AsyncCustomersResource", "CreateCustomerBody", "UpdateCustomerBody", - "AddressLegacy", - "CardType", "Customer", - "Error", - "ErrorForbidden", - "MandateResponse", "PaymentInstrumentResponse", - "PersonalDetails", ] diff --git a/sumup/customers/resource.py b/sumup/customers/resource.py index 4276ddf1..2a06f203 100755 --- a/sumup/customers/resource.py +++ b/sumup/customers/resource.py @@ -1,11 +1,8 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError -from .types import ( - Customer, - PaymentInstrumentResponse, - PersonalDetails, -) +from .. import _shared +from .types import Customer, PaymentInstrumentResponse import httpx import typing import pydantic @@ -21,7 +18,7 @@ class CreateCustomerBody(pydantic.BaseModel): Unique ID of the customer. """ - personal_details: typing.Optional[PersonalDetails] = None + personal_details: typing.Optional[_shared.PersonalDetails] = None """ Personal details for the customer. """ @@ -32,7 +29,7 @@ class UpdateCustomerBody(pydantic.BaseModel): UpdateCustomerBody is a schema definition. """ - personal_details: typing.Optional[PersonalDetails] = None + personal_details: typing.Optional[_shared.PersonalDetails] = None """ Personal details for the customer. """ diff --git a/sumup/customers/types.py b/sumup/customers/types.py index c25e8cb8..9152435a 100755 --- a/sumup/customers/types.py +++ b/sumup/customers/types.py @@ -1,88 +1,10 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic -class AddressLegacy(pydantic.BaseModel): - """ - Profile's personal address information. - """ - - city: typing.Optional[str] = None - """ - City name from the address. - """ - - country: typing.Optional[str] = None - """ - Two letter country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). - """ - - line_1: typing.Optional[str] = None - """ - First line of the address with details of the street name and number. - """ - - line_2: typing.Optional[str] = None - """ - Second line of the address with details of the building, unit, apartment, and floor numbers. - """ - - postal_code: typing.Optional[str] = None - """ - Postal code from the address. - """ - - state: typing.Optional[str] = None - """ - State name or abbreviation from the address. - """ - - -class PersonalDetails(pydantic.BaseModel): - """ - Personal details for the customer. - """ - - address: typing.Optional[AddressLegacy] = None - """ - Profile's personal address information. - """ - - birth_date: typing.Optional[datetime.date] = None - """ - Date of birth of the customer. - Format: date - """ - - email: typing.Optional[str] = None - """ - Email address of the customer. - """ - - first_name: typing.Optional[str] = None - """ - First name of the customer. - """ - - last_name: typing.Optional[str] = None - """ - Last name of the customer. - """ - - phone: typing.Optional[str] = None - """ - Phone number of the customer. - """ - - tax_id: typing.Optional[str] = None - """ - An identification number user for tax purposes (e.g. CPF) - Max length: 255 - """ - - class Customer(pydantic.BaseModel): """ Customer is a schema definition. @@ -93,88 +15,12 @@ class Customer(pydantic.BaseModel): Unique ID of the customer. """ - personal_details: typing.Optional[PersonalDetails] = None + personal_details: typing.Optional[_shared.PersonalDetails] = None """ Personal details for the customer. """ -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ - - -class ErrorForbidden(pydantic.BaseModel): - """ - Error message for forbidden requests. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - error_message: typing.Optional[str] = None - """ - Short description of the error. - """ - - status_code: typing.Optional[str] = None - """ - HTTP status code for the error. - """ - - -CardType = typing.Literal[ - "AMEX", - "CUP", - "DINERS", - "DISCOVER", - "ELO", - "ELV", - "HIPERCARD", - "JCB", - "MAESTRO", - "MASTERCARD", - "UNKNOWN", - "VISA", - "VISA_ELECTRON", - "VISA_VPAY", -] - - -class MandateResponse(pydantic.BaseModel): - """ - Created mandate - """ - - merchant_code: typing.Optional[str] = None - """ - Merchant code which has the mandate - """ - - status: typing.Optional[str] = None - """ - Mandate status - """ - - type: typing.Optional[str] = None - """ - Indicates the mandate type - """ - - PaymentInstrumentResponseType = typing.Literal["card"] @@ -191,7 +37,7 @@ class PaymentInstrumentResponseCard(pydantic.BaseModel): Max length: 4 """ - type: typing.Optional[CardType] = None + type: typing.Optional[_shared.CardType] = None """ Issuing card network of the payment card used for the transaction. """ @@ -219,7 +65,7 @@ class PaymentInstrumentResponse(pydantic.BaseModel): Creation date of payment instrument. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. """ - mandate: typing.Optional[MandateResponse] = None + mandate: typing.Optional[_shared.MandateResponse] = None """ Created mandate """ diff --git a/sumup/members/__init__.py b/sumup/members/__init__.py index 5f5e947f..a4c9b709 100755 --- a/sumup/members/__init__.py +++ b/sumup/members/__init__.py @@ -9,14 +9,9 @@ ListMerchantMembers200Response, ) from .types import ( - Attributes, - Invite, Member, - MembershipStatus, MembershipUser, MembershipUserClassic, - Metadata, - Problem, ) @@ -28,12 +23,7 @@ "UpdateMerchantMemberBody", "ListMerchantMembersParams", "ListMerchantMembers200Response", - "Attributes", - "Invite", "Member", - "MembershipStatus", "MembershipUser", "MembershipUserClassic", - "Metadata", - "Problem", ] diff --git a/sumup/members/resource.py b/sumup/members/resource.py index e10ccc83..c9761eba 100755 --- a/sumup/members/resource.py +++ b/sumup/members/resource.py @@ -2,12 +2,8 @@ from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError from .._secret import Secret -from .types import ( - Attributes, - Member, - MembershipStatus, - Metadata, -) +from .. import _shared +from .types import Member import httpx import typing import pydantic @@ -29,7 +25,7 @@ class CreateMerchantMemberBody(pydantic.BaseModel): List of roles to assign to the new member. """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ @@ -39,7 +35,7 @@ class CreateMerchantMemberBody(pydantic.BaseModel): True if the user is managed by the merchant. In this case, we'll created a virtual user with the provided passwordand nickname. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 @@ -81,12 +77,12 @@ class UpdateMerchantMemberBody(pydantic.BaseModel): UpdateMerchantMemberBody is a schema definition. """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 @@ -115,7 +111,7 @@ class ListMerchantMembersParams(pydantic.BaseModel): scroll: typing.Optional[bool] = None - status: typing.Optional[MembershipStatus] = None + status: typing.Optional[_shared.MembershipStatus] = None """ The status of the membership. """ diff --git a/sumup/members/types.py b/sumup/members/types.py index 0aadc885..db6ecf95 100755 --- a/sumup/members/types.py +++ b/sumup/members/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -69,34 +70,6 @@ class MembershipUser(pydantic.BaseModel): """ -class Invite(pydantic.BaseModel): - """ - Pending invitation for membership. - """ - - email: str - """ - Email address of the invited user. - Format: email - """ - - expires_at: datetime.datetime - - -MembershipStatus = typing.Literal["accepted", "disabled", "expired", "pending", "unknown"] - -Metadata = dict[typing.Any, typing.Any] -""" -Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. -Max properties: 64 -""" - -Attributes = dict[typing.Any, typing.Any] -""" -Object attributes that are modifiable only by SumUp applications. -""" - - class Member(pydantic.BaseModel): """ A member is user within specific resource identified by resource id, resource type, and associated roles. @@ -123,7 +96,7 @@ class Member(pydantic.BaseModel): User's roles. """ - status: MembershipStatus + status: _shared.MembershipStatus """ The status of the membership. """ @@ -133,17 +106,17 @@ class Member(pydantic.BaseModel): The timestamp of when the member was last updated. """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ - invite: typing.Optional[Invite] = None + invite: typing.Optional[_shared.Invite] = None """ Pending invitation for membership. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 @@ -153,40 +126,3 @@ class Member(pydantic.BaseModel): """ Information about the user associated with the membership. """ - - -class Problem(pydantic.BaseModel): - """ - A RFC 9457 problem details object. - - Additional properties specific to the problem type may be present. - """ - - type: str - """ - A URI reference that identifies the problem type. - Format: uri - """ - - detail: typing.Optional[str] = None - """ - A human-readable explanation specific to this occurrence of the problem. - """ - - instance: typing.Optional[str] = None - """ - A URI reference that identifies the specific occurrence of the problem. - Format: uri - """ - - status: typing.Optional[int] = None - """ - The HTTP status code generated by the origin server for this occurrence of the problem. - Min: 400 - Max: 600 - """ - - title: typing.Optional[str] = None - """ - A short, human-readable summary of the problem type. - """ diff --git a/sumup/memberships/__init__.py b/sumup/memberships/__init__.py index 5fe71598..10a0b7f7 100755 --- a/sumup/memberships/__init__.py +++ b/sumup/memberships/__init__.py @@ -6,12 +6,8 @@ ListMemberships200Response, ) from .types import ( - Attributes, - Invite, Membership, MembershipResource, - MembershipStatus, - Metadata, ResourceType, ) @@ -21,11 +17,7 @@ "AsyncMembershipsResource", "ListMembershipsParams", "ListMemberships200Response", - "Attributes", - "Invite", "Membership", "MembershipResource", - "MembershipStatus", - "Metadata", "ResourceType", ] diff --git a/sumup/memberships/resource.py b/sumup/memberships/resource.py index 7d439349..e2ba5e07 100755 --- a/sumup/memberships/resource.py +++ b/sumup/memberships/resource.py @@ -1,11 +1,8 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError -from .types import ( - Membership, - MembershipStatus, - ResourceType, -) +from .. import _shared +from .types import Membership, ResourceType import httpx import typing import pydantic @@ -68,7 +65,7 @@ class ListMembershipsParams(pydantic.BaseModel): roles: typing.Optional[list[str]] = None - status: typing.Optional[MembershipStatus] = None + status: typing.Optional[_shared.MembershipStatus] = None """ The status of the membership. """ diff --git a/sumup/memberships/types.py b/sumup/memberships/types.py index f39007c2..794ba132 100755 --- a/sumup/memberships/types.py +++ b/sumup/memberships/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -12,34 +13,6 @@ """ -class Invite(pydantic.BaseModel): - """ - Pending invitation for membership. - """ - - email: str - """ - Email address of the invited user. - Format: email - """ - - expires_at: datetime.datetime - - -MembershipStatus = typing.Literal["accepted", "disabled", "expired", "pending", "unknown"] - -Metadata = dict[typing.Any, typing.Any] -""" -Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. -Max properties: 64 -""" - -Attributes = dict[typing.Any, typing.Any] -""" -Object attributes that are modifiable only by SumUp applications. -""" - - class MembershipResource(pydantic.BaseModel): """ Information about the resource the membership is in. @@ -73,7 +46,7 @@ class MembershipResource(pydantic.BaseModel): The timestamp of when the membership resource was last updated. """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ @@ -122,7 +95,7 @@ class Membership(pydantic.BaseModel): User's roles. """ - status: MembershipStatus + status: _shared.MembershipStatus """ The status of the membership. """ @@ -140,17 +113,17 @@ class Membership(pydantic.BaseModel): The timestamp of when the membership was last updated. """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ - invite: typing.Optional[Invite] = None + invite: typing.Optional[_shared.Invite] = None """ Pending invitation for membership. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 diff --git a/sumup/merchant/__init__.py b/sumup/merchant/__init__.py index 439d9fb8..303bee7a 100755 --- a/sumup/merchant/__init__.py +++ b/sumup/merchant/__init__.py @@ -12,8 +12,6 @@ BusinessOwners, CountryDetails, DoingBusinessAsLegacy, - Error, - ErrorForbidden, LegalTypeLegacy, MerchantAccount, MerchantProfileLegacy, @@ -36,8 +34,6 @@ "BusinessOwners", "CountryDetails", "DoingBusinessAsLegacy", - "Error", - "ErrorForbidden", "LegalTypeLegacy", "MerchantAccount", "MerchantProfileLegacy", diff --git a/sumup/merchant/types.py b/sumup/merchant/types.py index c0df99dc..ada77217 100755 --- a/sumup/merchant/types.py +++ b/sumup/merchant/types.py @@ -731,40 +731,3 @@ class MerchantAccount(pydantic.BaseModel): """ Account's personal profile. """ - - -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ - - -class ErrorForbidden(pydantic.BaseModel): - """ - Error message for forbidden requests. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - error_message: typing.Optional[str] = None - """ - Short description of the error. - """ - - status_code: typing.Optional[str] = None - """ - HTTP status code for the error. - """ diff --git a/sumup/merchants/__init__.py b/sumup/merchants/__init__.py index d7c22a60..616d4579 100755 --- a/sumup/merchants/__init__.py +++ b/sumup/merchants/__init__.py @@ -8,7 +8,6 @@ ) from .types import ( Address, - Attributes, BaseError, BasePerson, Branding, @@ -43,7 +42,6 @@ "ListPersonsParams", "GetPersonParams", "Address", - "Attributes", "BaseError", "BasePerson", "Branding", diff --git a/sumup/merchants/types.py b/sumup/merchants/types.py index 5a5fb8dc..5ad241a5 100755 --- a/sumup/merchants/types.py +++ b/sumup/merchants/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -164,11 +165,6 @@ class CompanyIdentifier(pydantic.BaseModel): Max length: 64 """ -Attributes = dict[typing.Any, typing.Any] -""" -Object attributes that are modifiable only by SumUp applications. -""" - class Company(pydantic.BaseModel): """ @@ -184,7 +180,7 @@ class Company(pydantic.BaseModel): Address documentation: https://sumup.roadie.so/docs/default/Component/merchants/merchant/#addresses """ - attributes: typing.Optional[Attributes] = None + attributes: typing.Optional[_shared.Attributes] = None """ Object attributes that are modifiable only by SumUp applications. """ diff --git a/sumup/payouts/__init__.py b/sumup/payouts/__init__.py index fb4e3882..2e1a375b 100755 --- a/sumup/payouts/__init__.py +++ b/sumup/payouts/__init__.py @@ -6,7 +6,6 @@ ListPayoutsParams, ) from .types import ( - Error, FinancialPayouts, ) @@ -16,6 +15,5 @@ "AsyncPayoutsResource", "ListPayoutsV1Params", "ListPayoutsParams", - "Error", "FinancialPayouts", ] diff --git a/sumup/payouts/types.py b/sumup/payouts/types.py index 6b127289..996c7831 100755 --- a/sumup/payouts/types.py +++ b/sumup/payouts/types.py @@ -45,19 +45,3 @@ class FinancialPayout(pydantic.BaseModel): """ FinancialPayouts is a schema definition. """ - - -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ diff --git a/sumup/readers/__init__.py b/sumup/readers/__init__.py index be245de4..8e3f7c8d 100755 --- a/sumup/readers/__init__.py +++ b/sumup/readers/__init__.py @@ -21,9 +21,7 @@ CreateReaderTerminateUnprocessableEntity, GatewayTimeout, InternalServerError, - Metadata, NotFound, - Problem, Reader, ReaderDevice, ReaderId, @@ -55,9 +53,7 @@ "CreateReaderTerminateUnprocessableEntity", "GatewayTimeout", "InternalServerError", - "Metadata", "NotFound", - "Problem", "Reader", "ReaderDevice", "ReaderId", diff --git a/sumup/readers/resource.py b/sumup/readers/resource.py index 0dfdac99..944057a5 100755 --- a/sumup/readers/resource.py +++ b/sumup/readers/resource.py @@ -1,9 +1,9 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError +from .. import _shared from .types import ( CreateReaderCheckoutResponse, - Metadata, Reader, ReaderId, ReaderName, @@ -33,7 +33,7 @@ class CreateReaderBody(pydantic.BaseModel): Max length: 9 """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 @@ -45,7 +45,7 @@ class UpdateReaderBody(pydantic.BaseModel): UpdateReaderBody is a schema definition. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 diff --git a/sumup/readers/types.py b/sumup/readers/types.py index bfb8eeaa..831017b5 100755 --- a/sumup/readers/types.py +++ b/sumup/readers/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -39,13 +40,6 @@ class ReaderDevice(pydantic.BaseModel): """ -Metadata = dict[typing.Any, typing.Any] -""" -Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. -Max properties: 64 -""" - - class Reader(pydantic.BaseModel): """ A physical card reader device that can accept in-person payments. @@ -93,50 +87,13 @@ class Reader(pydantic.BaseModel): The timestamp of when the reader was last updated. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 """ -class Problem(pydantic.BaseModel): - """ - A RFC 9457 problem details object. - - Additional properties specific to the problem type may be present. - """ - - type: str - """ - A URI reference that identifies the problem type. - Format: uri - """ - - detail: typing.Optional[str] = None - """ - A human-readable explanation specific to this occurrence of the problem. - """ - - instance: typing.Optional[str] = None - """ - A URI reference that identifies the specific occurrence of the problem. - Format: uri - """ - - status: typing.Optional[int] = None - """ - The HTTP status code generated by the origin server for this occurrence of the problem. - Min: 400 - Max: 600 - """ - - title: typing.Optional[str] = None - """ - A short, human-readable summary of the problem type. - """ - - ReaderPairingCode = str """ The pairing code is a 8 or 9 character alphanumeric string that is displayed on a SumUp Device after initiatingthe pairing. It is used to link the physical device to the created pairing. @@ -340,12 +297,71 @@ class CreateReaderCheckoutRequest(pydantic.BaseModel): """ +StatusResponseDataConnectionType = typing.Literal[ + "Wi-Fi", "btle", "edge", "gprs", "lte", "umts", "usb" +] + +StatusResponseDataState = typing.Literal[ + "IDLE", + "SELECTING_TIP", + "UPDATING_FIRMWARE", + "WAITING_FOR_CARD", + "WAITING_FOR_PIN", + "WAITING_FOR_SIGNATURE", +] + +StatusResponseDataStatus = typing.Literal["OFFLINE", "ONLINE"] + + +class StatusResponseData(pydantic.BaseModel): + """ + StatusResponseData is a schema definition. + """ + + status: StatusResponseDataStatus + """ + Status of a device + """ + + battery_level: typing.Optional[typing.Any] = None + """ + Battery level percentage + Min: 0 + Max: 100 + """ + + battery_temperature: typing.Optional[int] = None + """ + Battery temperature in Celsius + """ + + connection_type: typing.Optional[StatusResponseDataConnectionType] = None + """ + Type of connection used by the device + """ + + firmware_version: typing.Optional[str] = None + """ + Firmware version of the device + """ + + last_activity: typing.Optional[datetime.datetime] = None + """ + Timestamp of the last activity from the device + """ + + state: typing.Optional[StatusResponseDataState] = None + """ + Latest state of the device + """ + + class StatusResponse(pydantic.BaseModel): """ Status of a device """ - data: typing.Any + data: StatusResponseData BadRequestErrorsType = typing.Literal[ diff --git a/sumup/receipts/__init__.py b/sumup/receipts/__init__.py index aa57f886..969daf1b 100755 --- a/sumup/receipts/__init__.py +++ b/sumup/receipts/__init__.py @@ -5,18 +5,11 @@ GetReceiptParams, ) from .types import ( - AmountEvent, - Error, - EventId, - EventStatus, - EventType, Receipt, ReceiptCard, ReceiptEvent, ReceiptMerchantData, ReceiptTransaction, - TimestampEvent, - TransactionId, ) @@ -24,16 +17,9 @@ "ReceiptsResource", "AsyncReceiptsResource", "GetReceiptParams", - "AmountEvent", - "Error", - "EventId", - "EventStatus", - "EventType", "Receipt", "ReceiptCard", "ReceiptEvent", "ReceiptMerchantData", "ReceiptTransaction", - "TimestampEvent", - "TransactionId", ] diff --git a/sumup/receipts/resource.py b/sumup/receipts/resource.py index 413962da..681d3ab5 100755 --- a/sumup/receipts/resource.py +++ b/sumup/receipts/resource.py @@ -1,9 +1,7 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError -from .types import ( - Receipt, -) +from .types import Receipt import httpx import typing import pydantic diff --git a/sumup/receipts/types.py b/sumup/receipts/types.py index 83084206..17aebd7a 100755 --- a/sumup/receipts/types.py +++ b/sumup/receipts/types.py @@ -1,4 +1,5 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic @@ -20,43 +21,17 @@ class ReceiptCard(pydantic.BaseModel): """ -EventId = int -""" -Unique ID of the transaction event. -Format: int64 -""" - -TransactionId = str -""" -Unique ID of the transaction. -""" - -EventType = typing.Literal["CHARGE_BACK", "PAYOUT", "PAYOUT_DEDUCTION", "REFUND"] - -EventStatus = typing.Literal["FAILED", "PAID_OUT", "PENDING", "REFUNDED", "SCHEDULED", "SUCCESSFUL"] - -AmountEvent = float -""" -Amount of the event. -""" - -TimestampEvent = str -""" -Date and time of the transaction event. -""" - - class ReceiptEvent(pydantic.BaseModel): """ ReceiptEvent is a schema definition. """ - amount: typing.Optional[AmountEvent] = None + amount: typing.Optional[_shared.AmountEvent] = None """ Amount of the event. """ - id: typing.Optional[EventId] = None + id: typing.Optional[_shared.EventId] = None """ Unique ID of the transaction event. Format: int64 @@ -64,22 +39,22 @@ class ReceiptEvent(pydantic.BaseModel): receipt_no: typing.Optional[str] = None - status: typing.Optional[EventStatus] = None + status: typing.Optional[_shared.EventStatus] = None """ Status of the transaction event. """ - timestamp: typing.Optional[TimestampEvent] = None + timestamp: typing.Optional[_shared.TimestampEvent] = None """ Date and time of the transaction event. """ - transaction_id: typing.Optional[TransactionId] = None + transaction_id: typing.Optional[_shared.TransactionId] = None """ Unique ID of the transaction. """ - type: typing.Optional[EventType] = None + type: typing.Optional[_shared.EventType] = None """ Type of the transaction event. """ @@ -307,19 +282,3 @@ class Receipt(pydantic.BaseModel): """ Transaction information. """ - - -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ diff --git a/sumup/roles/__init__.py b/sumup/roles/__init__.py index c54b3ea1..eac5d000 100755 --- a/sumup/roles/__init__.py +++ b/sumup/roles/__init__.py @@ -7,8 +7,6 @@ ListMerchantRoles200Response, ) from .types import ( - Metadata, - Problem, Role, ) @@ -19,7 +17,5 @@ "CreateMerchantRoleBody", "UpdateMerchantRoleBody", "ListMerchantRoles200Response", - "Metadata", - "Problem", "Role", ] diff --git a/sumup/roles/resource.py b/sumup/roles/resource.py index 0bd3d809..0f6b973b 100755 --- a/sumup/roles/resource.py +++ b/sumup/roles/resource.py @@ -1,7 +1,8 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError -from .types import Metadata, Role +from .. import _shared +from .types import Role import httpx import typing import pydantic @@ -28,7 +29,7 @@ class CreateMerchantRoleBody(pydantic.BaseModel): User-defined description of the role. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 diff --git a/sumup/roles/types.py b/sumup/roles/types.py index 9fcb2b3e..af81a291 100755 --- a/sumup/roles/types.py +++ b/sumup/roles/types.py @@ -1,14 +1,9 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic -Metadata = dict[typing.Any, typing.Any] -""" -Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. -Max properties: 64 -""" - class Role(pydantic.BaseModel): """ @@ -51,45 +46,8 @@ class Role(pydantic.BaseModel): User-defined description of the role. """ - metadata: typing.Optional[Metadata] = None + metadata: typing.Optional[_shared.Metadata] = None """ Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, alwayssubmit whole metadata. Maximum of 64 parameters are allowed in the object. Max properties: 64 """ - - -class Problem(pydantic.BaseModel): - """ - A RFC 9457 problem details object. - - Additional properties specific to the problem type may be present. - """ - - type: str - """ - A URI reference that identifies the problem type. - Format: uri - """ - - detail: typing.Optional[str] = None - """ - A human-readable explanation specific to this occurrence of the problem. - """ - - instance: typing.Optional[str] = None - """ - A URI reference that identifies the specific occurrence of the problem. - Format: uri - """ - - status: typing.Optional[int] = None - """ - The HTTP status code generated by the origin server for this occurrence of the problem. - Min: 400 - Max: 600 - """ - - title: typing.Optional[str] = None - """ - A short, human-readable summary of the problem type. - """ diff --git a/sumup/subaccounts/__init__.py b/sumup/subaccounts/__init__.py index 781e2e84..b4b18e04 100755 --- a/sumup/subaccounts/__init__.py +++ b/sumup/subaccounts/__init__.py @@ -11,7 +11,6 @@ from .types import ( Operator, Permissions, - Problem, ) @@ -25,5 +24,4 @@ "ListSubAccountsParams", "Operator", "Permissions", - "Problem", ] diff --git a/sumup/subaccounts/types.py b/sumup/subaccounts/types.py index 807f64b6..f7b73796 100755 --- a/sumup/subaccounts/types.py +++ b/sumup/subaccounts/types.py @@ -55,40 +55,3 @@ class Operator(pydantic.BaseModel): username: str nickname: typing.Optional[str] = None - - -class Problem(pydantic.BaseModel): - """ - A RFC 9457 problem details object. - - Additional properties specific to the problem type may be present. - """ - - type: str - """ - A URI reference that identifies the problem type. - Format: uri - """ - - detail: typing.Optional[str] = None - """ - A human-readable explanation specific to this occurrence of the problem. - """ - - instance: typing.Optional[str] = None - """ - A URI reference that identifies the specific occurrence of the problem. - Format: uri - """ - - status: typing.Optional[int] = None - """ - The HTTP status code generated by the origin server for this occurrence of the problem. - Min: 400 - Max: 600 - """ - - title: typing.Optional[str] = None - """ - A short, human-readable summary of the problem type. - """ diff --git a/sumup/transactions/__init__.py b/sumup/transactions/__init__.py index ccf6f365..d0800589 100755 --- a/sumup/transactions/__init__.py +++ b/sumup/transactions/__init__.py @@ -11,30 +11,17 @@ ListTransactions200Response, ) from .types import ( - AmountEvent, CardResponse, - CardType, - Currency, - EntryMode, - Error, Event, - EventId, - EventStatus, - EventType, HorizontalAccuracy, Lat, Link, LinkRefund, Lon, - PaymentType, Product, - TimestampEvent, - TransactionBase, - TransactionCheckoutInfo, TransactionEvent, TransactionFull, TransactionHistory, - TransactionId, TransactionMixinHistory, ) @@ -49,29 +36,16 @@ "ListTransactionsParams", "ListTransactionsV21200Response", "ListTransactions200Response", - "AmountEvent", "CardResponse", - "CardType", - "Currency", - "EntryMode", - "Error", "Event", - "EventId", - "EventStatus", - "EventType", "HorizontalAccuracy", "Lat", "Link", "LinkRefund", "Lon", - "PaymentType", "Product", - "TimestampEvent", - "TransactionBase", - "TransactionCheckoutInfo", "TransactionEvent", "TransactionFull", "TransactionHistory", - "TransactionId", "TransactionMixinHistory", ] diff --git a/sumup/transactions/resource.py b/sumup/transactions/resource.py index 110c16ed..9cf6be38 100755 --- a/sumup/transactions/resource.py +++ b/sumup/transactions/resource.py @@ -1,9 +1,9 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. from .._service import Resource, AsyncResource, HeaderTypes from .._exceptions import APIError +from .. import _shared from .types import ( Link, - PaymentType, TransactionFull, TransactionHistory, ) @@ -72,7 +72,7 @@ class ListTransactionsV21Params(pydantic.BaseModel): order: typing.Optional[str] = None - payment_types: typing.Optional[list[PaymentType]] = None + payment_types: typing.Optional[list[_shared.PaymentType]] = None statuses: typing.Optional[list[str]] = None @@ -102,7 +102,7 @@ class ListTransactionsParams(pydantic.BaseModel): order: typing.Optional[str] = None - payment_types: typing.Optional[list[PaymentType]] = None + payment_types: typing.Optional[list[_shared.PaymentType]] = None statuses: typing.Optional[list[str]] = None diff --git a/sumup/transactions/types.py b/sumup/transactions/types.py index 450452a1..c787192f 100755 --- a/sumup/transactions/types.py +++ b/sumup/transactions/types.py @@ -1,174 +1,9 @@ # Code generated by `py-sdk-gen`. DO NOT EDIT. +from .. import _shared import datetime import typing import pydantic - -class Error(pydantic.BaseModel): - """ - Error message structure. - """ - - error_code: typing.Optional[str] = None - """ - Platform code for the error. - """ - - message: typing.Optional[str] = None - """ - Short description of the error. - """ - - -Currency = typing.Literal[ - "BGN", - "BRL", - "CHF", - "CLP", - "CZK", - "DKK", - "EUR", - "GBP", - "HRK", - "HUF", - "NOK", - "PLN", - "RON", - "SEK", - "USD", -] - -PaymentType = typing.Literal[ - "APM", - "BALANCE", - "BITCOIN", - "BOLETO", - "CASH", - "DIRECT_DEBIT", - "ECOM", - "MOTO", - "POS", - "RECURRING", - "UNKNOWN", -] - -TransactionBaseStatus = typing.Literal["CANCELLED", "FAILED", "PENDING", "SUCCESSFUL"] - - -class TransactionBase(pydantic.BaseModel): - """ - Details of the transaction. - """ - - amount: typing.Optional[float] = None - """ - Total amount of the transaction. - """ - - currency: typing.Optional[Currency] = None - """ - Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. - """ - - id: typing.Optional[str] = None - """ - Unique ID of the transaction. - """ - - installments_count: typing.Optional[int] = None - """ - Current number of the installment for deferred payments. - Min: 1 - """ - - payment_type: typing.Optional[PaymentType] = None - """ - Payment type used for the transaction. - """ - - status: typing.Optional[TransactionBaseStatus] = None - """ - Current status of the transaction. - """ - - timestamp: typing.Optional[datetime.datetime] = None - """ - Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. - """ - - transaction_code: typing.Optional[str] = None - """ - Transaction code returned by the acquirer/processing entity after processing the transaction. - """ - - -EntryMode = typing.Literal[ - "APPLE_PAY", - "BANCONTACT", - "BLIK", - "BOLETO", - "CHIP", - "CONTACTLESS", - "CONTACTLESS_MAGSTRIPE", - "CUSTOMER_ENTRY", - "DIRECT_DEBIT", - "EPS", - "GIROPAY", - "GOOGLE_PAY", - "IDEAL", - "MAGSTRIPE", - "MAGSTRIPE_FALLBACK", - "MANUAL_ENTRY", - "MOTO", - "MYBANK", - "N/A", - "NONE", - "P24", - "PAYPAL", - "PIX", - "QR_CODE_PIX", - "SATISPAY", - "SOFORT", -] - - -class TransactionCheckoutInfo(pydantic.BaseModel): - """ - TransactionCheckoutInfo is a schema definition. - """ - - auth_code: typing.Optional[str] = None - """ - Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments. - """ - - entry_mode: typing.Optional[EntryMode] = None - """ - Entry mode of the payment details. - """ - - internal_id: typing.Optional[int] = None - """ - Internal unique ID of the transaction on the SumUp platform. - Format: int64 - """ - - merchant_code: typing.Optional[str] = None - """ - Unique code of the registered merchant to whom the payment is made. - """ - - tip_amount: typing.Optional[float] = None - """ - Amount of the tip (out of the total transaction amount). - """ - - vat_amount: typing.Optional[float] = None - """ - Amount of the applicable VAT (out of the total transaction amount). - """ - - TransactionMixinHistoryPayoutPlan = typing.Literal[ "ACCELERATED_INSTALLMENT", "SINGLE_PAYMENT", "TRUE_INSTALLMENT" ] @@ -219,23 +54,6 @@ class TransactionMixinHistory(pydantic.BaseModel): Indication of the precision of the geographical position received from the payment terminal. """ -CardType = typing.Literal[ - "AMEX", - "CUP", - "DINERS", - "DISCOVER", - "ELO", - "ELV", - "HIPERCARD", - "JCB", - "MAESTRO", - "MASTERCARD", - "UNKNOWN", - "VISA", - "VISA_ELECTRON", - "VISA_VPAY", -] - class CardResponse(pydantic.BaseModel): """ @@ -250,7 +68,7 @@ class CardResponse(pydantic.BaseModel): Max length: 4 """ - type: typing.Optional[CardType] = None + type: typing.Optional[_shared.CardType] = None """ Issuing card network of the payment card used for the transaction. """ @@ -307,33 +125,12 @@ class Product(pydantic.BaseModel): """ -EventId = int -""" -Unique ID of the transaction event. -Format: int64 -""" - -EventType = typing.Literal["CHARGE_BACK", "PAYOUT", "PAYOUT_DEDUCTION", "REFUND"] - -EventStatus = typing.Literal["FAILED", "PAID_OUT", "PENDING", "REFUNDED", "SCHEDULED", "SUCCESSFUL"] - -AmountEvent = float -""" -Amount of the event. -""" - -TimestampEvent = str -""" -Date and time of the transaction event. -""" - - class TransactionEvent(pydantic.BaseModel): """ Details of a transaction event. """ - amount: typing.Optional[AmountEvent] = None + amount: typing.Optional[_shared.AmountEvent] = None """ Amount of the event. """ @@ -350,12 +147,12 @@ class TransactionEvent(pydantic.BaseModel): Format: date """ - event_type: typing.Optional[EventType] = None + event_type: typing.Optional[_shared.EventType] = None """ Type of the transaction event. """ - id: typing.Optional[EventId] = None + id: typing.Optional[_shared.EventId] = None """ Unique ID of the transaction event. Format: int64 @@ -366,12 +163,12 @@ class TransactionEvent(pydantic.BaseModel): Consecutive number of the installment that is paid. Applicable only payout events, i.e. `event_type = PAYOUT`. """ - status: typing.Optional[EventStatus] = None + status: typing.Optional[_shared.EventStatus] = None """ Status of the transaction event. """ - timestamp: typing.Optional[TimestampEvent] = None + timestamp: typing.Optional[_shared.TimestampEvent] = None """ Date and time of the transaction event. """ @@ -431,18 +228,12 @@ class LinkRefund(pydantic.BaseModel): """ -TransactionId = str -""" -Unique ID of the transaction. -""" - - class Event(pydantic.BaseModel): """ Event is a schema definition. """ - amount: typing.Optional[AmountEvent] = None + amount: typing.Optional[_shared.AmountEvent] = None """ Amount of the event. """ @@ -462,7 +253,7 @@ class Event(pydantic.BaseModel): Amount of the fee related to the event. """ - id: typing.Optional[EventId] = None + id: typing.Optional[_shared.EventId] = None """ Unique ID of the transaction event. Format: int64 @@ -473,22 +264,22 @@ class Event(pydantic.BaseModel): Consecutive number of the installment. """ - status: typing.Optional[EventStatus] = None + status: typing.Optional[_shared.EventStatus] = None """ Status of the transaction event. """ - timestamp: typing.Optional[TimestampEvent] = None + timestamp: typing.Optional[_shared.TimestampEvent] = None """ Date and time of the transaction event. """ - transaction_id: typing.Optional[TransactionId] = None + transaction_id: typing.Optional[_shared.TransactionId] = None """ Unique ID of the transaction. """ - type: typing.Optional[EventType] = None + type: typing.Optional[_shared.EventType] = None """ Type of the transaction event. """ @@ -574,12 +365,12 @@ class TransactionFull(pydantic.BaseModel): Details of the payment card. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ - entry_mode: typing.Optional[EntryMode] = None + entry_mode: typing.Optional[_shared.EntryMode] = None """ Entry mode of the payment details. """ @@ -647,7 +438,7 @@ class TransactionFull(pydantic.BaseModel): Unique code of the registered merchant to whom the payment is made. """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -763,7 +554,7 @@ class TransactionHistory(pydantic.BaseModel): Total amount of the transaction. """ - card_type: typing.Optional[CardType] = None + card_type: typing.Optional[_shared.CardType] = None """ Issuing card network of the payment card used for the transaction. """ @@ -773,7 +564,7 @@ class TransactionHistory(pydantic.BaseModel): Client-specific ID of the transaction. """ - currency: typing.Optional[Currency] = None + currency: typing.Optional[_shared.Currency] = None """ Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supportedcurrency values are enumerated above. """ @@ -789,7 +580,7 @@ class TransactionHistory(pydantic.BaseModel): Min: 1 """ - payment_type: typing.Optional[PaymentType] = None + payment_type: typing.Optional[_shared.PaymentType] = None """ Payment type used for the transaction. """ @@ -829,7 +620,7 @@ class TransactionHistory(pydantic.BaseModel): Transaction code returned by the acquirer/processing entity after processing the transaction. """ - transaction_id: typing.Optional[TransactionId] = None + transaction_id: typing.Optional[_shared.TransactionId] = None """ Unique ID of the transaction. """ diff --git a/uv.lock b/uv.lock index 43d46d65..b8899808 100644 --- a/uv.lock +++ b/uv.lock @@ -365,7 +365,7 @@ wheels = [ [[package]] name = "sumup" -version = "0.0.16" +version = "0.0.17" source = { virtual = "." } dependencies = [ { name = "httpx" },