From 0cfa88083799a2f792587333d54c5c10a8398383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Tue, 17 Nov 2026 15:21:51 +0100 Subject: [PATCH] refactor!: accept request bodies only through body keyword --- README.md | 22 ++++---- codegen/generator_test.go | 7 ++- codegen/resources.go | 43 +++------------ examples/card_reader_checkout.rb | 6 ++- examples/checkout.rb | 14 ++--- lib/sumup/pagination.rb | 6 +-- lib/sumup/resource.rb | 8 --- lib/sumup/resources/checkouts.rb | 52 ++++++++---------- lib/sumup/resources/customers.rb | 28 +++++----- lib/sumup/resources/members.rb | 28 +++++----- lib/sumup/resources/readers.rb | 80 ++++++++++++---------------- lib/sumup/resources/roles.rb | 28 +++++----- lib/sumup/resources/sales.rb | 14 +++-- lib/sumup/resources/tokens.rb | 14 +++-- lib/sumup/resources/transactions.rb | 10 ++-- sig/sumup.rbs | 4 +- sig/sumup/resources/checkouts.rbs | 8 --- sig/sumup/resources/customers.rbs | 4 -- sig/sumup/resources/members.rbs | 4 -- sig/sumup/resources/readers.rbs | 10 ---- sig/sumup/resources/roles.rbs | 4 -- sig/sumup/resources/sales.rbs | 2 - sig/sumup/resources/tokens.rbs | 2 - sig/sumup/resources/transactions.rbs | 2 - test/client_test.rb | 16 ++++-- test/pagination_test.rb | 11 +++- 26 files changed, 172 insertions(+), 255 deletions(-) diff --git a/README.md b/README.md index f012c40..d6a0605 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,14 @@ require "securerandom" client = SumUp::Client.new(api_key: ENV.fetch("SUMUP_API_KEY")) checkout = client.checkouts.create( - checkout_reference: SecureRandom.uuid, - amount: 19.99, - currency: "EUR", - merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), - description: "Order 1234", - hosted_checkout: {enabled: true} + body: { + checkout_reference: SecureRandom.uuid, + amount: 19.99, + currency: "EUR", + merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), + description: "Order 1234", + hosted_checkout: {enabled: true} + } ) puts checkout.id @@ -54,7 +56,7 @@ Send the customer to `hosted_checkout_url` to pay. Retrieve the checkout on your server to verify its status before fulfilling the order. Keep credentials on your server. Sandbox merchants use the same API URL as live merchants. -Request bodies accept keyword arguments, a Hash, or a model from `SumUp::Types`. +Pass request bodies through `body:` as a Hash or a model from `SumUp::Types`. Response fields are available as Ruby methods or through `object["field_name"]`; `to_h` preserves unknown fields and explicit nulls. RBS signatures are included. @@ -67,8 +69,10 @@ Use a paired reader and the credentials required by the result = client.readers.create_checkout( merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), reader_id: ENV.fetch("SUMUP_READER_ID"), - total_amount: {currency: "EUR", minor_unit: 2, value: 1999}, - description: "Order 1234" + body: { + total_amount: {currency: "EUR", minor_unit: 2, value: 1999}, + description: "Order 1234" + } ) puts result.data.client_transaction_id diff --git a/codegen/generator_test.go b/codegen/generator_test.go index 09be7cd..9a95776 100644 --- a/codegen/generator_test.go +++ b/codegen/generator_test.go @@ -148,7 +148,12 @@ func TestCurrentSpec(t *testing.T) { t.Fatal(err) } files := generatedFiles(t, g) - contains(t, files["sig/sumup/resources/readers.rbs"], "total_amount: Types::CreateReaderCheckoutRequestTotalAmount | Hash[Symbol | String, untyped]") + contains(t, files["sig/sumup/resources/readers.rbs"], "body: Types::CreateReaderCheckoutRequest | Hash[Symbol | String, untyped]") + refundSignature := files["sig/sumup/resources/transactions.rbs"] + contains(t, refundSignature, "?body: Types::RefundTransactionRequest | Hash[Symbol | String, untyped]") + if strings.Contains(refundSignature, "?amount:") { + t.Fatal("refund signature accepts body keywords") + } expected := []string{} for _, path := range asObject(spec.get("paths")) { for _, entry := range asObject(path.value) { diff --git a/codegen/resources.go b/codegen/resources.go index 7e18b98..2d6ad7b 100644 --- a/codegen/resources.go +++ b/codegen/resources.go @@ -41,9 +41,6 @@ func (g *generator) renderResource(tag string, entries []operation) string { args = append(args, "body: UNSET") } args = append(args, "options: nil") - if op.body != nil { - args = append(args, "**body_fields") - } for _, withResponse := range []bool{false, true} { name := op.name if withResponse { @@ -72,20 +69,17 @@ func (g *generator) renderResource(tag string, entries []operation) string { if len(headers) > 0 { fmt.Fprintf(&b, " options = merge_header_options(options, {%s})\n", strings.Join(headers, ", ")) } - if op.body != nil { - b.WriteString(" payload = request_body(body, body_fields)\n") - if op.bodyRequired { - if len(asArray(g.merged(op.body).get("required"))) == 0 { - b.WriteString(" payload = {} if payload.equal?(UNSET)\n") - } else { - b.WriteString(" raise ArgumentError, \"request body is required\" if payload.equal?(UNSET)\n") - } + if op.body != nil && op.bodyRequired { + if len(asArray(g.merged(op.body).get("required"))) == 0 { + b.WriteString(" body = {} if body.equal?(UNSET)\n") + } else { + b.WriteString(" raise ArgumentError, \"request body is required\" if body.equal?(UNSET)\n") } } fmt.Fprintf(&b, " @client.request(method: %s, path: \"%s\",\n", quote(op.verb), path) body := "" if op.body != nil { - body = "body: payload, " + body = "body: body, " } fmt.Fprintf(&b, " query: {%s}, %soptions: options,\n", strings.Join(query, ", "), body) types := []string{} @@ -129,7 +123,6 @@ func (g *generator) renderResourceRBS(tag string, entries []operation) string { typ := g.describe(asObject(p.get("schema")), constant(op.id)+constant(asString(p.get("name")))) args = append(args, optional+parameterName(p)+": "+typ.rbs(false)) } - withoutBody := slices.Clone(args) if op.body != nil { optional := "" if !op.bodyRequired { @@ -138,23 +131,6 @@ func (g *generator) renderResourceRBS(tag string, entries []operation) string { args = append(args, optional+"body: "+op.bodyType.rbs(true)) } args = append(args, "?options: request_options") - variants := [][]string{args} - if op.body != nil && g.isObject(op.body) { - bodyArgs := append(withoutBody, "?options: request_options") - name := constant(op.id) + "Request" - if op.bodyType.kind == "model" { - name = op.bodyType.name - } - required := stringsOf(g.merged(op.body).get("required")) - for _, p := range g.properties(op.body) { - optional := "?" - if slices.Contains(required, p.key) { - optional = "" - } - bodyArgs = append(bodyArgs, optional+fieldName(p.key)+": "+g.describe(asObject(p.value), name+constant(p.key)).rbs(true)) - } - variants = append(variants, bodyArgs) - } for _, withResponse := range []bool{false, true} { name := op.name result := op.responseType.rbs(false) @@ -162,12 +138,7 @@ func (g *generator) renderResourceRBS(tag string, entries []operation) string { name += "_with_response" result = "Response[" + result + "]" } - fmt.Fprintf(&b, " def %s: ", name) - rendered := []string{} - for _, v := range variants { - rendered = append(rendered, "("+strings.Join(v, ", ")+") -> "+result) - } - b.WriteString(strings.Join(rendered, "\n | ") + "\n") + fmt.Fprintf(&b, " def %s: (%s) -> %s\n", name, strings.Join(args, ", "), result) } } return b.String() + " end\n end\nend\n" diff --git a/examples/card_reader_checkout.rb b/examples/card_reader_checkout.rb index f45ffa5..6d6e170 100644 --- a/examples/card_reader_checkout.rb +++ b/examples/card_reader_checkout.rb @@ -6,8 +6,10 @@ result = client.readers.create_checkout( merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), reader_id: ENV.fetch("SUMUP_READER_ID"), - total_amount: {currency: "EUR", minor_unit: 2, value: 1999}, - description: "Ruby SDK example" + body: { + total_amount: {currency: "EUR", minor_unit: 2, value: 1999}, + description: "Ruby SDK example" + } ) puts "Reader checkout started: #{result.data.client_transaction_id}" diff --git a/examples/checkout.rb b/examples/checkout.rb index 6c3b587..ed4ccd3 100644 --- a/examples/checkout.rb +++ b/examples/checkout.rb @@ -5,12 +5,14 @@ client = SumUp::Client.new(api_key: ENV.fetch("SUMUP_API_KEY")) checkout = client.checkouts.create( - checkout_reference: SecureRandom.uuid, - amount: 19.99, - currency: "EUR", - merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), - description: "Ruby SDK example", - hosted_checkout: {enabled: true} + body: { + checkout_reference: SecureRandom.uuid, + amount: 19.99, + currency: "EUR", + merchant_code: ENV.fetch("SUMUP_MERCHANT_CODE"), + description: "Ruby SDK example", + hosted_checkout: {enabled: true} + } ) puts "Checkout: #{checkout.id}" diff --git a/lib/sumup/pagination.rb b/lib/sumup/pagination.rb index 00399d7..e00ce78 100644 --- a/lib/sumup/pagination.rb +++ b/lib/sumup/pagination.rb @@ -9,7 +9,8 @@ def each(**arguments, &block) each_token_page(:list, arguments) { |page| page.items.each(&block) } end - def search_each(**arguments, &block) + def search_each(merchant_code:, body: UNSET, options: nil, &block) + arguments = {merchant_code: merchant_code, body: body, options: options} return enum_for(__method__, **arguments) unless block each_token_page(:search, arguments) { |page| page.items.each(&block) } end @@ -19,11 +20,10 @@ def search_each(**arguments, &block) def each_token_page(method, arguments) arguments = arguments.dup if method == :search - payload = request_body(arguments.delete(:body) { UNSET }, arguments.except(:merchant_code, :options)) + payload = arguments[:body] payload = payload.to_h if payload.is_a?(Model) payload = {} if payload.equal?(UNSET) raise ArgumentError, "search body must be a Hash or Model" unless payload.is_a?(Hash) - arguments = arguments.slice(:merchant_code, :options) arguments[:body] = payload.transform_keys(&:to_s) end seen = Set.new diff --git a/lib/sumup/resource.rb b/lib/sumup/resource.rb index 45538b1..7955a30 100644 --- a/lib/sumup/resource.rb +++ b/lib/sumup/resource.rb @@ -17,14 +17,6 @@ def path_segment(value) URI.encode_www_form_component(value.to_s).gsub("+", "%20") end - def request_body(body, fields) - unless body.equal?(UNSET) - raise ArgumentError, "pass body or body keywords, not both" unless fields.empty? - return body - end - fields.empty? ? UNSET : fields - end - def merge_header_options(options, parameters) options = RequestOptions.new(**options) if options.is_a?(Hash) options ||= RequestOptions.new diff --git a/lib/sumup/resources/checkouts.rb b/lib/sumup/resources/checkouts.rb index 9c32958..63fee59 100644 --- a/lib/sumup/resources/checkouts.rb +++ b/lib/sumup/resources/checkouts.rb @@ -26,19 +26,17 @@ def list_available_payment_methods_with_response(merchant_code:, amount: UNSET, # # Complete the payment through [Hosted Checkout](https://developer.sumup.com/online-payments/checkouts/hosted-checkout/) or the [Payment Widget](https://developer.sumup.com/online-payments/checkouts/card-widget). # @return [Types::Checkout] - def create(body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/checkouts", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Checkout"]}, with_response: false) end - def create_with_response(body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/checkouts", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Checkout"]}, with_response: true) end @@ -74,19 +72,17 @@ def get_with_response(checkout_id:, options: nil) # # This request changes the checkout details; it does not charge a payment instrument. Process the checkout separately to attempt a payment. # @return [Types::Checkout] - def update(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update(checkout_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/checkouts/#{path_segment(checkout_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Checkout"]}, with_response: false) end - def update_with_response(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update_with_response(checkout_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/checkouts/#{path_segment(checkout_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Checkout"]}, with_response: true) end @@ -100,19 +96,17 @@ def update_with_response(checkout_id:, body: UNSET, options: nil, **body_fields) # # Retrieve the checkout afterwards to confirm its payment status. Acceptance of the processing request does not by itself mean the checkout is paid. # @return [(Types::CheckoutSuccess | Types::CheckoutAccepted)] - def process(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def process(checkout_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/checkouts/#{path_segment(checkout_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "CheckoutSuccess"], 202 => [:model, "CheckoutAccepted"]}, with_response: false) end - def process_with_response(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def process_with_response(checkout_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/checkouts/#{path_segment(checkout_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "CheckoutSuccess"], 202 => [:model, "CheckoutAccepted"]}, with_response: true) end @@ -137,17 +131,15 @@ def deactivate_with_response(checkout_id:, options: nil) # SumUp validates the merchant session request and returns the Apple Pay # session object that your frontend should pass to Apple's JavaScript API. # @return [Hash[String, untyped]] - def create_apple_pay_session(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def create_apple_pay_session(checkout_id:, body: UNSET, options: nil) @client.request(method: "PUT", path: "/v0.2/checkouts/#{path_segment(checkout_id)}/apple-pay-session", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:map, :any]}, with_response: false) end - def create_apple_pay_session_with_response(checkout_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def create_apple_pay_session_with_response(checkout_id:, body: UNSET, options: nil) @client.request(method: "PUT", path: "/v0.2/checkouts/#{path_segment(checkout_id)}/apple-pay-session", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:map, :any]}, with_response: true) end end diff --git a/lib/sumup/resources/customers.rb b/lib/sumup/resources/customers.rb index 9f0abb2..7981062 100644 --- a/lib/sumup/resources/customers.rb +++ b/lib/sumup/resources/customers.rb @@ -7,19 +7,17 @@ module Resources class Customers < Resource # Creates a customer using the `customer_id` you supply. Choose an identifier that maps to the payer in your own system and reuse it when retrieving the customer or associating checkouts and saved payment instruments with them. # @return [Types::Customer] - def create(body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/customers", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Customer"]}, with_response: false) end - def create_with_response(body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/customers", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Customer"]}, with_response: true) end @@ -41,19 +39,17 @@ def get_with_response(customer_id:, options: nil) # # The request only overwrites the parameters included in the request, all other parameters will remain with their initially assigned values. # @return [Types::Customer] - def update(customer_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update(customer_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/customers/#{path_segment(customer_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Customer"]}, with_response: false) end - def update_with_response(customer_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update_with_response(customer_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/customers/#{path_segment(customer_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Customer"]}, with_response: true) end diff --git a/lib/sumup/resources/members.rb b/lib/sumup/resources/members.rb index eb1997e..cd44cd0 100644 --- a/lib/sumup/resources/members.rb +++ b/lib/sumup/resources/members.rb @@ -24,19 +24,17 @@ def list_with_response(merchant_code:, offset: UNSET, limit: UNSET, scroll: UNSE # By default, sends an invitation email to the provided address. The recipient must accept the invitation to join the account. # When `is_managed_user` is `true`, creates a managed user with the provided password and optional nickname and assigns the roles directly, without sending an invitation. # @return [Types::Member] - def create(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/members", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Member"]}, with_response: false) end - def create_with_response(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/members", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Member"]}, with_response: true) end @@ -59,19 +57,17 @@ def get_with_response(merchant_code:, member_id:, options: nil) # Providing `roles` replaces the member's assigned roles and can grant or revoke access. Providing `metadata` replaces the entire metadata object. # For managed users, `user.nickname` changes the display name and `user.password` replaces the password. Updating the password also enables the managed user account. # @return [Types::Member] - def update(merchant_code:, member_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update(merchant_code:, member_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/merchants/#{path_segment(merchant_code)}/members/#{path_segment(member_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Member"]}, with_response: false) end - def update_with_response(merchant_code:, member_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update_with_response(merchant_code:, member_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PUT", path: "/v0.1/merchants/#{path_segment(merchant_code)}/members/#{path_segment(member_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Member"]}, with_response: true) end diff --git a/lib/sumup/resources/readers.rb b/lib/sumup/resources/readers.rb index 7d28151..f1ae48f 100644 --- a/lib/sumup/resources/readers.rb +++ b/lib/sumup/resources/readers.rb @@ -9,19 +9,17 @@ class Readers < Resource # # Use `client_transaction_id` as an idempotency key: retrying the request with the same value returns the result of the original payment instead of creating a duplicate. # @return [Types::ReaderPaymentResponse] - def create_go_checkout(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_go_checkout(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/go-checkout", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "ReaderPaymentResponse"]}, with_response: false) end - def create_go_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_go_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/go-checkout", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "ReaderPaymentResponse"]}, with_response: true) end @@ -41,19 +39,17 @@ def list_with_response(merchant_code:, options: nil) # Create a new Reader for the merchant account. # @return [Types::Reader] - def create(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Reader"]}, with_response: false) end - def create_with_response(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Reader"]}, with_response: true) end @@ -91,19 +87,17 @@ def delete_with_response(merchant_code:, reader_id:, options: nil) # # Providing `metadata` replaces the entire metadata object; include all entries that should be retained. Omitted fields remain unchanged. # @return [Types::Reader] - def update(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update(merchant_code:, reader_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Reader"]}, with_response: false) end - def update_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update_with_response(merchant_code:, reader_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Reader"]}, with_response: true) end @@ -123,19 +117,17 @@ def update_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, # Optionally include an `affiliate` object to attach integrator metadata to the payment. # Provide both `app_id` and `key` when including this object. # @return [Types::CreateReaderCheckoutResponse] - def create_checkout(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_checkout(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/checkout", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "CreateReaderCheckoutResponse"]}, with_response: false) end - def create_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/checkout", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "CreateReaderCheckoutResponse"]}, with_response: true) end @@ -201,19 +193,17 @@ def get_reader_settings_with_response(merchant_code:, reader_id:, options: nil) # When enabling menu lock for a reader without a PIN, include a four-digit PIN # in `menu_lock.passcode` in the same request. # @return [Types::UpdateReaderSettingsResponse] - def update_reader_settings(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def update_reader_settings(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/settings", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "UpdateReaderSettingsResponse"]}, with_response: false) end - def update_reader_settings_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def update_reader_settings_with_response(merchant_code:, reader_id:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/settings", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "UpdateReaderSettingsResponse"]}, with_response: true) end @@ -232,17 +222,15 @@ def update_reader_settings_with_response(merchant_code:, reader_id:, body: UNSET # # **Note**: If the target device is a Solo, it must be in version 3.3.28.0 or higher. # @return [untyped] - def terminate_checkout(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def terminate_checkout(merchant_code:, reader_id:, body: UNSET, options: nil) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/terminate", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {202 => :any}, with_response: false) end - def terminate_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def terminate_checkout_with_response(merchant_code:, reader_id:, body: UNSET, options: nil) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/readers/#{path_segment(reader_id)}/terminate", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {202 => :any}, with_response: true) end diff --git a/lib/sumup/resources/roles.rb b/lib/sumup/resources/roles.rb index e7cedc5..7146f69 100644 --- a/lib/sumup/resources/roles.rb +++ b/lib/sumup/resources/roles.rb @@ -21,19 +21,17 @@ def list_with_response(merchant_code:, options: nil) # Create a custom role for the merchant. Roles are defined by the set of permissions that they grant to the members that they are assigned to. # @return [Types::Role] - def create(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/roles", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Role"]}, with_response: false) end - def create_with_response(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/roles", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "Role"]}, with_response: true) end @@ -69,19 +67,17 @@ def delete_with_response(merchant_code:, role_id:, options: nil) # # Providing `permissions` replaces the role's permission list and changes the access granted to members assigned to that role. Omitted fields remain unchanged. # @return [Types::Role] - def update(merchant_code:, role_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update(merchant_code:, role_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/roles/#{path_segment(role_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Role"]}, with_response: false) end - def update_with_response(merchant_code:, role_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def update_with_response(merchant_code:, role_id:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "PATCH", path: "/v0.1/merchants/#{path_segment(merchant_code)}/roles/#{path_segment(role_id)}", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Role"]}, with_response: true) end end diff --git a/lib/sumup/resources/sales.rb b/lib/sumup/resources/sales.rb index c07edc3..150200c 100644 --- a/lib/sumup/resources/sales.rb +++ b/lib/sumup/resources/sales.rb @@ -31,19 +31,17 @@ def list_with_response(merchant_code:, pagination_token: UNSET, pagination_limit # (narrow further with `start_date` / `end_date`). Pagination tokens are not interchangeable # with `GET /sales`. # @return [Types::SaleSearchResponse] - def search(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def search(merchant_code:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "POST", path: "/v1.0/merchants/#{path_segment(merchant_code)}/sales/search", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "SaleSearchResponse"]}, with_response: false) end - def search_with_response(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - payload = {} if payload.equal?(UNSET) + def search_with_response(merchant_code:, body: UNSET, options: nil) + body = {} if body.equal?(UNSET) @client.request(method: "POST", path: "/v1.0/merchants/#{path_segment(merchant_code)}/sales/search", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "SaleSearchResponse"]}, with_response: true) end diff --git a/lib/sumup/resources/tokens.rb b/lib/sumup/resources/tokens.rb index ae129c1..fb3fb3b 100644 --- a/lib/sumup/resources/tokens.rb +++ b/lib/sumup/resources/tokens.rb @@ -11,19 +11,17 @@ class Tokens < Resource # # Pass the returned `access_token` to the SDK. The token expires 15 minutes after creation; use `expires_in` for its remaining lifetime. To continue after it expires, create a new token through this endpoint. # @return [Types::Token] - def create(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/tokens", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Token"]}, with_response: false) end - def create_with_response(merchant_code:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) - raise ArgumentError, "request body is required" if payload.equal?(UNSET) + def create_with_response(merchant_code:, body: UNSET, options: nil) + raise ArgumentError, "request body is required" if body.equal?(UNSET) @client.request(method: "POST", path: "/v0.1/merchants/#{path_segment(merchant_code)}/tokens", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {200 => [:model, "Token"]}, with_response: true) end end diff --git a/lib/sumup/resources/transactions.rb b/lib/sumup/resources/transactions.rb index fedb87d..5dc2eff 100644 --- a/lib/sumup/resources/transactions.rb +++ b/lib/sumup/resources/transactions.rb @@ -9,17 +9,15 @@ class Transactions < Resource # # Retrieve the transaction afterwards to inspect its refunded amount and refund events. The transaction must be eligible for a refund; see the error responses for invalid amounts, permissions, and processing failures. # @return [Types::RefundTransactionResponse] - def refund(merchant_code:, transaction_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def refund(merchant_code:, transaction_id:, body: UNSET, options: nil) @client.request(method: "POST", path: "/v1.0/merchants/#{path_segment(merchant_code)}/payments/#{path_segment(transaction_id)}/refunds", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "RefundTransactionResponse"]}, with_response: false) end - def refund_with_response(merchant_code:, transaction_id:, body: UNSET, options: nil, **body_fields) - payload = request_body(body, body_fields) + def refund_with_response(merchant_code:, transaction_id:, body: UNSET, options: nil) @client.request(method: "POST", path: "/v1.0/merchants/#{path_segment(merchant_code)}/payments/#{path_segment(transaction_id)}/refunds", - query: {}, body: payload, options: options, + query: {}, body: body, options: options, response_type: {201 => [:model, "RefundTransactionResponse"]}, with_response: true) end diff --git a/sig/sumup.rbs b/sig/sumup.rbs index 9608b41..ccb2646 100644 --- a/sig/sumup.rbs +++ b/sig/sumup.rbs @@ -164,8 +164,8 @@ module SumUp class Sales < Resource def each: (**untyped) -> Enumerator[Types::Sale, untyped] | (**untyped) { (Types::Sale) -> untyped } -> untyped - def search_each: (**untyped) -> Enumerator[Types::SaleSearchItem, untyped] - | (**untyped) { (Types::SaleSearchItem) -> untyped } -> untyped + def search_each: (merchant_code: String, ?body: Types::SaleSearchRequest | attributes, ?options: request_options) -> Enumerator[Types::SaleSearchItem, untyped] + | (merchant_code: String, ?body: Types::SaleSearchRequest | attributes, ?options: request_options) { (Types::SaleSearchItem) -> untyped } -> untyped end class Transactions < Resource def each: (**untyped) -> Enumerator[Types::TransactionHistory, untyped] diff --git a/sig/sumup/resources/checkouts.rbs b/sig/sumup/resources/checkouts.rbs index 4a14904..f5a9f67 100644 --- a/sig/sumup/resources/checkouts.rbs +++ b/sig/sumup/resources/checkouts.rbs @@ -9,27 +9,19 @@ module SumUp def list_available_payment_methods: (merchant_code: String, ?amount: Numeric, ?currency: String, ?options: request_options) -> Types::GetPaymentMethodsResponse def list_available_payment_methods_with_response: (merchant_code: String, ?amount: Numeric, ?currency: String, ?options: request_options) -> Response[Types::GetPaymentMethodsResponse] def create: (body: Types::CheckoutCreateRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Checkout - | (?options: request_options, checkout_reference: String, amount: Numeric, currency: String, merchant_code: String, ?description: String, ?return_url: String, ?customer_id: String, ?purpose: String, ?valid_until: (String | nil), ?redirect_url: String, ?hosted_checkout: Types::HostedCheckout | Hash[Symbol | String, untyped]) -> Types::Checkout def create_with_response: (body: Types::CheckoutCreateRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Checkout] - | (?options: request_options, checkout_reference: String, amount: Numeric, currency: String, merchant_code: String, ?description: String, ?return_url: String, ?customer_id: String, ?purpose: String, ?valid_until: (String | nil), ?redirect_url: String, ?hosted_checkout: Types::HostedCheckout | Hash[Symbol | String, untyped]) -> Response[Types::Checkout] def list: (?checkout_reference: String, ?options: request_options) -> Array[Types::CheckoutSuccess] def list_with_response: (?checkout_reference: String, ?options: request_options) -> Response[Array[Types::CheckoutSuccess]] def get: (checkout_id: String, ?options: request_options) -> Types::CheckoutSuccess def get_with_response: (checkout_id: String, ?options: request_options) -> Response[Types::CheckoutSuccess] def update: (checkout_id: String, body: Types::CheckoutUpdateRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Checkout - | (checkout_id: String, ?options: request_options, ?amount: Numeric, ?currency: String, ?description: String, ?checkout_reference: String, ?valid_until: (String | nil), ?customer_id: String) -> Types::Checkout def update_with_response: (checkout_id: String, body: Types::CheckoutUpdateRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Checkout] - | (checkout_id: String, ?options: request_options, ?amount: Numeric, ?currency: String, ?description: String, ?checkout_reference: String, ?valid_until: (String | nil), ?customer_id: String) -> Response[Types::Checkout] def process: (checkout_id: String, body: Types::ProcessCheckout | Hash[Symbol | String, untyped], ?options: request_options) -> (Types::CheckoutSuccess | Types::CheckoutAccepted) - | (checkout_id: String, ?options: request_options, payment_type: String, ?installments: Integer, ?mandate: Types::MandatePayload | Hash[Symbol | String, untyped], ?card: Types::Card | Hash[Symbol | String, untyped], ?google_pay: Hash[Symbol | String, untyped], ?apple_pay: Hash[Symbol | String, untyped], ?token: String, ?customer_id: String, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> (Types::CheckoutSuccess | Types::CheckoutAccepted) def process_with_response: (checkout_id: String, body: Types::ProcessCheckout | Hash[Symbol | String, untyped], ?options: request_options) -> Response[(Types::CheckoutSuccess | Types::CheckoutAccepted)] - | (checkout_id: String, ?options: request_options, payment_type: String, ?installments: Integer, ?mandate: Types::MandatePayload | Hash[Symbol | String, untyped], ?card: Types::Card | Hash[Symbol | String, untyped], ?google_pay: Hash[Symbol | String, untyped], ?apple_pay: Hash[Symbol | String, untyped], ?token: String, ?customer_id: String, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> Response[(Types::CheckoutSuccess | Types::CheckoutAccepted)] def deactivate: (checkout_id: String, ?options: request_options) -> Types::Checkout def deactivate_with_response: (checkout_id: String, ?options: request_options) -> Response[Types::Checkout] def create_apple_pay_session: (checkout_id: String, ?body: Types::CreateApplePaySessionRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Hash[String, untyped] - | (checkout_id: String, ?options: request_options, context: String, target: String) -> Hash[String, untyped] def create_apple_pay_session_with_response: (checkout_id: String, ?body: Types::CreateApplePaySessionRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Hash[String, untyped]] - | (checkout_id: String, ?options: request_options, context: String, target: String) -> Response[Hash[String, untyped]] end end end diff --git a/sig/sumup/resources/customers.rbs b/sig/sumup/resources/customers.rbs index 172ce69..0b8217c 100644 --- a/sig/sumup/resources/customers.rbs +++ b/sig/sumup/resources/customers.rbs @@ -7,15 +7,11 @@ module SumUp module Resources class Customers < Resource def create: (body: Types::Customer | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Customer - | (?options: request_options, customer_id: String, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> Types::Customer def create_with_response: (body: Types::Customer | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Customer] - | (?options: request_options, customer_id: String, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> Response[Types::Customer] def get: (customer_id: String, ?options: request_options) -> Types::Customer def get_with_response: (customer_id: String, ?options: request_options) -> Response[Types::Customer] def update: (customer_id: String, body: Types::UpdateCustomerRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Customer - | (customer_id: String, ?options: request_options, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> Types::Customer def update_with_response: (customer_id: String, body: Types::UpdateCustomerRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Customer] - | (customer_id: String, ?options: request_options, ?personal_details: Types::PersonalDetails | Hash[Symbol | String, untyped]) -> Response[Types::Customer] def list_payment_instruments: (customer_id: String, ?options: request_options) -> Array[Types::PaymentInstrumentResponse] def list_payment_instruments_with_response: (customer_id: String, ?options: request_options) -> Response[Array[Types::PaymentInstrumentResponse]] def deactivate_payment_instrument: (customer_id: String, token: String, ?options: request_options) -> nil diff --git a/sig/sumup/resources/members.rbs b/sig/sumup/resources/members.rbs index 99a0d0d..1841532 100644 --- a/sig/sumup/resources/members.rbs +++ b/sig/sumup/resources/members.rbs @@ -9,15 +9,11 @@ module SumUp def list: (merchant_code: String, ?offset: Integer, ?limit: Integer, ?scroll: bool, ?email: String, ?user_id: String, ?status: String, ?roles: Array[String], ?options: request_options) -> Types::ListMerchantMembersResponse def list_with_response: (merchant_code: String, ?offset: Integer, ?limit: Integer, ?scroll: bool, ?email: String, ?user_id: String, ?status: String, ?roles: Array[String], ?options: request_options) -> Response[Types::ListMerchantMembersResponse] def create: (merchant_code: String, body: Types::CreateMerchantMemberRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Member - | (merchant_code: String, ?options: request_options, ?is_managed_user: bool, email: String, ?password: String, ?nickname: String, roles: Array[String], ?metadata: Hash[Symbol | String, untyped], ?attributes: Hash[Symbol | String, untyped]) -> Types::Member def create_with_response: (merchant_code: String, body: Types::CreateMerchantMemberRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Member] - | (merchant_code: String, ?options: request_options, ?is_managed_user: bool, email: String, ?password: String, ?nickname: String, roles: Array[String], ?metadata: Hash[Symbol | String, untyped], ?attributes: Hash[Symbol | String, untyped]) -> Response[Types::Member] def get: (merchant_code: String, member_id: String, ?options: request_options) -> Types::Member def get_with_response: (merchant_code: String, member_id: String, ?options: request_options) -> Response[Types::Member] def update: (merchant_code: String, member_id: String, body: Types::UpdateMerchantMemberRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Member - | (merchant_code: String, member_id: String, ?options: request_options, ?roles: Array[String], ?metadata: Hash[Symbol | String, untyped], ?attributes: Hash[Symbol | String, untyped], ?user: Types::UpdateMerchantMemberRequestUser | Hash[Symbol | String, untyped]) -> Types::Member def update_with_response: (merchant_code: String, member_id: String, body: Types::UpdateMerchantMemberRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Member] - | (merchant_code: String, member_id: String, ?options: request_options, ?roles: Array[String], ?metadata: Hash[Symbol | String, untyped], ?attributes: Hash[Symbol | String, untyped], ?user: Types::UpdateMerchantMemberRequestUser | Hash[Symbol | String, untyped]) -> Response[Types::Member] def delete: (merchant_code: String, member_id: String, ?options: request_options) -> nil def delete_with_response: (merchant_code: String, member_id: String, ?options: request_options) -> Response[nil] end diff --git a/sig/sumup/resources/readers.rbs b/sig/sumup/resources/readers.rbs index a1177d1..7d96112 100644 --- a/sig/sumup/resources/readers.rbs +++ b/sig/sumup/resources/readers.rbs @@ -7,35 +7,25 @@ module SumUp module Resources class Readers < Resource def create_go_checkout: (merchant_code: String, reader_id: String, body: Types::ReaderPaymentRequestParams | Hash[Symbol | String, untyped], ?options: request_options) -> Types::ReaderPaymentResponse - | (merchant_code: String, reader_id: String, ?options: request_options, ?affiliate: Types::ReaderPaymentRequestParamsAffiliate | Hash[Symbol | String, untyped], client_transaction_id: String, ?tip_amount: Integer, total_amount: Types::ReaderPaymentRequestParamsTotalAmount | Hash[Symbol | String, untyped]) -> Types::ReaderPaymentResponse def create_go_checkout_with_response: (merchant_code: String, reader_id: String, body: Types::ReaderPaymentRequestParams | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::ReaderPaymentResponse] - | (merchant_code: String, reader_id: String, ?options: request_options, ?affiliate: Types::ReaderPaymentRequestParamsAffiliate | Hash[Symbol | String, untyped], client_transaction_id: String, ?tip_amount: Integer, total_amount: Types::ReaderPaymentRequestParamsTotalAmount | Hash[Symbol | String, untyped]) -> Response[Types::ReaderPaymentResponse] def list: (merchant_code: String, ?options: request_options) -> Types::ListReadersResponse def list_with_response: (merchant_code: String, ?options: request_options) -> Response[Types::ListReadersResponse] def create: (merchant_code: String, body: Types::CreateReaderRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Reader - | (merchant_code: String, ?options: request_options, pairing_code: String, name: String, ?metadata: Hash[Symbol | String, untyped]) -> Types::Reader def create_with_response: (merchant_code: String, body: Types::CreateReaderRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Reader] - | (merchant_code: String, ?options: request_options, pairing_code: String, name: String, ?metadata: Hash[Symbol | String, untyped]) -> Response[Types::Reader] def get: (merchant_code: String, reader_id: String, ?if_modified_since: (String), ?options: request_options) -> Types::Reader def get_with_response: (merchant_code: String, reader_id: String, ?if_modified_since: (String), ?options: request_options) -> Response[Types::Reader] def delete: (merchant_code: String, reader_id: String, ?options: request_options) -> nil def delete_with_response: (merchant_code: String, reader_id: String, ?options: request_options) -> Response[nil] def update: (merchant_code: String, reader_id: String, body: Types::UpdateReaderRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Reader - | (merchant_code: String, reader_id: String, ?options: request_options, ?name: String, ?metadata: Hash[Symbol | String, untyped]) -> Types::Reader def update_with_response: (merchant_code: String, reader_id: String, body: Types::UpdateReaderRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Reader] - | (merchant_code: String, reader_id: String, ?options: request_options, ?name: String, ?metadata: Hash[Symbol | String, untyped]) -> Response[Types::Reader] def create_checkout: (merchant_code: String, reader_id: String, body: Types::CreateReaderCheckoutRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::CreateReaderCheckoutResponse - | (merchant_code: String, reader_id: String, ?options: request_options, ?aade: Types::CreateReaderCheckoutRequestAade | Hash[Symbol | String, untyped], ?affiliate: (Types::CreateReaderCheckoutRequestAffiliate | Hash[Symbol | String, untyped] | nil), ?card_type: String, ?description: String, ?installments: (Integer | nil), ?payment_type: String, ?return_url: String, ?tip_rates: Array[Numeric], ?tip_timeout: Integer, total_amount: Types::CreateReaderCheckoutRequestTotalAmount | Hash[Symbol | String, untyped]) -> Types::CreateReaderCheckoutResponse def create_checkout_with_response: (merchant_code: String, reader_id: String, body: Types::CreateReaderCheckoutRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::CreateReaderCheckoutResponse] - | (merchant_code: String, reader_id: String, ?options: request_options, ?aade: Types::CreateReaderCheckoutRequestAade | Hash[Symbol | String, untyped], ?affiliate: (Types::CreateReaderCheckoutRequestAffiliate | Hash[Symbol | String, untyped] | nil), ?card_type: String, ?description: String, ?installments: (Integer | nil), ?payment_type: String, ?return_url: String, ?tip_rates: Array[Numeric], ?tip_timeout: Integer, total_amount: Types::CreateReaderCheckoutRequestTotalAmount | Hash[Symbol | String, untyped]) -> Response[Types::CreateReaderCheckoutResponse] def get_status: (merchant_code: String, reader_id: String, ?options: request_options) -> Types::StatusResponse def get_status_with_response: (merchant_code: String, reader_id: String, ?options: request_options) -> Response[Types::StatusResponse] def get_reader_settings: (merchant_code: String, reader_id: String, ?options: request_options) -> Types::GetReaderSettingsResponse def get_reader_settings_with_response: (merchant_code: String, reader_id: String, ?options: request_options) -> Response[Types::GetReaderSettingsResponse] def update_reader_settings: (merchant_code: String, reader_id: String, body: Types::UpdateReaderSettingsRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::UpdateReaderSettingsResponse - | (merchant_code: String, reader_id: String, ?options: request_options, menu_lock: Types::UpdateReaderSettingsRequestMenuLock | Hash[Symbol | String, untyped]) -> Types::UpdateReaderSettingsResponse def update_reader_settings_with_response: (merchant_code: String, reader_id: String, body: Types::UpdateReaderSettingsRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::UpdateReaderSettingsResponse] - | (merchant_code: String, reader_id: String, ?options: request_options, menu_lock: Types::UpdateReaderSettingsRequestMenuLock | Hash[Symbol | String, untyped]) -> Response[Types::UpdateReaderSettingsResponse] def terminate_checkout: (merchant_code: String, reader_id: String, ?body: untyped, ?options: request_options) -> untyped def terminate_checkout_with_response: (merchant_code: String, reader_id: String, ?body: untyped, ?options: request_options) -> Response[untyped] def get_checkout: (merchant_code: String, reader_id: String, checkout_id: String, ?options: request_options) -> Types::GetReaderCheckoutResponse diff --git a/sig/sumup/resources/roles.rbs b/sig/sumup/resources/roles.rbs index 7e3a500..7d0304c 100644 --- a/sig/sumup/resources/roles.rbs +++ b/sig/sumup/resources/roles.rbs @@ -9,17 +9,13 @@ module SumUp def list: (merchant_code: String, ?options: request_options) -> Types::ListMerchantRolesResponse def list_with_response: (merchant_code: String, ?options: request_options) -> Response[Types::ListMerchantRolesResponse] def create: (merchant_code: String, body: Types::CreateMerchantRoleRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Role - | (merchant_code: String, ?options: request_options, name: String, permissions: Array[String], ?metadata: Hash[Symbol | String, untyped], ?description: String) -> Types::Role def create_with_response: (merchant_code: String, body: Types::CreateMerchantRoleRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Role] - | (merchant_code: String, ?options: request_options, name: String, permissions: Array[String], ?metadata: Hash[Symbol | String, untyped], ?description: String) -> Response[Types::Role] def get: (merchant_code: String, role_id: String, ?options: request_options) -> Types::Role def get_with_response: (merchant_code: String, role_id: String, ?options: request_options) -> Response[Types::Role] def delete: (merchant_code: String, role_id: String, ?options: request_options) -> nil def delete_with_response: (merchant_code: String, role_id: String, ?options: request_options) -> Response[nil] def update: (merchant_code: String, role_id: String, body: Types::UpdateMerchantRoleRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Role - | (merchant_code: String, role_id: String, ?options: request_options, ?name: String, ?permissions: Array[String], ?description: String) -> Types::Role def update_with_response: (merchant_code: String, role_id: String, body: Types::UpdateMerchantRoleRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Role] - | (merchant_code: String, role_id: String, ?options: request_options, ?name: String, ?permissions: Array[String], ?description: String) -> Response[Types::Role] end end end diff --git a/sig/sumup/resources/sales.rbs b/sig/sumup/resources/sales.rbs index ab64821..f7f6879 100644 --- a/sig/sumup/resources/sales.rbs +++ b/sig/sumup/resources/sales.rbs @@ -9,9 +9,7 @@ module SumUp def list: (merchant_code: String, ?pagination_token: String, ?pagination_limit: Integer, ?options: request_options) -> Types::SalePage def list_with_response: (merchant_code: String, ?pagination_token: String, ?pagination_limit: Integer, ?options: request_options) -> Response[Types::SalePage] def search: (merchant_code: String, body: Types::SaleSearchRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::SaleSearchResponse - | (merchant_code: String, ?options: request_options, ?start_date: String, ?end_date: String, ?sale_statuses: Array[String], ?payment_statuses: Array[String], ?sales_channels: Array[String], ?pagination_token: String, ?pagination_limit: Integer) -> Types::SaleSearchResponse def search_with_response: (merchant_code: String, body: Types::SaleSearchRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::SaleSearchResponse] - | (merchant_code: String, ?options: request_options, ?start_date: String, ?end_date: String, ?sale_statuses: Array[String], ?payment_statuses: Array[String], ?sales_channels: Array[String], ?pagination_token: String, ?pagination_limit: Integer) -> Response[Types::SaleSearchResponse] def get: (merchant_code: String, sale_id: String, ?options: request_options) -> Types::Sale def get_with_response: (merchant_code: String, sale_id: String, ?options: request_options) -> Response[Types::Sale] end diff --git a/sig/sumup/resources/tokens.rbs b/sig/sumup/resources/tokens.rbs index 0f933ea..a8fe424 100644 --- a/sig/sumup/resources/tokens.rbs +++ b/sig/sumup/resources/tokens.rbs @@ -7,9 +7,7 @@ module SumUp module Resources class Tokens < Resource def create: (merchant_code: String, body: Types::CreateMerchantTokenRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::Token - | (merchant_code: String, ?options: request_options, actions: Array[String]) -> Types::Token def create_with_response: (merchant_code: String, body: Types::CreateMerchantTokenRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::Token] - | (merchant_code: String, ?options: request_options, actions: Array[String]) -> Response[Types::Token] end end end diff --git a/sig/sumup/resources/transactions.rbs b/sig/sumup/resources/transactions.rbs index 1ebdc59..63d5a7a 100644 --- a/sig/sumup/resources/transactions.rbs +++ b/sig/sumup/resources/transactions.rbs @@ -7,9 +7,7 @@ module SumUp module Resources class Transactions < Resource def refund: (merchant_code: String, transaction_id: String, ?body: Types::RefundTransactionRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Types::RefundTransactionResponse - | (merchant_code: String, transaction_id: String, ?options: request_options, ?amount: Numeric) -> Types::RefundTransactionResponse def refund_with_response: (merchant_code: String, transaction_id: String, ?body: Types::RefundTransactionRequest | Hash[Symbol | String, untyped], ?options: request_options) -> Response[Types::RefundTransactionResponse] - | (merchant_code: String, transaction_id: String, ?options: request_options, ?amount: Numeric) -> Response[Types::RefundTransactionResponse] def get: (merchant_code: String, ?id: String, ?transaction_code: String, ?foreign_transaction_id: String, ?client_transaction_id: String, ?options: request_options) -> Types::TransactionFull def get_with_response: (merchant_code: String, ?id: String, ?transaction_code: String, ?foreign_transaction_id: String, ?client_transaction_id: String, ?options: request_options) -> Response[Types::TransactionFull] def list: (merchant_code: String, ?transaction_code: String, ?order: String, ?limit: Integer, ?users: Array[String], ?statuses: Array[String], ?payment_types: Array[String], ?entry_modes: Array[String], ?types: Array[String], ?changes_since: String, ?newest_time: String, ?newest_ref: String, ?oldest_time: String, ?oldest_ref: String, ?options: request_options) -> Types::ListTransactionsV21Response diff --git a/test/client_test.rb b/test/client_test.rb index 7d4f63b..d96bdc9 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -5,7 +5,7 @@ class ClientTest < Minitest::Test def test_checkout_creation_uses_bearer_auth_and_typed_response client = build_client(json_response({"id" => "checkout_1", "status" => "PENDING", "new_field" => false}, status: 201)) - result = client.checkouts.create(amount: 10.5, currency: "EUR", merchant_code: "M123", checkout_reference: "order-1") + result = client.checkouts.create(body: {amount: 10.5, currency: "EUR", merchant_code: "M123", checkout_reference: "order-1"}) assert_instance_of SumUp::Types::Checkout, result assert_equal "checkout_1", result.id assert_equal false, result["new_field"] @@ -24,12 +24,20 @@ def test_model_request_body_retains_explicit_null assert_equal({"valid_until" => nil}, JSON.parse(@transport.requests.last.body)) end - def test_body_and_keywords_are_mutually_exclusive + def test_body_keywords_are_rejected client = build_client - assert_raises(ArgumentError) { client.checkouts.create(body: {}, amount: 1) } + [:refund, :refund_with_response].each do |method| + assert_raises(ArgumentError) { client.transactions.public_send(method, merchant_code: "M123", transaction_id: "one", amount: 1) } + end assert_empty @transport.requests end + def test_refund_body_keeps_unknown_fields_and_explicit_nulls + client = build_client(json_response({}, status: 201)) + client.transactions.refund_with_response(merchant_code: "M123", transaction_id: "one", body: {"amount" => 1, "future_field" => nil}) + assert_equal({"amount" => 1, "future_field" => nil}, JSON.parse(@transport.requests.last.body)) + end + def test_missing_required_body_fails_before_a_request client = build_client assert_raises(ArgumentError) { client.checkouts.create } @@ -110,7 +118,7 @@ def test_empty_response_is_nil def test_success_status_selects_the_corresponding_checkout_model client = build_client(json_response({"next_step" => {"url" => "https://example.com", "method" => "POST"}}, status: 202)) - result = client.checkouts.process(checkout_id: "one", payment_type: "card") + result = client.checkouts.process(checkout_id: "one", body: {payment_type: "card"}) assert_instance_of SumUp::Types::CheckoutAccepted, result assert_equal "POST", result.next_step.method_value end diff --git a/test/pagination_test.rb b/test/pagination_test.rb index b416234..776765d 100644 --- a/test/pagination_test.rb +++ b/test/pagination_test.rb @@ -19,12 +19,19 @@ def test_search_pagination_keeps_filters_and_does_not_mutate_input refute body.key?(:pagination_token) end - def test_search_pagination_accepts_body_keywords + def test_search_pagination_accepts_a_request_model client = build_client(json_response({"items" => []})) - assert_empty client.sales.search_each(merchant_code: "M123", start_date: "2026-01-01").to_a + body = SumUp::Types::SaleSearchRequest.new(start_date: "2026-01-01") + assert_empty client.sales.search_each(merchant_code: "M123", body: body).to_a assert_equal({"start_date" => "2026-01-01"}, JSON.parse(@transport.requests.last.body)) end + def test_search_pagination_rejects_body_keywords + client = build_client + assert_raises(ArgumentError) { client.sales.search_each(merchant_code: "M123", start_date: "2026-01-01").to_a } + assert_empty @transport.requests + end + def test_repeated_tokens_do_not_loop_forever response = json_response({"items" => [], "pagination_token" => "same"}) client = build_client(response, response)