diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 46b9b6b24..3b005e525 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.9" + ".": "0.1.0-alpha.10" } \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index ec3ed2efc..b0ad29c38 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -244,6 +244,7 @@ Style/SafeNavigation: Style/SignalException: Exclude: - Rakefile + - "**/*.rake" # We use these sparingly, where we anticipate future branches for the # inner conditional. diff --git a/.stats.yml b/.stats.yml index d33052a80..68698ff6f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 199 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-55c174581a08cabdf3fcf2fc66d480d497c5f77ab8f0f5e776cc7113b4960037.yml -openapi_spec_hash: 8f70d88f00c9c15ebd8e9049e9f65063 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-1044f3fb430b9b4019ec3adeaa8b37e6615264fddb273a48b1d9ddd7c2b7b854.yml +openapi_spec_hash: c2526b64321711688cada903e7b4397d config_hash: 20a463ecd33bd32b7b9bc6f4990907ac diff --git a/CHANGELOG.md b/CHANGELOG.md index 08e7c84d5..77ea25e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## 0.1.0-alpha.10 (2025-04-15) + +Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.9...v0.1.0-alpha.10) + +### Features + +* **api:** api update ([f6c5568](https://github.com/Increase/increase-ruby/commit/f6c5568f67ff3b44fa3c27569cafbb99e48cc71d)) + + +### Chores + +* **internal:** always run post-processing when formatting when syntax_tree ([0ee8912](https://github.com/Increase/increase-ruby/commit/0ee8912f81636d5f74a736e4c8d1707b204e395a)) +* **internal:** loosen internal type restrictions ([56e169c](https://github.com/Increase/increase-ruby/commit/56e169c9fcc2a898d8671e591dec0c606f4ce24c)) +* **internal:** minor touch ups on sdk internals ([ed29ff6](https://github.com/Increase/increase-ruby/commit/ed29ff6868a89b11bea12c07b6cd834b6769cb41)) +* **internal:** mostly README touch ups ([23519d3](https://github.com/Increase/increase-ruby/commit/23519d3197bf59ba73812fda30d28101a6c5f40f)) +* make internal types pretty print ([18c33c5](https://github.com/Increase/increase-ruby/commit/18c33c5f6fe4bb1a0e0fac9083dac8b1f063fdd1)) + + +### Documentation + +* update documentation links to be more uniform ([b1f42d9](https://github.com/Increase/increase-ruby/commit/b1f42d9ef89f3a8d3db9f97e9267690e49826d2e)) + ## 0.1.0-alpha.9 (2025-04-12) Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.8...v0.1.0-alpha.9) diff --git a/Gemfile.lock b/Gemfile.lock index 6d3f578d8..61a55a225 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - increase (0.1.0.pre.alpha.9) + increase (0.1.0.pre.alpha.10) connection_pool GEM diff --git a/README.md b/README.md index a46e885a8..3b790fdc8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ The Increase Ruby library provides convenient access to the Increase REST API fr ## Documentation -Documentation for released of this gem can be found [on RubyDoc](https://gemdocs.org/gems/increase). +Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/increase). -The underlying REST API documentation can be found on [increase.com](https://increase.com/documentation). +The REST API documentation can be found on [increase.com](https://increase.com/documentation). ## Installation @@ -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.9" +gem "increase", "~> 0.1.0.pre.alpha.10" ``` diff --git a/Rakefile b/Rakefile index b03cc69ab..3bbb7689d 100644 --- a/Rakefile +++ b/Rakefile @@ -59,12 +59,19 @@ multitask(:syntax_tree) do # 2. at label `l1`, join previously annotated line with `class | module` information. pst = sed + [subst, "--"] + success = false + # transform class aliases to type aliases, which syntax tree has no trouble with sh("#{find.shelljoin} | #{pre.shelljoin}") # run syntax tree to format `*.rbs` files - sh("#{find.shelljoin} | #{fmt.shelljoin}") + sh("#{find.shelljoin} | #{fmt.shelljoin}") do + success = _1 + end # transform type aliases back to class aliases sh("#{find.shelljoin} | #{pst.shelljoin}") + + # always run post-processing to remove comment marker + fail unless success end multitask(format: [:ruboformat, :syntax_tree]) diff --git a/lib/increase/internal.rb b/lib/increase/internal.rb index 4fe8019ac..2be0303e6 100644 --- a/lib/increase/internal.rb +++ b/lib/increase/internal.rb @@ -3,6 +3,10 @@ module Increase # @api private module Internal - OMIT = Object.new.freeze + OMIT = + Object.new.tap do + _1.define_singleton_method(:inspect) { "#<#{Increase::Internal}::OMIT>" } + end + .freeze end end diff --git a/lib/increase/internal/page.rb b/lib/increase/internal/page.rb index 6414c4ed2..05f31f70c 100644 --- a/lib/increase/internal/page.rb +++ b/lib/increase/internal/page.rb @@ -22,29 +22,6 @@ class Page # @return [String, nil] attr_accessor :next_cursor - # @api private - # - # @param client [Increase::Internal::Transport::BaseClient] - # @param req [Hash{Symbol=>Object}] - # @param headers [Hash{String=>String}, Net::HTTPHeader] - # @param page_data [Hash{Symbol=>Object}] - def initialize(client:, req:, headers:, page_data:) - super - model = req.fetch(:model) - - case page_data - in {data: Array | nil => data} - @data = data&.map { Increase::Internal::Type::Converter.coerce(model, _1) } - else - end - - case page_data - in {next_cursor: String | nil => next_cursor} - @next_cursor = next_cursor - else - end - end - # @return [Boolean] def next_page? !next_cursor.nil? @@ -69,17 +46,40 @@ def auto_paging_each(&blk) unless block_given? raise ArgumentError.new("A block must be given to ##{__method__}") end + page = self loop do - page.data&.each { blk.call(_1) } + page.data&.each(&blk) + break unless page.next_page? page = page.next_page end end + # @api private + # + # @param client [Increase::Internal::Transport::BaseClient] + # @param req [Hash{Symbol=>Object}] + # @param headers [Hash{String=>String}, Net::HTTPHeader] + # @param page_data [Hash{Symbol=>Object}] + def initialize(client:, req:, headers:, page_data:) + super + + case page_data + in {data: Array | nil => data} + @data = data&.map { Increase::Internal::Type::Converter.coerce(@model, _1) } + else + end + @next_cursor = page_data[:next_cursor] + end + + # @api private + # # @return [String] def inspect - "#<#{self.class}:0x#{object_id.to_s(16)} data=#{data.inspect} next_cursor=#{next_cursor.inspect}>" + model = Increase::Internal::Type::Converter.inspect(@model, depth: 1) + + "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} next_cursor=#{next_cursor.inspect}>" end end end diff --git a/lib/increase/internal/transport/base_client.rb b/lib/increase/internal/transport/base_client.rb index e4cbb11d3..cb3d117f6 100644 --- a/lib/increase/internal/transport/base_client.rb +++ b/lib/increase/internal/transport/base_client.rb @@ -93,7 +93,11 @@ def follow_redirect(request, status:, response_headers:) URI.join(url, response_headers["location"]) rescue ArgumentError message = "Server responded with status #{status} but no valid location header." - raise Increase::Errors::APIConnectionError.new(url: url, message: message) + raise Increase::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) end request = {**request, url: location} @@ -101,7 +105,11 @@ def follow_redirect(request, status:, response_headers:) case [url.scheme, location.scheme] in ["https", "http"] message = "Tried to redirect to a insecure URL" - raise Increase::Errors::APIConnectionError.new(url: url, message: message) + raise Increase::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) else nil end @@ -350,7 +358,7 @@ def initialize( self.class.reap_connection!(status, stream: stream) message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects." - raise Increase::Errors::APIConnectionError.new(url: url, message: message) + raise Increase::Errors::APIConnectionError.new(url: url, response: response, message: message) in 300..399 self.class.reap_connection!(status, stream: stream) @@ -460,6 +468,8 @@ def request(req) end end + # @api private + # # @return [String] def inspect # rubocop:disable Layout/LineLength diff --git a/lib/increase/internal/type/array_of.rb b/lib/increase/internal/type/array_of.rb index 198355ca2..65ea2f424 100644 --- a/lib/increase/internal/type/array_of.rb +++ b/lib/increase/internal/type/array_of.rb @@ -13,6 +13,10 @@ module Type class ArrayOf include Increase::Internal::Type::Converter + private_class_method :new + + # @overload [](type_info, spec = {}) + # # @param type_info [Hash{Symbol=>Object}, Proc, Increase::Internal::Type::Converter, Class] # # @param spec [Hash{Symbol=>Object}] . @@ -24,7 +28,7 @@ class ArrayOf # @option spec [Proc] :union # # @option spec [Boolean] :"nil?" - def self.[](type_info, spec = {}) = new(type_info, spec) + def self.[](...) = new(...) # @param other [Object] # @@ -120,7 +124,18 @@ def dump(value, state:) # @option spec [Boolean] :"nil?" def initialize(type_info, spec = {}) @item_type_fn = Increase::Internal::Type::Converter.type_info(type_info || spec) - @nilable = spec[:nil?] + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Increase::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" end end end diff --git a/lib/increase/internal/type/base_model.rb b/lib/increase/internal/type/base_model.rb index c9452e657..fab12c0b4 100644 --- a/lib/increase/internal/type/base_model.rb +++ b/lib/increase/internal/type/base_model.rb @@ -63,7 +63,7 @@ def fields setter = "#{name_sym}=" api_name = info.fetch(:api_name, name_sym) - nilable = info[:nil?] + nilable = info.fetch(:nil?, false) const = if required && !nilable info.fetch( :const, @@ -368,14 +368,42 @@ def initialize(data = {}) end end + class << self + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + return super() if depth.positive? + + depth = depth.succ + deferred = fields.transform_values do |field| + type, required, nilable = field.fetch_values(:type, :required, :nilable) + -> do + [ + Increase::Internal::Type::Converter.inspect(type, depth: depth), + !required || nilable ? "nil" : nil + ].compact.join(" | ") + end + .tap { _1.define_singleton_method(:inspect) { call } } + end + + "#{name}[#{deferred.inspect}]" + end + end + + # @api private + # # @return [String] def inspect - rows = self.class.known_fields.keys.map do - "#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}" + rows = @data.map do + "#{_1}=#{self.class.known_fields.key?(_1) ? public_send(_1).inspect : ''}" rescue Increase::Errors::ConversionError - "#{_1}=#{@data.fetch(_1)}" + "#{_1}=#{_2.inspect}" end - "#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>" + + "#<#{self.class}:0x#{object_id.to_s(16)} #{rows.join(' ')}>" end end end diff --git a/lib/increase/internal/type/base_page.rb b/lib/increase/internal/type/base_page.rb index 6cfa0f8eb..63c947068 100644 --- a/lib/increase/internal/type/base_page.rb +++ b/lib/increase/internal/type/base_page.rb @@ -36,6 +36,7 @@ def to_enum = super(:auto_paging_each) def initialize(client:, req:, headers:, page_data:) @client = client @req = req + @model = req.fetch(:model) super() end diff --git a/lib/increase/internal/type/boolean.rb b/lib/increase/internal/type/boolean.rb index f55c003d3..35d9f8b6d 100644 --- a/lib/increase/internal/type/boolean.rb +++ b/lib/increase/internal/type/boolean.rb @@ -11,6 +11,8 @@ module Type class Boolean extend Increase::Internal::Type::Converter + private_class_method :new + # @param other [Object] # # @return [Boolean] diff --git a/lib/increase/internal/type/converter.rb b/lib/increase/internal/type/converter.rb index debe97ddf..eea85f1ad 100644 --- a/lib/increase/internal/type/converter.rb +++ b/lib/increase/internal/type/converter.rb @@ -49,6 +49,15 @@ def dump(value, state:) end end + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + super() + end + # rubocop:enable Lint/UnusedMethodArgument class << self @@ -240,6 +249,21 @@ def dump(target, value, state: {can_retry: true}) Increase::Internal::Type::Unknown.dump(value, state: state) end end + + # @api private + # + # @param target [Object] + # @param depth [Integer] + # + # @return [String] + def inspect(target, depth:) + case target + in Increase::Internal::Type::Converter + target.inspect(depth: depth.succ) + else + target.inspect + end + end end end end diff --git a/lib/increase/internal/type/enum.rb b/lib/increase/internal/type/enum.rb index 65e92a34b..1da9a38ce 100644 --- a/lib/increase/internal/type/enum.rb +++ b/lib/increase/internal/type/enum.rb @@ -37,9 +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 + # rubocop:disable Style/CaseEquality + Increase::Internal::Type::Enum === other && other.values.to_set == values.to_set + # rubocop:enable Style/CaseEquality end # @api private @@ -82,6 +82,22 @@ def coerce(value, state:) # # # # @return [Symbol, Object] # def dump(value, state:) = super + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = values.map { Increase::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end end end end diff --git a/lib/increase/internal/type/hash_of.rb b/lib/increase/internal/type/hash_of.rb index 776458316..6a4413682 100644 --- a/lib/increase/internal/type/hash_of.rb +++ b/lib/increase/internal/type/hash_of.rb @@ -13,6 +13,10 @@ module Type class HashOf include Increase::Internal::Type::Converter + private_class_method :new + + # @overload [](type_info, spec = {}) + # # @param type_info [Hash{Symbol=>Object}, Proc, Increase::Internal::Type::Converter, Class] # # @param spec [Hash{Symbol=>Object}] . @@ -24,7 +28,7 @@ class HashOf # @option spec [Proc] :union # # @option spec [Boolean] :"nil?" - def self.[](type_info, spec = {}) = new(type_info, spec) + def self.[](...) = new(...) # @param other [Object] # @@ -140,7 +144,18 @@ def dump(value, state:) # @option spec [Boolean] :"nil?" def initialize(type_info, spec = {}) @item_type_fn = Increase::Internal::Type::Converter.type_info(type_info || spec) - @nilable = spec[:nil?] + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Increase::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" end end end diff --git a/lib/increase/internal/type/io_like.rb b/lib/increase/internal/type/io_like.rb index 41068fb4f..e108d2618 100644 --- a/lib/increase/internal/type/io_like.rb +++ b/lib/increase/internal/type/io_like.rb @@ -11,6 +11,8 @@ module Type class IOLike extend Increase::Internal::Type::Converter + private_class_method :new + # @param other [Object] # # @return [Boolean] diff --git a/lib/increase/internal/type/union.rb b/lib/increase/internal/type/union.rb index b3fbb416e..5e57227ad 100644 --- a/lib/increase/internal/type/union.rb +++ b/lib/increase/internal/type/union.rb @@ -100,9 +100,7 @@ def ===(other) # # @return [Boolean] def ==(other) - # rubocop:disable Layout/LineLength - other.is_a?(Module) && other.singleton_class <= Increase::Internal::Type::Union && other.derefed_variants == derefed_variants - # rubocop:enable Layout/LineLength + Increase::Internal::Type::Union === other && other.derefed_variants == derefed_variants end # @api private @@ -185,6 +183,22 @@ def dump(value, state:) # rubocop:enable Style/CaseEquality # rubocop:enable Style/HashEachMethods + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = variants.map { Increase::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end end end end diff --git a/lib/increase/internal/type/unknown.rb b/lib/increase/internal/type/unknown.rb index 85f51ec3e..30bd44c75 100644 --- a/lib/increase/internal/type/unknown.rb +++ b/lib/increase/internal/type/unknown.rb @@ -13,6 +13,8 @@ class Unknown # rubocop:disable Lint/UnusedMethodArgument + private_class_method :new + # @param other [Object] # # @return [Boolean] diff --git a/lib/increase/models/ach_transfer.rb b/lib/increase/models/ach_transfer.rb index 7db4f19ed..1ea03cc3d 100644 --- a/lib/increase/models/ach_transfer.rb +++ b/lib/increase/models/ach_transfer.rb @@ -76,6 +76,12 @@ class ACHTransfer < Increase::Internal::Type::BaseModel # @return [String, nil] required :company_entry_description, String, nil?: true + # @!attribute company_id + # The company ID associated with the transfer. + # + # @return [String] + required :company_id, String + # @!attribute company_name # The name by which the recipient knows you. # @@ -256,6 +262,7 @@ class ACHTransfer < Increase::Internal::Type::BaseModel # # @param company_descriptive_date [String, nil] # # @param company_discretionary_data [String, nil] # # @param company_entry_description [String, nil] + # # @param company_id [String] # # @param company_name [String, nil] # # @param created_at [Time] # # @param created_by [Increase::Models::ACHTransfer::CreatedBy, nil] @@ -293,6 +300,7 @@ class ACHTransfer < Increase::Internal::Type::BaseModel # company_descriptive_date:, # company_discretionary_data:, # company_entry_description:, + # company_id:, # company_name:, # created_at:, # created_by:, diff --git a/lib/increase/version.rb b/lib/increase/version.rb index e9f349fff..d9f7264d8 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.pre.alpha.9" + VERSION = "0.1.0.pre.alpha.10" end diff --git a/rbi/lib/increase/internal.rbi b/rbi/lib/increase/internal.rbi index e8b36a6d8..528cb8934 100644 --- a/rbi/lib/increase/internal.rbi +++ b/rbi/lib/increase/internal.rbi @@ -7,6 +7,6 @@ module Increase # this alias might be refined in the future. AnyHash = T.type_alias { T::Hash[Symbol, T.anything] } - OMIT = T.let(T.anything, T.anything) + OMIT = T.let(Object.new.freeze, T.anything) end end diff --git a/rbi/lib/increase/internal/page.rbi b/rbi/lib/increase/internal/page.rbi index bc7a14bda..8388be6d7 100644 --- a/rbi/lib/increase/internal/page.rbi +++ b/rbi/lib/increase/internal/page.rbi @@ -13,6 +13,7 @@ module Increase sig { returns(T.nilable(String)) } attr_accessor :next_cursor + # @api private sig { returns(String) } def inspect; end end diff --git a/rbi/lib/increase/internal/transport/base_client.rbi b/rbi/lib/increase/internal/transport/base_client.rbi index 7c5313df3..e617789c0 100644 --- a/rbi/lib/increase/internal/transport/base_client.rbi +++ b/rbi/lib/increase/internal/transport/base_client.rbi @@ -190,6 +190,7 @@ module Increase model: Increase::Internal::Type::Unknown, options: {} ); end + # @api private sig { returns(String) } def inspect; end end diff --git a/rbi/lib/increase/internal/type/array_of.rbi b/rbi/lib/increase/internal/type/array_of.rbi index afc4b560b..4c33e004c 100644 --- a/rbi/lib/increase/internal/type/array_of.rbi +++ b/rbi/lib/increase/internal/type/array_of.rbi @@ -10,11 +10,10 @@ module Increase include Increase::Internal::Type::Converter abstract! - final! Elem = type_member(:out) - sig(:final) do + sig do params( type_info: T.any( Increase::Internal::AnyHash, @@ -27,14 +26,14 @@ module Increase end def self.[](type_info, spec = {}); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def ===(other); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def ==(other); end # @api private - sig(:final) do + sig do override .params( value: T.any(T::Array[T.anything], T.anything), @@ -45,7 +44,7 @@ module Increase def coerce(value, state:); end # @api private - sig(:final) do + sig do override .params( value: T.any(T::Array[T.anything], T.anything), @@ -56,15 +55,15 @@ module Increase def dump(value, state:); end # @api private - sig(:final) { returns(Elem) } + sig { returns(Elem) } protected def item_type; end # @api private - sig(:final) { returns(T::Boolean) } + sig { returns(T::Boolean) } protected def nilable?; end # @api private - sig(:final) do + sig do params( type_info: T.any( Increase::Internal::AnyHash, @@ -76,6 +75,10 @@ module Increase .void end def initialize(type_info, spec = {}); end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end end end end diff --git a/rbi/lib/increase/internal/type/base_model.rbi b/rbi/lib/increase/internal/type/base_model.rbi index 3453e0546..80dacfb57 100644 --- a/rbi/lib/increase/internal/type/base_model.rbi +++ b/rbi/lib/increase/internal/type/base_model.rbi @@ -189,6 +189,13 @@ module Increase sig { params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns(T.attached_class) } def self.new(data = {}); end + class << self + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end + end + + # @api private sig { returns(String) } def inspect; end end diff --git a/rbi/lib/increase/internal/type/boolean.rbi b/rbi/lib/increase/internal/type/boolean.rbi index 64ef96efe..71f200257 100644 --- a/rbi/lib/increase/internal/type/boolean.rbi +++ b/rbi/lib/increase/internal/type/boolean.rbi @@ -10,17 +10,16 @@ module Increase extend Increase::Internal::Type::Converter abstract! - final! - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.===(other); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.==(other); end class << self # @api private - sig(:final) do + sig do override .params(value: T.any( T::Boolean, @@ -32,7 +31,7 @@ module Increase def coerce(value, state:); end # @api private - sig(:final) do + sig do override .params(value: T.any( T::Boolean, diff --git a/rbi/lib/increase/internal/type/converter.rbi b/rbi/lib/increase/internal/type/converter.rbi index 49de4cc1b..f4c7bb112 100644 --- a/rbi/lib/increase/internal/type/converter.rbi +++ b/rbi/lib/increase/internal/type/converter.rbi @@ -34,6 +34,10 @@ module Increase end def dump(value, state:); end + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end + class << self # @api private sig do @@ -105,6 +109,10 @@ module Increase .returns(T.anything) end def self.dump(target, value, state: {can_retry: true}); end + + # @api private + sig { params(target: T.anything, depth: Integer).returns(String) } + def self.inspect(target, depth:); end end end end diff --git a/rbi/lib/increase/internal/type/enum.rbi b/rbi/lib/increase/internal/type/enum.rbi index 01e5e2f66..474ab6ef0 100644 --- a/rbi/lib/increase/internal/type/enum.rbi +++ b/rbi/lib/increase/internal/type/enum.rbi @@ -57,6 +57,10 @@ module Increase .returns(T.any(Symbol, T.anything)) end def dump(value, state:); end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end end end end diff --git a/rbi/lib/increase/internal/type/hash_of.rbi b/rbi/lib/increase/internal/type/hash_of.rbi index 13bf0c096..08292e39c 100644 --- a/rbi/lib/increase/internal/type/hash_of.rbi +++ b/rbi/lib/increase/internal/type/hash_of.rbi @@ -10,11 +10,10 @@ module Increase include Increase::Internal::Type::Converter abstract! - final! Elem = type_member(:out) - sig(:final) do + sig do params( type_info: T.any( Increase::Internal::AnyHash, @@ -27,14 +26,14 @@ module Increase end def self.[](type_info, spec = {}); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def ===(other); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def ==(other); end # @api private - sig(:final) do + sig do override .params( value: T.any(T::Hash[T.anything, T.anything], T.anything), @@ -45,7 +44,7 @@ module Increase def coerce(value, state:); end # @api private - sig(:final) do + sig do override .params( value: T.any(T::Hash[T.anything, T.anything], T.anything), @@ -56,15 +55,15 @@ module Increase def dump(value, state:); end # @api private - sig(:final) { returns(Elem) } + sig { returns(Elem) } protected def item_type; end # @api private - sig(:final) { returns(T::Boolean) } + sig { returns(T::Boolean) } protected def nilable?; end # @api private - sig(:final) do + sig do params( type_info: T.any( Increase::Internal::AnyHash, @@ -76,6 +75,10 @@ module Increase .void end def initialize(type_info, spec = {}); end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end end end end diff --git a/rbi/lib/increase/internal/type/io_like.rbi b/rbi/lib/increase/internal/type/io_like.rbi index d5974fe3e..5afc5243f 100644 --- a/rbi/lib/increase/internal/type/io_like.rbi +++ b/rbi/lib/increase/internal/type/io_like.rbi @@ -10,17 +10,16 @@ module Increase extend Increase::Internal::Type::Converter abstract! - final! - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.===(other); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.==(other); end class << self # @api private - sig(:final) do + sig do override .params( value: T.any(StringIO, String, T.anything), @@ -31,7 +30,7 @@ module Increase def coerce(value, state:); end # @api private - sig(:final) do + sig do override .params( value: T.any(Pathname, StringIO, IO, String, T.anything), diff --git a/rbi/lib/increase/internal/type/union.rbi b/rbi/lib/increase/internal/type/union.rbi index ca2a3dd2b..d53f690d5 100644 --- a/rbi/lib/increase/internal/type/union.rbi +++ b/rbi/lib/increase/internal/type/union.rbi @@ -62,6 +62,10 @@ module Increase .returns(T.anything) end def dump(value, state:); end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0); end end end end diff --git a/rbi/lib/increase/internal/type/unknown.rbi b/rbi/lib/increase/internal/type/unknown.rbi index a87d6ce0f..49737ff6d 100644 --- a/rbi/lib/increase/internal/type/unknown.rbi +++ b/rbi/lib/increase/internal/type/unknown.rbi @@ -10,17 +10,16 @@ module Increase extend Increase::Internal::Type::Converter abstract! - final! - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.===(other); end - sig(:final) { params(other: T.anything).returns(T::Boolean) } + sig { params(other: T.anything).returns(T::Boolean) } def self.==(other); end class << self # @api private - sig(:final) do + sig do override .params(value: T.anything, state: Increase::Internal::Type::Converter::CoerceState) .returns(T.anything) @@ -28,7 +27,7 @@ module Increase def coerce(value, state:); end # @api private - sig(:final) do + sig do override .params(value: T.anything, state: Increase::Internal::Type::Converter::DumpState) .returns(T.anything) diff --git a/rbi/lib/increase/models/ach_transfer.rbi b/rbi/lib/increase/models/ach_transfer.rbi index e5c5b028c..45ce99e67 100644 --- a/rbi/lib/increase/models/ach_transfer.rbi +++ b/rbi/lib/increase/models/ach_transfer.rbi @@ -80,6 +80,10 @@ module Increase sig { returns(T.nilable(String)) } attr_accessor :company_entry_description + # The company ID associated with the transfer. + sig { returns(String) } + attr_accessor :company_id + # The name by which the recipient knows you. sig { returns(T.nilable(String)) } attr_accessor :company_name @@ -254,6 +258,7 @@ module Increase company_descriptive_date: T.nilable(String), company_discretionary_data: T.nilable(String), company_entry_description: T.nilable(String), + company_id: String, company_name: T.nilable(String), created_at: Time, created_by: T.nilable(T.any(Increase::Models::ACHTransfer::CreatedBy, Increase::Internal::AnyHash)), @@ -293,6 +298,7 @@ module Increase company_descriptive_date:, company_discretionary_data:, company_entry_description:, + company_id:, company_name:, created_at:, created_by:, @@ -333,6 +339,7 @@ module Increase company_descriptive_date: T.nilable(String), company_discretionary_data: T.nilable(String), company_entry_description: T.nilable(String), + company_id: String, company_name: T.nilable(String), created_at: Time, created_by: T.nilable(Increase::Models::ACHTransfer::CreatedBy), diff --git a/sig/increase/internal.rbs b/sig/increase/internal.rbs index 62a4cd041..871f40835 100644 --- a/sig/increase/internal.rbs +++ b/sig/increase/internal.rbs @@ -1,5 +1,5 @@ module Increase module Internal - OMIT: top + OMIT: Object end end diff --git a/sig/increase/internal/type/array_of.rbs b/sig/increase/internal/type/array_of.rbs index 795f04892..74338ff85 100644 --- a/sig/increase/internal/type/array_of.rbs +++ b/sig/increase/internal/type/array_of.rbs @@ -35,6 +35,8 @@ module Increase | Increase::Internal::Type::Converter::input type_info, ?::Hash[Symbol, top] spec ) -> void + + def inspect: (?depth: Integer) -> String end end end diff --git a/sig/increase/internal/type/base_model.rbs b/sig/increase/internal/type/base_model.rbs index 9980f9e60..a72dd5a1b 100644 --- a/sig/increase/internal/type/base_model.rbs +++ b/sig/increase/internal/type/base_model.rbs @@ -75,6 +75,8 @@ module Increase def initialize: (?::Hash[Symbol, top] | self data) -> void + def self.inspect: (?depth: Integer) -> String + def inspect: -> String end end diff --git a/sig/increase/internal/type/converter.rbs b/sig/increase/internal/type/converter.rbs index c13aae74b..9d3581664 100644 --- a/sig/increase/internal/type/converter.rbs +++ b/sig/increase/internal/type/converter.rbs @@ -23,6 +23,8 @@ module Increase state: Increase::Internal::Type::Converter::dump_state ) -> top + def inspect: (?depth: Integer) -> String + def self.type_info: ( { const: (nil | bool | Integer | Float | Symbol)?, @@ -44,6 +46,8 @@ module Increase top value, ?state: Increase::Internal::Type::Converter::dump_state ) -> top + + def self.inspect: (top target, depth: Integer) -> String end end end diff --git a/sig/increase/internal/type/enum.rbs b/sig/increase/internal/type/enum.rbs index 34ec9c8d3..3e1bfafd1 100644 --- a/sig/increase/internal/type/enum.rbs +++ b/sig/increase/internal/type/enum.rbs @@ -21,6 +21,8 @@ module Increase Symbol | top value, state: Increase::Internal::Type::Converter::dump_state ) -> (Symbol | top) + + def inspect: (?depth: Integer) -> String end end end diff --git a/sig/increase/internal/type/hash_of.rbs b/sig/increase/internal/type/hash_of.rbs index 88c63c9da..50221ea0c 100644 --- a/sig/increase/internal/type/hash_of.rbs +++ b/sig/increase/internal/type/hash_of.rbs @@ -35,6 +35,8 @@ module Increase | Increase::Internal::Type::Converter::input type_info, ?::Hash[Symbol, top] spec ) -> void + + def inspect: (?depth: Integer) -> String end end end diff --git a/sig/increase/internal/type/union.rbs b/sig/increase/internal/type/union.rbs index 8f2219295..2b07fec48 100644 --- a/sig/increase/internal/type/union.rbs +++ b/sig/increase/internal/type/union.rbs @@ -39,6 +39,8 @@ module Increase top value, state: Increase::Internal::Type::Converter::dump_state ) -> top + + def inspect: (?depth: Integer) -> String end end end diff --git a/sig/increase/models/ach_transfer.rbs b/sig/increase/models/ach_transfer.rbs index a55998b5a..7334103c0 100644 --- a/sig/increase/models/ach_transfer.rbs +++ b/sig/increase/models/ach_transfer.rbs @@ -13,6 +13,7 @@ module Increase company_descriptive_date: String?, company_discretionary_data: String?, company_entry_description: String?, + company_id: String, company_name: String?, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy?, @@ -62,6 +63,8 @@ module Increase attr_accessor company_entry_description: String? + attr_accessor company_id: String + attr_accessor company_name: String? attr_accessor created_at: Time @@ -122,6 +125,7 @@ module Increase company_descriptive_date: String?, company_discretionary_data: String?, company_entry_description: String?, + company_id: String, company_name: String?, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy?, diff --git a/test/increase/internal/type/base_model_test.rb b/test/increase/internal/type/base_model_test.rb index ab9bc43d0..4cf104bfd 100644 --- a/test/increase/internal/type/base_model_test.rb +++ b/test/increase/internal/type/base_model_test.rb @@ -154,6 +154,12 @@ def test_dump_retry end class Increase::Test::EnumModelTest < Minitest::Test + class E0 + include Increase::Internal::Type::Enum + + def initialize(*values) = (@values = values) + end + module E1 extend Increase::Internal::Type::Enum @@ -183,6 +189,10 @@ module E4 def test_coerce cases = { + [E0.new, "one"] => [{no: 1}, "one"], + [E0.new(:one), "one"] => [{yes: 1}, :one], + [E0.new(:two), "one"] => [{maybe: 1}, "one"], + # rubocop:disable Lint/BooleanSymbol [E1, true] => [{yes: 1}, true], [E1, false] => [{no: 1}, false], @@ -432,8 +442,10 @@ def test_accessors end class Increase::Test::UnionTest < Minitest::Test - module U0 - extend Increase::Internal::Type::Union + class U0 + include Increase::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } end module U1 @@ -519,6 +531,11 @@ def test_coerce cases = { [U0, :""] => [{no: 1}, 0, :""], + [U0.new(Integer, Float), "one"] => [{no: 1}, 2, "one"], + [U0.new(Integer, Float), 1.0] => [{yes: 1}, 2, 1.0], + [U0.new({const: :a}), "a"] => [{yes: 1}, 1, :a], + [U0.new({const: :a}), "2"] => [{maybe: 1}, 1, "2"], + [U1, "a"] => [{yes: 1}, 1, :a], [U1, "2"] => [{maybe: 1}, 2, "2"], [U1, :b] => [{maybe: 1}, 2, :b], @@ -556,6 +573,12 @@ def test_coerce end class Increase::Test::BaseModelQoLTest < Minitest::Test + class E0 + include Increase::Internal::Type::Enum + + def initialize(*values) = (@values = values) + end + module E1 extend Increase::Internal::Type::Enum @@ -575,6 +598,26 @@ module E3 B = 3 end + class U0 + include Increase::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } + end + + module U1 + extend Increase::Internal::Type::Union + + variant String + variant Integer + end + + module U2 + extend Increase::Internal::Type::Union + + variant String + variant Integer + end + class M1 < Increase::Internal::Type::BaseModel required :a, Integer end @@ -592,8 +635,15 @@ def test_equality [Increase::Internal::Type::Unknown, Increase::Internal::Type::Unknown] => true, [Increase::Internal::Type::Boolean, Increase::Internal::Type::Boolean] => true, [Increase::Internal::Type::Unknown, Increase::Internal::Type::Boolean] => false, + [E0.new(:a, :b), E0.new(:a, :b)] => true, + [E0.new(:a, :b), E0.new(:b, :a)] => true, + [E0.new(:a, :b), E0.new(:b, :c)] => false, [E1, E2] => true, [E1, E3] => false, + [U0.new(String, Integer), U0.new(String, Integer)] => true, + [U0.new(String, Integer), U0.new(Integer, String)] => false, + [U0.new(String, Float), U0.new(String, Integer)] => false, + [U1, U2] => true, [M1, M2] => false, [M1, M3] => true } diff --git a/test/increase/resources/ach_transfers_test.rb b/test/increase/resources/ach_transfers_test.rb index 873f4609e..e001b4311 100644 --- a/test/increase/resources/ach_transfers_test.rb +++ b/test/increase/resources/ach_transfers_test.rb @@ -28,6 +28,7 @@ def test_create_required_params company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -76,6 +77,7 @@ def test_retrieve company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -131,6 +133,7 @@ def test_list company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -179,6 +182,7 @@ def test_approve company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -227,6 +231,7 @@ def test_cancel company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, diff --git a/test/increase/resources/simulations/ach_transfers_test.rb b/test/increase/resources/simulations/ach_transfers_test.rb index 61959c2dc..716a99c08 100644 --- a/test/increase/resources/simulations/ach_transfers_test.rb +++ b/test/increase/resources/simulations/ach_transfers_test.rb @@ -23,6 +23,7 @@ def test_acknowledge company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -76,6 +77,7 @@ def test_create_notification_of_change_required_params company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -124,6 +126,7 @@ def test_return_ company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -172,6 +175,7 @@ def test_settle company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil, @@ -220,6 +224,7 @@ def test_submit company_descriptive_date: String | nil, company_discretionary_data: String | nil, company_entry_description: String | nil, + company_id: String, company_name: String | nil, created_at: Time, created_by: Increase::Models::ACHTransfer::CreatedBy | nil,