diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b56c3d0b..e8285b71 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.4" + ".": "0.1.0-alpha.5" } \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 343956e1..f5e73346 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -202,6 +202,9 @@ Style/MethodCallWithArgsParentheses: Exclude: - "**/*.gemspec" +Style/MultilineBlockChain: + Enabled: false + # Perfectly fine. Style/MultipleComparison: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b23828..9ca3cfdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.1.0-alpha.5 (2025-04-05) + +Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.4...v0.1.0-alpha.5) + +### Features + +* allow all valid `JSON` types to be encoded ([#26](https://github.com/Increase/increase-ruby/issues/26)) ([92760b3](https://github.com/Increase/increase-ruby/commit/92760b3aba92abca8c6b4d6550d75b94c1a8fbc2)) +* support query, header, and body params that have identical names ([#25](https://github.com/Increase/increase-ruby/issues/25)) ([def73dd](https://github.com/Increase/increase-ruby/commit/def73dd349fa2aec3074e16bdfa2a165bf4fc1e1)) + + +### Bug Fixes + +* converter should transform stringio into string where applicable ([#28](https://github.com/Increase/increase-ruby/issues/28)) ([68e4e9d](https://github.com/Increase/increase-ruby/commit/68e4e9df4a5938442eb890da6f1918f04d34e333)) + + +### Chores + +* document LSP support in read me ([#24](https://github.com/Increase/increase-ruby/issues/24)) ([778538d](https://github.com/Increase/increase-ruby/commit/778538da18c49156d45c68c9370c3628fd7e594a)) +* **internal:** version bump ([#19](https://github.com/Increase/increase-ruby/issues/19)) ([fd9e8ad](https://github.com/Increase/increase-ruby/commit/fd9e8ada315a49377dbb2aa8ec6af48a180fb651)) +* misc sdk polish ([#23](https://github.com/Increase/increase-ruby/issues/23)) ([e056d8a](https://github.com/Increase/increase-ruby/commit/e056d8a96d3da4568daf30d68f980a81c69ab5dc)) +* rename confusing `Type::BooleanModel` to `Type::Boolean` ([#27](https://github.com/Increase/increase-ruby/issues/27)) ([ae0a5ee](https://github.com/Increase/increase-ruby/commit/ae0a5ee0e1c0177ab6aa08032f29655b5412b37d)) +* simplify internal utils ([#22](https://github.com/Increase/increase-ruby/issues/22)) ([da6ec29](https://github.com/Increase/increase-ruby/commit/da6ec29d5dd5ad6bfea0f3461221f3a80259738d)) + ## 0.1.0-alpha.4 (2025-04-04) Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) diff --git a/Gemfile.lock b/Gemfile.lock index b44278ff..d85a64f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - increase (0.1.0.pre.alpha.4) + increase (0.1.0.pre.alpha.5) connection_pool GEM diff --git a/README.md b/README.md index bd55470d..21134914 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "increase", "~> 0.1.0.pre.alpha.3" +gem "increase", "~> 0.1.0.pre.alpha.4" ``` @@ -140,9 +140,23 @@ increase.accounts.create( ## LSP Support -### Sorbet +### Solargraph + +This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition. + +```ruby +gem "solargraph", group: :development +``` + +After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal: + +```sh +bundle exec solargraph gems +``` -**This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality. +Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries. + +### Sorbet This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`. @@ -153,15 +167,21 @@ Due to limitations with the Sorbet type system, where a method otherwise can tak Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience. ```ruby -model = Increase::Models::AccountCreateParams.new( +params = Increase::Models::AccountCreateParams.new( name: "New Account!", entity_id: "entity_n8y8tnk2p9339ti393yi", program_id: "program_i2v2os4mwza1oetokh9i" ) -increase.accounts.create(**model) +increase.accounts.create(**params) ``` +Note: **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality. + +### Ruby LSP + +The Ruby LSP has [best effort support](https://shopify.github.io/ruby-lsp/#guessed-types) for inferring type information from Ruby code, and as such it may not always be able to provide accurate type information. + ## Advanced ### Making custom/undocumented requests diff --git a/lib/increase.rb b/lib/increase.rb index 04569a17..bb4ab646 100644 --- a/lib/increase.rb +++ b/lib/increase.rb @@ -39,7 +39,7 @@ require_relative "increase/internal/util" require_relative "increase/internal/type/converter" require_relative "increase/internal/type/unknown" -require_relative "increase/internal/type/boolean_model" +require_relative "increase/internal/type/boolean" require_relative "increase/internal/type/enum" require_relative "increase/internal/type/union" require_relative "increase/internal/type/array_of" diff --git a/lib/increase/internal/type/base_model.rb b/lib/increase/internal/type/base_model.rb index cedae18f..d94f5736 100644 --- a/lib/increase/internal/type/base_model.rb +++ b/lib/increase/internal/type/base_model.rb @@ -175,7 +175,9 @@ def optional(name_sym, type_info, spec = {}) # @param other [Object] # # @return [Boolean] - def ==(other) = other.is_a?(Class) && other <= Increase::Internal::Type::BaseModel && other.fields == fields + def ==(other) + other.is_a?(Class) && other <= Increase::Internal::Type::BaseModel && other.fields == fields + end end # @param other [Object] @@ -263,6 +265,7 @@ def dump(value) return super end + is_param = singleton_class <= Increase::Internal::Type::RequestParameters::Converter acc = {} coerced.each do |key, val| @@ -271,19 +274,21 @@ def dump(value) in nil acc.store(name, super(val)) else - mode, api_name, type_fn = field.fetch_values(:mode, :api_name, :type_fn) + mode, type_fn = field.fetch_values(:mode, :type_fn) case mode in :coerce next else target = type_fn.call + api_name = is_param ? name : field.fetch(:api_name) acc.store(api_name, Increase::Internal::Type::Converter.dump(target, val)) end end end - known_fields.each_value do |field| - mode, api_name, const = field.fetch_values(:mode, :api_name, :const) + known_fields.each do |name, field| + mode, const = field.fetch_values(:mode, :const) + api_name = is_param ? name : field.fetch(:api_name) next if mode == :coerce || acc.key?(api_name) || const == Increase::Internal::OMIT acc.store(api_name, const) end @@ -357,7 +362,8 @@ def initialize(data = {}) in Hash => coerced @data = coerced else - raise ArgumentError.new("Expected a #{Hash} or #{Increase::Internal::Type::BaseModel}, got #{data.inspect}") + message = "Expected a #{Hash} or #{Increase::Internal::Type::BaseModel}, got #{data.inspect}" + raise ArgumentError.new(message) end end @@ -365,7 +371,7 @@ def initialize(data = {}) def inspect rows = self.class.known_fields.keys.map do "#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}" - rescue Increase::ConversionError + rescue Increase::Errors::ConversionError "#{_1}=#{@data.fetch(_1)}" end "#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>" diff --git a/lib/increase/internal/type/boolean_model.rb b/lib/increase/internal/type/boolean.rb similarity index 95% rename from lib/increase/internal/type/boolean_model.rb rename to lib/increase/internal/type/boolean.rb index bce2ef7b..e82e636f 100644 --- a/lib/increase/internal/type/boolean_model.rb +++ b/lib/increase/internal/type/boolean.rb @@ -8,7 +8,7 @@ module Type # @abstract # # Ruby has no Boolean class; this is something for models to refer to. - class BooleanModel + class Boolean extend Increase::Internal::Type::Converter # @param other [Object] @@ -19,7 +19,7 @@ def self.===(other) = other == true || other == false # @param other [Object] # # @return [Boolean] - def self.==(other) = other.is_a?(Class) && other <= Increase::Internal::Type::BooleanModel + def self.==(other) = other.is_a?(Class) && other <= Increase::Internal::Type::Boolean class << self # @api private diff --git a/lib/increase/internal/type/converter.rb b/lib/increase/internal/type/converter.rb index a9c08802..a0d9eec3 100644 --- a/lib/increase/internal/type/converter.rb +++ b/lib/increase/internal/type/converter.rb @@ -64,7 +64,7 @@ def type_info(spec) in Hash type_info(spec.slice(:const, :enum, :union).first&.last) in true | false - -> { Increase::Internal::Type::BooleanModel } + -> { Increase::Internal::Type::Boolean } in Increase::Internal::Type::Converter | Class | Symbol -> { spec } in NilClass | Integer | Float @@ -168,6 +168,9 @@ def coerce( in String | Symbol | Numeric exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1 return value.to_s + in StringIO + exactness[:yes] += 1 + return value.string else if strictness == :strong message = "no implicit conversion of #{value.class} into #{target.inspect}" @@ -209,7 +212,9 @@ def coerce( # # @return [Object] def dump(target, value) + # rubocop:disable Layout/LineLength target.is_a?(Increase::Internal::Type::Converter) ? target.dump(value) : Increase::Internal::Type::Unknown.dump(value) + # rubocop:enable Layout/LineLength end end end diff --git a/lib/increase/internal/type/enum.rb b/lib/increase/internal/type/enum.rb index 4c0f84b9..b04af1e8 100644 --- a/lib/increase/internal/type/enum.rb +++ b/lib/increase/internal/type/enum.rb @@ -37,7 +37,9 @@ def ===(other) = values.include?(other) # # @return [Boolean] def ==(other) + # rubocop:disable Layout/LineLength other.is_a?(Module) && other.singleton_class <= Increase::Internal::Type::Enum && other.values.to_set == values.to_set + # rubocop:enable Layout/LineLength end # @api private diff --git a/lib/increase/internal/util.rb b/lib/increase/internal/util.rb index 2111977b..bcab7641 100644 --- a/lib/increase/internal/util.rb +++ b/lib/increase/internal/util.rb @@ -61,7 +61,7 @@ class << self # @return [Boolean] def primitive?(input) case input - in true | false | Integer | Float | Symbol | String + in true | false | Numeric | Symbol | String true else false @@ -70,13 +70,11 @@ def primitive?(input) # @api private # - # @param input [Object] + # @param input [String, Boolean] # # @return [Boolean, Object] def coerce_boolean(input) case input.is_a?(String) ? input.downcase : input - in Numeric - input.nonzero? in "true" true in "false" @@ -88,7 +86,7 @@ def coerce_boolean(input) # @api private # - # @param input [Object] + # @param input [String, Boolean] # # @raise [ArgumentError] # @return [Boolean, nil] @@ -103,34 +101,20 @@ def coerce_boolean!(input) # @api private # - # @param input [Object] + # @param input [String, Integer] # # @return [Integer, Object] def coerce_integer(input) - case input - in true - 1 - in false - 0 - else - Integer(input, exception: false) || input - end + Integer(input, exception: false) || input end # @api private # - # @param input [Object] + # @param input [String, Integer, Float] # # @return [Float, Object] def coerce_float(input) - case input - in true - 1.0 - in false - 0.0 - else - Float(input, exception: false) || input - end + Float(input, exception: false) || input end # @api private @@ -159,12 +143,7 @@ class << self private def deep_merge_lr(lhs, rhs, concat: false) case [lhs, rhs, concat] in [Hash, Hash, _] - rhs_cleaned = rhs.reject { _2 == Increase::Internal::OMIT } - lhs - .reject { |key, _| rhs[key] == Increase::Internal::OMIT } - .merge(rhs_cleaned) do |_, old_val, new_val| - deep_merge_lr(old_val, new_val, concat: concat) - end + lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) } in [Array, Array, true] lhs.concat(rhs) else @@ -362,7 +341,7 @@ def normalized_headers(*headers) value = case val in Array - val.map { _1.to_s.strip }.join(", ") + val.filter_map { _1&.to_s&.strip }.join(", ") else val&.to_s&.strip end @@ -469,7 +448,7 @@ class << self case val in IO y << "Content-Type: application/octet-stream\r\n\r\n" - IO.copy_stream(val, y) + IO.copy_stream(val.tap(&:rewind), y) in StringIO y << "Content-Type: application/octet-stream\r\n\r\n" y << val.string @@ -525,7 +504,7 @@ class << self def encode_content(headers, body) content_type = headers["content-type"] case [content_type, body] - in [%r{^application/(?:vnd\.api\+)?json}, Hash | Array] + in [%r{^application/(?:vnd\.api\+)?json}, _] unless body.nil? [headers, JSON.fast_generate(body)] in [%r{^application/(?:x-)?jsonl}, Enumerable] [headers, body.lazy.map { JSON.fast_generate(_1) }] @@ -533,8 +512,12 @@ def encode_content(headers, body) boundary, strio = encode_multipart_streaming(body) headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"} [headers, strio] + in [_, IO] + [headers, body.tap(&:rewind)] in [_, StringIO] [headers, body.string] + in [_, Symbol | Numeric] + [headers, body.to_s] else [headers, body] end @@ -673,7 +656,7 @@ def decode_lines(enum) # # @param lines [Enumerable] # - # @return [Hash{Symbol=>Object}] + # @return [EnumerableObject}>] def decode_sse(lines) # rubocop:disable Metrics/BlockLength chain_fused(lines) do |y| diff --git a/lib/increase/models/account_transfer_create_params.rb b/lib/increase/models/account_transfer_create_params.rb index 3a4ac32c..0651309c 100644 --- a/lib/increase/models/account_transfer_create_params.rb +++ b/lib/increase/models/account_transfer_create_params.rb @@ -37,7 +37,7 @@ class AccountTransferCreateParams < Increase::Internal::Type::BaseModel # Whether the transfer requires explicit approval via the dashboard or API. # # @return [Boolean, nil] - optional :require_approval, Increase::Internal::Type::BooleanModel + optional :require_approval, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/ach_transfer_create_params.rb b/lib/increase/models/ach_transfer_create_params.rb index 02e9c1b1..580f687b 100644 --- a/lib/increase/models/ach_transfer_create_params.rb +++ b/lib/increase/models/ach_transfer_create_params.rb @@ -170,7 +170,7 @@ class ACHTransferCreateParams < Increase::Internal::Type::BaseModel # Whether the transfer requires explicit approval via the dashboard or API. # # @return [Boolean, nil] - optional :require_approval, Increase::Internal::Type::BooleanModel + optional :require_approval, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/check_transfer_create_params.rb b/lib/increase/models/check_transfer_create_params.rb index fb61ab37..26f9dd33 100644 --- a/lib/increase/models/check_transfer_create_params.rb +++ b/lib/increase/models/check_transfer_create_params.rb @@ -49,7 +49,7 @@ class CheckTransferCreateParams < Increase::Internal::Type::BaseModel # Whether the transfer requires explicit approval via the dashboard or API. # # @return [Boolean, nil] - optional :require_approval, Increase::Internal::Type::BooleanModel + optional :require_approval, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/entity_create_beneficial_owner_params.rb b/lib/increase/models/entity_create_beneficial_owner_params.rb index f1a75a4b..592c07a7 100644 --- a/lib/increase/models/entity_create_beneficial_owner_params.rb +++ b/lib/increase/models/entity_create_beneficial_owner_params.rb @@ -98,7 +98,7 @@ class Individual < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/entity_create_params.rb b/lib/increase/models/entity_create_params.rb index a2c08964..a3165401 100644 --- a/lib/increase/models/entity_create_params.rb +++ b/lib/increase/models/entity_create_params.rb @@ -372,7 +372,7 @@ class Individual < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] @@ -915,7 +915,7 @@ class Individual < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] @@ -1247,7 +1247,7 @@ class NaturalPerson < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] @@ -1858,7 +1858,7 @@ class Individual < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] @@ -2195,7 +2195,7 @@ class Grantor < Increase::Internal::Type::BaseModel # Number). # # @return [Boolean, nil] - optional :confirmed_no_us_tax_id, Increase::Internal::Type::BooleanModel + optional :confirmed_no_us_tax_id, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/physical_card_profile.rb b/lib/increase/models/physical_card_profile.rb index f3695181..1ed8ab51 100644 --- a/lib/increase/models/physical_card_profile.rb +++ b/lib/increase/models/physical_card_profile.rb @@ -66,7 +66,7 @@ class PhysicalCardProfile < Increase::Internal::Type::BaseModel # group. # # @return [Boolean] - required :is_default, Increase::Internal::Type::BooleanModel + required :is_default, Increase::Internal::Type::Boolean # @!attribute status # The status of the Physical Card Profile. diff --git a/lib/increase/models/proof_of_authorization_request_submission.rb b/lib/increase/models/proof_of_authorization_request_submission.rb index 409fcd51..3616ccbc 100644 --- a/lib/increase/models/proof_of_authorization_request_submission.rb +++ b/lib/increase/models/proof_of_authorization_request_submission.rb @@ -62,7 +62,7 @@ class ProofOfAuthorizationRequestSubmission < Increase::Internal::Type::BaseMode # Whether the customer has been offboarded. # # @return [Boolean, nil] - required :customer_has_been_offboarded, Increase::Internal::Type::BooleanModel, nil?: true + required :customer_has_been_offboarded, Increase::Internal::Type::Boolean, nil?: true # @!attribute idempotency_key # The idempotency key you chose for this object. This value is unique across @@ -101,23 +101,21 @@ class ProofOfAuthorizationRequestSubmission < Increase::Internal::Type::BaseMode # Whether account ownership was validated via credential (for instance, Plaid). # # @return [Boolean, nil] - required :validated_account_ownership_via_credential, Increase::Internal::Type::BooleanModel, nil?: true + required :validated_account_ownership_via_credential, Increase::Internal::Type::Boolean, nil?: true # @!attribute validated_account_ownership_with_account_statement # Whether account ownership was validated with an account statement. # # @return [Boolean, nil] required :validated_account_ownership_with_account_statement, - Increase::Internal::Type::BooleanModel, + Increase::Internal::Type::Boolean, nil?: true # @!attribute validated_account_ownership_with_microdeposit # Whether account ownership was validated with microdeposit. # # @return [Boolean, nil] - required :validated_account_ownership_with_microdeposit, - Increase::Internal::Type::BooleanModel, - nil?: true + required :validated_account_ownership_with_microdeposit, Increase::Internal::Type::Boolean, nil?: true # @!parse # # Information submitted in response to a proof of authorization request. Per diff --git a/lib/increase/models/proof_of_authorization_request_submission_create_params.rb b/lib/increase/models/proof_of_authorization_request_submission_create_params.rb index 791b2313..c7c4f377 100644 --- a/lib/increase/models/proof_of_authorization_request_submission_create_params.rb +++ b/lib/increase/models/proof_of_authorization_request_submission_create_params.rb @@ -36,7 +36,7 @@ class ProofOfAuthorizationRequestSubmissionCreateParams < Increase::Internal::Ty # Whether the customer has been offboarded or suspended. # # @return [Boolean] - required :customer_has_been_offboarded, Increase::Internal::Type::BooleanModel + required :customer_has_been_offboarded, Increase::Internal::Type::Boolean # @!attribute proof_of_authorization_request_id # ID of the proof of authorization request. @@ -48,19 +48,19 @@ class ProofOfAuthorizationRequestSubmissionCreateParams < Increase::Internal::Ty # Whether the account ownership was validated via credential (e.g. Plaid). # # @return [Boolean] - required :validated_account_ownership_via_credential, Increase::Internal::Type::BooleanModel + required :validated_account_ownership_via_credential, Increase::Internal::Type::Boolean # @!attribute validated_account_ownership_with_account_statement # Whether the account ownership was validated with an account statement. # # @return [Boolean] - required :validated_account_ownership_with_account_statement, Increase::Internal::Type::BooleanModel + required :validated_account_ownership_with_account_statement, Increase::Internal::Type::Boolean # @!attribute validated_account_ownership_with_microdeposit # Whether the account ownership was validated with a microdeposit. # # @return [Boolean] - required :validated_account_ownership_with_microdeposit, Increase::Internal::Type::BooleanModel + required :validated_account_ownership_with_microdeposit, Increase::Internal::Type::Boolean # @!attribute [r] additional_evidence_file_id # File containing additional evidence. diff --git a/lib/increase/models/real_time_payments_transfer_create_params.rb b/lib/increase/models/real_time_payments_transfer_create_params.rb index e50e4a02..48ccc0b8 100644 --- a/lib/increase/models/real_time_payments_transfer_create_params.rb +++ b/lib/increase/models/real_time_payments_transfer_create_params.rb @@ -81,7 +81,7 @@ class RealTimePaymentsTransferCreateParams < Increase::Internal::Type::BaseModel # Whether the transfer requires explicit approval via the dashboard or API. # # @return [Boolean, nil] - optional :require_approval, Increase::Internal::Type::BooleanModel + optional :require_approval, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/models/wire_transfer_create_params.rb b/lib/increase/models/wire_transfer_create_params.rb index 7a899e65..578045f1 100644 --- a/lib/increase/models/wire_transfer_create_params.rb +++ b/lib/increase/models/wire_transfer_create_params.rb @@ -131,7 +131,7 @@ class WireTransferCreateParams < Increase::Internal::Type::BaseModel # Whether the transfer requires explicit approval via the dashboard or API. # # @return [Boolean, nil] - optional :require_approval, Increase::Internal::Type::BooleanModel + optional :require_approval, Increase::Internal::Type::Boolean # @!parse # # @return [Boolean] diff --git a/lib/increase/version.rb b/lib/increase/version.rb index 4bab1d73..fec5d071 100644 --- a/lib/increase/version.rb +++ b/lib/increase/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Increase - VERSION = "0.1.0-alpha.4" + VERSION = "0.1.0.pre.alpha.5" end diff --git a/rbi/lib/increase/internal/page.rbi b/rbi/lib/increase/internal/page.rbi index b563caba..7be81af9 100644 --- a/rbi/lib/increase/internal/page.rbi +++ b/rbi/lib/increase/internal/page.rbi @@ -3,10 +3,10 @@ module Increase module Internal class Page - Elem = type_member - include Increase::Internal::Type::BasePage + Elem = type_member + sig { returns(T.nilable(T::Array[Elem])) } attr_accessor :data diff --git a/rbi/lib/increase/internal/type/boolean_model.rbi b/rbi/lib/increase/internal/type/boolean.rbi similarity index 97% rename from rbi/lib/increase/internal/type/boolean_model.rbi rename to rbi/lib/increase/internal/type/boolean.rbi index 5949621a..e8f4eebc 100644 --- a/rbi/lib/increase/internal/type/boolean_model.rbi +++ b/rbi/lib/increase/internal/type/boolean.rbi @@ -6,7 +6,7 @@ module Increase # @api private # # Ruby has no Boolean class; this is something for models to refer to. - class BooleanModel + class Boolean extend Increase::Internal::Type::Converter abstract! diff --git a/rbi/lib/increase/internal/util.rbi b/rbi/lib/increase/internal/util.rbi index 755fb2b2..fe04005a 100644 --- a/rbi/lib/increase/internal/util.rbi +++ b/rbi/lib/increase/internal/util.rbi @@ -28,22 +28,22 @@ module Increase end # @api private - sig { params(input: T.anything).returns(T.any(T::Boolean, T.anything)) } + sig { params(input: T.any(String, T::Boolean)).returns(T.any(T::Boolean, T.anything)) } def coerce_boolean(input) end # @api private - sig { params(input: T.anything).returns(T.nilable(T::Boolean)) } + sig { params(input: T.any(String, T::Boolean)).returns(T.nilable(T::Boolean)) } def coerce_boolean!(input) end # @api private - sig { params(input: T.anything).returns(T.any(Integer, T.anything)) } + sig { params(input: T.any(String, Integer)).returns(T.any(Integer, T.anything)) } def coerce_integer(input) end # @api private - sig { params(input: T.anything).returns(T.any(Float, T.anything)) } + sig { params(input: T.any(String, Integer, Float)).returns(T.any(Float, T.anything)) } def coerce_float(input) end @@ -271,7 +271,9 @@ module Increase # @api private # # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream - sig { params(lines: T::Enumerable[String]).returns(Increase::Internal::Util::ServerSentEvent) } + sig do + params(lines: T::Enumerable[String]).returns(T::Enumerable[Increase::Internal::Util::ServerSentEvent]) + end def decode_sse(lines) end end diff --git a/sig/increase/internal/type/boolean_model.rbs b/sig/increase/internal/type/boolean.rbs similarity index 94% rename from sig/increase/internal/type/boolean_model.rbs rename to sig/increase/internal/type/boolean.rbs index 9e7b07c6..69767087 100644 --- a/sig/increase/internal/type/boolean_model.rbs +++ b/sig/increase/internal/type/boolean.rbs @@ -1,7 +1,7 @@ module Increase module Internal module Type - class BooleanModel + class Boolean extend Increase::Internal::Type::Converter def self.===: (top other) -> bool diff --git a/sig/increase/internal/util.rbs b/sig/increase/internal/util.rbs index af854121..5afdd426 100644 --- a/sig/increase/internal/util.rbs +++ b/sig/increase/internal/util.rbs @@ -9,13 +9,13 @@ module Increase def self?.primitive?: (top input) -> bool - def self?.coerce_boolean: (top input) -> (bool | top) + def self?.coerce_boolean: (String | bool input) -> (bool | top) - def self?.coerce_boolean!: (top input) -> bool? + def self?.coerce_boolean!: (String | bool input) -> bool? - def self?.coerce_integer: (top input) -> (Integer | top) + def self?.coerce_integer: (String | Integer input) -> (Integer | top) - def self?.coerce_float: (top input) -> (Float | top) + def self?.coerce_float: (String | Integer | Float input) -> (Float | top) def self?.coerce_hash: (top input) -> (::Hash[top, top] | top) @@ -133,7 +133,7 @@ module Increase def self?.decode_sse: ( Enumerable[String] lines - ) -> Increase::Internal::Util::server_sent_event + ) -> Enumerable[Increase::Internal::Util::server_sent_event] end end end diff --git a/test/increase/internal/type/base_model_test.rb b/test/increase/internal/type/base_model_test.rb index bda9fbbf..c2106f58 100644 --- a/test/increase/internal/type/base_model_test.rb +++ b/test/increase/internal/type/base_model_test.rb @@ -22,7 +22,7 @@ class B < Increase::Internal::Type::BaseModel def test_typing converters = [ Increase::Internal::Type::Unknown, - Increase::Internal::Type::BooleanModel, + Increase::Internal::Type::Boolean, A, H, E, @@ -42,8 +42,8 @@ def test_coerce [Increase::Internal::Type::Unknown, :a] => [{yes: 1}, :a], [NilClass, :a] => [{maybe: 1}, nil], [NilClass, nil] => [{yes: 1}, nil], - [Increase::Internal::Type::BooleanModel, true] => [{yes: 1}, true], - [Increase::Internal::Type::BooleanModel, "true"] => [{no: 1}, "true"], + [Increase::Internal::Type::Boolean, true] => [{yes: 1}, true], + [Increase::Internal::Type::Boolean, "true"] => [{no: 1}, "true"], [Integer, 1] => [{yes: 1}, 1], [Integer, 1.0] => [{maybe: 1}, 1], [Integer, "1"] => [{maybe: 1}, 1], @@ -85,8 +85,8 @@ def test_dump [String, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, [:b, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, [nil, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, - [Increase::Internal::Type::BooleanModel, true] => true, - [Increase::Internal::Type::BooleanModel, "true"] => "true", + [Increase::Internal::Type::Boolean, true] => true, + [Increase::Internal::Type::Boolean, "true"] => "true", [Integer, "1"] => "1", [Float, 1] => 1, [String, "one"] => "one", @@ -560,8 +560,8 @@ class M3 < M2 def test_equality cases = { [Increase::Internal::Type::Unknown, Increase::Internal::Type::Unknown] => true, - [Increase::Internal::Type::BooleanModel, Increase::Internal::Type::BooleanModel] => true, - [Increase::Internal::Type::Unknown, Increase::Internal::Type::BooleanModel] => false, + [Increase::Internal::Type::Boolean, Increase::Internal::Type::Boolean] => true, + [Increase::Internal::Type::Unknown, Increase::Internal::Type::Boolean] => false, [E1, E2] => true, [E1, E3] => false, [M1, M2] => false, diff --git a/test/increase/resources/physical_card_profiles_test.rb b/test/increase/resources/physical_card_profiles_test.rb index 0bded181..84f36727 100644 --- a/test/increase/resources/physical_card_profiles_test.rb +++ b/test/increase/resources/physical_card_profiles_test.rb @@ -27,7 +27,7 @@ def test_create_required_params description: String, front_image_file_id: String | nil, idempotency_key: String | nil, - is_default: Increase::Internal::Type::BooleanModel, + is_default: Increase::Internal::Type::Boolean, status: Increase::Models::PhysicalCardProfile::Status, type: Increase::Models::PhysicalCardProfile::Type } @@ -52,7 +52,7 @@ def test_retrieve description: String, front_image_file_id: String | nil, idempotency_key: String | nil, - is_default: Increase::Internal::Type::BooleanModel, + is_default: Increase::Internal::Type::Boolean, status: Increase::Models::PhysicalCardProfile::Status, type: Increase::Models::PhysicalCardProfile::Type } @@ -84,7 +84,7 @@ def test_list description: String, front_image_file_id: String | nil, idempotency_key: String | nil, - is_default: Increase::Internal::Type::BooleanModel, + is_default: Increase::Internal::Type::Boolean, status: Increase::Models::PhysicalCardProfile::Status, type: Increase::Models::PhysicalCardProfile::Type } @@ -109,7 +109,7 @@ def test_archive description: String, front_image_file_id: String | nil, idempotency_key: String | nil, - is_default: Increase::Internal::Type::BooleanModel, + is_default: Increase::Internal::Type::Boolean, status: Increase::Models::PhysicalCardProfile::Status, type: Increase::Models::PhysicalCardProfile::Type } @@ -134,7 +134,7 @@ def test_clone_ description: String, front_image_file_id: String | nil, idempotency_key: String | nil, - is_default: Increase::Internal::Type::BooleanModel, + is_default: Increase::Internal::Type::Boolean, status: Increase::Models::PhysicalCardProfile::Status, type: Increase::Models::PhysicalCardProfile::Type } diff --git a/test/increase/resources/proof_of_authorization_request_submissions_test.rb b/test/increase/resources/proof_of_authorization_request_submissions_test.rb index bf153a03..bb0a36fc 100644 --- a/test/increase/resources/proof_of_authorization_request_submissions_test.rb +++ b/test/increase/resources/proof_of_authorization_request_submissions_test.rb @@ -32,15 +32,15 @@ def test_create_required_params authorizer_ip_address: String | nil, authorizer_name: String | nil, created_at: Time, - customer_has_been_offboarded: Increase::Internal::Type::BooleanModel | nil, + customer_has_been_offboarded: Increase::Internal::Type::Boolean | nil, idempotency_key: String | nil, proof_of_authorization_request_id: String, status: Increase::Models::ProofOfAuthorizationRequestSubmission::Status, type: Increase::Models::ProofOfAuthorizationRequestSubmission::Type, updated_at: Time, - validated_account_ownership_via_credential: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_account_statement: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_microdeposit: Increase::Internal::Type::BooleanModel | nil + validated_account_ownership_via_credential: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_account_statement: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_microdeposit: Increase::Internal::Type::Boolean | nil } end end @@ -66,15 +66,15 @@ def test_retrieve authorizer_ip_address: String | nil, authorizer_name: String | nil, created_at: Time, - customer_has_been_offboarded: Increase::Internal::Type::BooleanModel | nil, + customer_has_been_offboarded: Increase::Internal::Type::Boolean | nil, idempotency_key: String | nil, proof_of_authorization_request_id: String, status: Increase::Models::ProofOfAuthorizationRequestSubmission::Status, type: Increase::Models::ProofOfAuthorizationRequestSubmission::Type, updated_at: Time, - validated_account_ownership_via_credential: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_account_statement: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_microdeposit: Increase::Internal::Type::BooleanModel | nil + validated_account_ownership_via_credential: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_account_statement: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_microdeposit: Increase::Internal::Type::Boolean | nil } end end @@ -104,15 +104,15 @@ def test_list authorizer_ip_address: String | nil, authorizer_name: String | nil, created_at: Time, - customer_has_been_offboarded: Increase::Internal::Type::BooleanModel | nil, + customer_has_been_offboarded: Increase::Internal::Type::Boolean | nil, idempotency_key: String | nil, proof_of_authorization_request_id: String, status: Increase::Models::ProofOfAuthorizationRequestSubmission::Status, type: Increase::Models::ProofOfAuthorizationRequestSubmission::Type, updated_at: Time, - validated_account_ownership_via_credential: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_account_statement: Increase::Internal::Type::BooleanModel | nil, - validated_account_ownership_with_microdeposit: Increase::Internal::Type::BooleanModel | nil + validated_account_ownership_via_credential: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_account_statement: Increase::Internal::Type::Boolean | nil, + validated_account_ownership_with_microdeposit: Increase::Internal::Type::Boolean | nil } end end