diff --git a/generators/ruby-v2/dynamic-snippets/src/EndpointSnippetGenerator.ts b/generators/ruby-v2/dynamic-snippets/src/EndpointSnippetGenerator.ts index 5bf3c0441372..e01156a747c5 100644 --- a/generators/ruby-v2/dynamic-snippets/src/EndpointSnippetGenerator.ts +++ b/generators/ruby-v2/dynamic-snippets/src/EndpointSnippetGenerator.ts @@ -553,7 +553,7 @@ export class EndpointSnippetGenerator { ); // Add body fields as keyword arguments - if (request.body != null) { + if (request.body != null && snippet.requestBody != null) { switch (request.body.type) { case "bytes": // Not supported in Ruby snippets yet @@ -563,22 +563,45 @@ export class EndpointSnippetGenerator { }); break; case "typeReference": { - // For typeReference bodies, we need to flatten the body fields into keyword arguments - // The Ruby SDK expects keyword args that get wrapped into the type by the method - const bodyRecord = this.context.getRecord(snippet.requestBody); - if (bodyRecord != null) { - // Get the type definition to understand the field names - const typeRef = request.body.value; - if (typeRef.type === "named") { - const namedType = this.context.resolveNamedType({ typeId: typeRef.value }); - if (namedType != null) { - // Convert the body record fields to keyword arguments + const typeRef = request.body.value; + + // Check if this is a named type that we can resolve + if (typeRef.type === "named") { + const namedType = this.context.resolveNamedType({ typeId: typeRef.value }); + if (namedType != null && namedType.type === "object") { + // For objects, flatten the body fields into keyword arguments + const bodyRecord = this.context.getRecord(snippet.requestBody); + if (bodyRecord != null) { const bodyFields = this.getBodyFieldsAsKeywordArgs({ namedType, bodyRecord }); args.push(...bodyFields); } + } else if (namedType != null) { + // For non-object named types (undiscriminated unions, aliases, etc.), + // convert the entire body value and pass as a single 'request' keyword argument + const bodyArgs = this.getBodyArgsForNonObjectType({ + namedType, + typeRef, + bodyValue: snippet.requestBody + }); + args.push(...bodyArgs); + } + } else { + // For non-named type references (containers, primitives, etc.), + // convert the body value directly + const convertedValue = this.context.dynamicTypeLiteralMapper.convert({ + typeReference: typeRef, + value: snippet.requestBody + }); + if (!ruby.TypeLiteral.isNop(convertedValue)) { + args.push( + ruby.keywordArgument({ + name: "request", + value: convertedValue + }) + ); } } break; @@ -591,6 +614,119 @@ export class EndpointSnippetGenerator { return args; } + private getBodyArgsForNonObjectType({ + namedType, + typeRef, + bodyValue + }: { + namedType: FernIr.dynamic.NamedType; + typeRef: FernIr.dynamic.TypeReference; + bodyValue: unknown; + }): ruby.KeywordArgument[] { + const args: ruby.KeywordArgument[] = []; + + switch (namedType.type) { + case "undiscriminatedUnion": { + // For undiscriminated unions, the body value should match one of the variants + // Try to convert it and extract the fields as keyword arguments + const bodyRecord = this.context.getRecord(bodyValue); + if (bodyRecord != null) { + // The body is an object - try to find a matching variant and extract its fields + for (const variant of namedType.types) { + if (variant.type === "named") { + const variantType = this.context.resolveNamedType({ typeId: variant.value }); + if (variantType != null && variantType.type === "object") { + // Check if the body matches this variant's properties + const variantProps = new Set(variantType.properties.map((p) => p.name.wireValue)); + const bodyKeys = Object.keys(bodyRecord); + const allKeysMatch = bodyKeys.every((key) => variantProps.has(key)); + if (allKeysMatch && bodyKeys.length > 0) { + // This variant matches - flatten its fields + const bodyFields = this.getBodyFieldsAsKeywordArgs({ + namedType: variantType, + bodyRecord + }); + args.push(...bodyFields); + return args; + } + } + } + } + } + // If we couldn't match a variant or extract fields, convert the whole value + const convertedValue = this.context.dynamicTypeLiteralMapper.convert({ + typeReference: typeRef, + value: bodyValue + }); + if (!ruby.TypeLiteral.isNop(convertedValue)) { + args.push( + ruby.keywordArgument({ + name: "request", + value: convertedValue + }) + ); + } + break; + } + case "alias": { + // For aliases, check if the underlying type is an object we can flatten + const aliasedType = namedType.typeReference; + if (aliasedType.type === "named") { + const resolvedAliasType = this.context.resolveNamedType({ typeId: aliasedType.value }); + if (resolvedAliasType != null && resolvedAliasType.type === "object") { + const bodyRecord = this.context.getRecord(bodyValue); + if (bodyRecord != null) { + const bodyFields = this.getBodyFieldsAsKeywordArgs({ + namedType: resolvedAliasType, + bodyRecord + }); + args.push(...bodyFields); + return args; + } + } + } + // For non-object aliases (arrays, primitives, etc.), convert the whole value + const convertedValue = this.context.dynamicTypeLiteralMapper.convert({ + typeReference: typeRef, + value: bodyValue + }); + if (!ruby.TypeLiteral.isNop(convertedValue)) { + args.push( + ruby.keywordArgument({ + name: "request", + value: convertedValue + }) + ); + } + break; + } + case "discriminatedUnion": + case "enum": { + // For discriminated unions and enums, convert the whole value + const convertedValue = this.context.dynamicTypeLiteralMapper.convert({ + typeReference: typeRef, + value: bodyValue + }); + if (!ruby.TypeLiteral.isNop(convertedValue)) { + args.push( + ruby.keywordArgument({ + name: "request", + value: convertedValue + }) + ); + } + break; + } + case "object": + // This shouldn't happen as objects are handled separately + break; + default: + assertNever(namedType); + } + + return args; + } + private getBodyFieldsAsKeywordArgs({ namedType, bodyRecord diff --git a/generators/ruby-v2/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap b/generators/ruby-v2/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap index 024b62c3de75..92dd6c9b77ca 100644 --- a/generators/ruby-v2/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap +++ b/generators/ruby-v2/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap @@ -31,6 +31,10 @@ exports[`snippets (default) > examples > 'POST /big-entity (simple)' 1`] = ` client = Acme::Client.new(token: ''); client.service.create_big_entity( + cast_member: { + id: 'john.doe', + name: 'John Doe' + }, extended_movie: { cast: ['John Travolta', 'Samuel L. Jackson', 'Uma Thurman', 'Bruce Willis'], id: 'movie-sda231x', @@ -43,7 +47,8 @@ client.service.create_big_entity( revenue: 1000000 }, migration: { - name: 'Migration 31 Aug' + name: 'Migration 31 Aug', + status: 'RUNNING' } ); " @@ -109,30 +114,43 @@ exports[`snippets (default) > exhaustive > 'POST /container/list-of-objects (inv "[ { "severity": "CRITICAL", - "path": [], - "message": "Expected object with key, value pairs but got: array" + "path": [ + "string" + ], + "message": "Expected string, got boolean" + }, + { + "severity": "CRITICAL", + "path": [ + "string" + ], + "message": "Expected string, got number" } ]" `; exports[`snippets (default) > exhaustive > 'POST /container/list-of-objects (simp…' 1`] = ` -"[ - { - "severity": "CRITICAL", - "path": [], - "message": "Expected object with key, value pairs but got: array" - } -]" +"require "acme" + +client = Acme::Client.new(token: ''); + +client.endpoints.container.get_and_return_list_of_objects(request: [{ + string: 'one' +}, { + string: 'two' +}, { + string: 'three' +}]); +" `; exports[`snippets (default) > exhaustive > 'POST /container/list-of-primitives (s…' 1`] = ` -"[ - { - "severity": "CRITICAL", - "path": [], - "message": "Expected object with key, value pairs but got: array" - } -]" +"require "acme" + +client = Acme::Client.new(token: ''); + +client.endpoints.container.get_and_return_list_of_primitives(request: ['one', 'two', 'three']); +" `; exports[`snippets (default) > file-upload > 'POST /' 1`] = ` diff --git a/generators/ruby-v2/dynamic-snippets/src/context/DynamicToLiteralMapper.ts b/generators/ruby-v2/dynamic-snippets/src/context/DynamicToLiteralMapper.ts index c56c2831f72e..d55b38f08cd8 100644 --- a/generators/ruby-v2/dynamic-snippets/src/context/DynamicToLiteralMapper.ts +++ b/generators/ruby-v2/dynamic-snippets/src/context/DynamicToLiteralMapper.ts @@ -1,4 +1,4 @@ -import { Severity } from "@fern-api/browser-compatible-base-generator"; +import { DiscriminatedUnionTypeInstance, Severity } from "@fern-api/browser-compatible-base-generator"; import { assertNever } from "@fern-api/core-utils"; import { FernIr } from "@fern-api/dynamic-ir-sdk"; import { ruby } from "@fern-api/ruby-ast"; @@ -172,22 +172,189 @@ export class DynamicTypeLiteralMapper { return this.convert({ typeReference: named.typeReference, value, as }); } case "discriminatedUnion": - // Not implemented - return ruby.TypeLiteral.nop(); + return this.convertDiscriminatedUnion({ + discriminatedUnion: named, + value + }); case "object": - // Not implemented return this.convertObject({ object: named, value }); case "enum": - // Not implemented - return ruby.TypeLiteral.nop(); + return this.convertEnum({ enum_: named, value }); case "undiscriminatedUnion": - // Not implemented - return ruby.TypeLiteral.nop(); + return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value }); default: assertNever(named); } } + private convertDiscriminatedUnion({ + discriminatedUnion, + value + }: { + discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType; + value: unknown; + }): ruby.AstNode { + const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({ + discriminatedUnion, + value + }); + if (discriminatedUnionTypeInstance == null) { + return ruby.TypeLiteral.nop(); + } + const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType; + const unionProperties = this.convertDiscriminatedUnionProperties({ + discriminatedUnionTypeInstance, + unionVariant + }); + if (unionProperties == null) { + return ruby.TypeLiteral.nop(); + } + return ruby.TypeLiteral.hash(unionProperties); + } + + private convertDiscriminatedUnionProperties({ + discriminatedUnionTypeInstance, + unionVariant + }: { + discriminatedUnionTypeInstance: DiscriminatedUnionTypeInstance; + unionVariant: FernIr.dynamic.SingleDiscriminatedUnionType; + }): ruby.HashEntry[] | undefined { + switch (unionVariant.type) { + case "samePropertiesAsObject": { + const named = this.context.resolveNamedType({ + typeId: unionVariant.typeId + }); + if (named == null) { + return undefined; + } + const converted = this.convertNamed({ named, value: discriminatedUnionTypeInstance.value }); + // For Ruby, we expect a hash back from convertNamed for objects + // We need to extract the entries from the hash + return this.extractHashEntries(converted); + } + case "singleProperty": { + try { + this.context.errors.scope(unionVariant.discriminantValue.wireValue); + const record = this.context.getRecord(discriminatedUnionTypeInstance.value); + if (record == null) { + return [ + { + key: ruby.TypeLiteral.string( + this.context.getPropertyName(unionVariant.discriminantValue.name) + ), + value: this.convert({ + typeReference: unionVariant.typeReference, + value: discriminatedUnionTypeInstance.value + }) + } + ]; + } + return [ + { + key: ruby.TypeLiteral.string( + this.context.getPropertyName(unionVariant.discriminantValue.name) + ), + value: this.convert({ + typeReference: unionVariant.typeReference, + value: record[unionVariant.discriminantValue.wireValue] + }) + } + ]; + } finally { + this.context.errors.unscope(); + } + } + case "noProperties": + return []; + default: + assertNever(unionVariant); + } + } + + private extractHashEntries(node: ruby.AstNode): ruby.HashEntry[] | undefined { + // This is a workaround to extract hash entries from a TypeLiteral + // We need to check if the node is a hash and extract its entries + // For now, we'll return an empty array if we can't extract entries + // The node should be a hash created by convertObject + if (node instanceof ruby.TypeLiteral) { + // TypeLiteral doesn't expose internal type, so we need to work around this + // by re-converting the value as an object + return undefined; + } + return undefined; + } + + private convertEnum({ enum_, value }: { enum_: FernIr.dynamic.EnumType; value: unknown }): ruby.AstNode { + const name = this.getEnumValueName({ enum_, value }); + if (name == null) { + return ruby.TypeLiteral.nop(); + } + // In Ruby, enum values are typically represented as strings + return ruby.TypeLiteral.string(name); + } + + private getEnumValueName({ enum_, value }: { enum_: FernIr.dynamic.EnumType; value: unknown }): string | undefined { + if (typeof value !== "string") { + this.context.errors.add({ + severity: Severity.Critical, + message: `Expected enum value string, got: ${typeof value}` + }); + return undefined; + } + const enumValue = enum_.values.find((v) => v.wireValue === value); + if (enumValue == null) { + this.context.errors.add({ + severity: Severity.Critical, + message: `An enum value named "${value}" does not exist in this context` + }); + return undefined; + } + // Return the wire value for Ruby (as a string) + return enumValue.wireValue; + } + + private convertUndiscriminatedUnion({ + undiscriminatedUnion, + value + }: { + undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType; + value: unknown; + }): ruby.AstNode { + const result = this.findMatchingUndiscriminatedUnionType({ + undiscriminatedUnion, + value + }); + if (result == null) { + return ruby.TypeLiteral.nop(); + } + return result; + } + + private findMatchingUndiscriminatedUnionType({ + undiscriminatedUnion, + value + }: { + undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType; + value: unknown; + }): ruby.AstNode | undefined { + for (const typeReference of undiscriminatedUnion.types) { + // Clone the context to avoid polluting errors + const clonedContext = this.context.clone(); + const clonedMapper = new DynamicTypeLiteralMapper({ context: clonedContext }); + const result = clonedMapper.convert({ typeReference, value }); + // If no errors were added, this type matched - return the already-converted result + // to avoid duplicate errors from calling convert() again on the main context + if (clonedContext.errors.empty()) { + return result; + } + } + this.context.errors.add({ + severity: Severity.Critical, + message: `None of the types in the undiscriminated union matched the given "${typeof value}" value` + }); + return undefined; + } + private convertPrimitive({ primitive, value, diff --git a/generators/ruby-v2/sdk/versions.yml b/generators/ruby-v2/sdk/versions.yml index 30f68c002c6c..cd12460fda71 100644 --- a/generators/ruby-v2/sdk/versions.yml +++ b/generators/ruby-v2/sdk/versions.yml @@ -1,5 +1,15 @@ # yaml-language-server: $schema=../../../fern-versions-yml.schema.json +- version: 1.0.0-rc62 + createdAt: "2025-12-08" + changelogEntry: + - type: feat + summary: | + Add support for discriminated unions, enums, and undiscriminated unions in dynamic snippets. + This fixes issues where snippet examples were showing empty arrays or missing values for + complex types like union recipients in email/message send operations. + irVersion: 61 + - version: 1.0.0-rc61 createdAt: "2025-12-05" changelogEntry: diff --git a/seed/ruby-sdk-v2/accept-header/.rubocop.yml b/seed/ruby-sdk-v2/accept-header/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/accept-header/.rubocop.yml +++ b/seed/ruby-sdk-v2/accept-header/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/accept-header/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/accept-header/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/accept-header/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/accept-header/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/accept-header/seed.gemspec b/seed/ruby-sdk-v2/accept-header/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/accept-header/seed.gemspec +++ b/seed/ruby-sdk-v2/accept-header/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/accept-header/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/alias-extends/.rubocop.yml b/seed/ruby-sdk-v2/alias-extends/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/alias-extends/.rubocop.yml +++ b/seed/ruby-sdk-v2/alias-extends/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/alias-extends/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/alias-extends/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/alias-extends/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/alias-extends/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/alias-extends/seed.gemspec b/seed/ruby-sdk-v2/alias-extends/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/alias-extends/seed.gemspec +++ b/seed/ruby-sdk-v2/alias-extends/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/alias-extends/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/alias/.rubocop.yml b/seed/ruby-sdk-v2/alias/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/alias/.rubocop.yml +++ b/seed/ruby-sdk-v2/alias/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/alias/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/alias/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/alias/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/alias/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/alias/seed.gemspec b/seed/ruby-sdk-v2/alias/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/alias/seed.gemspec +++ b/seed/ruby-sdk-v2/alias/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/alias/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/any-auth/.rubocop.yml b/seed/ruby-sdk-v2/any-auth/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/any-auth/.rubocop.yml +++ b/seed/ruby-sdk-v2/any-auth/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/any-auth/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/any-auth/lib/seed/auth/client.rb index 015a464dff62..c3759ca72769 100644 --- a/seed/ruby-sdk-v2/any-auth/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/any-auth/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/any-auth/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/any-auth/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/any-auth/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/any-auth/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/any-auth/seed.gemspec b/seed/ruby-sdk-v2/any-auth/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/any-auth/seed.gemspec +++ b/seed/ruby-sdk-v2/any-auth/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/any-auth/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/api-wide-base-path/.rubocop.yml b/seed/ruby-sdk-v2/api-wide-base-path/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/api-wide-base-path/.rubocop.yml +++ b/seed/ruby-sdk-v2/api-wide-base-path/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/api-wide-base-path/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/api-wide-base-path/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/api-wide-base-path/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/api-wide-base-path/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/api-wide-base-path/seed.gemspec b/seed/ruby-sdk-v2/api-wide-base-path/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/api-wide-base-path/seed.gemspec +++ b/seed/ruby-sdk-v2/api-wide-base-path/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/api-wide-base-path/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/audiences/.rubocop.yml b/seed/ruby-sdk-v2/audiences/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/audiences/.rubocop.yml +++ b/seed/ruby-sdk-v2/audiences/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/audiences/lib/seed/folder_a/service/client.rb b/seed/ruby-sdk-v2/audiences/lib/seed/folder_a/service/client.rb index 7342c18a749b..28e7c9b79b83 100644 --- a/seed/ruby-sdk-v2/audiences/lib/seed/folder_a/service/client.rb +++ b/seed/ruby-sdk-v2/audiences/lib/seed/folder_a/service/client.rb @@ -34,7 +34,8 @@ def get_direct_thread(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/audiences/lib/seed/foo/client.rb b/seed/ruby-sdk-v2/audiences/lib/seed/foo/client.rb index 132b34f8d311..24806ced2e31 100644 --- a/seed/ruby-sdk-v2/audiences/lib/seed/foo/client.rb +++ b/seed/ruby-sdk-v2/audiences/lib/seed/foo/client.rb @@ -35,7 +35,8 @@ def find(request_options: {}, **params) method: "POST", path: "", query: query_params, - body: Seed::Foo::Types::FindRequest.new(body_bag).to_h + body: Seed::Foo::Types::FindRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/audiences/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/audiences/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/audiences/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/audiences/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/audiences/seed.gemspec b/seed/ruby-sdk-v2/audiences/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/audiences/seed.gemspec +++ b/seed/ruby-sdk-v2/audiences/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/audiences/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/basic-auth-environment-variables/.rubocop.yml b/seed/ruby-sdk-v2/basic-auth-environment-variables/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/basic-auth-environment-variables/.rubocop.yml +++ b/seed/ruby-sdk-v2/basic-auth-environment-variables/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/basic-auth-environment-variables/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/basic-auth-environment-variables/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/basic-auth-environment-variables/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/basic-auth-environment-variables/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/basic-auth-environment-variables/seed.gemspec b/seed/ruby-sdk-v2/basic-auth-environment-variables/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/basic-auth-environment-variables/seed.gemspec +++ b/seed/ruby-sdk-v2/basic-auth-environment-variables/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/basic-auth-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/basic-auth/.rubocop.yml b/seed/ruby-sdk-v2/basic-auth/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/basic-auth/.rubocop.yml +++ b/seed/ruby-sdk-v2/basic-auth/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/basic-auth/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/basic-auth/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/basic-auth/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/basic-auth/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/basic-auth/seed.gemspec b/seed/ruby-sdk-v2/basic-auth/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/basic-auth/seed.gemspec +++ b/seed/ruby-sdk-v2/basic-auth/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/basic-auth/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/bearer-token-environment-variable/.rubocop.yml b/seed/ruby-sdk-v2/bearer-token-environment-variable/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/bearer-token-environment-variable/.rubocop.yml +++ b/seed/ruby-sdk-v2/bearer-token-environment-variable/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/bearer-token-environment-variable/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/bearer-token-environment-variable/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/bearer-token-environment-variable/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/bearer-token-environment-variable/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/bearer-token-environment-variable/seed.gemspec b/seed/ruby-sdk-v2/bearer-token-environment-variable/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/bearer-token-environment-variable/seed.gemspec +++ b/seed/ruby-sdk-v2/bearer-token-environment-variable/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/bearer-token-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/bytes-download/.rubocop.yml b/seed/ruby-sdk-v2/bytes-download/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/bytes-download/.rubocop.yml +++ b/seed/ruby-sdk-v2/bytes-download/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/bytes-download/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/bytes-download/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/bytes-download/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/bytes-download/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/bytes-download/seed.gemspec b/seed/ruby-sdk-v2/bytes-download/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/bytes-download/seed.gemspec +++ b/seed/ruby-sdk-v2/bytes-download/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/bytes-download/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/bytes-upload/.rubocop.yml b/seed/ruby-sdk-v2/bytes-upload/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/bytes-upload/.rubocop.yml +++ b/seed/ruby-sdk-v2/bytes-upload/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/bytes-upload/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/bytes-upload/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/bytes-upload/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/bytes-upload/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/bytes-upload/seed.gemspec b/seed/ruby-sdk-v2/bytes-upload/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/bytes-upload/seed.gemspec +++ b/seed/ruby-sdk-v2/bytes-upload/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/bytes-upload/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/circular-references-advanced/.rubocop.yml b/seed/ruby-sdk-v2/circular-references-advanced/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/.rubocop.yml +++ b/seed/ruby-sdk-v2/circular-references-advanced/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/ast/types/nodes_wrapper.rb b/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/ast/types/nodes_wrapper.rb index 63e8ba9e9fd0..7cd630a10469 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/ast/types/nodes_wrapper.rb +++ b/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/ast/types/nodes_wrapper.rb @@ -4,9 +4,7 @@ module Seed module Ast module Types class NodesWrapper < Internal::Types::Model - field :nodes, -> { - Internal::Types::Array[Internal::Types::Array[Seed::Ast::Types::Node]] - }, optional: false, nullable: false + field :nodes, -> { Internal::Types::Array[Internal::Types::Array[Seed::Ast::Types::Node]] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/circular-references-advanced/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/circular-references-advanced/seed.gemspec b/seed/ruby-sdk-v2/circular-references-advanced/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/seed.gemspec +++ b/seed/ruby-sdk-v2/circular-references-advanced/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/circular-references-advanced/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/circular-references/.rubocop.yml b/seed/ruby-sdk-v2/circular-references/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/circular-references/.rubocop.yml +++ b/seed/ruby-sdk-v2/circular-references/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/circular-references/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/circular-references/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/circular-references/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/circular-references/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/circular-references/seed.gemspec b/seed/ruby-sdk-v2/circular-references/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/circular-references/seed.gemspec +++ b/seed/ruby-sdk-v2/circular-references/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/circular-references/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/client-side-params/.rubocop.yml b/seed/ruby-sdk-v2/client-side-params/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/client-side-params/.rubocop.yml +++ b/seed/ruby-sdk-v2/client-side-params/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/service/client.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/service/client.rb index d53f0dadf472..792928c8f245 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/service/client.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/service/client.rb @@ -45,7 +45,8 @@ def list_resources(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/resources", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -85,7 +86,8 @@ def get_resource(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/resources/#{params[:resource_id]}", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -130,7 +132,8 @@ def search_resources(request_options: {}, **params) method: "POST", path: "/api/resources/search", query: query_params, - body: Seed::Service::Types::SearchResourcesRequest.new(body_bag).to_h + body: Seed::Service::Types::SearchResourcesRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -183,7 +186,8 @@ def list_users(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -225,7 +229,8 @@ def get_user_by_id(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/users/#{params[:user_id]}", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -257,7 +262,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/api/users", - body: Seed::Types::Types::CreateUserRequest.new(params).to_h + body: Seed::Types::Types::CreateUserRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -290,7 +296,8 @@ def update_user(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "/api/users/#{params[:user_id]}", - body: Seed::Types::Types::UpdateUserRequest.new(params).to_h + body: Seed::Types::Types::UpdateUserRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -322,7 +329,8 @@ def delete_user(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "DELETE", - path: "/api/users/#{params[:user_id]}" + path: "/api/users/#{params[:user_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -363,7 +371,8 @@ def list_connections(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/connections", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -401,7 +410,8 @@ def get_connection(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/connections/#{params[:connection_id]}", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -454,7 +464,8 @@ def list_clients(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/clients", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -496,7 +507,8 @@ def get_client(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/clients/#{params[:client_id]}", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/service/types/search_resources_request.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/service/types/search_resources_request.rb index 17591356b68c..d6bec277c3eb 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/service/types/search_resources_request.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/service/types/search_resources_request.rb @@ -7,9 +7,7 @@ class SearchResourcesRequest < Internal::Types::Model field :limit, -> { Integer }, optional: false, nullable: false field :offset, -> { Integer }, optional: false, nullable: false field :query, -> { String }, optional: true, nullable: false - field :filters, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :filters, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/client.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/client.rb index a99c04c464d7..6dca800411a4 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/client.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/client.rb @@ -19,15 +19,9 @@ class Client < Internal::Types::Model field :allowed_origins, -> { Internal::Types::Array[String] }, optional: true, nullable: false field :web_origins, -> { Internal::Types::Array[String] }, optional: true, nullable: false field :grant_types, -> { Internal::Types::Array[String] }, optional: true, nullable: false - field :jwt_configuration, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false - field :signing_keys, -> { - Internal::Types::Array[Internal::Types::Hash[String, Internal::Types::Hash[String, Object]]] - }, optional: true, nullable: false - field :encryption_key, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :jwt_configuration, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false + field :signing_keys, -> { Internal::Types::Array[Internal::Types::Hash[String, Object]] }, optional: true, nullable: false + field :encryption_key, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :sso, -> { Internal::Types::Boolean }, optional: true, nullable: false field :sso_disabled, -> { Internal::Types::Boolean }, optional: true, nullable: false field :cross_origin_auth, -> { Internal::Types::Boolean }, optional: true, nullable: false @@ -37,16 +31,10 @@ class Client < Internal::Types::Model field :custom_login_page_preview, -> { String }, optional: true, nullable: false field :form_template, -> { String }, optional: true, nullable: false field :is_heroku_app, -> { Internal::Types::Boolean }, optional: true, nullable: false - field :addons, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :addons, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :token_endpoint_auth_method, -> { String }, optional: true, nullable: false - field :client_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false - field :mobile, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :client_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false + field :mobile, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/connection.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/connection.rb index 1e941d575797..b250bafd484f 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/connection.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/connection.rb @@ -9,15 +9,11 @@ class Connection < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false field :display_name, -> { String }, optional: true, nullable: false field :strategy, -> { String }, optional: false, nullable: false - field :options, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :options, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :enabled_clients, -> { Internal::Types::Array[String] }, optional: true, nullable: false field :realms, -> { Internal::Types::Array[String] }, optional: true, nullable: false field :is_domain_connection, -> { Internal::Types::Boolean }, optional: true, nullable: false - field :metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/create_user_request.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/create_user_request.rb index f49d10bbabf1..2d1c12c95c7e 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/create_user_request.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/create_user_request.rb @@ -10,12 +10,8 @@ class CreateUserRequest < Internal::Types::Model field :password, -> { String }, optional: true, nullable: false field :phone_number, -> { String }, optional: true, nullable: false field :phone_verified, -> { Internal::Types::Boolean }, optional: true, nullable: false - field :user_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false - field :app_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :user_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false + field :app_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :connection, -> { String }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/resource.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/resource.rb index 75365839ccf3..d40afc943529 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/resource.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/resource.rb @@ -9,9 +9,7 @@ class Resource < Internal::Types::Model field :description, -> { String }, optional: true, nullable: false field :created_at, -> { String }, optional: false, nullable: false field :updated_at, -> { String }, optional: false, nullable: false - field :metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/update_user_request.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/update_user_request.rb index ac4ba0660fbf..3214a36e13c2 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/update_user_request.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/update_user_request.rb @@ -9,12 +9,8 @@ class UpdateUserRequest < Internal::Types::Model field :username, -> { String }, optional: true, nullable: false field :phone_number, -> { String }, optional: true, nullable: false field :phone_verified, -> { Internal::Types::Boolean }, optional: true, nullable: false - field :user_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false - field :app_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :user_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false + field :app_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :password, -> { String }, optional: true, nullable: false field :blocked, -> { Internal::Types::Boolean }, optional: true, nullable: false end diff --git a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/user.rb b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/user.rb index 8d360cb74540..017e36e79e54 100644 --- a/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/user.rb +++ b/seed/ruby-sdk-v2/client-side-params/lib/seed/types/types/user.rb @@ -14,12 +14,8 @@ class User < Internal::Types::Model field :created_at, -> { String }, optional: false, nullable: false field :updated_at, -> { String }, optional: false, nullable: false field :identities, -> { Internal::Types::Array[Seed::Types::Types::Identity] }, optional: true, nullable: false - field :app_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false - field :user_metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :app_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false + field :user_metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :picture, -> { String }, optional: true, nullable: false field :name, -> { String }, optional: true, nullable: false field :nickname, -> { String }, optional: true, nullable: false diff --git a/seed/ruby-sdk-v2/client-side-params/seed.gemspec b/seed/ruby-sdk-v2/client-side-params/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/client-side-params/seed.gemspec +++ b/seed/ruby-sdk-v2/client-side-params/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/client-side-params/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/content-type/.rubocop.yml b/seed/ruby-sdk-v2/content-type/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/content-type/.rubocop.yml +++ b/seed/ruby-sdk-v2/content-type/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/content-type/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/content-type/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/content-type/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/content-type/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/content-type/lib/seed/service/client.rb b/seed/ruby-sdk-v2/content-type/lib/seed/service/client.rb index bbf44bf74258..53d97c07ead8 100644 --- a/seed/ruby-sdk-v2/content-type/lib/seed/service/client.rb +++ b/seed/ruby-sdk-v2/content-type/lib/seed/service/client.rb @@ -27,7 +27,8 @@ def patch(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "", - body: Seed::Service::Types::PatchProxyRequest.new(body_bag).to_h + body: Seed::Service::Types::PatchProxyRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -66,7 +67,8 @@ def patch_complex(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "complex/#{params[:id]}", - body: Seed::Service::Types::PatchComplexRequest.new(body_bag).to_h + body: Seed::Service::Types::PatchComplexRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -103,7 +105,8 @@ def named_patch_with_mixed(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "named-mixed/#{params[:id]}", - body: Seed::Service::Types::NamedMixedPatchRequest.new(body_bag).to_h + body: Seed::Service::Types::NamedMixedPatchRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -139,7 +142,8 @@ def optional_merge_patch_test(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "optional-merge-patch-test", - body: Seed::Service::Types::OptionalMergePatchRequest.new(body_bag).to_h + body: Seed::Service::Types::OptionalMergePatchRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -175,7 +179,8 @@ def regular_patch(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "regular/#{params[:id]}", - body: Seed::Service::Types::RegularPatchRequest.new(body_bag).to_h + body: Seed::Service::Types::RegularPatchRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/content-type/lib/seed/service/types/optional_merge_patch_request.rb b/seed/ruby-sdk-v2/content-type/lib/seed/service/types/optional_merge_patch_request.rb index e5b82a411ffa..38cf48a4d5d1 100644 --- a/seed/ruby-sdk-v2/content-type/lib/seed/service/types/optional_merge_patch_request.rb +++ b/seed/ruby-sdk-v2/content-type/lib/seed/service/types/optional_merge_patch_request.rb @@ -7,9 +7,7 @@ class OptionalMergePatchRequest < Internal::Types::Model field :required_field, -> { String }, optional: false, nullable: false, api_name: "requiredField" field :optional_string, -> { String }, optional: true, nullable: false, api_name: "optionalString" field :optional_integer, -> { Integer }, optional: true, nullable: false, api_name: "optionalInteger" - field :optional_boolean, -> { - Internal::Types::Boolean - }, optional: true, nullable: false, api_name: "optionalBoolean" + field :optional_boolean, -> { Internal::Types::Boolean }, optional: true, nullable: false, api_name: "optionalBoolean" field :nullable_string, -> { String }, optional: false, nullable: true, api_name: "nullableString" end end diff --git a/seed/ruby-sdk-v2/content-type/lib/seed/service/types/patch_complex_request.rb b/seed/ruby-sdk-v2/content-type/lib/seed/service/types/patch_complex_request.rb index a788a2a92d9d..26b61c89bb35 100644 --- a/seed/ruby-sdk-v2/content-type/lib/seed/service/types/patch_complex_request.rb +++ b/seed/ruby-sdk-v2/content-type/lib/seed/service/types/patch_complex_request.rb @@ -8,17 +8,13 @@ class PatchComplexRequest < Internal::Types::Model field :name, -> { String }, optional: true, nullable: false field :age, -> { Integer }, optional: true, nullable: false field :active, -> { Internal::Types::Boolean }, optional: true, nullable: false - field :metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false field :tags, -> { Internal::Types::Array[String] }, optional: true, nullable: false field :email, -> { String }, optional: true, nullable: false field :nickname, -> { String }, optional: true, nullable: false field :bio, -> { String }, optional: true, nullable: false field :profile_image_url, -> { String }, optional: true, nullable: false, api_name: "profileImageUrl" - field :settings, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :settings, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/content-type/seed.gemspec b/seed/ruby-sdk-v2/content-type/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/content-type/seed.gemspec +++ b/seed/ruby-sdk-v2/content-type/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/content-type/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/cross-package-type-names/.rubocop.yml b/seed/ruby-sdk-v2/cross-package-type-names/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/.rubocop.yml +++ b/seed/ruby-sdk-v2/cross-package-type-names/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/foo/client.rb b/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/foo/client.rb index 132b34f8d311..24806ced2e31 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/foo/client.rb +++ b/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/foo/client.rb @@ -35,7 +35,8 @@ def find(request_options: {}, **params) method: "POST", path: "", query: query_params, - body: Seed::Foo::Types::FindRequest.new(body_bag).to_h + body: Seed::Foo::Types::FindRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/cross-package-type-names/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/cross-package-type-names/seed.gemspec b/seed/ruby-sdk-v2/cross-package-type-names/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/seed.gemspec +++ b/seed/ruby-sdk-v2/cross-package-type-names/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/cross-package-type-names/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/empty-clients/.rubocop.yml b/seed/ruby-sdk-v2/empty-clients/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/empty-clients/.rubocop.yml +++ b/seed/ruby-sdk-v2/empty-clients/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/empty-clients/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/empty-clients/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/empty-clients/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/empty-clients/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/empty-clients/seed.gemspec b/seed/ruby-sdk-v2/empty-clients/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/empty-clients/seed.gemspec +++ b/seed/ruby-sdk-v2/empty-clients/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/empty-clients/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/enum/.rubocop.yml b/seed/ruby-sdk-v2/enum/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/enum/.rubocop.yml +++ b/seed/ruby-sdk-v2/enum/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example0/snippet.rb index 91aa8895a123..acc1900df5e0 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example0/snippet.rb @@ -2,4 +2,8 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.headers.send_(); +client.headers.send_( + operand: '>', + maybe_operand: '>', + operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example1/snippet.rb index 3d56f7c6271e..268f57bffec0 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example1/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.inlined_request.send_(); +client.inlined_request.send_( + operand: '>', + operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example2/snippet.rb index 3d56f7c6271e..46ab2816693e 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example2/snippet.rb @@ -2,4 +2,9 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.inlined_request.send_(); +client.inlined_request.send_( + operand: '>', + maybe_operand: '>', + operand_or_color: 'red', + maybe_operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example3/snippet.rb index b7a2dd6deeb5..64b2b5f8d032 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example3/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.path_param.send_(); +client.path_param.send_( + operand: '>', + operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example4/snippet.rb index b7a2dd6deeb5..64b2b5f8d032 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example4/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.path_param.send_(); +client.path_param.send_( + operand: '>', + operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example5/snippet.rb index 15d7172d69f8..2055253bd5f6 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example5/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.query_param.send_(); +client.query_param.send_( + operand: '>', + operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/enum/dynamic-snippets/example6/snippet.rb index 15d7172d69f8..15678f371d1e 100644 --- a/seed/ruby-sdk-v2/enum/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/enum/dynamic-snippets/example6/snippet.rb @@ -2,4 +2,9 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.query_param.send_(); +client.query_param.send_( + operand: '>', + maybe_operand: '>', + operand_or_color: 'red', + maybe_operand_or_color: 'red' +); diff --git a/seed/ruby-sdk-v2/enum/lib/seed/headers/types/send_enum_as_header_request.rb b/seed/ruby-sdk-v2/enum/lib/seed/headers/types/send_enum_as_header_request.rb index e6ada6bab760..d939481f2656 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/headers/types/send_enum_as_header_request.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/headers/types/send_enum_as_header_request.rb @@ -6,12 +6,8 @@ module Types class SendEnumAsHeaderRequest < Internal::Types::Model field :operand, -> { Seed::Types::Operand }, optional: false, nullable: false field :maybe_operand, -> { Seed::Types::Operand }, optional: true, nullable: false, api_name: "maybeOperand" - field :operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: false, nullable: false, api_name: "operandOrColor" - field :maybe_operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: true, nullable: false, api_name: "maybeOperandOrColor" + field :operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: false, nullable: false, api_name: "operandOrColor" + field :maybe_operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: true, nullable: false, api_name: "maybeOperandOrColor" end end end diff --git a/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/client.rb b/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/client.rb index d973211b05b2..6ff5e1a95dd6 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/client.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/client.rb @@ -27,7 +27,8 @@ def send_(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "inlined", - body: Seed::InlinedRequest::Types::SendEnumInlinedRequest.new(body_bag).to_h + body: Seed::InlinedRequest::Types::SendEnumInlinedRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/types/send_enum_inlined_request.rb b/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/types/send_enum_inlined_request.rb index 71deb0558c9e..c2430b9ab8d4 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/types/send_enum_inlined_request.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/inlined_request/types/send_enum_inlined_request.rb @@ -6,12 +6,8 @@ module Types class SendEnumInlinedRequest < Internal::Types::Model field :operand, -> { Seed::Types::Operand }, optional: false, nullable: false field :maybe_operand, -> { Seed::Types::Operand }, optional: true, nullable: false, api_name: "maybeOperand" - field :operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: false, nullable: false, api_name: "operandOrColor" - field :maybe_operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: true, nullable: false, api_name: "maybeOperandOrColor" + field :operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: false, nullable: false, api_name: "operandOrColor" + field :maybe_operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: true, nullable: false, api_name: "maybeOperandOrColor" end end end diff --git a/seed/ruby-sdk-v2/enum/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/enum/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/enum/lib/seed/query_param/client.rb b/seed/ruby-sdk-v2/enum/lib/seed/query_param/client.rb index b821af5d6940..546578752e10 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/query_param/client.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/query_param/client.rb @@ -37,7 +37,8 @@ def send_(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "query", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -78,7 +79,8 @@ def send_list(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "query-list", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_as_query_param_request.rb b/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_as_query_param_request.rb index d523fd9c9a41..3eecd92226a7 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_as_query_param_request.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_as_query_param_request.rb @@ -6,12 +6,8 @@ module Types class SendEnumAsQueryParamRequest < Internal::Types::Model field :operand, -> { Seed::Types::Operand }, optional: false, nullable: false field :maybe_operand, -> { Seed::Types::Operand }, optional: true, nullable: false, api_name: "maybeOperand" - field :operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: false, nullable: false, api_name: "operandOrColor" - field :maybe_operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: true, nullable: false, api_name: "maybeOperandOrColor" + field :operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: false, nullable: false, api_name: "operandOrColor" + field :maybe_operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: true, nullable: false, api_name: "maybeOperandOrColor" end end end diff --git a/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_list_as_query_param_request.rb b/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_list_as_query_param_request.rb index 421f8bb2f068..b8776d561823 100644 --- a/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_list_as_query_param_request.rb +++ b/seed/ruby-sdk-v2/enum/lib/seed/query_param/types/send_enum_list_as_query_param_request.rb @@ -6,12 +6,8 @@ module Types class SendEnumListAsQueryParamRequest < Internal::Types::Model field :operand, -> { Seed::Types::Operand }, optional: false, nullable: false field :maybe_operand, -> { Seed::Types::Operand }, optional: true, nullable: false, api_name: "maybeOperand" - field :operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: false, nullable: false, api_name: "operandOrColor" - field :maybe_operand_or_color, -> { - Seed::Types::ColorOrOperand - }, optional: true, nullable: false, api_name: "maybeOperandOrColor" + field :operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: false, nullable: false, api_name: "operandOrColor" + field :maybe_operand_or_color, -> { Seed::Types::ColorOrOperand }, optional: true, nullable: false, api_name: "maybeOperandOrColor" end end end diff --git a/seed/ruby-sdk-v2/enum/reference.md b/seed/ruby-sdk-v2/enum/reference.md index 4ff341768c8c..5cd594aed052 100644 --- a/seed/ruby-sdk-v2/enum/reference.md +++ b/seed/ruby-sdk-v2/enum/reference.md @@ -13,7 +13,11 @@
```ruby -client.headers.send_(); +client.headers.send_( + operand: '>', + maybe_operand: '>', + operand_or_color: 'red' +); ```
@@ -78,7 +82,10 @@ client.headers.send_();
```ruby -client.inlined_request.send_(); +client.inlined_request.send_( + operand: '>', + operand_or_color: 'red' +); ```
@@ -144,7 +151,10 @@ client.inlined_request.send_();
```ruby -client.path_param.send_(); +client.path_param.send_( + operand: '>', + operand_or_color: 'red' +); ```
@@ -193,7 +203,10 @@ client.path_param.send_();
```ruby -client.query_param.send_(); +client.query_param.send_( + operand: '>', + operand_or_color: 'red' +); ```
diff --git a/seed/ruby-sdk-v2/enum/seed.gemspec b/seed/ruby-sdk-v2/enum/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/enum/seed.gemspec +++ b/seed/ruby-sdk-v2/enum/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/enum/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/error-property/.rubocop.yml b/seed/ruby-sdk-v2/error-property/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/error-property/.rubocop.yml +++ b/seed/ruby-sdk-v2/error-property/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/error-property/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/error-property/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/error-property/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/error-property/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/error-property/seed.gemspec b/seed/ruby-sdk-v2/error-property/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/error-property/seed.gemspec +++ b/seed/ruby-sdk-v2/error-property/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/error-property/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/errors/.rubocop.yml b/seed/ruby-sdk-v2/errors/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/errors/.rubocop.yml +++ b/seed/ruby-sdk-v2/errors/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/errors/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/errors/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/errors/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/errors/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/errors/seed.gemspec b/seed/ruby-sdk-v2/errors/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/errors/seed.gemspec +++ b/seed/ruby-sdk-v2/errors/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/errors/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/.rubocop.yml b/seed/ruby-sdk-v2/examples/no-custom-config/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/.rubocop.yml +++ b/seed/ruby-sdk-v2/examples/no-custom-config/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example0/snippet.rb index fc83f7a9c273..231ea78339b0 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example0/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example1/snippet.rb index fc83f7a9c273..1e60192ac875 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example1/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'string'); diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example19/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example19/snippet.rb index 11e126116692..5096430fab90 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example19/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example19/snippet.rb @@ -6,6 +6,10 @@ ); client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -20,8 +24,10 @@ revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -29,9 +35,12 @@ }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example2/snippet.rb index fc83f7a9c273..92ff42da744f 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example2/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'primitive'); diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example21/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example21/snippet.rb index dbd0db80ba5c..25cc1e2ca24d 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example21/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example21/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 420 +}); diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example22/snippet.rb b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example22/snippet.rb index dbd0db80ba5c..36532df34335 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example22/snippet.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/dynamic-snippets/example22/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 1 +}); diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/service/client.rb b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/service/client.rb index 2ecb3c43b6ee..b459549cb4d5 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/service/client.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/service/client.rb @@ -24,7 +24,8 @@ def get_movie(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/movie/#{params[:movie_id]}" + path: "/movie/#{params[:movie_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -54,7 +55,8 @@ def create_movie(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/movie", - body: Seed::Types::Types::Movie.new(params).to_h + body: Seed::Types::Types::Movie.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -94,7 +96,8 @@ def get_metadata(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/metadata", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -124,7 +127,8 @@ def create_big_entity(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/big-entity", - body: Seed::Types::Types::BigEntity.new(params).to_h + body: Seed::Types::Types::BigEntity.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -154,7 +158,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/refresh-token", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/big_entity.rb b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/big_entity.rb index c0dc0f851497..8d6d91641b70 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/big_entity.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/big_entity.rb @@ -4,20 +4,12 @@ module Seed module Types module Types class BigEntity < Internal::Types::Model - field :cast_member, -> { - Seed::Types::Types::CastMember - }, optional: true, nullable: false, api_name: "castMember" - field :extended_movie, -> { - Seed::Types::Types::ExtendedMovie - }, optional: true, nullable: false, api_name: "extendedMovie" + field :cast_member, -> { Seed::Types::Types::CastMember }, optional: true, nullable: false, api_name: "castMember" + field :extended_movie, -> { Seed::Types::Types::ExtendedMovie }, optional: true, nullable: false, api_name: "extendedMovie" field :entity, -> { Seed::Types::Types::Entity }, optional: true, nullable: false field :metadata, -> { Seed::Types::Types::Metadata }, optional: true, nullable: false - field :common_metadata, -> { - Seed::Commons::Types::Types::Metadata - }, optional: true, nullable: false, api_name: "commonMetadata" - field :event_info, -> { - Seed::Commons::Types::Types::EventInfo - }, optional: true, nullable: false, api_name: "eventInfo" + field :common_metadata, -> { Seed::Commons::Types::Types::Metadata }, optional: true, nullable: false, api_name: "commonMetadata" + field :event_info, -> { Seed::Commons::Types::Types::EventInfo }, optional: true, nullable: false, api_name: "eventInfo" field :data, -> { Seed::Commons::Types::Types::Data }, optional: true, nullable: false field :migration, -> { Seed::Types::Types::Migration }, optional: true, nullable: false field :exception, -> { Seed::Types::Types::Exception }, optional: true, nullable: false diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/directory.rb b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/directory.rb index 06d05d7d40b9..652903273926 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/directory.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/directory.rb @@ -6,9 +6,7 @@ module Types class Directory < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false field :files, -> { Internal::Types::Array[Seed::Types::Types::File] }, optional: true, nullable: false - field :directories, -> { - Internal::Types::Array[Seed::Types::Types::Directory] - }, optional: true, nullable: false + field :directories, -> { Internal::Types::Array[Seed::Types::Types::Directory] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/movie.rb b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/movie.rb index e69fb2724bc7..956ebfae0e1f 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/movie.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/lib/seed/types/types/movie.rb @@ -12,9 +12,7 @@ class Movie < Internal::Types::Model field :type, -> { String }, optional: false, nullable: false field :tag, -> { String }, optional: false, nullable: false field :book, -> { String }, optional: true, nullable: false - field :metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: false, nullable: false + field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false field :revenue, -> { Integer }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/reference.md b/seed/ruby-sdk-v2/examples/no-custom-config/reference.md index 8ca7167abd3c..7a238a3e090a 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/reference.md +++ b/seed/ruby-sdk-v2/examples/no-custom-config/reference.md @@ -12,7 +12,7 @@
```ruby -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); ```
@@ -52,7 +52,7 @@ client.create_type();
```ruby -client.create_type(); +client.echo(request: 'primitive'); ```
@@ -436,6 +436,10 @@ client.service.get_metadata( ```ruby client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -450,8 +454,10 @@ client.service.create_big_entity( revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -459,9 +465,12 @@ client.service.create_big_entity( }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/seed.gemspec b/seed/ruby-sdk-v2/examples/no-custom-config/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/seed.gemspec +++ b/seed/ruby-sdk-v2/examples/no-custom-config/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/no-custom-config/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/examples/readme-config/.rubocop.yml b/seed/ruby-sdk-v2/examples/readme-config/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/.rubocop.yml +++ b/seed/ruby-sdk-v2/examples/readme-config/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example0/snippet.rb index fc83f7a9c273..231ea78339b0 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example0/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example1/snippet.rb index fc83f7a9c273..1e60192ac875 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example1/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'string'); diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example19/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example19/snippet.rb index 11e126116692..5096430fab90 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example19/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example19/snippet.rb @@ -6,6 +6,10 @@ ); client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -20,8 +24,10 @@ revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -29,9 +35,12 @@ }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example2/snippet.rb index fc83f7a9c273..92ff42da744f 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example2/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'primitive'); diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example21/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example21/snippet.rb index dbd0db80ba5c..25cc1e2ca24d 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example21/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example21/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 420 +}); diff --git a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example22/snippet.rb b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example22/snippet.rb index dbd0db80ba5c..36532df34335 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example22/snippet.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/dynamic-snippets/example22/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 1 +}); diff --git a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/service/client.rb b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/service/client.rb index 2ecb3c43b6ee..b459549cb4d5 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/service/client.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/service/client.rb @@ -24,7 +24,8 @@ def get_movie(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/movie/#{params[:movie_id]}" + path: "/movie/#{params[:movie_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -54,7 +55,8 @@ def create_movie(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/movie", - body: Seed::Types::Types::Movie.new(params).to_h + body: Seed::Types::Types::Movie.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -94,7 +96,8 @@ def get_metadata(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/metadata", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -124,7 +127,8 @@ def create_big_entity(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/big-entity", - body: Seed::Types::Types::BigEntity.new(params).to_h + body: Seed::Types::Types::BigEntity.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -154,7 +158,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/refresh-token", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/big_entity.rb b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/big_entity.rb index c0dc0f851497..8d6d91641b70 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/big_entity.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/big_entity.rb @@ -4,20 +4,12 @@ module Seed module Types module Types class BigEntity < Internal::Types::Model - field :cast_member, -> { - Seed::Types::Types::CastMember - }, optional: true, nullable: false, api_name: "castMember" - field :extended_movie, -> { - Seed::Types::Types::ExtendedMovie - }, optional: true, nullable: false, api_name: "extendedMovie" + field :cast_member, -> { Seed::Types::Types::CastMember }, optional: true, nullable: false, api_name: "castMember" + field :extended_movie, -> { Seed::Types::Types::ExtendedMovie }, optional: true, nullable: false, api_name: "extendedMovie" field :entity, -> { Seed::Types::Types::Entity }, optional: true, nullable: false field :metadata, -> { Seed::Types::Types::Metadata }, optional: true, nullable: false - field :common_metadata, -> { - Seed::Commons::Types::Types::Metadata - }, optional: true, nullable: false, api_name: "commonMetadata" - field :event_info, -> { - Seed::Commons::Types::Types::EventInfo - }, optional: true, nullable: false, api_name: "eventInfo" + field :common_metadata, -> { Seed::Commons::Types::Types::Metadata }, optional: true, nullable: false, api_name: "commonMetadata" + field :event_info, -> { Seed::Commons::Types::Types::EventInfo }, optional: true, nullable: false, api_name: "eventInfo" field :data, -> { Seed::Commons::Types::Types::Data }, optional: true, nullable: false field :migration, -> { Seed::Types::Types::Migration }, optional: true, nullable: false field :exception, -> { Seed::Types::Types::Exception }, optional: true, nullable: false diff --git a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/directory.rb b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/directory.rb index 06d05d7d40b9..652903273926 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/directory.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/directory.rb @@ -6,9 +6,7 @@ module Types class Directory < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false field :files, -> { Internal::Types::Array[Seed::Types::Types::File] }, optional: true, nullable: false - field :directories, -> { - Internal::Types::Array[Seed::Types::Types::Directory] - }, optional: true, nullable: false + field :directories, -> { Internal::Types::Array[Seed::Types::Types::Directory] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/movie.rb b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/movie.rb index e69fb2724bc7..956ebfae0e1f 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/movie.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/lib/seed/types/types/movie.rb @@ -12,9 +12,7 @@ class Movie < Internal::Types::Model field :type, -> { String }, optional: false, nullable: false field :tag, -> { String }, optional: false, nullable: false field :book, -> { String }, optional: true, nullable: false - field :metadata, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: false, nullable: false + field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false field :revenue, -> { Integer }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/examples/readme-config/reference.md b/seed/ruby-sdk-v2/examples/readme-config/reference.md index 8ca7167abd3c..7a238a3e090a 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/reference.md +++ b/seed/ruby-sdk-v2/examples/readme-config/reference.md @@ -12,7 +12,7 @@
```ruby -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); ```
@@ -52,7 +52,7 @@ client.create_type();
```ruby -client.create_type(); +client.echo(request: 'primitive'); ```
@@ -436,6 +436,10 @@ client.service.get_metadata( ```ruby client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -450,8 +454,10 @@ client.service.create_big_entity( revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -459,9 +465,12 @@ client.service.create_big_entity( }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/readme-config/seed.gemspec b/seed/ruby-sdk-v2/examples/readme-config/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/seed.gemspec +++ b/seed/ruby-sdk-v2/examples/readme-config/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/readme-config/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/.rubocop.yml b/seed/ruby-sdk-v2/examples/wire-tests/.rubocop.yml index 0c50c297a213..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/.rubocop.yml +++ b/seed/ruby-sdk-v2/examples/wire-tests/.rubocop.yml @@ -2,7 +2,7 @@ plugins: - rubocop-minitest AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.3 NewCops: enable Style/StringLiterals: @@ -38,5 +38,23 @@ Metrics/PerceivedComplexity: Metrics/CyclomaticComplexity: Enabled: false +Metrics/ModuleLength: + Enabled: false + +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false + +Style/Lambda: + EnforcedStyle: literal + +Minitest/MultipleAssertions: + Enabled: false + +Minitest/UselessAssertion: + Enabled: false diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example0/snippet.rb index fc83f7a9c273..231ea78339b0 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example0/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example1/snippet.rb index fc83f7a9c273..1e60192ac875 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example1/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'string'); diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example19/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example19/snippet.rb index 11e126116692..5096430fab90 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example19/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example19/snippet.rb @@ -6,6 +6,10 @@ ); client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -20,8 +24,10 @@ revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -29,9 +35,12 @@ }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example2/snippet.rb index fc83f7a9c273..92ff42da744f 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example2/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.create_type(); +client.echo(request: 'primitive'); diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example21/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example21/snippet.rb index dbd0db80ba5c..25cc1e2ca24d 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example21/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example21/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 420 +}); diff --git a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example22/snippet.rb b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example22/snippet.rb index dbd0db80ba5c..36532df34335 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example22/snippet.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/dynamic-snippets/example22/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.service.refresh_token(); +client.service.refresh_token(request: { + ttl: 1 +}); diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb index 2ff467078811..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -10,9 +10,10 @@ class CursorItemIterator < ItemIterator # @param item_field [Symbol] The field in API responses to extract the items to iterate over. # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] - def initialize(initial_cursor:, cursor_field:, item_field:, &block) + def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field - @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &block) + @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb index a76124aa2a0e..f8840246686d 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb @@ -12,9 +12,10 @@ class OffsetItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. # # @return [Seed::Internal::OffsetItemIterator] - def initialize(initial_page:, item_field:, has_next_field:, step:, &block) + def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field - @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &block) + @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/model.rb index e382e00fef98..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/big_entity.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/big_entity.rb index 029cf5497ed5..8d6d91641b70 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/big_entity.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/big_entity.rb @@ -4,20 +4,12 @@ module Seed module Types module Types class BigEntity < Internal::Types::Model - field :cast_member, lambda { - Seed::Types::Types::CastMember - }, optional: true, nullable: false, api_name: "castMember" - field :extended_movie, lambda { - Seed::Types::Types::ExtendedMovie - }, optional: true, nullable: false, api_name: "extendedMovie" + field :cast_member, -> { Seed::Types::Types::CastMember }, optional: true, nullable: false, api_name: "castMember" + field :extended_movie, -> { Seed::Types::Types::ExtendedMovie }, optional: true, nullable: false, api_name: "extendedMovie" field :entity, -> { Seed::Types::Types::Entity }, optional: true, nullable: false field :metadata, -> { Seed::Types::Types::Metadata }, optional: true, nullable: false - field :common_metadata, lambda { - Seed::Commons::Types::Types::Metadata - }, optional: true, nullable: false, api_name: "commonMetadata" - field :event_info, lambda { - Seed::Commons::Types::Types::EventInfo - }, optional: true, nullable: false, api_name: "eventInfo" + field :common_metadata, -> { Seed::Commons::Types::Types::Metadata }, optional: true, nullable: false, api_name: "commonMetadata" + field :event_info, -> { Seed::Commons::Types::Types::EventInfo }, optional: true, nullable: false, api_name: "eventInfo" field :data, -> { Seed::Commons::Types::Types::Data }, optional: true, nullable: false field :migration, -> { Seed::Types::Types::Migration }, optional: true, nullable: false field :exception, -> { Seed::Types::Types::Exception }, optional: true, nullable: false diff --git a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/directory.rb b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/directory.rb index 789de4e1a2b7..652903273926 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/directory.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/lib/seed/types/types/directory.rb @@ -6,9 +6,7 @@ module Types class Directory < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false field :files, -> { Internal::Types::Array[Seed::Types::Types::File] }, optional: true, nullable: false - field :directories, lambda { - Internal::Types::Array[Seed::Types::Types::Directory] - }, optional: true, nullable: false + field :directories, -> { Internal::Types::Array[Seed::Types::Types::Directory] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/examples/wire-tests/reference.md b/seed/ruby-sdk-v2/examples/wire-tests/reference.md index 8ca7167abd3c..7a238a3e090a 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/reference.md +++ b/seed/ruby-sdk-v2/examples/wire-tests/reference.md @@ -12,7 +12,7 @@
```ruby -client.create_type(); +client.echo(request: 'Hello world!\n\nwith\n\tnewlines'); ```
@@ -52,7 +52,7 @@ client.create_type();
```ruby -client.create_type(); +client.echo(request: 'primitive'); ```
@@ -436,6 +436,10 @@ client.service.get_metadata( ```ruby client.service.create_big_entity( + cast_member: { + name: 'name', + id: 'id' + }, extended_movie: { cast: ['cast', 'cast'], id: 'id', @@ -450,8 +454,10 @@ client.service.create_big_entity( revenue: 1000000 }, entity: { + type: 'primitive', name: 'name' }, + metadata: {}, common_metadata: { id: 'id', data: { @@ -459,9 +465,12 @@ client.service.create_big_entity( }, json_string: 'jsonString' }, + data: {}, migration: { - name: 'name' + name: 'name', + status: 'RUNNING' }, + test: {}, node: { name: 'name', nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/wire-tests/seed.gemspec b/seed/ruby-sdk-v2/examples/wire-tests/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/seed.gemspec +++ b/seed/ruby-sdk-v2/examples/wire-tests/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb index fcb8a312dde4..92576b820128 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -84,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -99,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/examples/wire-tests/test/wire/service_test.rb b/seed/ruby-sdk-v2/examples/wire-tests/test/wire/service_test.rb index a3c353d5cc71..6df1d624e723 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/test/wire/service_test.rb +++ b/seed/ruby-sdk-v2/examples/wire-tests/test/wire/service_test.rb @@ -115,6 +115,10 @@ def test_service_create_big_entity_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") client.service.create_big_entity( + cast_member: { + name: "name", + id: "id" + }, extended_movie: { cast: %w[cast cast], id: "id", @@ -129,8 +133,10 @@ def test_service_create_big_entity_with_wiremock revenue: 1_000_000 }, entity: { + type: "primitive", name: "name" }, + metadata: {}, common_metadata: { id: "id", data: { @@ -138,9 +144,12 @@ def test_service_create_big_entity_with_wiremock }, json_string: "jsonString" }, + data: {}, migration: { - name: "name" + name: "name", + status: "RUNNING" }, + test: {}, node: { name: "name", nodes: [{ diff --git a/seed/ruby-sdk-v2/examples/wire-tests/wiremock/docker-compose.test.yml b/seed/ruby-sdk-v2/examples/wire-tests/wiremock/docker-compose.test.yml index b65fc8855e0a..f80c6b0aab6a 100644 --- a/seed/ruby-sdk-v2/examples/wire-tests/wiremock/docker-compose.test.yml +++ b/seed/ruby-sdk-v2/examples/wire-tests/wiremock/docker-compose.test.yml @@ -6,3 +6,9 @@ services: volumes: - ./wiremock-mappings.json:/home/wiremock/mappings/wiremock-mappings.json command: ["--global-response-templating", "--verbose"] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/__admin/health"] + interval: 2s + timeout: 5s + retries: 15 + start_period: 5s diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/.rubocop.yml b/seed/ruby-sdk-v2/exhaustive/wire-tests/.rubocop.yml index 0c50c297a213..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/.rubocop.yml +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/.rubocop.yml @@ -2,7 +2,7 @@ plugins: - rubocop-minitest AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.3 NewCops: enable Style/StringLiterals: @@ -38,5 +38,23 @@ Metrics/PerceivedComplexity: Metrics/CyclomaticComplexity: Enabled: false +Metrics/ModuleLength: + Enabled: false + +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false + +Style/Lambda: + EnforcedStyle: literal + +Minitest/MultipleAssertions: + Enabled: false + +Minitest/UselessAssertion: + Enabled: false diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example0/snippet.rb index c8da9d6fe2bc..34145146fed2 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example0/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_list_of_primitives(); +client.endpoints.container.get_and_return_list_of_primitives(request: ['string', 'string']); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example1/snippet.rb index b5525947b27e..9ad7a756a0a2 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example1/snippet.rb @@ -5,4 +5,8 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_list_of_objects(); +client.endpoints.container.get_and_return_list_of_objects(request: [{ + string: 'string' +}, { + string: 'string' +}]); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example2/snippet.rb index dafdfc4ac0a4..1183fa6938d3 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example2/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_set_of_primitives(); +client.endpoints.container.get_and_return_set_of_primitives(request: Set.new(['string'])); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example20/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example20/snippet.rb index 7d90dd3776f1..5a5c0cea6802 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example20/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example20/snippet.rb @@ -5,4 +5,42 @@ base_url: 'https://api.fern.com' ); -client.endpoints.object.get_and_return_nested_with_required_field_as_list(); +client.endpoints.object.get_and_return_nested_with_required_field_as_list(request: [{ + string: 'string', + nested_object: { + string: 'string', + integer: 1, + long: 1000000, + double: 1.1, + bool: true, + datetime: '2024-01-15T09:30:00Z', + date: '2023-01-15', + uuid: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + base_64: 'SGVsbG8gd29ybGQh', + list: ['list', 'list'], + set: Set.new(['set']), + map: { + 1 => 'map' + }, + bigint: '1000000' + } +}, { + string: 'string', + nested_object: { + string: 'string', + integer: 1, + long: 1000000, + double: 1.1, + bool: true, + datetime: '2024-01-15T09:30:00Z', + date: '2023-01-15', + uuid: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + base_64: 'SGVsbG8gd29ybGQh', + list: ['list', 'list'], + set: Set.new(['set']), + map: { + 1 => 'map' + }, + bigint: '1000000' + } +}]); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example27/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example27/snippet.rb index b8e594e5f9aa..b7a7a41baca1 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example27/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example27/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.endpoints.params.modify_with_inline_path(param: 'param'); +client.endpoints.params.modify_with_path( + param: 'param', + request: 'string' +); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example28/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example28/snippet.rb index b8e594e5f9aa..b7a7a41baca1 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example28/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example28/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.endpoints.params.modify_with_inline_path(param: 'param'); +client.endpoints.params.modify_with_path( + param: 'param', + request: 'string' +); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example29/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example29/snippet.rb index ad98012fa4f6..d4da16efa074 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example29/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example29/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_string(); +client.endpoints.primitive.get_and_return_string(request: 'string'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example3/snippet.rb index 8f25165df6e9..a33701909749 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example3/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_set_of_objects(); +client.endpoints.container.get_and_return_set_of_objects(request: Set.new([{ + string: 'string' +}])); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example30/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example30/snippet.rb index 59766682c5ca..4acab04c3af2 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example30/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example30/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_int(); +client.endpoints.primitive.get_and_return_int(request: 1); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example31/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example31/snippet.rb index 4809e9f23aac..8cb16a0d839e 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example31/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example31/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_long(); +client.endpoints.primitive.get_and_return_long(request: 1000000); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example32/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example32/snippet.rb index dc3f80b91f32..df55c5f911dd 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example32/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example32/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_double(); +client.endpoints.primitive.get_and_return_double(request: 1.1); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example33/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example33/snippet.rb index 3b05dc3de785..83c3b1a4cb28 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example33/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example33/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_bool(); +client.endpoints.primitive.get_and_return_bool(request: true); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example34/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example34/snippet.rb index 6f28f920c509..1b527c226c39 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example34/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example34/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_datetime(); +client.endpoints.primitive.get_and_return_datetime(request: '2024-01-15T09:30:00Z'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example35/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example35/snippet.rb index b25d204c445c..ca39b8b3d024 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example35/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example35/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_date(); +client.endpoints.primitive.get_and_return_date(request: '2023-01-15'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example36/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example36/snippet.rb index 804b365a55af..89190d1b407d 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example36/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example36/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_uuid(); +client.endpoints.primitive.get_and_return_uuid(request: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example37/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example37/snippet.rb index f639cd1864aa..1f61795278a2 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example37/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example37/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.primitive.get_and_return_base_64(); +client.endpoints.primitive.get_and_return_base_64(request: 'SGVsbG8gd29ybGQh'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example4/snippet.rb index 232f84f40eb9..03c3c18b83b1 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example4/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_map_prim_to_prim(); +client.endpoints.container.get_and_return_map_prim_to_prim(request: { + string: 'string' +}); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example5/snippet.rb index 63a9b2ac6983..3cd8267b4858 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example5/snippet.rb @@ -5,4 +5,8 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_map_of_prim_to_object(); +client.endpoints.container.get_and_return_map_of_prim_to_object(request: { + string: { + string: 'string' + } +}); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example6/snippet.rb index 5197232935af..1786847d4a4a 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example6/snippet.rb @@ -5,4 +5,6 @@ base_url: 'https://api.fern.com' ); -client.endpoints.container.get_and_return_optional(); +client.endpoints.container.get_and_return_optional(request: { + string: 'string' +}); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example9/snippet.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example9/snippet.rb index da1c7d961c0b..854e1dae7af1 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example9/snippet.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/dynamic-snippets/example9/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.endpoints.enum.get_and_return_enum(); +client.endpoints.enum.get_and_return_enum(request: 'SUNNY'); diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/endpoints/put/types/put_response.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/endpoints/put/types/put_response.rb index 4d428366aac4..e288556c4443 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/endpoints/put/types/put_response.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/endpoints/put/types/put_response.rb @@ -5,9 +5,7 @@ module Endpoints module Put module Types class PutResponse < Internal::Types::Model - field :errors, lambda { - Internal::Types::Array[Seed::Endpoints::Put::Types::Error] - }, optional: true, nullable: false + field :errors, -> { Internal::Types::Array[Seed::Endpoints::Put::Types::Error] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/inlined_requests/types/post_with_object_body.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/inlined_requests/types/post_with_object_body.rb index 157b7037f9af..9bc937a51477 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/inlined_requests/types/post_with_object_body.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/inlined_requests/types/post_with_object_body.rb @@ -6,9 +6,7 @@ module Types class PostWithObjectBody < Internal::Types::Model field :string, -> { String }, optional: false, nullable: false field :integer, -> { Integer }, optional: false, nullable: false - field :nested_object, lambda { - Seed::Types::Object_::Types::ObjectWithOptionalField - }, optional: false, nullable: false, api_name: "NestedObject" + field :nested_object, -> { Seed::Types::Object_::Types::ObjectWithOptionalField }, optional: false, nullable: false, api_name: "NestedObject" end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb index 2ff467078811..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -10,9 +10,10 @@ class CursorItemIterator < ItemIterator # @param item_field [Symbol] The field in API responses to extract the items to iterate over. # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] - def initialize(initial_cursor:, cursor_field:, item_field:, &block) + def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field - @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &block) + @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb index a76124aa2a0e..f8840246686d 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_item_iterator.rb @@ -12,9 +12,10 @@ class OffsetItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. # # @return [Seed::Internal::OffsetItemIterator] - def initialize(initial_page:, item_field:, has_next_field:, step:, &block) + def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field - @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &block) + @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/model.rb index e382e00fef98..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/req_with_headers/types/req_with_headers.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/req_with_headers/types/req_with_headers.rb index 57a90666cb42..76ba75e3a02c 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/req_with_headers/types/req_with_headers.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/req_with_headers/types/req_with_headers.rb @@ -4,9 +4,7 @@ module Seed module ReqWithHeaders module Types class ReqWithHeaders < Internal::Types::Model - field :x_test_endpoint_header, lambda { - String - }, optional: false, nullable: false, api_name: "X-TEST-ENDPOINT-HEADER" + field :x_test_endpoint_header, -> { String }, optional: false, nullable: false, api_name: "X-TEST-ENDPOINT-HEADER" field :body, -> { String }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_optional_field.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_optional_field.rb index 32389e004873..c63df946de42 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_optional_field.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_optional_field.rb @@ -6,9 +6,7 @@ module Object_ module Types class NestedObjectWithOptionalField < Internal::Types::Model field :string, -> { String }, optional: true, nullable: false - field :nested_object, lambda { - Seed::Types::Object_::Types::ObjectWithOptionalField - }, optional: true, nullable: false, api_name: "NestedObject" + field :nested_object, -> { Seed::Types::Object_::Types::ObjectWithOptionalField }, optional: true, nullable: false, api_name: "NestedObject" end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_required_field.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_required_field.rb index 4a831933e26a..5aabf64701a8 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_required_field.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/nested_object_with_required_field.rb @@ -6,9 +6,7 @@ module Object_ module Types class NestedObjectWithRequiredField < Internal::Types::Model field :string, -> { String }, optional: false, nullable: false - field :nested_object, lambda { - Seed::Types::Object_::Types::ObjectWithOptionalField - }, optional: false, nullable: false, api_name: "NestedObject" + field :nested_object, -> { Seed::Types::Object_::Types::ObjectWithOptionalField }, optional: false, nullable: false, api_name: "NestedObject" end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/object_with_map_of_map.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/object_with_map_of_map.rb index f52df6bbc6f6..b143e4f81b62 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/object_with_map_of_map.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/object/types/object_with_map_of_map.rb @@ -5,9 +5,7 @@ module Types module Object_ module Types class ObjectWithMapOfMap < Internal::Types::Model - field :map, lambda { - Internal::Types::Hash[String, Internal::Types::Hash[String, String]] - }, optional: false, nullable: false + field :map, -> { Internal::Types::Hash[String, Internal::Types::Hash[String, String]] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/cat.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/cat.rb index e8b507e69770..3262ccd164c4 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/cat.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/cat.rb @@ -6,9 +6,7 @@ module Union module Types class Cat < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false - field :likes_to_meow, lambda { - Internal::Types::Boolean - }, optional: false, nullable: false, api_name: "likesToMeow" + field :likes_to_meow, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "likesToMeow" end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/dog.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/dog.rb index 9141e0673558..417c0dba686d 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/dog.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/lib/seed/types/union/types/dog.rb @@ -6,9 +6,7 @@ module Union module Types class Dog < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false - field :likes_to_woof, lambda { - Internal::Types::Boolean - }, optional: false, nullable: false, api_name: "likesToWoof" + field :likes_to_woof, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "likesToWoof" end end end diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/reference.md b/seed/ruby-sdk-v2/exhaustive/wire-tests/reference.md index ae8f4bb231bb..9c7d86924eb7 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/reference.md +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/reference.md @@ -13,7 +13,7 @@
```ruby -client.endpoints.container.get_and_return_list_of_primitives(); +client.endpoints.container.get_and_return_list_of_primitives(request: ['string', 'string']); ```
@@ -53,7 +53,11 @@ client.endpoints.container.get_and_return_list_of_primitives();
```ruby -client.endpoints.container.get_and_return_list_of_objects(); +client.endpoints.container.get_and_return_list_of_objects(request: [{ + string: 'string' +}, { + string: 'string' +}]); ```
@@ -93,7 +97,7 @@ client.endpoints.container.get_and_return_list_of_objects();
```ruby -client.endpoints.container.get_and_return_set_of_primitives(); +client.endpoints.container.get_and_return_set_of_primitives(request: Set.new(['string'])); ```
@@ -133,7 +137,9 @@ client.endpoints.container.get_and_return_set_of_primitives();
```ruby -client.endpoints.container.get_and_return_set_of_objects(); +client.endpoints.container.get_and_return_set_of_objects(request: Set.new([{ + string: 'string' +}])); ```
@@ -173,7 +179,9 @@ client.endpoints.container.get_and_return_set_of_objects();
```ruby -client.endpoints.container.get_and_return_map_prim_to_prim(); +client.endpoints.container.get_and_return_map_prim_to_prim(request: { + string: 'string' +}); ```
@@ -213,7 +221,11 @@ client.endpoints.container.get_and_return_map_prim_to_prim();
```ruby -client.endpoints.container.get_and_return_map_of_prim_to_object(); +client.endpoints.container.get_and_return_map_of_prim_to_object(request: { + string: { + string: 'string' + } +}); ```
@@ -253,7 +265,9 @@ client.endpoints.container.get_and_return_map_of_prim_to_object();
```ruby -client.endpoints.container.get_and_return_optional(); +client.endpoints.container.get_and_return_optional(request: { + string: 'string' +}); ```
@@ -407,7 +421,7 @@ client.endpoints.content_type.post_json_patch_content_with_charset_type(
```ruby -client.endpoints.enum.get_and_return_enum(); +client.endpoints.enum.get_and_return_enum(request: 'SUNNY'); ```
@@ -952,7 +966,45 @@ client.endpoints.object.get_and_return_nested_with_required_field(
```ruby -client.endpoints.object.get_and_return_nested_with_required_field_as_list(); +client.endpoints.object.get_and_return_nested_with_required_field_as_list(request: [{ + string: 'string', + nested_object: { + string: 'string', + integer: 1, + long: 1000000, + double: 1.1, + bool: true, + datetime: '2024-01-15T09:30:00Z', + date: '2023-01-15', + uuid: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + base_64: 'SGVsbG8gd29ybGQh', + list: ['list', 'list'], + set: Set.new(['set']), + map: { + 1 => 'map' + }, + bigint: '1000000' + } +}, { + string: 'string', + nested_object: { + string: 'string', + integer: 1, + long: 1000000, + double: 1.1, + bool: true, + datetime: '2024-01-15T09:30:00Z', + date: '2023-01-15', + uuid: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + base_64: 'SGVsbG8gd29ybGQh', + list: ['list', 'list'], + set: Set.new(['set']), + map: { + 1 => 'map' + }, + bigint: '1000000' + } +}]); ```
@@ -1375,7 +1427,10 @@ PUT to update with path param
```ruby -client.endpoints.params.modify_with_inline_path(param: 'param'); +client.endpoints.params.modify_with_path( + param: 'param', + request: 'string' +); ```
@@ -1437,7 +1492,10 @@ PUT to update with path param
```ruby -client.endpoints.params.modify_with_inline_path(param: 'param'); +client.endpoints.params.modify_with_path( + param: 'param', + request: 'string' +); ```
@@ -1486,7 +1544,7 @@ client.endpoints.params.modify_with_inline_path(param: 'param');
```ruby -client.endpoints.primitive.get_and_return_string(); +client.endpoints.primitive.get_and_return_string(request: 'string'); ```
@@ -1526,7 +1584,7 @@ client.endpoints.primitive.get_and_return_string();
```ruby -client.endpoints.primitive.get_and_return_int(); +client.endpoints.primitive.get_and_return_int(request: 1); ```
@@ -1566,7 +1624,7 @@ client.endpoints.primitive.get_and_return_int();
```ruby -client.endpoints.primitive.get_and_return_long(); +client.endpoints.primitive.get_and_return_long(request: 1000000); ```
@@ -1606,7 +1664,7 @@ client.endpoints.primitive.get_and_return_long();
```ruby -client.endpoints.primitive.get_and_return_double(); +client.endpoints.primitive.get_and_return_double(request: 1.1); ```
@@ -1646,7 +1704,7 @@ client.endpoints.primitive.get_and_return_double();
```ruby -client.endpoints.primitive.get_and_return_bool(); +client.endpoints.primitive.get_and_return_bool(request: true); ```
@@ -1686,7 +1744,7 @@ client.endpoints.primitive.get_and_return_bool();
```ruby -client.endpoints.primitive.get_and_return_datetime(); +client.endpoints.primitive.get_and_return_datetime(request: '2024-01-15T09:30:00Z'); ```
@@ -1726,7 +1784,7 @@ client.endpoints.primitive.get_and_return_datetime();
```ruby -client.endpoints.primitive.get_and_return_date(); +client.endpoints.primitive.get_and_return_date(request: '2023-01-15'); ```
@@ -1766,7 +1824,7 @@ client.endpoints.primitive.get_and_return_date();
```ruby -client.endpoints.primitive.get_and_return_uuid(); +client.endpoints.primitive.get_and_return_uuid(request: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); ```
@@ -1806,7 +1864,7 @@ client.endpoints.primitive.get_and_return_uuid();
```ruby -client.endpoints.primitive.get_and_return_base_64(); +client.endpoints.primitive.get_and_return_base_64(request: 'SGVsbG8gd29ybGQh'); ```
diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/seed.gemspec b/seed/ruby-sdk-v2/exhaustive/wire-tests/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/seed.gemspec +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb index fcb8a312dde4..92576b820128 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -84,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -99,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_container_test.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_container_test.rb index 86f77d639db0..2c9379e40240 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_container_test.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_container_test.rb @@ -39,10 +39,13 @@ def test_endpoints_container_get_and_return_list_of_primitives_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_list_of_primitives(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_list_of_primitives.0" - } }) + client.endpoints.container.get_and_return_list_of_primitives( + request: %w[string string], + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_list_of_primitives.0" + } } + ) verify_request_count( test_id: test_id, @@ -58,10 +61,17 @@ def test_endpoints_container_get_and_return_list_of_objects_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_list_of_objects(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_list_of_objects.0" - } }) + client.endpoints.container.get_and_return_list_of_objects( + request: [{ + string: "string" + }, { + string: "string" + }], + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_list_of_objects.0" + } } + ) verify_request_count( test_id: test_id, @@ -77,10 +87,13 @@ def test_endpoints_container_get_and_return_set_of_primitives_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_set_of_primitives(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_set_of_primitives.0" - } }) + client.endpoints.container.get_and_return_set_of_primitives( + request: Set.new(["string"]), + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_set_of_primitives.0" + } } + ) verify_request_count( test_id: test_id, @@ -96,10 +109,15 @@ def test_endpoints_container_get_and_return_set_of_objects_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_set_of_objects(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_set_of_objects.0" - } }) + client.endpoints.container.get_and_return_set_of_objects( + request: Set.new([{ + string: "string" + }]), + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_set_of_objects.0" + } } + ) verify_request_count( test_id: test_id, @@ -115,10 +133,15 @@ def test_endpoints_container_get_and_return_map_prim_to_prim_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_map_prim_to_prim(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_map_prim_to_prim.0" - } }) + client.endpoints.container.get_and_return_map_prim_to_prim( + request: { + string: "string" + }, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_map_prim_to_prim.0" + } } + ) verify_request_count( test_id: test_id, @@ -134,10 +157,17 @@ def test_endpoints_container_get_and_return_map_of_prim_to_object_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_map_of_prim_to_object(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_map_of_prim_to_object.0" - } }) + client.endpoints.container.get_and_return_map_of_prim_to_object( + request: { + string: { + string: "string" + } + }, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_map_of_prim_to_object.0" + } } + ) verify_request_count( test_id: test_id, @@ -153,10 +183,15 @@ def test_endpoints_container_get_and_return_optional_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.container.get_and_return_optional(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.container.get_and_return_optional.0" - } }) + client.endpoints.container.get_and_return_optional( + request: { + string: "string" + }, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.container.get_and_return_optional.0" + } } + ) verify_request_count( test_id: test_id, diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_enum_test.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_enum_test.rb index 7f9e6a3d2072..5c376b751189 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_enum_test.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_enum_test.rb @@ -39,10 +39,13 @@ def test_endpoints_enum_get_and_return_enum_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.enum.get_and_return_enum(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.enum.get_and_return_enum.0" - } }) + client.endpoints.enum.get_and_return_enum( + request: "SUNNY", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.enum.get_and_return_enum.0" + } } + ) verify_request_count( test_id: test_id, diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_object_test.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_object_test.rb index b6a930a520d9..9b13f6718f6f 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_object_test.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_object_test.rb @@ -202,10 +202,51 @@ def test_endpoints_object_get_and_return_nested_with_required_field_as_list_with require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.object.get_and_return_nested_with_required_field_as_list(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.object.get_and_return_nested_with_required_field_as_list.0" - } }) + client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request: [{ + string: "string", + nested_object: { + string: "string", + integer: 1, + long: 1_000_000, + double: 1.1, + bool: true, + datetime: "2024-01-15T09:30:00Z", + date: "2023-01-15", + uuid: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64: "SGVsbG8gd29ybGQh", + list: %w[list list], + set: Set.new(["set"]), + map: { + 1 => "map" + }, + bigint: "1000000" + } + }, { + string: "string", + nested_object: { + string: "string", + integer: 1, + long: 1_000_000, + double: 1.1, + bool: true, + datetime: "2024-01-15T09:30:00Z", + date: "2023-01-15", + uuid: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64: "SGVsbG8gd29ybGQh", + list: %w[list list], + set: Set.new(["set"]), + map: { + 1 => "map" + }, + bigint: "1000000" + } + }], + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.object.get_and_return_nested_with_required_field_as_list.0" + } } + ) verify_request_count( test_id: test_id, diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_params_test.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_params_test.rb index 8453b10670aa..81ac1166e012 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_params_test.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_params_test.rb @@ -175,8 +175,9 @@ def test_endpoints_params_modify_with_path_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.params.modify_with_inline_path( + client.endpoints.params.modify_with_path( param: "param", + request: "string", request_options: { base_url: WIREMOCK_BASE_URL, additional_headers: { "X-Test-Id" => "endpoints.params.modify_with_path.0" @@ -197,8 +198,9 @@ def test_endpoints_params_modify_with_inline_path_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.params.modify_with_inline_path( + client.endpoints.params.modify_with_path( param: "param", + request: "string", request_options: { base_url: WIREMOCK_BASE_URL, additional_headers: { "X-Test-Id" => "endpoints.params.modify_with_inline_path.0" diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_primitive_test.rb b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_primitive_test.rb index 9cc2684b879e..1b305cd174ee 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_primitive_test.rb +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/test/wire/endpoints_primitive_test.rb @@ -39,10 +39,13 @@ def test_endpoints_primitive_get_and_return_string_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_string(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_string.0" - } }) + client.endpoints.primitive.get_and_return_string( + request: "string", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_string.0" + } } + ) verify_request_count( test_id: test_id, @@ -58,10 +61,13 @@ def test_endpoints_primitive_get_and_return_int_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_int(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_int.0" - } }) + client.endpoints.primitive.get_and_return_int( + request: 1, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_int.0" + } } + ) verify_request_count( test_id: test_id, @@ -77,10 +83,13 @@ def test_endpoints_primitive_get_and_return_long_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_long(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_long.0" - } }) + client.endpoints.primitive.get_and_return_long( + request: 1_000_000, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_long.0" + } } + ) verify_request_count( test_id: test_id, @@ -96,10 +105,13 @@ def test_endpoints_primitive_get_and_return_double_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_double(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_double.0" - } }) + client.endpoints.primitive.get_and_return_double( + request: 1.1, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_double.0" + } } + ) verify_request_count( test_id: test_id, @@ -115,10 +127,13 @@ def test_endpoints_primitive_get_and_return_bool_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_bool(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_bool.0" - } }) + client.endpoints.primitive.get_and_return_bool( + request: true, + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_bool.0" + } } + ) verify_request_count( test_id: test_id, @@ -134,10 +149,13 @@ def test_endpoints_primitive_get_and_return_datetime_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_datetime(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_datetime.0" - } }) + client.endpoints.primitive.get_and_return_datetime( + request: "2024-01-15T09:30:00Z", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_datetime.0" + } } + ) verify_request_count( test_id: test_id, @@ -153,10 +171,13 @@ def test_endpoints_primitive_get_and_return_date_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_date(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_date.0" - } }) + client.endpoints.primitive.get_and_return_date( + request: "2023-01-15", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_date.0" + } } + ) verify_request_count( test_id: test_id, @@ -172,10 +193,13 @@ def test_endpoints_primitive_get_and_return_uuid_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_uuid(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_uuid.0" - } }) + client.endpoints.primitive.get_and_return_uuid( + request: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_uuid.0" + } } + ) verify_request_count( test_id: test_id, @@ -191,10 +215,13 @@ def test_endpoints_primitive_get_and_return_base_64_with_wiremock require "seed" client = Seed::Client.new(base_url: WIREMOCK_BASE_URL, token: "") - client.endpoints.primitive.get_and_return_base_64(request_options: { base_url: WIREMOCK_BASE_URL, - additional_headers: { - "X-Test-Id" => "endpoints.primitive.get_and_return_base_64.0" - } }) + client.endpoints.primitive.get_and_return_base_64( + request: "SGVsbG8gd29ybGQh", + request_options: { base_url: WIREMOCK_BASE_URL, + additional_headers: { + "X-Test-Id" => "endpoints.primitive.get_and_return_base_64.0" + } } + ) verify_request_count( test_id: test_id, diff --git a/seed/ruby-sdk-v2/exhaustive/wire-tests/wiremock/docker-compose.test.yml b/seed/ruby-sdk-v2/exhaustive/wire-tests/wiremock/docker-compose.test.yml index b65fc8855e0a..f80c6b0aab6a 100644 --- a/seed/ruby-sdk-v2/exhaustive/wire-tests/wiremock/docker-compose.test.yml +++ b/seed/ruby-sdk-v2/exhaustive/wire-tests/wiremock/docker-compose.test.yml @@ -6,3 +6,9 @@ services: volumes: - ./wiremock-mappings.json:/home/wiremock/mappings/wiremock-mappings.json command: ["--global-response-templating", "--verbose"] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/__admin/health"] + interval: 2s + timeout: 5s + retries: 15 + start_period: 5s diff --git a/seed/ruby-sdk-v2/extends/.rubocop.yml b/seed/ruby-sdk-v2/extends/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/extends/.rubocop.yml +++ b/seed/ruby-sdk-v2/extends/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/extends/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/extends/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/extends/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/extends/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/extends/seed.gemspec b/seed/ruby-sdk-v2/extends/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/extends/seed.gemspec +++ b/seed/ruby-sdk-v2/extends/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/extends/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/extra-properties/.rubocop.yml b/seed/ruby-sdk-v2/extra-properties/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/extra-properties/.rubocop.yml +++ b/seed/ruby-sdk-v2/extra-properties/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/extra-properties/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/extra-properties/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/extra-properties/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/extra-properties/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/extra-properties/lib/seed/user/client.rb b/seed/ruby-sdk-v2/extra-properties/lib/seed/user/client.rb index 651850abff36..56b54a5e0fe6 100644 --- a/seed/ruby-sdk-v2/extra-properties/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/extra-properties/lib/seed/user/client.rb @@ -27,7 +27,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/user", - body: Seed::User::Types::CreateUserRequest.new(body_bag).to_h + body: Seed::User::Types::CreateUserRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/extra-properties/seed.gemspec b/seed/ruby-sdk-v2/extra-properties/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/extra-properties/seed.gemspec +++ b/seed/ruby-sdk-v2/extra-properties/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/extra-properties/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/file-download/.rubocop.yml b/seed/ruby-sdk-v2/file-download/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/file-download/.rubocop.yml +++ b/seed/ruby-sdk-v2/file-download/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/file-download/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/file-download/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/file-download/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/file-download/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/file-download/seed.gemspec b/seed/ruby-sdk-v2/file-download/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/file-download/seed.gemspec +++ b/seed/ruby-sdk-v2/file-download/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-download/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/file-upload-openapi/.rubocop.yml b/seed/ruby-sdk-v2/file-upload-openapi/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/file-upload-openapi/.rubocop.yml +++ b/seed/ruby-sdk-v2/file-upload-openapi/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/file-upload-openapi/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/file-upload-openapi/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/file-upload-openapi/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/file-upload-openapi/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/file-upload-openapi/seed.gemspec b/seed/ruby-sdk-v2/file-upload-openapi/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/file-upload-openapi/seed.gemspec +++ b/seed/ruby-sdk-v2/file-upload-openapi/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-upload-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/file-upload/.rubocop.yml b/seed/ruby-sdk-v2/file-upload/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/file-upload/.rubocop.yml +++ b/seed/ruby-sdk-v2/file-upload/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/file-upload/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/file-upload/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/file-upload/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/file-upload/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/file-upload/lib/seed/service/types/just_file_with_query_params_request.rb b/seed/ruby-sdk-v2/file-upload/lib/seed/service/types/just_file_with_query_params_request.rb index 423403f8a27b..79014151d02e 100644 --- a/seed/ruby-sdk-v2/file-upload/lib/seed/service/types/just_file_with_query_params_request.rb +++ b/seed/ruby-sdk-v2/file-upload/lib/seed/service/types/just_file_with_query_params_request.rb @@ -8,9 +8,7 @@ class JustFileWithQueryParamsRequest < Internal::Types::Model field :integer, -> { Integer }, optional: false, nullable: false field :maybe_integer, -> { Integer }, optional: true, nullable: false, api_name: "maybeInteger" field :list_of_strings, -> { String }, optional: false, nullable: false, api_name: "listOfStrings" - field :optional_list_of_strings, -> { - String - }, optional: true, nullable: false, api_name: "optionalListOfStrings" + field :optional_list_of_strings, -> { String }, optional: true, nullable: false, api_name: "optionalListOfStrings" end end end diff --git a/seed/ruby-sdk-v2/file-upload/seed.gemspec b/seed/ruby-sdk-v2/file-upload/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/file-upload/seed.gemspec +++ b/seed/ruby-sdk-v2/file-upload/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/file-upload/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/folders/.rubocop.yml b/seed/ruby-sdk-v2/folders/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/folders/.rubocop.yml +++ b/seed/ruby-sdk-v2/folders/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/folders/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/folders/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/folders/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/folders/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/folders/seed.gemspec b/seed/ruby-sdk-v2/folders/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/folders/seed.gemspec +++ b/seed/ruby-sdk-v2/folders/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/folders/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/header-auth-environment-variable/.rubocop.yml b/seed/ruby-sdk-v2/header-auth-environment-variable/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/header-auth-environment-variable/.rubocop.yml +++ b/seed/ruby-sdk-v2/header-auth-environment-variable/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/header-auth-environment-variable/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/header-auth-environment-variable/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/header-auth-environment-variable/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/header-auth-environment-variable/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/header-auth-environment-variable/seed.gemspec b/seed/ruby-sdk-v2/header-auth-environment-variable/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/header-auth-environment-variable/seed.gemspec +++ b/seed/ruby-sdk-v2/header-auth-environment-variable/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/header-auth-environment-variable/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/header-auth/.rubocop.yml b/seed/ruby-sdk-v2/header-auth/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/header-auth/.rubocop.yml +++ b/seed/ruby-sdk-v2/header-auth/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/header-auth/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/header-auth/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/header-auth/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/header-auth/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/header-auth/seed.gemspec b/seed/ruby-sdk-v2/header-auth/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/header-auth/seed.gemspec +++ b/seed/ruby-sdk-v2/header-auth/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/header-auth/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/http-head/.rubocop.yml b/seed/ruby-sdk-v2/http-head/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/http-head/.rubocop.yml +++ b/seed/ruby-sdk-v2/http-head/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/http-head/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/http-head/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/http-head/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/http-head/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/http-head/lib/seed/user/client.rb b/seed/ruby-sdk-v2/http-head/lib/seed/user/client.rb index 9df5e5adf4d7..4ba2eba888b2 100644 --- a/seed/ruby-sdk-v2/http-head/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/http-head/lib/seed/user/client.rb @@ -23,7 +23,8 @@ def head(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "HEAD", - path: "/users" + path: "/users", + request_options: request_options ) begin response = @client.send(request) @@ -58,7 +59,8 @@ def list(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/http-head/seed.gemspec b/seed/ruby-sdk-v2/http-head/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/http-head/seed.gemspec +++ b/seed/ruby-sdk-v2/http-head/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/http-head/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/idempotency-headers/.rubocop.yml b/seed/ruby-sdk-v2/idempotency-headers/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/.rubocop.yml +++ b/seed/ruby-sdk-v2/idempotency-headers/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/idempotency-headers/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/idempotency-headers/dynamic-snippets/example0/snippet.rb index 0e280e2c02f2..dfbabfd8134c 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/idempotency-headers/dynamic-snippets/example0/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.payment.create(amount: 1); +client.payment.create( + amount: 1, + currency: 'USD' +); diff --git a/seed/ruby-sdk-v2/idempotency-headers/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/idempotency-headers/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/idempotency-headers/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/idempotency-headers/lib/seed/payment/client.rb b/seed/ruby-sdk-v2/idempotency-headers/lib/seed/payment/client.rb index 7c236f700124..a02a03c086b9 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/lib/seed/payment/client.rb +++ b/seed/ruby-sdk-v2/idempotency-headers/lib/seed/payment/client.rb @@ -27,7 +27,8 @@ def create(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/payment", - body: Seed::Payment::Types::CreatePaymentRequest.new(body_bag).to_h + body: Seed::Payment::Types::CreatePaymentRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -55,7 +56,8 @@ def delete(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "DELETE", - path: "/payment/#{params[:payment_id]}" + path: "/payment/#{params[:payment_id]}", + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/idempotency-headers/reference.md b/seed/ruby-sdk-v2/idempotency-headers/reference.md index df5c008d0ecf..da2aeeb0bbad 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/reference.md +++ b/seed/ruby-sdk-v2/idempotency-headers/reference.md @@ -13,7 +13,10 @@
```ruby -client.payment.create(amount: 1); +client.payment.create( + amount: 1, + currency: 'USD' +); ```
diff --git a/seed/ruby-sdk-v2/idempotency-headers/seed.gemspec b/seed/ruby-sdk-v2/idempotency-headers/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/seed.gemspec +++ b/seed/ruby-sdk-v2/idempotency-headers/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/idempotency-headers/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/imdb/.rubocop.yml b/seed/ruby-sdk-v2/imdb/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/imdb/.rubocop.yml +++ b/seed/ruby-sdk-v2/imdb/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/imdb/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/imdb/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/imdb/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/imdb/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/imdb/seed.gemspec b/seed/ruby-sdk-v2/imdb/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/imdb/seed.gemspec +++ b/seed/ruby-sdk-v2/imdb/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/imdb/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/.rubocop.yml b/seed/ruby-sdk-v2/inferred-auth-explicit/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/.rubocop.yml +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/auth/client.rb index e59bd162be52..bb6c07da0736 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/auth/client.rb @@ -28,7 +28,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -62,7 +63,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token/refresh", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/client.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/client.rb index 55ae4c8ed74c..271d4328e933 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/client.rb @@ -28,8 +28,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) # Create the auth provider with the auth client and credentials @auth_provider = Seed::Internal::InferredAuthProvider.new( auth_client: auth_client, - options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, - x_api_key: x_api_key } + options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, x_api_key: x_api_key } ) @raw_client = Seed::Internal::Http::RawClient.new( @@ -37,7 +36,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) headers: { "User-Agent" => "fern_inferred-auth-explicit/0.0.1", "X-Fern-Language" => "Ruby" - }.merge(@auth_provider.get_auth_headers) + }.merge(@auth_provider.auth_headers) ) end diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/inferred_auth_provider.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/inferred_auth_provider.rb index 2a2bd3f65345..83f07005f415 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/inferred_auth_provider.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/inferred_auth_provider.rb @@ -20,7 +20,7 @@ def initialize(auth_client:, options:) # Refreshes the token if it's nil, or if we're within the buffer period before expiration. # # @return [String] - def get_token + def token return refresh if @access_token.nil? || token_needs_refresh? @access_token @@ -29,10 +29,10 @@ def get_token # Returns the authentication headers to be included in requests. # # @return [Hash[String, String]] - def get_auth_headers - token = get_token + def auth_headers + access_token = token { - "Authorization" => "Bearer #{token}" + "Authorization" => "Bearer #{access_token}" } end # Checks if the token needs to be refreshed. @@ -57,8 +57,7 @@ def get_auth_headers scope: @options[:scope] } - token_response = @auth_client.get_token_with_client_credentials(**request_params, -request_options: { base_url: @options[:base_url] }) + token_response = @auth_client.get_token_with_client_credentials(**request_params, request_options: { base_url: @options[:base_url] }) @access_token = token_response.access_token @expires_at = Time.now + token_response.expires_in diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/seed.gemspec b/seed/ruby-sdk-v2/inferred-auth-explicit/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/seed.gemspec +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-explicit/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/.rubocop.yml b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/.rubocop.yml +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/auth/client.rb index e59bd162be52..bb6c07da0736 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/auth/client.rb @@ -28,7 +28,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -62,7 +63,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token/refresh", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/client.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/client.rb index 3addb6b3f45a..72f7af79dc6c 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/client.rb @@ -28,8 +28,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) # Create the auth provider with the auth client and credentials @auth_provider = Seed::Internal::InferredAuthProvider.new( auth_client: auth_client, - options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, - x_api_key: x_api_key } + options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, x_api_key: x_api_key } ) @raw_client = Seed::Internal::Http::RawClient.new( @@ -37,7 +36,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) headers: { "User-Agent" => "fern_inferred-auth-implicit-no-expiry/0.0.1", "X-Fern-Language" => "Ruby" - }.merge(@auth_provider.get_auth_headers) + }.merge(@auth_provider.auth_headers) ) end diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/inferred_auth_provider.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/inferred_auth_provider.rb index ac882f4886c8..b3ec8a0ea7bc 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/inferred_auth_provider.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/inferred_auth_provider.rb @@ -19,7 +19,7 @@ def initialize(auth_client:, options:) # Refreshes the token if it's nil, or if we're within the buffer period before expiration. # # @return [String] - def get_token + def token return refresh if @access_token.nil? @access_token @@ -28,10 +28,10 @@ def get_token # Returns the authentication headers to be included in requests. # # @return [Hash[String, String]] - def get_auth_headers - token = get_token + def auth_headers + access_token = token { - "Authorization" => "Bearer #{token}" + "Authorization" => "Bearer #{access_token}" } end # Refreshes the access token by calling the token endpoint. @@ -47,8 +47,7 @@ def get_auth_headers scope: @options[:scope] } - token_response = @auth_client.get_token_with_client_credentials(**request_params, -request_options: { base_url: @options[:base_url] }) + token_response = @auth_client.get_token_with_client_credentials(**request_params, request_options: { base_url: @options[:base_url] }) @access_token = token_response.access_token diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/seed.gemspec b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/seed.gemspec +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit-no-expiry/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/.rubocop.yml b/seed/ruby-sdk-v2/inferred-auth-implicit/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/.rubocop.yml +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/auth/client.rb index e59bd162be52..bb6c07da0736 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/auth/client.rb @@ -28,7 +28,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -62,7 +63,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token/refresh", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/client.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/client.rb index 6a58159f93a2..f3264be9e03d 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/client.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/client.rb @@ -28,8 +28,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) # Create the auth provider with the auth client and credentials @auth_provider = Seed::Internal::InferredAuthProvider.new( auth_client: auth_client, - options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, - x_api_key: x_api_key } + options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, x_api_key: x_api_key } ) @raw_client = Seed::Internal::Http::RawClient.new( @@ -37,7 +36,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) headers: { "User-Agent" => "fern_inferred-auth-implicit/0.0.1", "X-Fern-Language" => "Ruby" - }.merge(@auth_provider.get_auth_headers) + }.merge(@auth_provider.auth_headers) ) end diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/inferred_auth_provider.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/inferred_auth_provider.rb index 2a2bd3f65345..83f07005f415 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/inferred_auth_provider.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/inferred_auth_provider.rb @@ -20,7 +20,7 @@ def initialize(auth_client:, options:) # Refreshes the token if it's nil, or if we're within the buffer period before expiration. # # @return [String] - def get_token + def token return refresh if @access_token.nil? || token_needs_refresh? @access_token @@ -29,10 +29,10 @@ def get_token # Returns the authentication headers to be included in requests. # # @return [Hash[String, String]] - def get_auth_headers - token = get_token + def auth_headers + access_token = token { - "Authorization" => "Bearer #{token}" + "Authorization" => "Bearer #{access_token}" } end # Checks if the token needs to be refreshed. @@ -57,8 +57,7 @@ def get_auth_headers scope: @options[:scope] } - token_response = @auth_client.get_token_with_client_credentials(**request_params, -request_options: { base_url: @options[:base_url] }) + token_response = @auth_client.get_token_with_client_credentials(**request_params, request_options: { base_url: @options[:base_url] }) @access_token = token_response.access_token @expires_at = Time.now + token_response.expires_in diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/seed.gemspec b/seed/ruby-sdk-v2/inferred-auth-implicit/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/seed.gemspec +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/inferred-auth-implicit/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/license/.rubocop.yml b/seed/ruby-sdk-v2/license/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/license/.rubocop.yml +++ b/seed/ruby-sdk-v2/license/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/license/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/license/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/license/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/license/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/license/seed.gemspec b/seed/ruby-sdk-v2/license/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/license/seed.gemspec +++ b/seed/ruby-sdk-v2/license/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/license/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/literal/.rubocop.yml b/seed/ruby-sdk-v2/literal/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/literal/.rubocop.yml +++ b/seed/ruby-sdk-v2/literal/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/literal/lib/seed/headers/client.rb b/seed/ruby-sdk-v2/literal/lib/seed/headers/client.rb index 2cd0462f93c7..585538745a3e 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/headers/client.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/headers/client.rb @@ -29,7 +29,8 @@ def send_(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "headers", - body: Seed::Headers::Types::SendLiteralsInHeadersRequest.new(body_bag).to_h + body: Seed::Headers::Types::SendLiteralsInHeadersRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/literal/lib/seed/inlined/client.rb b/seed/ruby-sdk-v2/literal/lib/seed/inlined/client.rb index ddd088976462..32d95e22ac6c 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/inlined/client.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/inlined/client.rb @@ -27,7 +27,8 @@ def send_(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "inlined", - body: Seed::Inlined::Types::SendLiteralsInlinedRequest.new(body_bag).to_h + body: Seed::Inlined::Types::SendLiteralsInlinedRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/a_top_level_literal.rb b/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/a_top_level_literal.rb index ec6bec39bcca..a8e9f68f05ff 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/a_top_level_literal.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/a_top_level_literal.rb @@ -4,9 +4,7 @@ module Seed module Inlined module Types class ATopLevelLiteral < Internal::Types::Model - field :nested_literal, -> { - Seed::Inlined::Types::ANestedLiteral - }, optional: false, nullable: false, api_name: "nestedLiteral" + field :nested_literal, -> { Seed::Inlined::Types::ANestedLiteral }, optional: false, nullable: false, api_name: "nestedLiteral" end end end diff --git a/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/send_literals_inlined_request.rb b/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/send_literals_inlined_request.rb index 1da42703852c..53cbb94005b3 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/send_literals_inlined_request.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/inlined/types/send_literals_inlined_request.rb @@ -11,9 +11,7 @@ class SendLiteralsInlinedRequest < Internal::Types::Model field :stream, -> { Internal::Types::Boolean }, optional: false, nullable: false field :aliased_context, -> { String }, optional: false, nullable: false, api_name: "aliasedContext" field :maybe_context, -> { String }, optional: true, nullable: false, api_name: "maybeContext" - field :object_with_literal, -> { - Seed::Inlined::Types::ATopLevelLiteral - }, optional: false, nullable: false, api_name: "objectWithLiteral" + field :object_with_literal, -> { Seed::Inlined::Types::ATopLevelLiteral }, optional: false, nullable: false, api_name: "objectWithLiteral" end end end diff --git a/seed/ruby-sdk-v2/literal/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/literal/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/literal/lib/seed/query/client.rb b/seed/ruby-sdk-v2/literal/lib/seed/query/client.rb index 5ca74238253c..e198db0fc657 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/query/client.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/query/client.rb @@ -30,8 +30,7 @@ def initialize(client:) # @return [Seed::Types::SendResponse] def send_(request_options: {}, **params) params = Seed::Internal::Types::Utils.symbolize_keys(params) - query_param_names = %i[prompt optional_prompt alias_prompt alias_optional_prompt query stream optional_stream - alias_stream alias_optional_stream] + query_param_names = %i[prompt optional_prompt alias_prompt alias_optional_prompt query stream optional_stream alias_stream alias_optional_stream] query_params = {} query_params["prompt"] = params[:prompt] if params.key?(:prompt) query_params["optional_prompt"] = params[:optional_prompt] if params.key?(:optional_prompt) @@ -48,7 +47,8 @@ def send_(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "query", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/literal/lib/seed/reference/types/container_object.rb b/seed/ruby-sdk-v2/literal/lib/seed/reference/types/container_object.rb index 88ac9fffd8af..c5ed3cd40f9c 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/reference/types/container_object.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/reference/types/container_object.rb @@ -4,9 +4,7 @@ module Seed module Reference module Types class ContainerObject < Internal::Types::Model - field :nested_objects, -> { - Internal::Types::Array[Seed::Reference::Types::NestedObjectWithLiterals] - }, optional: false, nullable: false, api_name: "nestedObjects" + field :nested_objects, -> { Internal::Types::Array[Seed::Reference::Types::NestedObjectWithLiterals] }, optional: false, nullable: false, api_name: "nestedObjects" end end end diff --git a/seed/ruby-sdk-v2/literal/lib/seed/reference/types/send_request.rb b/seed/ruby-sdk-v2/literal/lib/seed/reference/types/send_request.rb index e9db756fbd71..6ec6e96b60fb 100644 --- a/seed/ruby-sdk-v2/literal/lib/seed/reference/types/send_request.rb +++ b/seed/ruby-sdk-v2/literal/lib/seed/reference/types/send_request.rb @@ -10,9 +10,7 @@ class SendRequest < Internal::Types::Model field :ending, -> { String }, optional: false, nullable: false field :context, -> { String }, optional: false, nullable: false field :maybe_context, -> { String }, optional: true, nullable: false, api_name: "maybeContext" - field :container_object, -> { - Seed::Reference::Types::ContainerObject - }, optional: false, nullable: false, api_name: "containerObject" + field :container_object, -> { Seed::Reference::Types::ContainerObject }, optional: false, nullable: false, api_name: "containerObject" end end end diff --git a/seed/ruby-sdk-v2/literal/seed.gemspec b/seed/ruby-sdk-v2/literal/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/literal/seed.gemspec +++ b/seed/ruby-sdk-v2/literal/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/literal/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/literals-unions/.rubocop.yml b/seed/ruby-sdk-v2/literals-unions/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/literals-unions/.rubocop.yml +++ b/seed/ruby-sdk-v2/literals-unions/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/literals-unions/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/literals-unions/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/literals-unions/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/literals-unions/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/literals-unions/seed.gemspec b/seed/ruby-sdk-v2/literals-unions/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/literals-unions/seed.gemspec +++ b/seed/ruby-sdk-v2/literals-unions/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/literals-unions/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/mixed-case/.rubocop.yml b/seed/ruby-sdk-v2/mixed-case/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/mixed-case/.rubocop.yml +++ b/seed/ruby-sdk-v2/mixed-case/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/mixed-case/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/mixed-case/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/mixed-case/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/mixed-case/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/mixed-case/lib/seed/service/client.rb b/seed/ruby-sdk-v2/mixed-case/lib/seed/service/client.rb index 3d0587d30e3f..3889aa3dfec1 100644 --- a/seed/ruby-sdk-v2/mixed-case/lib/seed/service/client.rb +++ b/seed/ruby-sdk-v2/mixed-case/lib/seed/service/client.rb @@ -24,7 +24,8 @@ def get_resource(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/resource/#{params[:resource_id]}" + path: "/resource/#{params[:resource_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -63,7 +64,8 @@ def list_resources(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/resource", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/mixed-case/lib/seed/service/types/user.rb b/seed/ruby-sdk-v2/mixed-case/lib/seed/service/types/user.rb index c0766a6b2eba..5efff45c7762 100644 --- a/seed/ruby-sdk-v2/mixed-case/lib/seed/service/types/user.rb +++ b/seed/ruby-sdk-v2/mixed-case/lib/seed/service/types/user.rb @@ -6,9 +6,7 @@ module Types class User < Internal::Types::Model field :user_name, -> { String }, optional: false, nullable: false, api_name: "userName" field :metadata_tags, -> { Internal::Types::Array[String] }, optional: false, nullable: false - field :extra_properties, -> { - Internal::Types::Hash[String, String] - }, optional: false, nullable: false, api_name: "EXTRA_PROPERTIES" + field :extra_properties, -> { Internal::Types::Hash[String, String] }, optional: false, nullable: false, api_name: "EXTRA_PROPERTIES" end end end diff --git a/seed/ruby-sdk-v2/mixed-case/seed.gemspec b/seed/ruby-sdk-v2/mixed-case/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/mixed-case/seed.gemspec +++ b/seed/ruby-sdk-v2/mixed-case/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/mixed-case/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/mixed-file-directory/.rubocop.yml b/seed/ruby-sdk-v2/mixed-file-directory/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/.rubocop.yml +++ b/seed/ruby-sdk-v2/mixed-file-directory/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/client.rb b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/client.rb index f8096c7804d1..7b564f16e5e9 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/client.rb @@ -33,7 +33,8 @@ def list(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users/", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/client.rb b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/client.rb index a85cd95a1451..c683068d6da3 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/client.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/client.rb @@ -34,7 +34,8 @@ def list_events(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users/events/", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/metadata/client.rb b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/metadata/client.rb index 95341a4f2d98..1dcc3c0dd12f 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/metadata/client.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/lib/seed/user/events/metadata/client.rb @@ -35,7 +35,8 @@ def get_metadata(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users/events/metadata/", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/mixed-file-directory/seed.gemspec b/seed/ruby-sdk-v2/mixed-file-directory/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/seed.gemspec +++ b/seed/ruby-sdk-v2/mixed-file-directory/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/mixed-file-directory/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/multi-line-docs/.rubocop.yml b/seed/ruby-sdk-v2/multi-line-docs/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/.rubocop.yml +++ b/seed/ruby-sdk-v2/multi-line-docs/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/multi-line-docs/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/multi-line-docs/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/multi-line-docs/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/multi-line-docs/lib/seed/user/client.rb b/seed/ruby-sdk-v2/multi-line-docs/lib/seed/user/client.rb index 33b44e109811..a9619399c895 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/multi-line-docs/lib/seed/user/client.rb @@ -27,7 +27,8 @@ def get_user(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "users/#{params[:user_id]}" + path: "users/#{params[:user_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -61,7 +62,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "users", - body: Seed::User::Types::CreateUserRequest.new(body_bag).to_h + body: Seed::User::Types::CreateUserRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/multi-line-docs/seed.gemspec b/seed/ruby-sdk-v2/multi-line-docs/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/seed.gemspec +++ b/seed/ruby-sdk-v2/multi-line-docs/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-line-docs/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/http/raw_client.rb index b79f4d9125ef..3370a92b608b 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/http/raw_client.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/http/raw_client.rb @@ -45,7 +45,8 @@ def send(request) # @return [URI::Generic] The URL. def build_url(request) path = request.path.start_with?("/") ? request.path[1..] : request.path - url = "#{@base_url.chomp("/")}/#{path}" + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" url = "#{url}?#{encode_query(request.query)}" if request.query&.any? URI.parse(url) end @@ -94,6 +95,11 @@ def connect(url) http.max_retries = @max_retries http end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb index 8189180b2041..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -11,6 +11,7 @@ class CursorItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb index c5f46f8033a9..f8840246686d 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb @@ -13,6 +13,7 @@ class OffsetItemIterator < ItemIterator # # @return [Seed::Internal::OffsetItemIterator] def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/json/request.rb index 93db7f188cf2..15773d44c641 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/json/request.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/json/request.rb @@ -22,10 +22,11 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => "application/json", "Accept" => "application/json" - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb index d87eea059db1..915dada8c56e 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb @@ -22,9 +22,10 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => @body.content_type - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/enum.rb index af56cf76b98c..72e45e4c1f27 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/enum.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/enum.rb @@ -39,6 +39,14 @@ def coerce(value, strict: strict?) value end + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + def inspect "#{name}[#{values.join(", ")}]" end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model.rb index 515b63fbaa25..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) @@ -187,7 +187,9 @@ def ==(other) # @return [String] def inspect attrs = @data.map do |name, value| - "#{name}=#{value.inspect}" + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" end "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model/field.rb index 5294b2710a0d..6ce0186f6a5d 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model/field.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/model/field.rb @@ -6,6 +6,11 @@ module Types class Model # Definition of a field on a model class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) @@ -21,6 +26,11 @@ def initialize(name:, type:, optional: false, nullable: false, api_name: nil, va def literal? !value.nil? end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/union.rb index 868ab392ebb9..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/union.rb @@ -100,6 +100,14 @@ def coerce(value, strict: strict?) Utils.coerce(type, value, strict: strict) end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb index a94fde9e1c15..92576b820128 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -66,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -83,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -98,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/types/test_model.rb index 7412306821a6..3d87b9f5a8c7 100644 --- a/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/types/test_model.rb +++ b/seed/ruby-sdk-v2/multi-url-environment-no-default/test/unit/internal/types/test_model.rb @@ -111,4 +111,44 @@ class ExampleParent < Seed::Internal::Types::Model refute_respond_to example, :yearOfRelease end end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/http/raw_client.rb index b79f4d9125ef..3370a92b608b 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/http/raw_client.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/http/raw_client.rb @@ -45,7 +45,8 @@ def send(request) # @return [URI::Generic] The URL. def build_url(request) path = request.path.start_with?("/") ? request.path[1..] : request.path - url = "#{@base_url.chomp("/")}/#{path}" + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" url = "#{url}?#{encode_query(request.query)}" if request.query&.any? URI.parse(url) end @@ -94,6 +95,11 @@ def connect(url) http.max_retries = @max_retries http end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_item_iterator.rb index 8189180b2041..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -11,6 +11,7 @@ class CursorItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_item_iterator.rb index c5f46f8033a9..f8840246686d 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_item_iterator.rb @@ -13,6 +13,7 @@ class OffsetItemIterator < ItemIterator # # @return [Seed::Internal::OffsetItemIterator] def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/json/request.rb index 93db7f188cf2..15773d44c641 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/json/request.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/json/request.rb @@ -22,10 +22,11 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => "application/json", "Accept" => "application/json" - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/multipart/multipart_request.rb index d87eea059db1..915dada8c56e 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/multipart/multipart_request.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/multipart/multipart_request.rb @@ -22,9 +22,10 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => @body.content_type - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/enum.rb index af56cf76b98c..72e45e4c1f27 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/enum.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/enum.rb @@ -39,6 +39,14 @@ def coerce(value, strict: strict?) value end + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + def inspect "#{name}[#{values.join(", ")}]" end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model.rb index 515b63fbaa25..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) @@ -187,7 +187,9 @@ def ==(other) # @return [String] def inspect attrs = @data.map do |name, value| - "#{name}=#{value.inspect}" + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" end "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model/field.rb index 5294b2710a0d..6ce0186f6a5d 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model/field.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/model/field.rb @@ -6,6 +6,11 @@ module Types class Model # Definition of a field on a model class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) @@ -21,6 +26,11 @@ def initialize(name:, type:, optional: false, nullable: false, api_name: nil, va def literal? !value.nil? end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/union.rb index 868ab392ebb9..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/union.rb @@ -100,6 +100,14 @@ def coerce(value, strict: strict?) Utils.coerce(type, value, strict: strict) end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end end end end diff --git a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_offset_item_iterator.rb index a94fde9e1c15..92576b820128 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -66,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -83,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -98,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/types/test_model.rb index 7412306821a6..3d87b9f5a8c7 100644 --- a/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/types/test_model.rb +++ b/seed/ruby-sdk-v2/multi-url-environment/test/unit/internal/types/test_model.rb @@ -111,4 +111,44 @@ class ExampleParent < Seed::Internal::Types::Model refute_respond_to example, :yearOfRelease end end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end end diff --git a/seed/ruby-sdk-v2/multiple-request-bodies/.rubocop.yml b/seed/ruby-sdk-v2/multiple-request-bodies/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/multiple-request-bodies/.rubocop.yml +++ b/seed/ruby-sdk-v2/multiple-request-bodies/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/multiple-request-bodies/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/multiple-request-bodies/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/multiple-request-bodies/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/multiple-request-bodies/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/multiple-request-bodies/seed.gemspec b/seed/ruby-sdk-v2/multiple-request-bodies/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/multiple-request-bodies/seed.gemspec +++ b/seed/ruby-sdk-v2/multiple-request-bodies/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/multiple-request-bodies/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/no-environment/.rubocop.yml b/seed/ruby-sdk-v2/no-environment/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/no-environment/.rubocop.yml +++ b/seed/ruby-sdk-v2/no-environment/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/no-environment/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/no-environment/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/no-environment/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/no-environment/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/no-environment/seed.gemspec b/seed/ruby-sdk-v2/no-environment/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/no-environment/seed.gemspec +++ b/seed/ruby-sdk-v2/no-environment/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/no-environment/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/no-retries/.rubocop.yml b/seed/ruby-sdk-v2/no-retries/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/no-retries/.rubocop.yml +++ b/seed/ruby-sdk-v2/no-retries/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/no-retries/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/no-retries/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/no-retries/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/no-retries/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/no-retries/seed.gemspec b/seed/ruby-sdk-v2/no-retries/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/no-retries/seed.gemspec +++ b/seed/ruby-sdk-v2/no-retries/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/no-retries/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/.fern/metadata.json b/seed/ruby-sdk-v2/nullable-allof-extends/.fern/metadata.json new file mode 100644 index 000000000000..ce04af614b97 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/.fern/metadata.json @@ -0,0 +1,5 @@ +{ + "cliVersion": "DUMMY", + "generatorName": "fernapi/fern-ruby-sdk-v2", + "generatorVersion": "latest" +} \ No newline at end of file diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/.rubocop.yml b/seed/ruby-sdk-v2/nullable-allof-extends/.rubocop.yml new file mode 100644 index 000000000000..2c5567ea193e --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/.rubocop.yml @@ -0,0 +1,60 @@ +plugins: + - rubocop-minitest + +AllCops: + TargetRubyVersion: 3.3 + NewCops: enable + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + +Style/AccessModifierDeclarations: + Enabled: false + +Lint/ConstantDefinitionInBlock: + Enabled: false + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + +Style/Documentation: + Enabled: false + +Style/Lambda: + EnforcedStyle: literal + +Minitest/MultipleAssertions: + Enabled: false + +Minitest/UselessAssertion: + Enabled: false diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile b/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile new file mode 100644 index 000000000000..29b144d77f48 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gemspec + +group :test, :development do + gem "rake", "~> 13.0" + + gem "minitest", "~> 5.16" + gem "minitest-rg" + + gem "rubocop", "~> 1.21" + gem "rubocop-minitest" + + gem "pry" + + gem "webmock" +end + +# Load custom Gemfile configuration if it exists +custom_gemfile = File.join(__dir__, "Gemfile.custom") +eval_gemfile(custom_gemfile) if File.exist?(custom_gemfile) diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile.custom b/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile.custom new file mode 100644 index 000000000000..11bdfaf13f2d --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/Gemfile.custom @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Custom Gemfile configuration file +# This file is automatically loaded by the main Gemfile. You can add custom gems, +# groups, or other Gemfile configurations here. If you do make changes to this file, +# you will need to add it to the .fernignore file to prevent your changes from being +# overwritten by the generator. + +# Example usage: +# group :test, :development do +# gem 'custom-gem', '~> 2.0' +# end + +# Add your custom gem dependencies here \ No newline at end of file diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/Rakefile b/seed/ruby-sdk-v2/nullable-allof-extends/Rakefile new file mode 100644 index 000000000000..9bdd4a6ce80b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/Rakefile @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require "bundler/gem_tasks" +require "minitest/test_task" + +Minitest::TestTask.create + +require "rubocop/rake_task" + +RuboCop::RakeTask.new + +task default: %i[test] + +task lint: %i[rubocop] + +# Run only the custom test file +Minitest::TestTask.create(:customtest) do |t| + t.libs << "test" + t.test_globs = ["test/custom.test.rb"] +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/custom.gemspec.rb b/seed/ruby-sdk-v2/nullable-allof-extends/custom.gemspec.rb new file mode 100644 index 000000000000..86d8efd3cd3c --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/custom.gemspec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Custom gemspec configuration file +# This file is automatically loaded by the main gemspec file. The 'spec' variable is available +# in this context from the main gemspec file. You can modify this file to add custom metadata, +# dependencies, or other gemspec configurations. If you do make changes to this file, you will +# need to add it to the .fernignore file to prevent your changes from being overwritten. + +def add_custom_gemspec_data(spec) + # Example custom configurations (uncomment and modify as needed) + + # spec.authors = ["Your name"] + # spec.email = ["your.email@example.com"] + # spec.homepage = "https://github.com/your-org/seed-ruby" + # spec.license = "Your license" +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example0/snippet.rb new file mode 100644 index 000000000000..cd1f65c44e3b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example0/snippet.rb @@ -0,0 +1,5 @@ +require "seed" + +client = Seed::Client.new(base_url: 'https://api.fern.com'); + +client.get_test(); diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example1/snippet.rb new file mode 100644 index 000000000000..cd1f65c44e3b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example1/snippet.rb @@ -0,0 +1,5 @@ +require "seed" + +client = Seed::Client.new(base_url: 'https://api.fern.com'); + +client.get_test(); diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example2/snippet.rb new file mode 100644 index 000000000000..c4a1a9b1d1a0 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example2/snippet.rb @@ -0,0 +1,5 @@ +require "seed" + +client = Seed::Client.new(base_url: 'https://api.fern.com'); + +client.create_test(); diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example3/snippet.rb new file mode 100644 index 000000000000..08713d1719e7 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/dynamic-snippets/example3/snippet.rb @@ -0,0 +1,8 @@ +require "seed" + +client = Seed::Client.new(base_url: 'https://api.fern.com'); + +client.create_test( + normal_field: 'normalField', + nullable_field: 'nullableField' +); diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed.rb new file mode 100644 index 000000000000..7874f9605b77 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require "json" +require "net/http" +require "securerandom" + +require_relative "seed/internal/json/serializable" +require_relative "seed/internal/types/type" +require_relative "seed/internal/types/utils" +require_relative "seed/internal/types/union" +require_relative "seed/internal/errors/constraint_error" +require_relative "seed/internal/errors/type_error" +require_relative "seed/internal/http/base_request" +require_relative "seed/internal/json/request" +require_relative "seed/internal/http/raw_client" +require_relative "seed/internal/multipart/multipart_encoder" +require_relative "seed/internal/multipart/multipart_form_data_part" +require_relative "seed/internal/multipart/multipart_form_data" +require_relative "seed/internal/multipart/multipart_request" +require_relative "seed/internal/types/model/field" +require_relative "seed/internal/types/model" +require_relative "seed/internal/types/array" +require_relative "seed/internal/types/boolean" +require_relative "seed/internal/types/enum" +require_relative "seed/internal/types/hash" +require_relative "seed/internal/types/unknown" +require_relative "seed/errors/api_error" +require_relative "seed/errors/response_error" +require_relative "seed/errors/client_error" +require_relative "seed/errors/redirect_error" +require_relative "seed/errors/server_error" +require_relative "seed/errors/timeout_error" +require_relative "seed/internal/iterators/item_iterator" +require_relative "seed/internal/iterators/cursor_item_iterator" +require_relative "seed/internal/iterators/offset_item_iterator" +require_relative "seed/internal/iterators/cursor_page_iterator" +require_relative "seed/internal/iterators/offset_page_iterator" +require_relative "seed/types/normal_object" +require_relative "seed/types/nullable_object" +require_relative "seed/types/root_object" +require_relative "seed/environment" diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/environment.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/environment.rb new file mode 100644 index 000000000000..e994144e9573 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/environment.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Seed + class Environment + DEFAULT = "https://api.example.com" + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/api_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/api_error.rb new file mode 100644 index 000000000000..b8ba53889b36 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/api_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ApiError < StandardError + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/client_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/client_error.rb new file mode 100644 index 000000000000..c3c6033641e2 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/client_error.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ClientError < ResponseError + end + + class UnauthorizedError < ClientError + end + + class ForbiddenError < ClientError + end + + class NotFoundError < ClientError + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/redirect_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/redirect_error.rb new file mode 100644 index 000000000000..f663c01e7615 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/redirect_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class RedirectError < ResponseError + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/response_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/response_error.rb new file mode 100644 index 000000000000..beb4a1baf959 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/response_error.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ResponseError < ApiError + attr_reader :code + + def initialize(msg, code:) + @code = code + super(msg) + end + + def inspect + "#<#{self.class.name} @code=#{code} @body=#{message}>" + end + + # Returns the most appropriate error class for the given code. + # + # @return [Class] + def self.subclass_for_code(code) + case code + when 300..399 + RedirectError + when 401 + UnauthorizedError + when 403 + ForbiddenError + when 404 + NotFoundError + when 400..499 + ClientError + when 503 + ServiceUnavailableError + when 500..599 + ServerError + else + ResponseError + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/server_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/server_error.rb new file mode 100644 index 000000000000..1838027cdeab --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/server_error.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ServerError < ResponseError + end + + class ServiceUnavailableError < ApiError + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/timeout_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/timeout_error.rb new file mode 100644 index 000000000000..ec3a24bb7e96 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/errors/timeout_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class TimeoutError < ApiError + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/constraint_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/constraint_error.rb new file mode 100644 index 000000000000..e2f0bd66ac37 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/constraint_error.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Errors + class ConstraintError < StandardError + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/type_error.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/type_error.rb new file mode 100644 index 000000000000..6aec80f59f05 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/errors/type_error.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Errors + class TypeError < StandardError + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/base_request.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/base_request.rb new file mode 100644 index 000000000000..5f65f1327023 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/base_request.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Http + # @api private + class BaseRequest + attr_reader :base_url, :path, :method, :headers, :query, :request_options + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [String] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, request_options: {}) + @base_url = base_url + @path = path + @method = method + @headers = headers + @query = query + @request_options = request_options + end + + # Child classes should implement: + # - encode_headers: Returns the encoded HTTP request headers. + # - encode_body: Returns the encoded HTTP request body. + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/raw_client.rb new file mode 100644 index 000000000000..3370a92b608b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/http/raw_client.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Http + # @api private + class RawClient + # @param base_url [String] The base url for the request. + # @param max_retries [Integer] The number of times to retry a failed request, defaults to 2. + # @param timeout [Float] The timeout for the request, defaults to 60.0 seconds. + # @param headers [Hash] The headers for the request. + def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {}) + @base_url = base_url + @max_retries = max_retries + @timeout = timeout + @default_headers = { + "X-Fern-Language": "Ruby", + "X-Fern-SDK-Name": "seed", + "X-Fern-SDK-Version": "0.0.1" + }.merge(headers) + end + + # @param request [Seed::Internal::Http::BaseRequest] The HTTP request. + # @return [HTTP::Response] The HTTP response. + def send(request) + url = build_url(request) + + http_request = build_http_request( + url:, + method: request.method, + headers: request.encode_headers, + body: request.encode_body + ) + + conn = connect(url) + conn.open_timeout = @timeout + conn.read_timeout = @timeout + conn.write_timeout = @timeout + conn.continue_timeout = @timeout + + conn.request(http_request) + end + + # @param request [Seed::Internal::Http::BaseRequest] The HTTP request. + # @return [URI::Generic] The URL. + def build_url(request) + path = request.path.start_with?("/") ? request.path[1..] : request.path + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" + url = "#{url}?#{encode_query(request.query)}" if request.query&.any? + URI.parse(url) + end + + # @param url [URI::Generic] The url to the resource. + # @param method [String] The HTTP method to use. + # @param headers [Hash] The headers for the request. + # @param body [String, nil] The body for the request. + # @return [HTTP::Request] The HTTP request. + def build_http_request(url:, method:, headers: {}, body: nil) + request = Net::HTTPGenericRequest.new( + method, + !body.nil?, + method != "HEAD", + url + ) + + request_headers = @default_headers.merge(headers) + request_headers.each { |name, value| request[name] = value } + request.body = body if body + + request + end + + # @param query [Hash] The query for the request. + # @return [String, nil] The encoded query. + def encode_query(query) + query.to_h.empty? ? nil : URI.encode_www_form(query) + end + + # @param url [URI::Generic] The url to connect to. + # @return [Net::HTTP] The HTTP connection. + def connect(url) + is_https = (url.scheme == "https") + + port = if url.port + url.port + elsif is_https + Net::HTTP.https_default_port + else + Net::HTTP.http_default_port + end + + http = Net::HTTP.new(url.host, port) + http.use_ssl = is_https + http.max_retries = @max_retries + http + end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_item_iterator.rb new file mode 100644 index 000000000000..ab627ffc7025 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Seed + module Internal + class CursorItemIterator < ItemIterator + # Instantiates a CursorItemIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields individual items from it. + # + # @param initial_cursor [String] The initial cursor to use when iterating, if any. + # @param cursor_field [Symbol] The field in API responses to extract the next cursor from. + # @param item_field [Symbol] The field in API responses to extract the items to iterate over. + # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. + # @return [Seed::Internal::CursorItemIterator] + def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() + @item_field = item_field + @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) + @page = nil + end + + # Returns the CursorPageIterator mediating access to the underlying API. + # + # @return [Seed::Internal::CursorPageIterator] + def pages + @page_iterator + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_page_iterator.rb new file mode 100644 index 000000000000..f479a749fef9 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Seed + module Internal + class CursorPageIterator + include Enumerable + + # Instantiates a CursorPageIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields pages of items. + # + # @param initial_cursor [String] The initial cursor to use when iterating, if any. + # @param cursor_field [Symbol] The name of the field in API responses to extract the next cursor from. + # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. + # @return [Seed::Internal::CursorPageIterator] + def initialize(initial_cursor:, cursor_field:, &block) + @need_initial_load = initial_cursor.nil? + @cursor = initial_cursor + @cursor_field = cursor_field + @get_next_page = block + end + + # Iterates over each page returned by the API. + # + # @param block [Proc] The block which each retrieved page is yielded to. + # @return [NilClass] + def each(&block) + while (page = next_page) + block.call(page) + end + end + + # Whether another page will be available from the API. + # + # @return [Boolean] + def next? + @need_initial_load || !@cursor.nil? + end + + # Retrieves the next page from the API. + # + # @return [Boolean] + def next_page + return if !@need_initial_load && @cursor.nil? + + @need_initial_load = false + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/item_iterator.rb new file mode 100644 index 000000000000..1284fb0fd367 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/item_iterator.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Seed + module Internal + class ItemIterator + include Enumerable + + # Iterates over each item returned by the API. + # + # @param block [Proc] The block which each retrieved item is yielded to. + # @return [NilClass] + def each(&block) + while (item = next_element) + block.call(item) + end + end + + # Whether another item will be available from the API. + # + # @return [Boolean] + def next? + load_next_page if @page.nil? + return false if @page.nil? + + return true if any_items_in_cached_page? + + load_next_page + any_items_in_cached_page? + end + + # Retrieves the next item from the API. + def next_element + item = next_item_from_cached_page + return item if item + + load_next_page + next_item_from_cached_page + end + + private + + def next_item_from_cached_page + return unless @page + + @page.send(@item_field).shift + end + + def any_items_in_cached_page? + return false unless @page + + !@page.send(@item_field).empty? + end + + def load_next_page + @page = @page_iterator.next_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_item_iterator.rb new file mode 100644 index 000000000000..f8840246686d --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_item_iterator.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Seed + module Internal + class OffsetItemIterator < ItemIterator + # Instantiates an OffsetItemIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields the individual items from it. + # + # @param initial_page [Integer] The initial page or offset to start from when iterating. + # @param item_field [Symbol] The name of the field in API responses to extract the items to iterate over. + # @param has_next_field [Symbol] The name of the field in API responses containing a boolean of whether another page exists. + # @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1) + # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. + # + # @return [Seed::Internal::OffsetItemIterator] + def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() + @item_field = item_field + @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) + @page = nil + end + + # Returns the OffsetPageIterator that is mediating access to the underlying API. + # + # @return [Seed::Internal::OffsetPageIterator] + def pages + @page_iterator + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_page_iterator.rb new file mode 100644 index 000000000000..051b65c5774c --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/iterators/offset_page_iterator.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Seed + module Internal + class OffsetPageIterator + include Enumerable + + # Instantiates an OffsetPageIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields pages of items from it. + # + # @param initial_page [Integer] The initial page to use when iterating, if any. + # @param item_field [Symbol] The field to pull the list of items to iterate over. + # @param has_next_field [Symbol] The field to pull the boolean of whether a next page exists from, if any. + # @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1) + # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. + # @return [Seed::Internal::OffsetPageIterator] + def initialize(initial_page:, item_field:, has_next_field:, step:, &block) + @page_number = initial_page || (step ? 0 : 1) + @item_field = item_field + @has_next_field = has_next_field + @step = step + @get_next_page = block + + # A cache of whether the API has another page, if it gives us that information... + @next_page = nil + # ...or the actual next page, preloaded, if it doesn't. + @has_next_page = nil + end + + # Iterates over each page returned by the API. + # + # @param block [Proc] The block which each retrieved page is yielded to. + # @return [NilClass] + def each(&block) + while (page = next_page) + block.call(page) + end + end + + # Whether another page will be available from the API. + # + # @return [Boolean] + def next? + return @has_next_page unless @has_next_page.nil? + return true if @next_page + + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? + @has_next_page = false + else + @next_page = fetched_page + true + end + end + + # Returns the next page from the API. + def next_page + return nil if @page_number.nil? + + if @next_page + this_page = @next_page + @next_page = nil + else + this_page = @get_next_page.call(@page_number) + end + + @has_next_page = this_page&.send(@has_next_field) if @has_next_field + + items = this_page.send(@item_field) + if items.nil? || items.empty? + @page_number = nil + return nil + elsif @step + @page_number += items.length + else + @page_number += 1 + end + + this_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/request.rb new file mode 100644 index 000000000000..15773d44c641 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/request.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Seed + module Internal + module JSON + # @api private + class Request < Seed::Internal::Http::BaseRequest + attr_reader :body + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [Symbol] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param body [Object, nil] The JSON request body (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {}) + super(base_url:, path:, method:, headers:, query:, request_options:) + + @body = body + end + + # @return [Hash] The encoded HTTP request headers. + def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} + { + "Content-Type" => "application/json", + "Accept" => "application/json" + }.merge(@headers).merge(additional_headers) + end + + # @return [String, nil] The encoded HTTP request body. + def encode_body + @body.nil? ? nil : ::JSON.generate(@body) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/serializable.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/serializable.rb new file mode 100644 index 000000000000..f80a15fb962c --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/json/serializable.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Seed + module Internal + module JSON + module Serializable + # Loads data from JSON into its deserialized form + # + # @param str [String] Raw JSON to load into an object + # @return [Object] + def load(str) + raise NotImplementedError + end + + # Dumps data from its deserialized form into JSON + # + # @param value [Object] The deserialized value + # @return [String] + def dump(value) + raise NotImplementedError + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_encoder.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_encoder.rb new file mode 100644 index 000000000000..307ad7436a57 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_encoder.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # Encodes parameters into a `multipart/form-data` payload as described by RFC + # 2388: + # + # https://tools.ietf.org/html/rfc2388 + # + # This is most useful for transferring file-like objects. + # + # Parameters should be added with `#encode`. When ready, use `#body` to get + # the encoded result and `#content_type` to get the value that should be + # placed in the `Content-Type` header of a subsequent request (which includes + # a boundary value). + # + # This abstraction is heavily inspired by Stripe's multipart/form-data implementation, + # which can be found here: + # + # https://github.com/stripe/stripe-ruby/blob/ca00b676f04ac421cf5cb5ff0325f243651677b6/lib/stripe/multipart_encoder.rb#L18 + # + # @api private + class Encoder + CONTENT_TYPE = "multipart/form-data" + CRLF = "\r\n" + + attr_reader :boundary, :body + + def initialize + # Chose the same number of random bytes that Go uses in its standard + # library implementation. Easily enough entropy to ensure that it won't + # be present in a file we're sending. + @boundary = SecureRandom.hex(30) + + @body = String.new + @closed = false + @first_field = true + end + + # Gets the content type string including the boundary. + # + # @return [String] The content type with boundary + def content_type + "#{CONTENT_TYPE}; boundary=#{@boundary}" + end + + # Encode the given FormData object into a multipart/form-data payload. + # + # @param form_data [FormData] The form data to encode + # @return [String] The encoded body. + def encode(form_data) + return "" if form_data.parts.empty? + + form_data.parts.each do |part| + write_part(part) + end + close + + @body + end + + # Writes a FormDataPart to the encoder. + # + # @param part [FormDataPart] The part to write + # @return [nil] + def write_part(part) + raise "Cannot write to closed encoder" if @closed + + write_field( + name: part.name, + data: part.contents, + filename: part.filename, + headers: part.headers + ) + + nil + end + + # Writes a field to the encoder. + # + # @param name [String] The field name + # @param data [String] The field data + # @param filename [String, nil] Optional filename + # @param headers [Hash, nil] Optional additional headers + # @return [nil] + def write_field(name:, data:, filename: nil, headers: nil) + raise "Cannot write to closed encoder" if @closed + + if @first_field + @first_field = false + else + @body << CRLF + end + + @body << "--#{@boundary}#{CRLF}" + @body << %(Content-Disposition: form-data; name="#{escape(name.to_s)}") + @body << %(; filename="#{escape(filename)}") if filename + @body << CRLF + + if headers + headers.each do |key, value| + @body << "#{key}: #{value}#{CRLF}" + end + elsif filename + # Default content type for files. + @body << "Content-Type: application/octet-stream#{CRLF}" + end + + @body << CRLF + @body << data.to_s + + nil + end + + # Finalizes the encoder by writing the final boundary. + # + # @return [nil] + def close + raise "Encoder already closed" if @closed + + @body << CRLF + @body << "--#{@boundary}--" + @closed = true + + nil + end + + private + + # Escapes quotes for use in header values and replaces line breaks with spaces. + # + # @param str [String] The string to escape + # @return [String] The escaped string + def escape(str) + str.to_s.gsub('"', "%22").tr("\n", " ").tr("\r", " ") + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data.rb new file mode 100644 index 000000000000..5be1bb25341f --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # @api private + class FormData + # @return [Array] The parts in this multipart form data. + attr_reader :parts + + # @return [Encoder] The encoder for this multipart form data. + private attr_reader :encoder + + def initialize + @encoder = Encoder.new + @parts = [] + end + + # Adds a new part to the multipart form data. + # + # @param name [String] The name of the form field + # @param value [String, Integer, Float, Boolean, #read] The value of the field + # @param content_type [String, nil] Optional content type + # @return [self] Returns self for chaining + def add(name:, value:, content_type: nil) + headers = content_type ? { "Content-Type" => content_type } : nil + add_part(FormDataPart.new(name:, value:, headers:)) + end + + # Adds a file to the multipart form data. + # + # @param name [String] The name of the form field + # @param file [#read] The file or readable object + # @param filename [String, nil] Optional filename (defaults to basename of path for File objects) + # @param content_type [String, nil] Optional content type (e.g. "image/png") + # @return [self] Returns self for chaining + def add_file(name:, file:, filename: nil, content_type: nil) + headers = content_type ? { "Content-Type" => content_type } : nil + filename ||= filename_for(file) + add_part(FormDataPart.new(name:, value: file, filename:, headers:)) + end + + # Adds a pre-created part to the multipart form data. + # + # @param part [FormDataPart] The part to add + # @return [self] Returns self for chaining + def add_part(part) + @parts << part + self + end + + # Gets the content type string including the boundary. + # + # @return [String] The content type with boundary. + def content_type + @encoder.content_type + end + + # Encode the multipart form data into a multipart/form-data payload. + # + # @return [String] The encoded body. + def encode + @encoder.encode(self) + end + + private + + def filename_for(file) + if file.is_a?(::File) || file.respond_to?(:path) + ::File.basename(file.path) + elsif file.respond_to?(:name) + file.name + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data_part.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data_part.rb new file mode 100644 index 000000000000..de45416ee087 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_form_data_part.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require "securerandom" + +module Seed + module Internal + module Multipart + # @api private + class FormDataPart + attr_reader :name, :contents, :filename, :headers + + # @param name [String] The name of the form field + # @param value [String, Integer, Float, Boolean, File, #read] The value of the field + # @param filename [String, nil] Optional filename for file uploads + # @param headers [Hash, nil] Optional additional headers + def initialize(name:, value:, filename: nil, headers: nil) + @name = name + @contents = convert_to_content(value) + @filename = filename + @headers = headers + end + + # Converts the part to a hash suitable for serialization. + # + # @return [Hash] A hash representation of the part + def to_hash + result = { + name: @name, + contents: @contents + } + result[:filename] = @filename if @filename + result[:headers] = @headers if @headers + result + end + + private + + # Converts various types of values to a content representation + # @param value [String, Integer, Float, Boolean, #read] The value to convert + # @return [String] The string representation of the value + def convert_to_content(value) + if value.respond_to?(:read) + value.read + else + value.to_s + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_request.rb new file mode 100644 index 000000000000..915dada8c56e --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/multipart/multipart_request.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # @api private + class Request < Seed::Internal::Http::BaseRequest + attr_reader :body + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [Symbol] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param body [MultipartFormData, nil] The multipart form data for the request (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {}) + super(base_url:, path:, method:, headers:, query:, request_options:) + + @body = body + end + + # @return [Hash] The encoded HTTP request headers. + def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} + { + "Content-Type" => @body.content_type + }.merge(@headers).merge(additional_headers) + end + + # @return [String, nil] The encoded HTTP request body. + def encode_body + @body&.encode + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/array.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/array.rb new file mode 100644 index 000000000000..f3c7c1bd9549 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/array.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # An array of a specific type + class Array + include Seed::Internal::Types::Type + + attr_reader :type + + class << self + # Instantiates a new `Array` of a given type + # + # @param type [Object] The member type of this array + # + # @return [Seed::Internal::Types::Array] + def [](type) + new(type) + end + end + + # @api private + def initialize(type) + @type = type + end + + # Coerces a value into this array + # + # @param value [Object] + # @option strict [Boolean] + # @return [::Array] + def coerce(value, strict: strict?) + unless value.is_a?(::Array) + raise Errors::TypeError, "cannot coerce `#{value.class}` to Array<#{type}>" if strict + + return value + end + + value.map do |element| + Utils.coerce(type, element, strict: strict) + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/boolean.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/boolean.rb new file mode 100644 index 000000000000..de0503d9e56b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/boolean.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + module Boolean + extend Seed::Internal::Types::Union + + member TrueClass + member FalseClass + + # Overrides the base coercion method for enums to allow integer and string values to become booleans + # + # @param value [Object] + # @option strict [Boolean] + # @return [Object] + def self.coerce(value, strict: strict?) + case value + when TrueClass, FalseClass + value + when Integer + return value == 1 + when String + return %w[1 true].include?(value) + end + + raise Errors::TypeError, "cannot coerce `#{value.class}` to Boolean" if strict + + value + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/enum.rb new file mode 100644 index 000000000000..72e45e4c1f27 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/enum.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Module for defining enums + module Enum + include Type + + # @api private + # + # @return [Array] + def values + @values ||= constants.map { |c| const_get(c) } + end + + # @api private + def finalize! + values + end + + # @api private + def strict? + @strict ||= false + end + + # @api private + def strict! + @strict = true + end + + def coerce(value, strict: strict?) + coerced_value = Utils.coerce(Symbol, value) + + return coerced_value if values.include?(coerced_value) + + raise Errors::TypeError, "`#{value}` not in enum #{self}" if strict + + value + end + + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + + def inspect + "#{name}[#{values.join(", ")}]" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/hash.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/hash.rb new file mode 100644 index 000000000000..d8bffa63ac11 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/hash.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + class Hash + include Type + + attr_reader :key_type, :value_type + + class << self + def [](key_type, value_type) + new(key_type, value_type) + end + end + + def initialize(key_type, value_type) + @key_type = key_type + @value_type = value_type + end + + def coerce(value, strict: strict?) + unless value.is_a?(::Hash) + raise Errors::TypeError, "not hash" if strict + + return value + end + + value.to_h do |k, v| + [Utils.coerce(key_type, k, strict: strict), Utils.coerce(value_type, v, strict: strict)] + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model.rb new file mode 100644 index 000000000000..9b1480c7333a --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # @abstract + # + # An abstract model that all data objects will inherit from + class Model + include Type + + class << self + # The defined fields for this model + # + # @api private + # + # @return [Hash] + def fields + @fields ||= if self < Seed::Internal::Types::Model + superclass.fields.dup + else + {} + end + end + + # Any extra fields that have been created from instantiation + # + # @api private + # + # @return [Hash] + def extra_fields + @extra_fields ||= {} + end + + # Define a new field on this model + # + # @param name [Symbol] The name of the field + # @param type [Class] Type of the field + # @option optional [Boolean] If it is an optional field + # @option nullable [Boolean] If it is a nullable field + # @option api_name [Symbol, String] Name in the API of this field. When serializing/deserializing, will use + # this field name + # @return [void] + def field(name, type, optional: false, nullable: false, api_name: nil, default: nil) + add_field_definition(name: name, type: type, optional: optional, nullable: nullable, api_name: api_name, + default: default) + + define_accessor(name) + define_setter(name) + end + + # Define a new literal for this model + # + # @param name [Symbol] + # @param value [Object] + # @option api_name [Symbol, String] + # @return [void] + def literal(name, value, api_name: nil) + add_field_definition(name: name, type: value.class, optional: false, nullable: false, api_name: api_name, + value: value) + + define_accessor(name) + end + + # Adds a new field definition into the class's fields registry + # + # @api private + # + # @param name [Symbol] + # @param type [Class] + # @option optional [Boolean] + # @return [void] + private def add_field_definition(name:, type:, optional:, nullable:, api_name:, default: nil, value: nil) + fields[name.to_sym] = + Field.new(name: name, type: type, optional: optional, nullable: nullable, api_name: api_name, + value: value, default: default) + end + + # Adds a new field definition into the class's extra fields registry + # + # @api private + # + # @param name [Symbol] + # @param type [Class] + # @option required [Boolean] + # @option optional [Boolean] + # @return [void] + def add_extra_field_definition(name:, type:) + return if extra_fields.key?(name.to_sym) + + extra_fields[name.to_sym] = Field.new(name: name, type: type, optional: true, nullable: false) + + define_accessor(name) + define_setter(name) + end + + # @api private + private def define_accessor(name) + method_name = name.to_sym + + define_method(method_name) do + @data[name] + end + end + + # @api private + private def define_setter(name) + method_name = :"#{name}=" + + define_method(method_name) do |val| + @data[name] = val + end + end + + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument + return value if value.is_a?(self) + + return value unless value.is_a?(::Hash) + + new(value) + end + + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end + + def ===(instance) + instance.class.ancestors.include?(self) + end + end + + # Creates a new instance of this model + # TODO: Should all this logic be in `#coerce` instead? + # + # @param values [Hash] + # @option strict [Boolean] + # @return [self] + def initialize(values = {}) + @data = {} + + values = Utils.symbolize_keys(values.dup) + + self.class.fields.each do |field_name, field| + value = values.delete(field.api_name.to_sym) || values.delete(field.api_name) || values.delete(field_name) + + field_value = value || (if field.literal? + field.value + elsif field.default + field.default + end) + + @data[field_name] = Utils.coerce(field.type, field_value) + end + + # Any remaining values in the input become extra fields + values.each do |name, value| + self.class.add_extra_field_definition(name: name, type: value.class) + + @data[name.to_sym] = value + end + end + + def to_h + self.class.fields.merge(self.class.extra_fields).each_with_object({}) do |(name, field), acc| + # If there is a value present in the data, use that value + # If there is a `nil` value present in the data, and it is optional but NOT nullable, exclude key altogether + # If there is a `nil` value present in the data, and it is optional and nullable, use the nil value + + value = @data[name] + + next if value.nil? && field.optional && !field.nullable + + if value.is_a?(::Array) + value = value.map { |item| item.respond_to?(:to_h) ? item.to_h : item } + elsif value.respond_to?(:to_h) + value = value.to_h + end + + acc[field.api_name] = value + end + end + + def ==(other) + self.class == other.class && to_h == other.to_h + end + + # @return [String] + def inspect + attrs = @data.map do |name, value| + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" + end + + "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model/field.rb new file mode 100644 index 000000000000..6ce0186f6a5d --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/model/field.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + class Model + # Definition of a field on a model + class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default + + def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) + @name = name.to_sym + @type = type + @optional = optional + @nullable = nullable + @api_name = api_name || name.to_s + @value = value + @default = default + end + + def literal? + !value.nil? + end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/type.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/type.rb new file mode 100644 index 000000000000..5866caf1dbda --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/type.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # @abstract + module Type + include Seed::Internal::JSON::Serializable + + # Coerces a value to this type + # + # @param value [unknown] + # @option strict [Boolean] If we should strictly coerce this value + def coerce(value, strict: strict?) + raise NotImplementedError + end + + # Returns if strictness is on for this type, defaults to `false` + # + # @return [Boolean] + def strict? + @strict ||= false + end + + # Enable strictness by default for this type + # + # @return [void] + def strict! + @strict = true + self + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/union.rb new file mode 100644 index 000000000000..8e47f2f1a592 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/union.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Define a union between two types + module Union + include Seed::Internal::Types::Type + + def members + @members ||= [] + end + + # Add a member to this union + # + # @param type [Object] + # @option key [Symbol, String] + # @return [void] + def member(type, key: nil) + members.push([key, Utils.wrap_type(type)]) + self + end + + def member?(type) + members.any? { |_key, type_fn| type == type_fn.call } + end + + # Set the discriminant for this union + # + # @param key [Symbol, String] + # @return [void] + def discriminant(key) + @discriminant = key + end + + # @api private + private def discriminated? + !@discriminant.nil? + end + + # Resolves the type of a value to be one of the members + # + # @param value [Object] + # @return [Class] + private def resolve_member(value) + if discriminated? && value.is_a?(::Hash) + discriminant_value = value.fetch(@discriminant, nil) + + return if discriminant_value.nil? + + members.to_h[discriminant_value]&.call + else + # First try exact type matching + result = members.find do |_key, mem| + member_type = Utils.unwrap_type(mem) + value.is_a?(member_type) + end&.last&.call + + return result if result + + # For Hash values, try to coerce into Model member types + if value.is_a?(::Hash) + members.find do |_key, mem| + member_type = Utils.unwrap_type(mem) + # Check if member_type is a Model class + next unless member_type.is_a?(Class) && member_type <= Model + + # Try to coerce the hash into this model type with strict mode + begin + candidate = Utils.coerce(member_type, value, strict: true) + + # Validate that all required (non-optional) fields are present + # This ensures undiscriminated unions properly distinguish between member types + member_type.fields.each do |field_name, field| + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional + end + + true + rescue Errors::TypeError + false + end + end&.last&.call + end + end + end + + def coerce(value, strict: strict?) + type = resolve_member(value) + + unless type + return value unless strict + + if discriminated? + raise Errors::TypeError, + "value of type `#{value.class}` not member of union #{self}" + end + + raise Errors::TypeError, "could not resolve to member of union #{self}" + end + + Utils.coerce(type, value, strict: strict) + end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/unknown.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/unknown.rb new file mode 100644 index 000000000000..7b58de956da9 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/unknown.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + module Unknown + include Seed::Internal::Types::Type + + def coerce(value) + value + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/utils.rb new file mode 100644 index 000000000000..4685ec234596 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/internal/types/utils.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Utilities for dealing with and checking types + module Utils + # Wraps a type into a type function + # + # @param type [Proc, Object] + # @return [Proc] + def self.wrap_type(type) + case type + when Proc + type + else + -> { type } + end + end + + # Resolves a type or type function into a type + # + # @param type [Proc, Object] + # @return [Object] + def self.unwrap_type(type) + type.is_a?(Proc) ? type.call : type + end + + def self.coerce(target, value, strict: false) + type = unwrap_type(target) + + case type + in Array + case value + when ::Array + return type.coerce(value, strict: strict) + when Set, ::Hash + return coerce(type, value.to_a) + end + in Hash + case value + when ::Hash + return type.coerce(value, strict: strict) + when ::Array + return coerce(type, value.to_h) + end + in ->(t) { t <= NilClass } + return nil + in ->(t) { t <= String } + case value + when String, Symbol, Numeric, TrueClass, FalseClass + return value.to_s + end + in ->(t) { t <= Symbol } + case value + when Symbol, String + return value.to_sym + end + in ->(t) { t <= Integer } + case value + when Numeric, String, Time + return value.to_i + end + in ->(t) { t <= Float } + case value + when Numeric, Time, String + return value.to_f + end + in ->(t) { t <= Model } + case value + when type + return value + when ::Hash + return type.coerce(value, strict: strict) + end + in Module + case type + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } + return type.coerce(value, strict: strict) + else + value + end + else + value + end + + raise Errors::TypeError, "cannot coerce value of type `#{value.class}` to `#{target}`" if strict + + value + end + + def self.symbolize_keys(hash) + hash.transform_keys(&:to_sym) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/normal_object.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/normal_object.rb new file mode 100644 index 000000000000..48b32a62589a --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/normal_object.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Types + # A standard object with no nullable issues. + class NormalObject < Internal::Types::Model + field :normal_field, -> { String }, optional: true, nullable: false, api_name: "normalField" + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/nullable_object.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/nullable_object.rb new file mode 100644 index 000000000000..ce949b08aea5 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/nullable_object.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Types + # This schema has nullable:true at the top level. + class NullableObject < Internal::Types::Model + field :nullable_field, -> { String }, optional: true, nullable: false, api_name: "nullableField" + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/root_object.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/root_object.rb new file mode 100644 index 000000000000..7219fa34545a --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/types/root_object.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Types + # Object inheriting from a nullable schema via allOf. + class RootObject < Internal::Types::Model; end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/version.rb b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/version.rb new file mode 100644 index 000000000000..00dd45cdd958 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/lib/seed/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Seed + VERSION = "0.0.1" +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/reference.md b/seed/ruby-sdk-v2/nullable-allof-extends/reference.md new file mode 100644 index 000000000000..ad238c729a02 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/reference.md @@ -0,0 +1,93 @@ +# Reference +
client.get_test() -> Seed::Types::RootObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a RootObject which inherits from a nullable schema. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.get_test(); +``` +
+
+
+
+ + +
+
+
+ +
client.create_test(request) -> Seed::Types::RootObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a test object with nullable allOf in request body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.create_test(); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Seed::Types::RootObject` + +
+
+
+
+ + +
+
+
diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/seed.gemspec b/seed/ruby-sdk-v2/nullable-allof-extends/seed.gemspec new file mode 100644 index 000000000000..23b6a2279add --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/seed.gemspec @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require_relative "lib/seed/version" +require_relative "custom.gemspec" + +# NOTE: A handful of these fields are required as part of the Ruby specification. +# You can change them here or overwrite them in the custom gemspec file. +Gem::Specification.new do |spec| + spec.name = "seed" + spec.authors = ["Seed"] + spec.version = Seed::VERSION + spec.summary = "Ruby client library for the Seed API" + spec.description = "The Seed Ruby library provides convenient access to the Seed API from Ruby." + spec.required_ruby_version = ">= 3.3.0" + spec.metadata["rubygems_mfa_required"] = "true" + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) + spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| + ls.readlines("\x0", chomp: true).reject do |f| + (f == gemspec) || + f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile]) + end + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + # For more information and examples about making a new gem, check out our + # guide at: https://bundler.io/guides/creating_gem.html + + # Load custom gemspec configuration if it exists + custom_gemspec_file = File.join(__dir__, "custom.gemspec.rb") + add_custom_gemspec_data(spec) if File.exist?(custom_gemspec_file) +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/snippet.json b/seed/ruby-sdk-v2/nullable-allof-extends/snippet.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/custom.test.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/custom.test.rb new file mode 100644 index 000000000000..4bd57989d43d --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/custom.test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# This is a custom test file, if you wish to add more tests +# to your SDK. +# Be sure to mark this file in `.fernignore`. +# +# If you include example requests/responses in your fern definition, +# you will have tests automatically generated for you. + +# This test is run via command line: rake customtest +describe "Custom Test" do + it "Default" do + refute false + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/test_helper.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/test_helper.rb new file mode 100644 index 000000000000..b086fe6d76ec --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/test_helper.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "../lib/seed" diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb new file mode 100644 index 000000000000..5008f6abf69f --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -0,0 +1,189 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "stringio" +require "json" +require "test_helper" + +NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) + +class CursorItemIteratorTest < Minitest::Test + def make_iterator(initial_cursor:) + @times_called = 0 + + Seed::Internal::CursorItemIterator.new(initial_cursor:, cursor_field: :next_cursor, item_field: :cards) do |cursor| + @times_called += 1 + cursor ||= 0 + next_cursor = cursor + 10 + PageResponse.new( + cards: NUMBERS[cursor...next_cursor], + next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil + ) + end + end + + def test_item_iterator_can_iterate_to_exhaustion + iterator = make_iterator(initial_cursor: 0) + + assert_equal NUMBERS, iterator.to_a + assert_equal 7, @times_called + + iterator = make_iterator(initial_cursor: 10) + + assert_equal (11..65).to_a, iterator.to_a + + iterator = make_iterator(initial_cursor: 5) + + assert_equal (6..65).to_a, iterator.to_a + end + + def test_item_iterator_can_work_without_an_initial_cursor + iterator = make_iterator(initial_cursor: nil) + + assert_equal NUMBERS, iterator.to_a + assert_equal 7, @times_called + end + + def test_items_iterator_iterates_lazily + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + assert_equal 1, iterator.first + assert_equal 1, @times_called + + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + assert_equal (1..15).to_a, iterator.first(15) + assert_equal 2, @times_called + + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + iterator.each do |card| + break if card >= 15 + end + + assert_equal 2, @times_called + end + + def test_items_iterator_implements_enumerable + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + doubled = iterator.map { |card| card * 2 } + + assert_equal 7, @times_called + assert_equal NUMBERS.length, doubled.length + end + + def test_items_iterator_can_be_advanced_manually + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + + items = [] + expected_times_called = 0 + while (item = iterator.next_element) + expected_times_called += 1 if (item % 10) == 1 + + assert_equal expected_times_called, @times_called + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" + items.push(item) + end + + assert_equal 7, @times_called + assert_equal NUMBERS, items + end + + def test_pages_iterator + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal( + [ + (1..10).to_a, + (11..20).to_a, + (21..30).to_a, + (31..40).to_a, + (41..50).to_a, + (51..60).to_a, + (61..65).to_a + ], + iterator.to_a.map(&:cards) + ) + + iterator = make_iterator(initial_cursor: 10).pages + + assert_equal( + [ + (11..20).to_a, + (21..30).to_a, + (31..40).to_a, + (41..50).to_a, + (51..60).to_a, + (61..65).to_a + ], + iterator.to_a.map(&:cards) + ) + end + + def test_pages_iterator_can_work_without_an_initial_cursor + iterator = make_iterator(initial_cursor: nil).pages + + assert_equal 7, iterator.to_a.length + assert_equal 7, @times_called + end + + def test_pages_iterator_iterates_lazily + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + iterator.first + + assert_equal 1, @times_called + + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + assert_equal 2, iterator.first(2).length + assert_equal 2, @times_called + end + + def test_pages_iterator_knows_whether_another_page_is_upcoming + iterator = make_iterator(initial_cursor: 0).pages + + iterator.each_with_index do |_page, index| + assert_equal index + 1, @times_called + assert_equal index < 6, iterator.next? + end + end + + def test_pages_iterator_can_be_advanced_manually + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + + lengths = [] + expected_times_called = 0 + while (page = iterator.next_page) + expected_times_called += 1 + + assert_equal expected_times_called, @times_called + lengths.push(page.cards.length) + end + + assert_equal 7, @times_called + assert_equal [10, 10, 10, 10, 10, 10, 5], lengths + end + + def test_pages_iterator_implements_enumerable + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + lengths = iterator.map { |page| page.cards.length } + + assert_equal 7, @times_called + assert_equal [10, 10, 10, 10, 10, 10, 5], lengths + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_offset_item_iterator.rb new file mode 100644 index 000000000000..92576b820128 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "stringio" +require "json" +require "test_helper" + +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) +TestIteratorConfig = Struct.new( + :step, + :has_next_field, + :total_item_count, + :per_page, + :initial_page +) do + def first_item_returned + if step + (initial_page || 0) + 1 + else + (((initial_page || 1) - 1) * per_page) + 1 + end + end +end + +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) +ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| + [:has_next, nil].map do |has_next_field| + [0, 5, 10, 60, 63].map do |total_item_count| + [5, 10].map do |per_page| + initial_pages = [nil, 3, 100] + initial_pages << (step ? 0 : 1) + + initial_pages.map do |initial_page| + TestIteratorConfig.new( + step: step, + has_next_field: has_next_field, + total_item_count: total_item_count, + per_page: per_page, + initial_page: initial_page + ) + end + end + end + end +end.flatten + +class OffsetItemIteratorTest < Minitest::Test + def make_iterator(config) + @times_called = 0 + + items = (1..config.total_item_count).to_a + + Seed::Internal::OffsetItemIterator.new( + initial_page: config.initial_page, + item_field: :items, + has_next_field: config.has_next_field, + step: config.step + ) do |page| + @times_called += 1 + + slice_start = config.step ? page : (page - 1) * config.per_page + slice_end = slice_start + config.per_page + + output = { + items: items[slice_start...slice_end] + } + output[config.has_next_field] = slice_end < items.length if config.has_next_field + + OffsetPageResponse.new(**output) + end + end + + def test_item_iterator_can_iterate_to_exhaustion + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config) + + assert_equal (config.first_item_returned..config.total_item_count).to_a, iterator.to_a + end + end + + def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config) + items = [] + + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") + items.push(item) + end + + assert_equal (config.first_item_returned..config.total_item_count).to_a, items + end + end + + def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config).pages + pages = [] + + loop do + has_next_output = iterator.next? + page = iterator.next_page + + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") + break if page.nil? + + pages.push(page) + end + + assert_equal pages, make_iterator(config).pages.to_a + end + end + + def test_items_iterator_iterates_lazily + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + assert_equal 1, iterator.first + assert_equal 1, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + assert_equal (1..15).to_a, iterator.first(15) + assert_equal 2, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + iterator.each do |card| + break if card >= 15 + end + + assert_equal 2, @times_called + end + + def test_pages_iterator_iterates_lazily + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG).pages + + assert_equal 0, @times_called + iterator.first + + assert_equal 1, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG).pages + + assert_equal 0, @times_called + assert_equal 3, iterator.first(3).length + assert_equal 3, @times_called + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_array.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_array.rb new file mode 100644 index 000000000000..e7e6571f03ee --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_array.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Array do + module TestArray + StringArray = Seed::Internal::Types::Array[String] + end + + describe "#initialize" do + it "sets the type" do + assert_equal String, TestArray::StringArray.type + end + end + + describe "#coerce" do + it "does not perform coercion if not an array" do + assert_equal 1, TestArray::StringArray.coerce(1) + end + + it "raises an error if not an array and strictness is on" do + assert_raises Seed::Internal::Errors::TypeError do + TestArray::StringArray.coerce(1, strict: true) + end + end + + it "coerces the elements" do + assert_equal %w[foobar 1 true], TestArray::StringArray.coerce(["foobar", 1, true]) + end + + it "raises an error if element of array is not coercable and strictness is on" do + assert_raises Seed::Internal::Errors::TypeError do + TestArray::StringArray.coerce([Object.new], strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_boolean.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_boolean.rb new file mode 100644 index 000000000000..cba18e48765b --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_boolean.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Boolean do + describe ".coerce" do + it "coerces true/false" do + assert Seed::Internal::Types::Boolean.coerce(true) + refute Seed::Internal::Types::Boolean.coerce(false) + end + + it "coerces an Integer" do + assert Seed::Internal::Types::Boolean.coerce(1) + refute Seed::Internal::Types::Boolean.coerce(0) + end + + it "coerces a String" do + assert Seed::Internal::Types::Boolean.coerce("1") + assert Seed::Internal::Types::Boolean.coerce("true") + refute Seed::Internal::Types::Boolean.coerce("0") + end + + it "passes through other values with strictness off" do + obj = Object.new + + assert_equal obj, Seed::Internal::Types::Boolean.coerce(obj) + end + + it "raises an error with other values with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + Seed::Internal::Types::Boolean.coerce(Object.new, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_enum.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_enum.rb new file mode 100644 index 000000000000..e8d89bce467f --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_enum.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Enum do + module EnumTest + module ExampleEnum + extend Seed::Internal::Types::Enum + + FOO = :foo + BAR = :bar + + finalize! + end + end + + describe "#values" do + it "defines values" do + assert_equal %i[foo bar].sort, EnumTest::ExampleEnum.values.sort + end + end + + describe "#coerce" do + it "coerces an existing member" do + assert_equal :foo, EnumTest::ExampleEnum.coerce(:foo) + end + + it "coerces a string version of a member" do + assert_equal :foo, EnumTest::ExampleEnum.coerce("foo") + end + + it "returns the value if not a member with strictness off" do + assert_equal 1, EnumTest::ExampleEnum.coerce(1) + end + + it "raises an error if value is not a member with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + EnumTest::ExampleEnum.coerce(1, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_hash.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_hash.rb new file mode 100644 index 000000000000..6c5e58a6a946 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_hash.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Hash do + module TestHash + SymbolStringHash = Seed::Internal::Types::Hash[Symbol, String] + end + + describe ".[]" do + it "defines the key and value type" do + assert_equal Symbol, TestHash::SymbolStringHash.key_type + assert_equal String, TestHash::SymbolStringHash.value_type + end + end + + describe "#coerce" do + it "coerces the keys" do + assert_equal %i[foo bar], TestHash::SymbolStringHash.coerce({ "foo" => "1", :bar => "2" }).keys + end + + it "coerces the values" do + assert_equal %w[foo 1], TestHash::SymbolStringHash.coerce({ foo: :foo, bar: 1 }).values + end + + it "passes through other values with strictness off" do + obj = Object.new + + assert_equal obj, TestHash::SymbolStringHash.coerce(obj) + end + + it "raises an error with other values with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce(Object.new, strict: true) + end + end + + it "raises an error with non-coercable key types with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce({ Object.new => 1 }, strict: true) + end + end + + it "raises an error with non-coercable value types with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce({ "foobar" => Object.new }, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_model.rb new file mode 100644 index 000000000000..3d87b9f5a8c7 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_model.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Model do + module StringInteger + extend Seed::Internal::Types::Union + + member String + member Integer + end + + class ExampleModel < Seed::Internal::Types::Model + field :name, String + field :rating, StringInteger, optional: true + field :year, Integer, optional: true, nullable: true, api_name: "yearOfRelease" + end + + class ExampleModelInheritance < ExampleModel + field :director, String + end + + class ExampleWithDefaults < ExampleModel + field :type, String, default: "example" + end + + class ExampleChild < Seed::Internal::Types::Model + field :value, String + end + + class ExampleParent < Seed::Internal::Types::Model + field :child, ExampleChild + end + + describe ".field" do + before do + @example = ExampleModel.new(name: "Inception", rating: 4) + end + + it "defines fields on model" do + assert_equal %i[name rating year], ExampleModel.fields.keys + end + + it "defines fields from parent models" do + assert_equal %i[name rating year director], ExampleModelInheritance.fields.keys + end + + it "sets the field's type" do + assert_equal String, ExampleModel.fields[:name].type + assert_equal StringInteger, ExampleModel.fields[:rating].type + end + + it "sets the `default` option" do + assert_equal "example", ExampleWithDefaults.fields[:type].default + end + + it "defines getters" do + assert_respond_to @example, :name + assert_respond_to @example, :rating + + assert_equal "Inception", @example.name + assert_equal 4, @example.rating + end + + it "defines setters" do + assert_respond_to @example, :name= + assert_respond_to @example, :rating= + + @example.name = "Inception 2" + @example.rating = 5 + + assert_equal "Inception 2", @example.name + assert_equal 5, @example.rating + end + end + + describe "#initialize" do + it "sets the data" do + example = ExampleModel.new(name: "Inception", rating: 4) + + assert_equal "Inception", example.name + assert_equal 4, example.rating + end + + it "allows extra fields to be set" do + example = ExampleModel.new(name: "Inception", rating: 4, director: "Christopher Nolan") + + assert_equal "Christopher Nolan", example.director + end + + it "sets the defaults where applicable" do + example_using_defaults = ExampleWithDefaults.new + + assert_equal "example", example_using_defaults.type + + example_without_defaults = ExampleWithDefaults.new(type: "not example") + + assert_equal "not example", example_without_defaults.type + end + + it "coerces child models" do + parent = ExampleParent.new(child: { value: "foobar" }) + + assert_kind_of ExampleChild, parent.child + end + + it "uses the api_name to pull the value" do + example = ExampleModel.new({ name: "Inception", yearOfRelease: 2014 }) + + assert_equal 2014, example.year + refute_respond_to example, :yearOfRelease + end + end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_union.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_union.rb new file mode 100644 index 000000000000..2b08e7f91d8f --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_union.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Union do + class Rectangle < Seed::Internal::Types::Model + literal :type, "square" + + field :area, Float + end + + class Circle < Seed::Internal::Types::Model + literal :type, "circle" + + field :area, Float + end + + class Pineapple < Seed::Internal::Types::Model + literal :type, "pineapple" + + field :area, Float + end + + module Shape + extend Seed::Internal::Types::Union + + discriminant :type + + member -> { Rectangle }, key: "rect" + member -> { Circle }, key: "circle" + end + + module StringOrInteger + extend Seed::Internal::Types::Union + + member String + member Integer + end + + describe "#coerce" do + it "coerces hashes into member models with discriminated unions" do + circle = Shape.coerce({ type: "circle", area: 4.0 }) + + assert_instance_of Circle, circle + end + end + + describe "#member" do + it "defines Model members" do + assert Shape.member?(Rectangle) + assert Shape.member?(Circle) + refute Shape.member?(Pineapple) + end + + it "defines other members" do + assert StringOrInteger.member?(String) + assert StringOrInteger.member?(Integer) + refute StringOrInteger.member?(Float) + refute StringOrInteger.member?(Pineapple) + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_utils.rb b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_utils.rb new file mode 100644 index 000000000000..29d14621a229 --- /dev/null +++ b/seed/ruby-sdk-v2/nullable-allof-extends/test/unit/internal/types/test_utils.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Utils do + Utils = Seed::Internal::Types::Utils + + module TestUtils + class M < Seed::Internal::Types::Model + field :value, String + end + + class UnionMemberA < Seed::Internal::Types::Model + literal :type, "A" + field :only_on_a, String + end + + class UnionMemberB < Seed::Internal::Types::Model + literal :type, "B" + field :only_on_b, String + end + + module U + extend Seed::Internal::Types::Union + + discriminant :type + + member -> { UnionMemberA }, key: "A" + member -> { UnionMemberB }, key: "B" + end + + SymbolStringHash = Seed::Internal::Types::Hash[Symbol, String] + SymbolModelHash = -> { Seed::Internal::Types::Hash[Symbol, TestUtils::M] } + end + + describe ".coerce" do + describe "NilClass" do + it "always returns nil" do + assert_nil Utils.coerce(NilClass, "foobar") + assert_nil Utils.coerce(NilClass, 1) + assert_nil Utils.coerce(NilClass, Object.new) + end + end + + describe "String" do + it "coerces from String, Symbol, Numeric, or Boolean" do + assert_equal "foobar", Utils.coerce(String, "foobar") + assert_equal "foobar", Utils.coerce(String, :foobar) + assert_equal "1", Utils.coerce(String, 1) + assert_equal "1.0", Utils.coerce(String, 1.0) + assert_equal "true", Utils.coerce(String, true) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(String, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(String, Object.new, strict: true) + end + end + end + + describe "Symbol" do + it "coerces from Symbol, String" do + assert_equal :foobar, Utils.coerce(Symbol, :foobar) + assert_equal :foobar, Utils.coerce(Symbol, "foobar") + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Symbol, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Symbol, Object.new, strict: true) + end + end + end + + describe "Integer" do + it "coerces from Numeric, String, Time" do + assert_equal 1, Utils.coerce(Integer, 1) + assert_equal 1, Utils.coerce(Integer, 1.0) + assert_equal 1, Utils.coerce(Integer, Complex.rect(1)) + assert_equal 1, Utils.coerce(Integer, Rational(1)) + assert_equal 1, Utils.coerce(Integer, "1") + assert_equal 1_713_916_800, Utils.coerce(Integer, Time.utc(2024, 4, 24)) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Integer, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Integer, Object.new, strict: true) + end + end + end + + describe "Float" do + it "coerces from Numeric, Time" do + assert_in_delta(1.0, Utils.coerce(Float, 1.0)) + assert_in_delta(1.0, Utils.coerce(Float, 1)) + assert_in_delta(1.0, Utils.coerce(Float, Complex.rect(1))) + assert_in_delta(1.0, Utils.coerce(Float, Rational(1))) + assert_in_delta(1_713_916_800.0, Utils.coerce(Integer, Time.utc(2024, 4, 24))) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Float, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Float, Object.new, strict: true) + end + end + end + + describe "Model" do + it "coerces a hash" do + result = Utils.coerce(TestUtils::M, { value: "foobar" }) + + assert_kind_of TestUtils::M, result + assert_equal "foobar", result.value + end + + it "coerces a hash when the target is a type function" do + result = Utils.coerce(-> { TestUtils::M }, { value: "foobar" }) + + assert_kind_of TestUtils::M, result + assert_equal "foobar", result.value + end + + it "will not coerce non-hashes" do + assert_equal "foobar", Utils.coerce(TestUtils::M, "foobar") + end + end + + describe "Enum" do + module ExampleEnum + extend Seed::Internal::Types::Enum + + FOO = :FOO + BAR = :BAR + + finalize! + end + + it "coerces into a Symbol version of the member value" do + assert_equal :FOO, Utils.coerce(ExampleEnum, "FOO") + end + + it "returns given value if not a member" do + assert_equal "NOPE", Utils.coerce(ExampleEnum, "NOPE") + end + end + + describe "Array" do + StringArray = Seed::Internal::Types::Array[String] + ModelArray = -> { Seed::Internal::Types::Array[TestUtils::M] } + UnionArray = -> { Seed::Internal::Types::Array[TestUtils::U] } + + it "coerces an array of literals" do + assert_equal %w[a b c], Utils.coerce(StringArray, %w[a b c]) + assert_equal ["1", "2.0", "true"], Utils.coerce(StringArray, [1, 2.0, true]) + assert_equal ["1", "2.0", "true"], Utils.coerce(StringArray, Set.new([1, 2.0, true])) + end + + it "coerces an array of Models" do + assert_equal [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")], + Utils.coerce(ModelArray, [{ value: "foobar" }, { value: "bizbaz" }]) + + assert_equal [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")], + Utils.coerce(ModelArray, [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")]) + end + + it "coerces an array of model unions" do + assert_equal [TestUtils::UnionMemberA.new(type: "A", only_on_a: "A"), TestUtils::UnionMemberB.new(type: "B", only_on_b: "B")], + Utils.coerce(UnionArray, [{ type: "A", only_on_a: "A" }, { type: "B", only_on_b: "B" }]) + end + + it "returns given value if not an array" do + assert_equal 1, Utils.coerce(StringArray, 1) + end + end + + describe "Hash" do + it "coerces the keys and values" do + ssh_res = Utils.coerce(TestUtils::SymbolStringHash, { "foo" => "bar", "biz" => "2" }) + + assert_equal "bar", ssh_res[:foo] + assert_equal "2", ssh_res[:biz] + + smh_res = Utils.coerce(TestUtils::SymbolModelHash, { "foo" => { "value" => "foo" } }) + + assert_equal TestUtils::M.new(value: "foo"), smh_res[:foo] + end + end + end +end diff --git a/seed/ruby-sdk-v2/nullable-optional/.rubocop.yml b/seed/ruby-sdk-v2/nullable-optional/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/nullable-optional/.rubocop.yml +++ b/seed/ruby-sdk-v2/nullable-optional/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example5/snippet.rb index d23ff6414f96..e8a8c4a77925 100644 --- a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example5/snippet.rb @@ -4,6 +4,12 @@ client.nullable_optional.create_complex_profile( id: 'id', + nullable_role: 'ADMIN', + optional_role: 'ADMIN', + optional_nullable_role: 'ADMIN', + nullable_status: 'active', + optional_status: 'active', + optional_nullable_status: 'active', nullable_array: ['nullableArray', 'nullableArray'], optional_array: ['optionalArray', 'optionalArray'], optional_nullable_array: ['optionalNullableArray', 'optionalNullableArray'], @@ -20,5 +26,7 @@ } }, nullable_list_of_unions: [], - optional_map_of_enums: {} + optional_map_of_enums: { + optionalMapOfEnums: 'ADMIN' + } ); diff --git a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example7/snippet.rb b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example7/snippet.rb index fb1ee9740e72..b3397988a6df 100644 --- a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example7/snippet.rb +++ b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example7/snippet.rb @@ -4,5 +4,7 @@ client.nullable_optional.update_complex_profile( profile_id: 'profileId', + nullable_role: 'ADMIN', + nullable_status: 'active', nullable_array: ['nullableArray', 'nullableArray'] ); diff --git a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example8/snippet.rb b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example8/snippet.rb index b3d3a64c0e76..95895a3f96ce 100644 --- a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example8/snippet.rb +++ b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example8/snippet.rb @@ -7,6 +7,8 @@ nullable_string: 'nullableString', optional_string: 'optionalString', optional_nullable_string: 'optionalNullableString', + nullable_enum: 'ADMIN', + optional_enum: 'active', nullable_list: ['nullableList', 'nullableList'], nullable_map: { nullableMap: 1 diff --git a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example9/snippet.rb b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example9/snippet.rb index 29f5ec92d1b4..f9ceb2db7b3d 100644 --- a/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example9/snippet.rb +++ b/seed/ruby-sdk-v2/nullable-optional/dynamic-snippets/example9/snippet.rb @@ -2,4 +2,8 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.nullable_optional.filter_by_role(); +client.nullable_optional.filter_by_role( + role: 'ADMIN', + status: 'active', + secondary_role: 'ADMIN' +); diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/client.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/client.rb index 493397e0673d..540fee3fc76a 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/client.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/client.rb @@ -26,7 +26,8 @@ def get_user(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/api/users/#{params[:user_id]}" + path: "/api/users/#{params[:user_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -58,7 +59,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/api/users", - body: Seed::NullableOptional::Types::CreateUserRequest.new(params).to_h + body: Seed::NullableOptional::Types::CreateUserRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -91,7 +93,8 @@ def update_user(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "/api/users/#{params[:user_id]}", - body: Seed::NullableOptional::Types::UpdateUserRequest.new(params).to_h + body: Seed::NullableOptional::Types::UpdateUserRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -136,7 +139,8 @@ def list_users(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -179,7 +183,8 @@ def search_users(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/users/search", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -209,7 +214,8 @@ def create_complex_profile(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/api/profiles/complex", - body: Seed::NullableOptional::Types::ComplexProfile.new(params).to_h + body: Seed::NullableOptional::Types::ComplexProfile.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -241,7 +247,8 @@ def get_complex_profile(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/api/profiles/complex/#{params[:profile_id]}" + path: "/api/profiles/complex/#{params[:profile_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -279,7 +286,8 @@ def update_complex_profile(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "/api/profiles/complex/#{params[:profile_id]}", - body: Seed::NullableOptional::Types::UpdateComplexProfileRequest.new(body_bag).to_h + body: Seed::NullableOptional::Types::UpdateComplexProfileRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -311,7 +319,8 @@ def test_deserialization(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/api/test/deserialization", - body: Seed::NullableOptional::Types::DeserializationTestRequest.new(params).to_h + body: Seed::NullableOptional::Types::DeserializationTestRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -354,7 +363,8 @@ def filter_by_role(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/api/users/filter", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -384,7 +394,8 @@ def get_notification_settings(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/api/users/#{params[:user_id]}/notifications" + path: "/api/users/#{params[:user_id]}/notifications", + request_options: request_options ) begin response = @client.send(request) @@ -420,7 +431,8 @@ def update_tags(request_options: {}, **params) base_url: request_options[:base_url], method: "PUT", path: "/api/users/#{params[:user_id]}/tags", - body: Seed::NullableOptional::Types::UpdateTagsRequest.new(body_bag).to_h + body: Seed::NullableOptional::Types::UpdateTagsRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -453,7 +465,8 @@ def get_search_results(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/api/search", - body: Seed::NullableOptional::Types::SearchRequest.new(body_bag).to_h + body: Seed::NullableOptional::Types::SearchRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/complex_profile.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/complex_profile.rb index f302d81654b3..a82c4bc3ce69 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/complex_profile.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/complex_profile.rb @@ -6,60 +6,24 @@ module Types # Test object with nullable enums, unions, and arrays class ComplexProfile < Internal::Types::Model field :id, -> { String }, optional: false, nullable: false - field :nullable_role, -> { - Seed::NullableOptional::Types::UserRole - }, optional: false, nullable: true, api_name: "nullableRole" - field :optional_role, -> { - Seed::NullableOptional::Types::UserRole - }, optional: true, nullable: false, api_name: "optionalRole" - field :optional_nullable_role, -> { - Seed::NullableOptional::Types::UserRole - }, optional: true, nullable: false, api_name: "optionalNullableRole" - field :nullable_status, -> { - Seed::NullableOptional::Types::UserStatus - }, optional: false, nullable: true, api_name: "nullableStatus" - field :optional_status, -> { - Seed::NullableOptional::Types::UserStatus - }, optional: true, nullable: false, api_name: "optionalStatus" - field :optional_nullable_status, -> { - Seed::NullableOptional::Types::UserStatus - }, optional: true, nullable: false, api_name: "optionalNullableStatus" - field :nullable_notification, -> { - Seed::NullableOptional::Types::NotificationMethod - }, optional: false, nullable: true, api_name: "nullableNotification" - field :optional_notification, -> { - Seed::NullableOptional::Types::NotificationMethod - }, optional: true, nullable: false, api_name: "optionalNotification" - field :optional_nullable_notification, -> { - Seed::NullableOptional::Types::NotificationMethod - }, optional: true, nullable: false, api_name: "optionalNullableNotification" - field :nullable_search_result, -> { - Seed::NullableOptional::Types::SearchResult - }, optional: false, nullable: true, api_name: "nullableSearchResult" - field :optional_search_result, -> { - Seed::NullableOptional::Types::SearchResult - }, optional: true, nullable: false, api_name: "optionalSearchResult" - field :nullable_array, -> { - Internal::Types::Array[String] - }, optional: false, nullable: true, api_name: "nullableArray" - field :optional_array, -> { - Internal::Types::Array[String] - }, optional: true, nullable: false, api_name: "optionalArray" - field :optional_nullable_array, -> { - Internal::Types::Array[String] - }, optional: true, nullable: false, api_name: "optionalNullableArray" - field :nullable_list_of_nullables, -> { - Internal::Types::Array[String] - }, optional: false, nullable: true, api_name: "nullableListOfNullables" - field :nullable_map_of_nullables, -> { - Internal::Types::Hash[String, Seed::NullableOptional::Types::Address] - }, optional: false, nullable: true, api_name: "nullableMapOfNullables" - field :nullable_list_of_unions, -> { - Internal::Types::Array[Seed::NullableOptional::Types::NotificationMethod] - }, optional: false, nullable: true, api_name: "nullableListOfUnions" - field :optional_map_of_enums, -> { - Internal::Types::Hash[String, Seed::NullableOptional::Types::UserRole] - }, optional: true, nullable: false, api_name: "optionalMapOfEnums" + field :nullable_role, -> { Seed::NullableOptional::Types::UserRole }, optional: false, nullable: true, api_name: "nullableRole" + field :optional_role, -> { Seed::NullableOptional::Types::UserRole }, optional: true, nullable: false, api_name: "optionalRole" + field :optional_nullable_role, -> { Seed::NullableOptional::Types::UserRole }, optional: true, nullable: false, api_name: "optionalNullableRole" + field :nullable_status, -> { Seed::NullableOptional::Types::UserStatus }, optional: false, nullable: true, api_name: "nullableStatus" + field :optional_status, -> { Seed::NullableOptional::Types::UserStatus }, optional: true, nullable: false, api_name: "optionalStatus" + field :optional_nullable_status, -> { Seed::NullableOptional::Types::UserStatus }, optional: true, nullable: false, api_name: "optionalNullableStatus" + field :nullable_notification, -> { Seed::NullableOptional::Types::NotificationMethod }, optional: false, nullable: true, api_name: "nullableNotification" + field :optional_notification, -> { Seed::NullableOptional::Types::NotificationMethod }, optional: true, nullable: false, api_name: "optionalNotification" + field :optional_nullable_notification, -> { Seed::NullableOptional::Types::NotificationMethod }, optional: true, nullable: false, api_name: "optionalNullableNotification" + field :nullable_search_result, -> { Seed::NullableOptional::Types::SearchResult }, optional: false, nullable: true, api_name: "nullableSearchResult" + field :optional_search_result, -> { Seed::NullableOptional::Types::SearchResult }, optional: true, nullable: false, api_name: "optionalSearchResult" + field :nullable_array, -> { Internal::Types::Array[String] }, optional: false, nullable: true, api_name: "nullableArray" + field :optional_array, -> { Internal::Types::Array[String] }, optional: true, nullable: false, api_name: "optionalArray" + field :optional_nullable_array, -> { Internal::Types::Array[String] }, optional: true, nullable: false, api_name: "optionalNullableArray" + field :nullable_list_of_nullables, -> { Internal::Types::Array[String] }, optional: false, nullable: true, api_name: "nullableListOfNullables" + field :nullable_map_of_nullables, -> { Internal::Types::Hash[String, Seed::NullableOptional::Types::Address] }, optional: false, nullable: true, api_name: "nullableMapOfNullables" + field :nullable_list_of_unions, -> { Internal::Types::Array[Seed::NullableOptional::Types::NotificationMethod] }, optional: false, nullable: true, api_name: "nullableListOfUnions" + field :optional_map_of_enums, -> { Internal::Types::Hash[String, Seed::NullableOptional::Types::UserRole] }, optional: true, nullable: false, api_name: "optionalMapOfEnums" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/deserialization_test_request.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/deserialization_test_request.rb index 315b36879ef1..e781236b49c6 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/deserialization_test_request.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/deserialization_test_request.rb @@ -8,33 +8,15 @@ class DeserializationTestRequest < Internal::Types::Model field :required_string, -> { String }, optional: false, nullable: false, api_name: "requiredString" field :nullable_string, -> { String }, optional: false, nullable: true, api_name: "nullableString" field :optional_string, -> { String }, optional: true, nullable: false, api_name: "optionalString" - field :optional_nullable_string, -> { - String - }, optional: true, nullable: false, api_name: "optionalNullableString" - field :nullable_enum, -> { - Seed::NullableOptional::Types::UserRole - }, optional: false, nullable: true, api_name: "nullableEnum" - field :optional_enum, -> { - Seed::NullableOptional::Types::UserStatus - }, optional: true, nullable: false, api_name: "optionalEnum" - field :nullable_union, -> { - Seed::NullableOptional::Types::NotificationMethod - }, optional: false, nullable: true, api_name: "nullableUnion" - field :optional_union, -> { - Seed::NullableOptional::Types::SearchResult - }, optional: true, nullable: false, api_name: "optionalUnion" - field :nullable_list, -> { - Internal::Types::Array[String] - }, optional: false, nullable: true, api_name: "nullableList" - field :nullable_map, -> { - Internal::Types::Hash[String, Integer] - }, optional: false, nullable: true, api_name: "nullableMap" - field :nullable_object, -> { - Seed::NullableOptional::Types::Address - }, optional: false, nullable: true, api_name: "nullableObject" - field :optional_object, -> { - Seed::NullableOptional::Types::Organization - }, optional: true, nullable: false, api_name: "optionalObject" + field :optional_nullable_string, -> { String }, optional: true, nullable: false, api_name: "optionalNullableString" + field :nullable_enum, -> { Seed::NullableOptional::Types::UserRole }, optional: false, nullable: true, api_name: "nullableEnum" + field :optional_enum, -> { Seed::NullableOptional::Types::UserStatus }, optional: true, nullable: false, api_name: "optionalEnum" + field :nullable_union, -> { Seed::NullableOptional::Types::NotificationMethod }, optional: false, nullable: true, api_name: "nullableUnion" + field :optional_union, -> { Seed::NullableOptional::Types::SearchResult }, optional: true, nullable: false, api_name: "optionalUnion" + field :nullable_list, -> { Internal::Types::Array[String] }, optional: false, nullable: true, api_name: "nullableList" + field :nullable_map, -> { Internal::Types::Hash[String, Integer] }, optional: false, nullable: true, api_name: "nullableMap" + field :nullable_object, -> { Seed::NullableOptional::Types::Address }, optional: false, nullable: true, api_name: "nullableObject" + field :optional_object, -> { Seed::NullableOptional::Types::Organization }, optional: true, nullable: false, api_name: "optionalObject" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/filter_by_role_request.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/filter_by_role_request.rb index d8e178770bc7..0e68016fbe51 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/filter_by_role_request.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/filter_by_role_request.rb @@ -6,9 +6,7 @@ module Types class FilterByRoleRequest < Internal::Types::Model field :role, -> { Seed::NullableOptional::Types::UserRole }, optional: false, nullable: true field :status, -> { Seed::NullableOptional::Types::UserStatus }, optional: true, nullable: false - field :secondary_role, -> { - Seed::NullableOptional::Types::UserRole - }, optional: true, nullable: false, api_name: "secondaryRole" + field :secondary_role, -> { Seed::NullableOptional::Types::UserRole }, optional: true, nullable: false, api_name: "secondaryRole" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/list_users_request.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/list_users_request.rb index 231bc823e973..06b5e589a8e4 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/list_users_request.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/list_users_request.rb @@ -6,9 +6,7 @@ module Types class ListUsersRequest < Internal::Types::Model field :limit, -> { Integer }, optional: true, nullable: false field :offset, -> { Integer }, optional: true, nullable: false - field :include_deleted, -> { - Internal::Types::Boolean - }, optional: true, nullable: false, api_name: "includeDeleted" + field :include_deleted, -> { Internal::Types::Boolean }, optional: true, nullable: false, api_name: "includeDeleted" field :sort_by, -> { String }, optional: true, nullable: false, api_name: "sortBy" end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/search_request.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/search_request.rb index 371402af80ec..0b377224ee2f 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/search_request.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/search_request.rb @@ -6,9 +6,7 @@ module Types class SearchRequest < Internal::Types::Model field :query, -> { String }, optional: false, nullable: false field :filters, -> { Internal::Types::Hash[String, String] }, optional: true, nullable: false - field :include_types, -> { - Internal::Types::Array[String] - }, optional: false, nullable: true, api_name: "includeTypes" + field :include_types, -> { Internal::Types::Array[String] }, optional: false, nullable: true, api_name: "includeTypes" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/update_complex_profile_request.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/update_complex_profile_request.rb index 977a1622fb96..ca9a7902ae8b 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/update_complex_profile_request.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/update_complex_profile_request.rb @@ -5,21 +5,11 @@ module NullableOptional module Types class UpdateComplexProfileRequest < Internal::Types::Model field :profile_id, -> { String }, optional: false, nullable: false, api_name: "profileId" - field :nullable_role, -> { - Seed::NullableOptional::Types::UserRole - }, optional: true, nullable: false, api_name: "nullableRole" - field :nullable_status, -> { - Seed::NullableOptional::Types::UserStatus - }, optional: true, nullable: false, api_name: "nullableStatus" - field :nullable_notification, -> { - Seed::NullableOptional::Types::NotificationMethod - }, optional: true, nullable: false, api_name: "nullableNotification" - field :nullable_search_result, -> { - Seed::NullableOptional::Types::SearchResult - }, optional: true, nullable: false, api_name: "nullableSearchResult" - field :nullable_array, -> { - Internal::Types::Array[String] - }, optional: true, nullable: false, api_name: "nullableArray" + field :nullable_role, -> { Seed::NullableOptional::Types::UserRole }, optional: true, nullable: false, api_name: "nullableRole" + field :nullable_status, -> { Seed::NullableOptional::Types::UserStatus }, optional: true, nullable: false, api_name: "nullableStatus" + field :nullable_notification, -> { Seed::NullableOptional::Types::NotificationMethod }, optional: true, nullable: false, api_name: "nullableNotification" + field :nullable_search_result, -> { Seed::NullableOptional::Types::SearchResult }, optional: true, nullable: false, api_name: "nullableSearchResult" + field :nullable_array, -> { Internal::Types::Array[String] }, optional: true, nullable: false, api_name: "nullableArray" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/user_profile.rb b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/user_profile.rb index 60d2e5038dd8..7d8449c923be 100644 --- a/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/user_profile.rb +++ b/seed/ruby-sdk-v2/nullable-optional/lib/seed/nullable_optional/types/user_profile.rb @@ -9,40 +9,20 @@ class UserProfile < Internal::Types::Model field :username, -> { String }, optional: false, nullable: false field :nullable_string, -> { String }, optional: false, nullable: true, api_name: "nullableString" field :nullable_integer, -> { Integer }, optional: false, nullable: true, api_name: "nullableInteger" - field :nullable_boolean, -> { - Internal::Types::Boolean - }, optional: false, nullable: true, api_name: "nullableBoolean" + field :nullable_boolean, -> { Internal::Types::Boolean }, optional: false, nullable: true, api_name: "nullableBoolean" field :nullable_date, -> { String }, optional: false, nullable: true, api_name: "nullableDate" - field :nullable_object, -> { - Seed::NullableOptional::Types::Address - }, optional: false, nullable: true, api_name: "nullableObject" - field :nullable_list, -> { - Internal::Types::Array[String] - }, optional: false, nullable: true, api_name: "nullableList" - field :nullable_map, -> { - Internal::Types::Hash[String, String] - }, optional: false, nullable: true, api_name: "nullableMap" + field :nullable_object, -> { Seed::NullableOptional::Types::Address }, optional: false, nullable: true, api_name: "nullableObject" + field :nullable_list, -> { Internal::Types::Array[String] }, optional: false, nullable: true, api_name: "nullableList" + field :nullable_map, -> { Internal::Types::Hash[String, String] }, optional: false, nullable: true, api_name: "nullableMap" field :optional_string, -> { String }, optional: true, nullable: false, api_name: "optionalString" field :optional_integer, -> { Integer }, optional: true, nullable: false, api_name: "optionalInteger" - field :optional_boolean, -> { - Internal::Types::Boolean - }, optional: true, nullable: false, api_name: "optionalBoolean" + field :optional_boolean, -> { Internal::Types::Boolean }, optional: true, nullable: false, api_name: "optionalBoolean" field :optional_date, -> { String }, optional: true, nullable: false, api_name: "optionalDate" - field :optional_object, -> { - Seed::NullableOptional::Types::Address - }, optional: true, nullable: false, api_name: "optionalObject" - field :optional_list, -> { - Internal::Types::Array[String] - }, optional: true, nullable: false, api_name: "optionalList" - field :optional_map, -> { - Internal::Types::Hash[String, String] - }, optional: true, nullable: false, api_name: "optionalMap" - field :optional_nullable_string, -> { - String - }, optional: true, nullable: false, api_name: "optionalNullableString" - field :optional_nullable_object, -> { - Seed::NullableOptional::Types::Address - }, optional: true, nullable: false, api_name: "optionalNullableObject" + field :optional_object, -> { Seed::NullableOptional::Types::Address }, optional: true, nullable: false, api_name: "optionalObject" + field :optional_list, -> { Internal::Types::Array[String] }, optional: true, nullable: false, api_name: "optionalList" + field :optional_map, -> { Internal::Types::Hash[String, String] }, optional: true, nullable: false, api_name: "optionalMap" + field :optional_nullable_string, -> { String }, optional: true, nullable: false, api_name: "optionalNullableString" + field :optional_nullable_object, -> { Seed::NullableOptional::Types::Address }, optional: true, nullable: false, api_name: "optionalNullableObject" end end end diff --git a/seed/ruby-sdk-v2/nullable-optional/reference.md b/seed/ruby-sdk-v2/nullable-optional/reference.md index e2fc0f66be61..0e19e767692d 100644 --- a/seed/ruby-sdk-v2/nullable-optional/reference.md +++ b/seed/ruby-sdk-v2/nullable-optional/reference.md @@ -392,6 +392,12 @@ Create a complex profile to test nullable enums and unions ```ruby client.nullable_optional.create_complex_profile( id: 'id', + nullable_role: 'ADMIN', + optional_role: 'ADMIN', + optional_nullable_role: 'ADMIN', + nullable_status: 'active', + optional_status: 'active', + optional_nullable_status: 'active', nullable_array: ['nullableArray', 'nullableArray'], optional_array: ['optionalArray', 'optionalArray'], optional_nullable_array: ['optionalNullableArray', 'optionalNullableArray'], @@ -408,7 +414,9 @@ client.nullable_optional.create_complex_profile( } }, nullable_list_of_unions: [], - optional_map_of_enums: {} + optional_map_of_enums: { + optionalMapOfEnums: 'ADMIN' + } ); ``` @@ -519,6 +527,8 @@ Update complex profile to test nullable field updates ```ruby client.nullable_optional.update_complex_profile( profile_id: 'profileId', + nullable_role: 'ADMIN', + nullable_status: 'active', nullable_array: ['nullableArray', 'nullableArray'] ); ``` @@ -619,6 +629,8 @@ client.nullable_optional.test_deserialization( nullable_string: 'nullableString', optional_string: 'optionalString', optional_nullable_string: 'optionalNullableString', + nullable_enum: 'ADMIN', + optional_enum: 'active', nullable_list: ['nullableList', 'nullableList'], nullable_map: { nullableMap: 1 @@ -692,7 +704,11 @@ Filter users by role with nullable enum
```ruby -client.nullable_optional.filter_by_role(); +client.nullable_optional.filter_by_role( + role: 'ADMIN', + status: 'active', + secondary_role: 'ADMIN' +); ```
diff --git a/seed/ruby-sdk-v2/nullable-optional/seed.gemspec b/seed/ruby-sdk-v2/nullable-optional/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/nullable-optional/seed.gemspec +++ b/seed/ruby-sdk-v2/nullable-optional/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable-optional/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/nullable-request-body/.rubocop.yml b/seed/ruby-sdk-v2/nullable-request-body/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/.rubocop.yml +++ b/seed/ruby-sdk-v2/nullable-request-body/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/nullable-request-body/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/nullable-request-body/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/nullable-request-body/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/nullable-request-body/lib/seed/test_group/client.rb b/seed/ruby-sdk-v2/nullable-request-body/lib/seed/test_group/client.rb index 63aaab6d4055..d57ac65dce35 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/lib/seed/test_group/client.rb +++ b/seed/ruby-sdk-v2/nullable-request-body/lib/seed/test_group/client.rb @@ -23,8 +23,11 @@ def initialize(client:) # @option params [Seed::Types::PlainObject, nil] :query_param_object # @option params [Integer, nil] :query_param_integer # - # @return [Hash[String, Object]] + # @return [Object] def test_method_name(request_options: {}, **params) + path_param_names = %i[path_param] + body_params = params.except(*path_param_names) + params = Seed::Internal::Types::Utils.symbolize_keys(params) query_param_names = %i[query_param_object query_param_integer] query_params = {} @@ -37,7 +40,8 @@ def test_method_name(request_options: {}, **params) method: "POST", path: "optional-request-body/#{params[:path_param]}", query: query_params, - body: body_params + body: body_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/nullable-request-body/seed.gemspec b/seed/ruby-sdk-v2/nullable-request-body/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/seed.gemspec +++ b/seed/ruby-sdk-v2/nullable-request-body/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable-request-body/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/nullable/.rubocop.yml b/seed/ruby-sdk-v2/nullable/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/nullable/.rubocop.yml +++ b/seed/ruby-sdk-v2/nullable/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/nullable/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/nullable/dynamic-snippets/example1/snippet.rb index 5f99231fe287..fee670aadb1b 100644 --- a/seed/ruby-sdk-v2/nullable/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/nullable/dynamic-snippets/example1/snippet.rb @@ -10,6 +10,7 @@ updated_at: '2024-01-15T09:30:00Z', avatar: 'avatar', activated: true, + status: {}, values: { values: 'values' } diff --git a/seed/ruby-sdk-v2/nullable/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/nullable/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/nullable/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/nullable/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/nullable/lib/seed/nullable/client.rb b/seed/ruby-sdk-v2/nullable/lib/seed/nullable/client.rb index fc5c40eb79c2..d19d234fbf95 100644 --- a/seed/ruby-sdk-v2/nullable/lib/seed/nullable/client.rb +++ b/seed/ruby-sdk-v2/nullable/lib/seed/nullable/client.rb @@ -39,7 +39,8 @@ def get_users(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -70,7 +71,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/users", - body: Seed::Nullable::Types::CreateUserRequest.new(body_bag).to_h + body: Seed::Nullable::Types::CreateUserRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -103,7 +105,8 @@ def delete_user(request_options: {}, **params) base_url: request_options[:base_url], method: "DELETE", path: "/users", - body: Seed::Nullable::Types::DeleteUserRequest.new(body_bag).to_h + body: Seed::Nullable::Types::DeleteUserRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/nullable/lib/seed/nullable/types/user.rb b/seed/ruby-sdk-v2/nullable/lib/seed/nullable/types/user.rb index b20aac5b4c4c..4f11af5b39a4 100644 --- a/seed/ruby-sdk-v2/nullable/lib/seed/nullable/types/user.rb +++ b/seed/ruby-sdk-v2/nullable/lib/seed/nullable/types/user.rb @@ -9,13 +9,9 @@ class User < Internal::Types::Model field :tags, -> { Internal::Types::Array[String] }, optional: false, nullable: true field :metadata, -> { Seed::Nullable::Types::Metadata }, optional: true, nullable: false field :email, -> { String }, optional: false, nullable: false - field :favorite_number, -> { - Seed::Nullable::Types::WeirdNumber - }, optional: false, nullable: false, api_name: "favorite-number" + field :favorite_number, -> { Seed::Nullable::Types::WeirdNumber }, optional: false, nullable: false, api_name: "favorite-number" field :numbers, -> { Internal::Types::Array[Integer] }, optional: true, nullable: false - field :strings, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: true, nullable: false + field :strings, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/nullable/reference.md b/seed/ruby-sdk-v2/nullable/reference.md index e09bf3f52f65..43f5b4568649 100644 --- a/seed/ruby-sdk-v2/nullable/reference.md +++ b/seed/ruby-sdk-v2/nullable/reference.md @@ -96,6 +96,7 @@ client.nullable.create_user( updated_at: '2024-01-15T09:30:00Z', avatar: 'avatar', activated: true, + status: {}, values: { values: 'values' } diff --git a/seed/ruby-sdk-v2/nullable/seed.gemspec b/seed/ruby-sdk-v2/nullable/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/nullable/seed.gemspec +++ b/seed/ruby-sdk-v2/nullable/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/nullable/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials-custom/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/auth/client.rb index 667ef651a4e8..b8701b2d1f44 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -60,7 +61,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials-custom/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-custom/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials-default/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/auth/client.rb index b9cab8e4a515..31db469302cd 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials-default/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-default/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/auth/client.rb index e3d92c27c6a4..46f1d2ad4264 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -60,7 +61,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-environment-variables/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/auth/client.rb index 015a464dff62..c3759ca72769 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-nested-root/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/auth/client.rb index e3d92c27c6a4..46f1d2ad4264 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -60,7 +61,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials-with-variables/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/.rubocop.yml b/seed/ruby-sdk-v2/oauth-client-credentials/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/.rubocop.yml +++ b/seed/ruby-sdk-v2/oauth-client-credentials/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/auth/client.rb index e3d92c27c6a4..46f1d2ad4264 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/auth/client.rb @@ -27,7 +27,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -60,7 +61,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/seed.gemspec b/seed/ruby-sdk-v2/oauth-client-credentials/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/seed.gemspec +++ b/seed/ruby-sdk-v2/oauth-client-credentials/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/oauth-client-credentials/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/object/.rubocop.yml b/seed/ruby-sdk-v2/object/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/object/.rubocop.yml +++ b/seed/ruby-sdk-v2/object/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/object/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/object/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/object/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/object/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/object/lib/seed/types/type.rb b/seed/ruby-sdk-v2/object/lib/seed/types/type.rb index bc1f1dd3de51..8181e26405df 100644 --- a/seed/ruby-sdk-v2/object/lib/seed/types/type.rb +++ b/seed/ruby-sdk-v2/object/lib/seed/types/type.rb @@ -19,9 +19,7 @@ class Type < Internal::Types::Model field :thirteen, -> { Integer }, optional: true, nullable: false field :fourteen, -> { Object }, optional: false, nullable: false field :fifteen, -> { Internal::Types::Array[Internal::Types::Array[Integer]] }, optional: false, nullable: false - field :sixteen, -> { - Internal::Types::Array[Internal::Types::Hash[String, Integer]] - }, optional: false, nullable: false + field :sixteen, -> { Internal::Types::Array[Internal::Types::Hash[String, Integer]] }, optional: false, nullable: false field :seventeen, -> { Internal::Types::Array[String] }, optional: false, nullable: false field :eighteen, -> { String }, optional: false, nullable: false field :nineteen, -> { Seed::Types::Name }, optional: false, nullable: false diff --git a/seed/ruby-sdk-v2/object/seed.gemspec b/seed/ruby-sdk-v2/object/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/object/seed.gemspec +++ b/seed/ruby-sdk-v2/object/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/object/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/objects-with-imports/.rubocop.yml b/seed/ruby-sdk-v2/objects-with-imports/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/.rubocop.yml +++ b/seed/ruby-sdk-v2/objects-with-imports/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/objects-with-imports/lib/seed/file/directory/types/directory.rb b/seed/ruby-sdk-v2/objects-with-imports/lib/seed/file/directory/types/directory.rb index df36c7cc7dea..b3bd74e008fa 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/lib/seed/file/directory/types/directory.rb +++ b/seed/ruby-sdk-v2/objects-with-imports/lib/seed/file/directory/types/directory.rb @@ -7,9 +7,7 @@ module Types class Directory < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false field :files, -> { Internal::Types::Array[Seed::File::Types::File] }, optional: true, nullable: false - field :directories, -> { - Internal::Types::Array[Seed::File::Directory::Types::Directory] - }, optional: true, nullable: false + field :directories, -> { Internal::Types::Array[Seed::File::Directory::Types::Directory] }, optional: true, nullable: false end end end diff --git a/seed/ruby-sdk-v2/objects-with-imports/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/objects-with-imports/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/objects-with-imports/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/objects-with-imports/seed.gemspec b/seed/ruby-sdk-v2/objects-with-imports/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/seed.gemspec +++ b/seed/ruby-sdk-v2/objects-with-imports/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/objects-with-imports/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/optional/.rubocop.yml b/seed/ruby-sdk-v2/optional/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/optional/.rubocop.yml +++ b/seed/ruby-sdk-v2/optional/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/optional/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/optional/dynamic-snippets/example0/snippet.rb index dc5656a541f7..953df55fe5e1 100644 --- a/seed/ruby-sdk-v2/optional/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/optional/dynamic-snippets/example0/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.optional.send_optional_body(); +client.optional.send_optional_body(request: {}); diff --git a/seed/ruby-sdk-v2/optional/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/optional/dynamic-snippets/example1/snippet.rb index 41b58f7ea6dc..051fb87c5ae9 100644 --- a/seed/ruby-sdk-v2/optional/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/optional/dynamic-snippets/example1/snippet.rb @@ -2,4 +2,6 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.optional.send_optional_typed_body(); +client.optional.send_optional_typed_body(request: { + message: 'message' +}); diff --git a/seed/ruby-sdk-v2/optional/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/optional/dynamic-snippets/example2/snippet.rb index e9822ae7d0f3..0a238668eb5f 100644 --- a/seed/ruby-sdk-v2/optional/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/optional/dynamic-snippets/example2/snippet.rb @@ -4,5 +4,8 @@ client.optional.send_optional_nullable_with_all_optional_properties( action_id: 'actionId', - id: 'id' + id: 'id', + request: { + update_draft: true + } ); diff --git a/seed/ruby-sdk-v2/optional/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/optional/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/optional/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/optional/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/optional/reference.md b/seed/ruby-sdk-v2/optional/reference.md index a67e81e60789..16650da3cb62 100644 --- a/seed/ruby-sdk-v2/optional/reference.md +++ b/seed/ruby-sdk-v2/optional/reference.md @@ -13,7 +13,7 @@
```ruby -client.optional.send_optional_body(); +client.optional.send_optional_body(request: {}); ```
@@ -53,7 +53,9 @@ client.optional.send_optional_body();
```ruby -client.optional.send_optional_typed_body(); +client.optional.send_optional_typed_body(request: { + message: 'message' +}); ```
@@ -110,7 +112,10 @@ This should not generate wire tests expecting {} when Optional.empty() is passed ```ruby client.optional.send_optional_nullable_with_all_optional_properties( action_id: 'actionId', - id: 'id' + id: 'id', + request: { + update_draft: true + } ); ``` diff --git a/seed/ruby-sdk-v2/optional/seed.gemspec b/seed/ruby-sdk-v2/optional/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/optional/seed.gemspec +++ b/seed/ruby-sdk-v2/optional/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/optional/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/package-yml/.rubocop.yml b/seed/ruby-sdk-v2/package-yml/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/package-yml/.rubocop.yml +++ b/seed/ruby-sdk-v2/package-yml/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/package-yml/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/package-yml/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/package-yml/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/package-yml/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/package-yml/seed.gemspec b/seed/ruby-sdk-v2/package-yml/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/package-yml/seed.gemspec +++ b/seed/ruby-sdk-v2/package-yml/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/package-yml/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/pagination-custom/.fern/metadata.json b/seed/ruby-sdk-v2/pagination-custom/.fern/metadata.json new file mode 100644 index 000000000000..95ec381c758d --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/.fern/metadata.json @@ -0,0 +1,8 @@ +{ + "cliVersion": "DUMMY", + "generatorName": "fernapi/fern-ruby-sdk-v2", + "generatorVersion": "latest", + "generatorConfig": { + "customPagerName": "FooPager" + } +} \ No newline at end of file diff --git a/seed/ruby-sdk-v2/pagination-custom/.rubocop.yml b/seed/ruby-sdk-v2/pagination-custom/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/pagination-custom/.rubocop.yml +++ b/seed/ruby-sdk-v2/pagination-custom/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/pagination-custom/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/pagination-custom/dynamic-snippets/example0/snippet.rb new file mode 100644 index 000000000000..371e2a63bb65 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/dynamic-snippets/example0/snippet.rb @@ -0,0 +1,8 @@ +require "seed" + +client = Seed::Client.new( + token: '', + base_url: 'https://api.fern.com' +); + +client.users.list_usernames_custom(starting_after: 'starting_after'); diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed.rb new file mode 100644 index 000000000000..2e8f4db77ef1 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require "json" +require "net/http" +require "securerandom" + +require_relative "seed/internal/json/serializable" +require_relative "seed/internal/types/type" +require_relative "seed/internal/types/utils" +require_relative "seed/internal/types/union" +require_relative "seed/internal/errors/constraint_error" +require_relative "seed/internal/errors/type_error" +require_relative "seed/internal/http/base_request" +require_relative "seed/internal/json/request" +require_relative "seed/internal/http/raw_client" +require_relative "seed/internal/multipart/multipart_encoder" +require_relative "seed/internal/multipart/multipart_form_data_part" +require_relative "seed/internal/multipart/multipart_form_data" +require_relative "seed/internal/multipart/multipart_request" +require_relative "seed/internal/types/model/field" +require_relative "seed/internal/types/model" +require_relative "seed/internal/types/array" +require_relative "seed/internal/types/boolean" +require_relative "seed/internal/types/enum" +require_relative "seed/internal/types/hash" +require_relative "seed/internal/types/unknown" +require_relative "seed/errors/api_error" +require_relative "seed/errors/response_error" +require_relative "seed/errors/client_error" +require_relative "seed/errors/redirect_error" +require_relative "seed/errors/server_error" +require_relative "seed/errors/timeout_error" +require_relative "seed/internal/iterators/item_iterator" +require_relative "seed/internal/iterators/cursor_item_iterator" +require_relative "seed/internal/iterators/offset_item_iterator" +require_relative "seed/internal/iterators/cursor_page_iterator" +require_relative "seed/internal/iterators/offset_page_iterator" +require_relative "seed/internal/iterators/custom_pager" +require_relative "seed/types/username_page" +require_relative "seed/types/username_cursor" +require_relative "seed/client" +require_relative "seed/users/client" +require_relative "seed/users/types/list_usernames_request_custom" diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/client.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/client.rb new file mode 100644 index 000000000000..3485cebc6ab4 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/client.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Seed + class Client + # @param base_url [String, nil] + # @param token [String] + # + # @return [void] + def initialize(base_url:, token:) + @raw_client = Seed::Internal::Http::RawClient.new( + base_url: base_url, + headers: { + "User-Agent" => "fern_pagination-custom/0.0.1", + "X-Fern-Language" => "Ruby", + Authorization: "Bearer #{token}" + } + ) + end + + # @return [Seed::Users::Client] + def users + @users ||= Seed::Users::Client.new(client: @raw_client) + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/api_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/api_error.rb new file mode 100644 index 000000000000..b8ba53889b36 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/api_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ApiError < StandardError + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/client_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/client_error.rb new file mode 100644 index 000000000000..c3c6033641e2 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/client_error.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ClientError < ResponseError + end + + class UnauthorizedError < ClientError + end + + class ForbiddenError < ClientError + end + + class NotFoundError < ClientError + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/redirect_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/redirect_error.rb new file mode 100644 index 000000000000..f663c01e7615 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/redirect_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class RedirectError < ResponseError + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/response_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/response_error.rb new file mode 100644 index 000000000000..beb4a1baf959 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/response_error.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ResponseError < ApiError + attr_reader :code + + def initialize(msg, code:) + @code = code + super(msg) + end + + def inspect + "#<#{self.class.name} @code=#{code} @body=#{message}>" + end + + # Returns the most appropriate error class for the given code. + # + # @return [Class] + def self.subclass_for_code(code) + case code + when 300..399 + RedirectError + when 401 + UnauthorizedError + when 403 + ForbiddenError + when 404 + NotFoundError + when 400..499 + ClientError + when 503 + ServiceUnavailableError + when 500..599 + ServerError + else + ResponseError + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/server_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/server_error.rb new file mode 100644 index 000000000000..1838027cdeab --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/server_error.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Seed + module Errors + class ServerError < ResponseError + end + + class ServiceUnavailableError < ApiError + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/timeout_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/timeout_error.rb new file mode 100644 index 000000000000..ec3a24bb7e96 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/errors/timeout_error.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Seed + module Errors + class TimeoutError < ApiError + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/constraint_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/constraint_error.rb new file mode 100644 index 000000000000..e2f0bd66ac37 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/constraint_error.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Errors + class ConstraintError < StandardError + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/type_error.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/type_error.rb new file mode 100644 index 000000000000..6aec80f59f05 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/errors/type_error.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Errors + class TypeError < StandardError + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/base_request.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/base_request.rb new file mode 100644 index 000000000000..5f65f1327023 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/base_request.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Http + # @api private + class BaseRequest + attr_reader :base_url, :path, :method, :headers, :query, :request_options + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [String] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, request_options: {}) + @base_url = base_url + @path = path + @method = method + @headers = headers + @query = query + @request_options = request_options + end + + # Child classes should implement: + # - encode_headers: Returns the encoded HTTP request headers. + # - encode_body: Returns the encoded HTTP request body. + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/raw_client.rb new file mode 100644 index 000000000000..3370a92b608b --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/http/raw_client.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Http + # @api private + class RawClient + # @param base_url [String] The base url for the request. + # @param max_retries [Integer] The number of times to retry a failed request, defaults to 2. + # @param timeout [Float] The timeout for the request, defaults to 60.0 seconds. + # @param headers [Hash] The headers for the request. + def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {}) + @base_url = base_url + @max_retries = max_retries + @timeout = timeout + @default_headers = { + "X-Fern-Language": "Ruby", + "X-Fern-SDK-Name": "seed", + "X-Fern-SDK-Version": "0.0.1" + }.merge(headers) + end + + # @param request [Seed::Internal::Http::BaseRequest] The HTTP request. + # @return [HTTP::Response] The HTTP response. + def send(request) + url = build_url(request) + + http_request = build_http_request( + url:, + method: request.method, + headers: request.encode_headers, + body: request.encode_body + ) + + conn = connect(url) + conn.open_timeout = @timeout + conn.read_timeout = @timeout + conn.write_timeout = @timeout + conn.continue_timeout = @timeout + + conn.request(http_request) + end + + # @param request [Seed::Internal::Http::BaseRequest] The HTTP request. + # @return [URI::Generic] The URL. + def build_url(request) + path = request.path.start_with?("/") ? request.path[1..] : request.path + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" + url = "#{url}?#{encode_query(request.query)}" if request.query&.any? + URI.parse(url) + end + + # @param url [URI::Generic] The url to the resource. + # @param method [String] The HTTP method to use. + # @param headers [Hash] The headers for the request. + # @param body [String, nil] The body for the request. + # @return [HTTP::Request] The HTTP request. + def build_http_request(url:, method:, headers: {}, body: nil) + request = Net::HTTPGenericRequest.new( + method, + !body.nil?, + method != "HEAD", + url + ) + + request_headers = @default_headers.merge(headers) + request_headers.each { |name, value| request[name] = value } + request.body = body if body + + request + end + + # @param query [Hash] The query for the request. + # @return [String, nil] The encoded query. + def encode_query(query) + query.to_h.empty? ? nil : URI.encode_www_form(query) + end + + # @param url [URI::Generic] The url to connect to. + # @return [Net::HTTP] The HTTP connection. + def connect(url) + is_https = (url.scheme == "https") + + port = if url.port + url.port + elsif is_https + Net::HTTP.https_default_port + else + Net::HTTP.http_default_port + end + + http = Net::HTTP.new(url.host, port) + http.use_ssl = is_https + http.max_retries = @max_retries + http + end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_item_iterator.rb new file mode 100644 index 000000000000..ab627ffc7025 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Seed + module Internal + class CursorItemIterator < ItemIterator + # Instantiates a CursorItemIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields individual items from it. + # + # @param initial_cursor [String] The initial cursor to use when iterating, if any. + # @param cursor_field [Symbol] The field in API responses to extract the next cursor from. + # @param item_field [Symbol] The field in API responses to extract the items to iterate over. + # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. + # @return [Seed::Internal::CursorItemIterator] + def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() + @item_field = item_field + @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) + @page = nil + end + + # Returns the CursorPageIterator mediating access to the underlying API. + # + # @return [Seed::Internal::CursorPageIterator] + def pages + @page_iterator + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_page_iterator.rb new file mode 100644 index 000000000000..f479a749fef9 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Seed + module Internal + class CursorPageIterator + include Enumerable + + # Instantiates a CursorPageIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields pages of items. + # + # @param initial_cursor [String] The initial cursor to use when iterating, if any. + # @param cursor_field [Symbol] The name of the field in API responses to extract the next cursor from. + # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. + # @return [Seed::Internal::CursorPageIterator] + def initialize(initial_cursor:, cursor_field:, &block) + @need_initial_load = initial_cursor.nil? + @cursor = initial_cursor + @cursor_field = cursor_field + @get_next_page = block + end + + # Iterates over each page returned by the API. + # + # @param block [Proc] The block which each retrieved page is yielded to. + # @return [NilClass] + def each(&block) + while (page = next_page) + block.call(page) + end + end + + # Whether another page will be available from the API. + # + # @return [Boolean] + def next? + @need_initial_load || !@cursor.nil? + end + + # Retrieves the next page from the API. + # + # @return [Boolean] + def next_page + return if !@need_initial_load && @cursor.nil? + + @need_initial_load = false + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/custom_pager.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/custom_pager.rb new file mode 100644 index 000000000000..5bc3de65a920 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/custom_pager.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Seed + module Internal + # FooPager wraps a paginated response and provides navigation methods. + # This is used for custom pagination endpoints where the pagination pattern + # doesn't fit the standard cursor or offset patterns. + # + # The pager provides methods to check for and navigate to next/previous pages, + # but the actual page fetching logic must be implemented by the user through + # the provided fetcher block. + class FooPager + include Enumerable + + # @return [Object] The current page response + attr_reader :current + + # Creates a new custom pager with the given initial response. + # + # @param initial [Object] The initial page response + # @param item_field [Symbol, nil] The field name containing items for iteration + # @param raw_client [Object, nil] The HTTP client for fetching additional pages + # @param has_next_proc [Proc, nil] A proc that returns true if there's a next page + # @param has_prev_proc [Proc, nil] A proc that returns true if there's a previous page + # @param get_next_proc [Proc, nil] A proc that fetches the next page + # @param get_prev_proc [Proc, nil] A proc that fetches the previous page + # @return [Seed::Internal::FooPager] + def initialize(initial, item_field: nil, raw_client: nil, has_next_proc: nil, has_prev_proc: nil, + get_next_proc: nil, get_prev_proc: nil) + @current = initial + @item_field = item_field + @raw_client = raw_client + @has_next_proc = has_next_proc + @has_prev_proc = has_prev_proc + @get_next_proc = get_next_proc + @get_prev_proc = get_prev_proc + end + + # Returns true if there is a next page available. + # + # @return [Boolean] + def next_page? + return false if @has_next_proc.nil? + + @has_next_proc.call(@current) + end + + # Returns true if there is a previous page available. + # + # @return [Boolean] + def prev_page? + return false if @has_prev_proc.nil? + + @has_prev_proc.call(@current) + end + + # Fetches the next page of results. + # + # @return [Object, nil] The next page response, or nil if not available + def next_page + return nil unless next_page? + return nil if @get_next_proc.nil? + + @current = @get_next_proc.call(@current) + @current + end + + # Fetches the previous page of results. + # + # @return [Object, nil] The previous page response, or nil if not available + def prev_page + return nil unless prev_page? + return nil if @get_prev_proc.nil? + + @current = @get_prev_proc.call(@current) + @current + end + + # Iterates over each page of results. + # + # @param block [Proc] The block to yield each page to + # @return [NilClass] + def each_page(&block) + page = @current + loop do + block.call(page) + break unless next_page? + + page = next_page + break if page.nil? + end + end + + # Iterates over each item in all pages. + # Requires item_field to be set. + # + # @param block [Proc] The block to yield each item to + # @return [NilClass] + def each(&block) + return enum_for(:each) unless block_given? + return each_page(&block) if @item_field.nil? + + each_page do |page| + items = page.respond_to?(@item_field) ? page.send(@item_field) : [] + items.each { |item| block.call(item) } + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/item_iterator.rb new file mode 100644 index 000000000000..1284fb0fd367 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/item_iterator.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Seed + module Internal + class ItemIterator + include Enumerable + + # Iterates over each item returned by the API. + # + # @param block [Proc] The block which each retrieved item is yielded to. + # @return [NilClass] + def each(&block) + while (item = next_element) + block.call(item) + end + end + + # Whether another item will be available from the API. + # + # @return [Boolean] + def next? + load_next_page if @page.nil? + return false if @page.nil? + + return true if any_items_in_cached_page? + + load_next_page + any_items_in_cached_page? + end + + # Retrieves the next item from the API. + def next_element + item = next_item_from_cached_page + return item if item + + load_next_page + next_item_from_cached_page + end + + private + + def next_item_from_cached_page + return unless @page + + @page.send(@item_field).shift + end + + def any_items_in_cached_page? + return false unless @page + + !@page.send(@item_field).empty? + end + + def load_next_page + @page = @page_iterator.next_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_item_iterator.rb new file mode 100644 index 000000000000..f8840246686d --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_item_iterator.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Seed + module Internal + class OffsetItemIterator < ItemIterator + # Instantiates an OffsetItemIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields the individual items from it. + # + # @param initial_page [Integer] The initial page or offset to start from when iterating. + # @param item_field [Symbol] The name of the field in API responses to extract the items to iterate over. + # @param has_next_field [Symbol] The name of the field in API responses containing a boolean of whether another page exists. + # @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1) + # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. + # + # @return [Seed::Internal::OffsetItemIterator] + def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() + @item_field = item_field + @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) + @page = nil + end + + # Returns the OffsetPageIterator that is mediating access to the underlying API. + # + # @return [Seed::Internal::OffsetPageIterator] + def pages + @page_iterator + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_page_iterator.rb new file mode 100644 index 000000000000..051b65c5774c --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/iterators/offset_page_iterator.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Seed + module Internal + class OffsetPageIterator + include Enumerable + + # Instantiates an OffsetPageIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields pages of items from it. + # + # @param initial_page [Integer] The initial page to use when iterating, if any. + # @param item_field [Symbol] The field to pull the list of items to iterate over. + # @param has_next_field [Symbol] The field to pull the boolean of whether a next page exists from, if any. + # @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1) + # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. + # @return [Seed::Internal::OffsetPageIterator] + def initialize(initial_page:, item_field:, has_next_field:, step:, &block) + @page_number = initial_page || (step ? 0 : 1) + @item_field = item_field + @has_next_field = has_next_field + @step = step + @get_next_page = block + + # A cache of whether the API has another page, if it gives us that information... + @next_page = nil + # ...or the actual next page, preloaded, if it doesn't. + @has_next_page = nil + end + + # Iterates over each page returned by the API. + # + # @param block [Proc] The block which each retrieved page is yielded to. + # @return [NilClass] + def each(&block) + while (page = next_page) + block.call(page) + end + end + + # Whether another page will be available from the API. + # + # @return [Boolean] + def next? + return @has_next_page unless @has_next_page.nil? + return true if @next_page + + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? + @has_next_page = false + else + @next_page = fetched_page + true + end + end + + # Returns the next page from the API. + def next_page + return nil if @page_number.nil? + + if @next_page + this_page = @next_page + @next_page = nil + else + this_page = @get_next_page.call(@page_number) + end + + @has_next_page = this_page&.send(@has_next_field) if @has_next_field + + items = this_page.send(@item_field) + if items.nil? || items.empty? + @page_number = nil + return nil + elsif @step + @page_number += items.length + else + @page_number += 1 + end + + this_page + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/request.rb new file mode 100644 index 000000000000..15773d44c641 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/request.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Seed + module Internal + module JSON + # @api private + class Request < Seed::Internal::Http::BaseRequest + attr_reader :body + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [Symbol] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param body [Object, nil] The JSON request body (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {}) + super(base_url:, path:, method:, headers:, query:, request_options:) + + @body = body + end + + # @return [Hash] The encoded HTTP request headers. + def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} + { + "Content-Type" => "application/json", + "Accept" => "application/json" + }.merge(@headers).merge(additional_headers) + end + + # @return [String, nil] The encoded HTTP request body. + def encode_body + @body.nil? ? nil : ::JSON.generate(@body) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/serializable.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/serializable.rb new file mode 100644 index 000000000000..f80a15fb962c --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/json/serializable.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Seed + module Internal + module JSON + module Serializable + # Loads data from JSON into its deserialized form + # + # @param str [String] Raw JSON to load into an object + # @return [Object] + def load(str) + raise NotImplementedError + end + + # Dumps data from its deserialized form into JSON + # + # @param value [Object] The deserialized value + # @return [String] + def dump(value) + raise NotImplementedError + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_encoder.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_encoder.rb new file mode 100644 index 000000000000..307ad7436a57 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_encoder.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # Encodes parameters into a `multipart/form-data` payload as described by RFC + # 2388: + # + # https://tools.ietf.org/html/rfc2388 + # + # This is most useful for transferring file-like objects. + # + # Parameters should be added with `#encode`. When ready, use `#body` to get + # the encoded result and `#content_type` to get the value that should be + # placed in the `Content-Type` header of a subsequent request (which includes + # a boundary value). + # + # This abstraction is heavily inspired by Stripe's multipart/form-data implementation, + # which can be found here: + # + # https://github.com/stripe/stripe-ruby/blob/ca00b676f04ac421cf5cb5ff0325f243651677b6/lib/stripe/multipart_encoder.rb#L18 + # + # @api private + class Encoder + CONTENT_TYPE = "multipart/form-data" + CRLF = "\r\n" + + attr_reader :boundary, :body + + def initialize + # Chose the same number of random bytes that Go uses in its standard + # library implementation. Easily enough entropy to ensure that it won't + # be present in a file we're sending. + @boundary = SecureRandom.hex(30) + + @body = String.new + @closed = false + @first_field = true + end + + # Gets the content type string including the boundary. + # + # @return [String] The content type with boundary + def content_type + "#{CONTENT_TYPE}; boundary=#{@boundary}" + end + + # Encode the given FormData object into a multipart/form-data payload. + # + # @param form_data [FormData] The form data to encode + # @return [String] The encoded body. + def encode(form_data) + return "" if form_data.parts.empty? + + form_data.parts.each do |part| + write_part(part) + end + close + + @body + end + + # Writes a FormDataPart to the encoder. + # + # @param part [FormDataPart] The part to write + # @return [nil] + def write_part(part) + raise "Cannot write to closed encoder" if @closed + + write_field( + name: part.name, + data: part.contents, + filename: part.filename, + headers: part.headers + ) + + nil + end + + # Writes a field to the encoder. + # + # @param name [String] The field name + # @param data [String] The field data + # @param filename [String, nil] Optional filename + # @param headers [Hash, nil] Optional additional headers + # @return [nil] + def write_field(name:, data:, filename: nil, headers: nil) + raise "Cannot write to closed encoder" if @closed + + if @first_field + @first_field = false + else + @body << CRLF + end + + @body << "--#{@boundary}#{CRLF}" + @body << %(Content-Disposition: form-data; name="#{escape(name.to_s)}") + @body << %(; filename="#{escape(filename)}") if filename + @body << CRLF + + if headers + headers.each do |key, value| + @body << "#{key}: #{value}#{CRLF}" + end + elsif filename + # Default content type for files. + @body << "Content-Type: application/octet-stream#{CRLF}" + end + + @body << CRLF + @body << data.to_s + + nil + end + + # Finalizes the encoder by writing the final boundary. + # + # @return [nil] + def close + raise "Encoder already closed" if @closed + + @body << CRLF + @body << "--#{@boundary}--" + @closed = true + + nil + end + + private + + # Escapes quotes for use in header values and replaces line breaks with spaces. + # + # @param str [String] The string to escape + # @return [String] The escaped string + def escape(str) + str.to_s.gsub('"', "%22").tr("\n", " ").tr("\r", " ") + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data.rb new file mode 100644 index 000000000000..5be1bb25341f --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # @api private + class FormData + # @return [Array] The parts in this multipart form data. + attr_reader :parts + + # @return [Encoder] The encoder for this multipart form data. + private attr_reader :encoder + + def initialize + @encoder = Encoder.new + @parts = [] + end + + # Adds a new part to the multipart form data. + # + # @param name [String] The name of the form field + # @param value [String, Integer, Float, Boolean, #read] The value of the field + # @param content_type [String, nil] Optional content type + # @return [self] Returns self for chaining + def add(name:, value:, content_type: nil) + headers = content_type ? { "Content-Type" => content_type } : nil + add_part(FormDataPart.new(name:, value:, headers:)) + end + + # Adds a file to the multipart form data. + # + # @param name [String] The name of the form field + # @param file [#read] The file or readable object + # @param filename [String, nil] Optional filename (defaults to basename of path for File objects) + # @param content_type [String, nil] Optional content type (e.g. "image/png") + # @return [self] Returns self for chaining + def add_file(name:, file:, filename: nil, content_type: nil) + headers = content_type ? { "Content-Type" => content_type } : nil + filename ||= filename_for(file) + add_part(FormDataPart.new(name:, value: file, filename:, headers:)) + end + + # Adds a pre-created part to the multipart form data. + # + # @param part [FormDataPart] The part to add + # @return [self] Returns self for chaining + def add_part(part) + @parts << part + self + end + + # Gets the content type string including the boundary. + # + # @return [String] The content type with boundary. + def content_type + @encoder.content_type + end + + # Encode the multipart form data into a multipart/form-data payload. + # + # @return [String] The encoded body. + def encode + @encoder.encode(self) + end + + private + + def filename_for(file) + if file.is_a?(::File) || file.respond_to?(:path) + ::File.basename(file.path) + elsif file.respond_to?(:name) + file.name + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data_part.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data_part.rb new file mode 100644 index 000000000000..de45416ee087 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_form_data_part.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require "securerandom" + +module Seed + module Internal + module Multipart + # @api private + class FormDataPart + attr_reader :name, :contents, :filename, :headers + + # @param name [String] The name of the form field + # @param value [String, Integer, Float, Boolean, File, #read] The value of the field + # @param filename [String, nil] Optional filename for file uploads + # @param headers [Hash, nil] Optional additional headers + def initialize(name:, value:, filename: nil, headers: nil) + @name = name + @contents = convert_to_content(value) + @filename = filename + @headers = headers + end + + # Converts the part to a hash suitable for serialization. + # + # @return [Hash] A hash representation of the part + def to_hash + result = { + name: @name, + contents: @contents + } + result[:filename] = @filename if @filename + result[:headers] = @headers if @headers + result + end + + private + + # Converts various types of values to a content representation + # @param value [String, Integer, Float, Boolean, #read] The value to convert + # @return [String] The string representation of the value + def convert_to_content(value) + if value.respond_to?(:read) + value.read + else + value.to_s + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_request.rb new file mode 100644 index 000000000000..915dada8c56e --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/multipart/multipart_request.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Multipart + # @api private + class Request < Seed::Internal::Http::BaseRequest + attr_reader :body + + # @param base_url [String] The base URL for the request + # @param path [String] The path for the request + # @param method [Symbol] The HTTP method for the request (:get, :post, etc.) + # @param headers [Hash] Additional headers for the request (optional) + # @param query [Hash] Query parameters for the request (optional) + # @param body [MultipartFormData, nil] The multipart form data for the request (optional) + # @param request_options [Seed::RequestOptions, Hash{Symbol=>Object}, nil] + def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {}) + super(base_url:, path:, method:, headers:, query:, request_options:) + + @body = body + end + + # @return [Hash] The encoded HTTP request headers. + def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} + { + "Content-Type" => @body.content_type + }.merge(@headers).merge(additional_headers) + end + + # @return [String, nil] The encoded HTTP request body. + def encode_body + @body&.encode + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/array.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/array.rb new file mode 100644 index 000000000000..f3c7c1bd9549 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/array.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # An array of a specific type + class Array + include Seed::Internal::Types::Type + + attr_reader :type + + class << self + # Instantiates a new `Array` of a given type + # + # @param type [Object] The member type of this array + # + # @return [Seed::Internal::Types::Array] + def [](type) + new(type) + end + end + + # @api private + def initialize(type) + @type = type + end + + # Coerces a value into this array + # + # @param value [Object] + # @option strict [Boolean] + # @return [::Array] + def coerce(value, strict: strict?) + unless value.is_a?(::Array) + raise Errors::TypeError, "cannot coerce `#{value.class}` to Array<#{type}>" if strict + + return value + end + + value.map do |element| + Utils.coerce(type, element, strict: strict) + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/boolean.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/boolean.rb new file mode 100644 index 000000000000..de0503d9e56b --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/boolean.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + module Boolean + extend Seed::Internal::Types::Union + + member TrueClass + member FalseClass + + # Overrides the base coercion method for enums to allow integer and string values to become booleans + # + # @param value [Object] + # @option strict [Boolean] + # @return [Object] + def self.coerce(value, strict: strict?) + case value + when TrueClass, FalseClass + value + when Integer + return value == 1 + when String + return %w[1 true].include?(value) + end + + raise Errors::TypeError, "cannot coerce `#{value.class}` to Boolean" if strict + + value + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/enum.rb new file mode 100644 index 000000000000..72e45e4c1f27 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/enum.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Module for defining enums + module Enum + include Type + + # @api private + # + # @return [Array] + def values + @values ||= constants.map { |c| const_get(c) } + end + + # @api private + def finalize! + values + end + + # @api private + def strict? + @strict ||= false + end + + # @api private + def strict! + @strict = true + end + + def coerce(value, strict: strict?) + coerced_value = Utils.coerce(Symbol, value) + + return coerced_value if values.include?(coerced_value) + + raise Errors::TypeError, "`#{value}` not in enum #{self}" if strict + + value + end + + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + + def inspect + "#{name}[#{values.join(", ")}]" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/hash.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/hash.rb new file mode 100644 index 000000000000..d8bffa63ac11 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/hash.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + class Hash + include Type + + attr_reader :key_type, :value_type + + class << self + def [](key_type, value_type) + new(key_type, value_type) + end + end + + def initialize(key_type, value_type) + @key_type = key_type + @value_type = value_type + end + + def coerce(value, strict: strict?) + unless value.is_a?(::Hash) + raise Errors::TypeError, "not hash" if strict + + return value + end + + value.to_h do |k, v| + [Utils.coerce(key_type, k, strict: strict), Utils.coerce(value_type, v, strict: strict)] + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model.rb new file mode 100644 index 000000000000..9b1480c7333a --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model.rb @@ -0,0 +1,200 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # @abstract + # + # An abstract model that all data objects will inherit from + class Model + include Type + + class << self + # The defined fields for this model + # + # @api private + # + # @return [Hash] + def fields + @fields ||= if self < Seed::Internal::Types::Model + superclass.fields.dup + else + {} + end + end + + # Any extra fields that have been created from instantiation + # + # @api private + # + # @return [Hash] + def extra_fields + @extra_fields ||= {} + end + + # Define a new field on this model + # + # @param name [Symbol] The name of the field + # @param type [Class] Type of the field + # @option optional [Boolean] If it is an optional field + # @option nullable [Boolean] If it is a nullable field + # @option api_name [Symbol, String] Name in the API of this field. When serializing/deserializing, will use + # this field name + # @return [void] + def field(name, type, optional: false, nullable: false, api_name: nil, default: nil) + add_field_definition(name: name, type: type, optional: optional, nullable: nullable, api_name: api_name, + default: default) + + define_accessor(name) + define_setter(name) + end + + # Define a new literal for this model + # + # @param name [Symbol] + # @param value [Object] + # @option api_name [Symbol, String] + # @return [void] + def literal(name, value, api_name: nil) + add_field_definition(name: name, type: value.class, optional: false, nullable: false, api_name: api_name, + value: value) + + define_accessor(name) + end + + # Adds a new field definition into the class's fields registry + # + # @api private + # + # @param name [Symbol] + # @param type [Class] + # @option optional [Boolean] + # @return [void] + private def add_field_definition(name:, type:, optional:, nullable:, api_name:, default: nil, value: nil) + fields[name.to_sym] = + Field.new(name: name, type: type, optional: optional, nullable: nullable, api_name: api_name, + value: value, default: default) + end + + # Adds a new field definition into the class's extra fields registry + # + # @api private + # + # @param name [Symbol] + # @param type [Class] + # @option required [Boolean] + # @option optional [Boolean] + # @return [void] + def add_extra_field_definition(name:, type:) + return if extra_fields.key?(name.to_sym) + + extra_fields[name.to_sym] = Field.new(name: name, type: type, optional: true, nullable: false) + + define_accessor(name) + define_setter(name) + end + + # @api private + private def define_accessor(name) + method_name = name.to_sym + + define_method(method_name) do + @data[name] + end + end + + # @api private + private def define_setter(name) + method_name = :"#{name}=" + + define_method(method_name) do |val| + @data[name] = val + end + end + + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument + return value if value.is_a?(self) + + return value unless value.is_a?(::Hash) + + new(value) + end + + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end + + def ===(instance) + instance.class.ancestors.include?(self) + end + end + + # Creates a new instance of this model + # TODO: Should all this logic be in `#coerce` instead? + # + # @param values [Hash] + # @option strict [Boolean] + # @return [self] + def initialize(values = {}) + @data = {} + + values = Utils.symbolize_keys(values.dup) + + self.class.fields.each do |field_name, field| + value = values.delete(field.api_name.to_sym) || values.delete(field.api_name) || values.delete(field_name) + + field_value = value || (if field.literal? + field.value + elsif field.default + field.default + end) + + @data[field_name] = Utils.coerce(field.type, field_value) + end + + # Any remaining values in the input become extra fields + values.each do |name, value| + self.class.add_extra_field_definition(name: name, type: value.class) + + @data[name.to_sym] = value + end + end + + def to_h + self.class.fields.merge(self.class.extra_fields).each_with_object({}) do |(name, field), acc| + # If there is a value present in the data, use that value + # If there is a `nil` value present in the data, and it is optional but NOT nullable, exclude key altogether + # If there is a `nil` value present in the data, and it is optional and nullable, use the nil value + + value = @data[name] + + next if value.nil? && field.optional && !field.nullable + + if value.is_a?(::Array) + value = value.map { |item| item.respond_to?(:to_h) ? item.to_h : item } + elsif value.respond_to?(:to_h) + value = value.to_h + end + + acc[field.api_name] = value + end + end + + def ==(other) + self.class == other.class && to_h == other.to_h + end + + # @return [String] + def inspect + attrs = @data.map do |name, value| + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" + end + + "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model/field.rb new file mode 100644 index 000000000000..6ce0186f6a5d --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/model/field.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + class Model + # Definition of a field on a model + class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default + + def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) + @name = name.to_sym + @type = type + @optional = optional + @nullable = nullable + @api_name = api_name || name.to_s + @value = value + @default = default + end + + def literal? + !value.nil? + end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/type.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/type.rb new file mode 100644 index 000000000000..5866caf1dbda --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/type.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # @abstract + module Type + include Seed::Internal::JSON::Serializable + + # Coerces a value to this type + # + # @param value [unknown] + # @option strict [Boolean] If we should strictly coerce this value + def coerce(value, strict: strict?) + raise NotImplementedError + end + + # Returns if strictness is on for this type, defaults to `false` + # + # @return [Boolean] + def strict? + @strict ||= false + end + + # Enable strictness by default for this type + # + # @return [void] + def strict! + @strict = true + self + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/union.rb new file mode 100644 index 000000000000..8e47f2f1a592 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/union.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Define a union between two types + module Union + include Seed::Internal::Types::Type + + def members + @members ||= [] + end + + # Add a member to this union + # + # @param type [Object] + # @option key [Symbol, String] + # @return [void] + def member(type, key: nil) + members.push([key, Utils.wrap_type(type)]) + self + end + + def member?(type) + members.any? { |_key, type_fn| type == type_fn.call } + end + + # Set the discriminant for this union + # + # @param key [Symbol, String] + # @return [void] + def discriminant(key) + @discriminant = key + end + + # @api private + private def discriminated? + !@discriminant.nil? + end + + # Resolves the type of a value to be one of the members + # + # @param value [Object] + # @return [Class] + private def resolve_member(value) + if discriminated? && value.is_a?(::Hash) + discriminant_value = value.fetch(@discriminant, nil) + + return if discriminant_value.nil? + + members.to_h[discriminant_value]&.call + else + # First try exact type matching + result = members.find do |_key, mem| + member_type = Utils.unwrap_type(mem) + value.is_a?(member_type) + end&.last&.call + + return result if result + + # For Hash values, try to coerce into Model member types + if value.is_a?(::Hash) + members.find do |_key, mem| + member_type = Utils.unwrap_type(mem) + # Check if member_type is a Model class + next unless member_type.is_a?(Class) && member_type <= Model + + # Try to coerce the hash into this model type with strict mode + begin + candidate = Utils.coerce(member_type, value, strict: true) + + # Validate that all required (non-optional) fields are present + # This ensures undiscriminated unions properly distinguish between member types + member_type.fields.each do |field_name, field| + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional + end + + true + rescue Errors::TypeError + false + end + end&.last&.call + end + end + end + + def coerce(value, strict: strict?) + type = resolve_member(value) + + unless type + return value unless strict + + if discriminated? + raise Errors::TypeError, + "value of type `#{value.class}` not member of union #{self}" + end + + raise Errors::TypeError, "could not resolve to member of union #{self}" + end + + Utils.coerce(type, value, strict: strict) + end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/unknown.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/unknown.rb new file mode 100644 index 000000000000..7b58de956da9 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/unknown.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + module Unknown + include Seed::Internal::Types::Type + + def coerce(value) + value + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/utils.rb new file mode 100644 index 000000000000..4685ec234596 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/internal/types/utils.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +module Seed + module Internal + module Types + # Utilities for dealing with and checking types + module Utils + # Wraps a type into a type function + # + # @param type [Proc, Object] + # @return [Proc] + def self.wrap_type(type) + case type + when Proc + type + else + -> { type } + end + end + + # Resolves a type or type function into a type + # + # @param type [Proc, Object] + # @return [Object] + def self.unwrap_type(type) + type.is_a?(Proc) ? type.call : type + end + + def self.coerce(target, value, strict: false) + type = unwrap_type(target) + + case type + in Array + case value + when ::Array + return type.coerce(value, strict: strict) + when Set, ::Hash + return coerce(type, value.to_a) + end + in Hash + case value + when ::Hash + return type.coerce(value, strict: strict) + when ::Array + return coerce(type, value.to_h) + end + in ->(t) { t <= NilClass } + return nil + in ->(t) { t <= String } + case value + when String, Symbol, Numeric, TrueClass, FalseClass + return value.to_s + end + in ->(t) { t <= Symbol } + case value + when Symbol, String + return value.to_sym + end + in ->(t) { t <= Integer } + case value + when Numeric, String, Time + return value.to_i + end + in ->(t) { t <= Float } + case value + when Numeric, Time, String + return value.to_f + end + in ->(t) { t <= Model } + case value + when type + return value + when ::Hash + return type.coerce(value, strict: strict) + end + in Module + case type + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } + return type.coerce(value, strict: strict) + else + value + end + else + value + end + + raise Errors::TypeError, "cannot coerce value of type `#{value.class}` to `#{target}`" if strict + + value + end + + def self.symbolize_keys(hash) + hash.transform_keys(&:to_sym) + end + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_cursor.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_cursor.rb new file mode 100644 index 000000000000..4976e7c9e6ab --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_cursor.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Seed + module Types + class UsernameCursor < Internal::Types::Model + field :cursor, -> { Seed::Types::UsernamePage }, optional: false, nullable: false + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_page.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_page.rb new file mode 100644 index 000000000000..b565b5be4863 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/types/username_page.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Seed + module Types + class UsernamePage < Internal::Types::Model + field :after, -> { String }, optional: true, nullable: false + field :data, -> { Internal::Types::Array[String] }, optional: false, nullable: false + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/client.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/client.rb new file mode 100644 index 000000000000..d1d3a50a1f13 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/client.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +module Seed + module Users + class Client + # @param client [Seed::Internal::Http::RawClient] + # + # @return [void] + def initialize(client:) + @client = client + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String, nil] :starting_after + # + # @return [Seed::Types::UsernameCursor] + def list_usernames_custom(request_options: {}, **params) + params = Seed::Internal::Types::Utils.symbolize_keys(params) + query_param_names = %i[starting_after] + query_params = {} + query_params["starting_after"] = params[:starting_after] if params.key?(:starting_after) + params.except(*query_param_names) + + request = Seed::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "/users", + query: query_params, + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Seed::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + parsed_response = Seed::Types::UsernameCursor.load(response.body) + else + error_class = Seed::Errors::ResponseError.subclass_for_code(code) + raise error_class.new(response.body, code: code) + end + + Seed::Internal::FooPager.new( + parsed_response, + item_field: :data, + raw_client: @client + ) + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/types/list_usernames_request_custom.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/types/list_usernames_request_custom.rb new file mode 100644 index 000000000000..27d6be3ad7e9 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/users/types/list_usernames_request_custom.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Seed + module Users + module Types + class ListUsernamesRequestCustom < Internal::Types::Model + field :starting_after, -> { String }, optional: true, nullable: false + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/lib/seed/version.rb b/seed/ruby-sdk-v2/pagination-custom/lib/seed/version.rb new file mode 100644 index 000000000000..00dd45cdd958 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/lib/seed/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Seed + VERSION = "0.0.1" +end diff --git a/seed/ruby-sdk-v2/pagination-custom/seed.gemspec b/seed/ruby-sdk-v2/pagination-custom/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/pagination-custom/seed.gemspec +++ b/seed/ruby-sdk-v2/pagination-custom/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/pagination-custom/test/custom.test.rb b/seed/ruby-sdk-v2/pagination-custom/test/custom.test.rb new file mode 100644 index 000000000000..4bd57989d43d --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/custom.test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# This is a custom test file, if you wish to add more tests +# to your SDK. +# Be sure to mark this file in `.fernignore`. +# +# If you include example requests/responses in your fern definition, +# you will have tests automatically generated for you. + +# This test is run via command line: rake customtest +describe "Custom Test" do + it "Default" do + refute false + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/test_helper.rb b/seed/ruby-sdk-v2/pagination-custom/test/test_helper.rb new file mode 100644 index 000000000000..b086fe6d76ec --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/test_helper.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require_relative "../lib/seed" diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb new file mode 100644 index 000000000000..5008f6abf69f --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -0,0 +1,189 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "stringio" +require "json" +require "test_helper" + +NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) + +class CursorItemIteratorTest < Minitest::Test + def make_iterator(initial_cursor:) + @times_called = 0 + + Seed::Internal::CursorItemIterator.new(initial_cursor:, cursor_field: :next_cursor, item_field: :cards) do |cursor| + @times_called += 1 + cursor ||= 0 + next_cursor = cursor + 10 + PageResponse.new( + cards: NUMBERS[cursor...next_cursor], + next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil + ) + end + end + + def test_item_iterator_can_iterate_to_exhaustion + iterator = make_iterator(initial_cursor: 0) + + assert_equal NUMBERS, iterator.to_a + assert_equal 7, @times_called + + iterator = make_iterator(initial_cursor: 10) + + assert_equal (11..65).to_a, iterator.to_a + + iterator = make_iterator(initial_cursor: 5) + + assert_equal (6..65).to_a, iterator.to_a + end + + def test_item_iterator_can_work_without_an_initial_cursor + iterator = make_iterator(initial_cursor: nil) + + assert_equal NUMBERS, iterator.to_a + assert_equal 7, @times_called + end + + def test_items_iterator_iterates_lazily + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + assert_equal 1, iterator.first + assert_equal 1, @times_called + + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + assert_equal (1..15).to_a, iterator.first(15) + assert_equal 2, @times_called + + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + iterator.each do |card| + break if card >= 15 + end + + assert_equal 2, @times_called + end + + def test_items_iterator_implements_enumerable + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + doubled = iterator.map { |card| card * 2 } + + assert_equal 7, @times_called + assert_equal NUMBERS.length, doubled.length + end + + def test_items_iterator_can_be_advanced_manually + iterator = make_iterator(initial_cursor: 0) + + assert_equal 0, @times_called + + items = [] + expected_times_called = 0 + while (item = iterator.next_element) + expected_times_called += 1 if (item % 10) == 1 + + assert_equal expected_times_called, @times_called + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" + items.push(item) + end + + assert_equal 7, @times_called + assert_equal NUMBERS, items + end + + def test_pages_iterator + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal( + [ + (1..10).to_a, + (11..20).to_a, + (21..30).to_a, + (31..40).to_a, + (41..50).to_a, + (51..60).to_a, + (61..65).to_a + ], + iterator.to_a.map(&:cards) + ) + + iterator = make_iterator(initial_cursor: 10).pages + + assert_equal( + [ + (11..20).to_a, + (21..30).to_a, + (31..40).to_a, + (41..50).to_a, + (51..60).to_a, + (61..65).to_a + ], + iterator.to_a.map(&:cards) + ) + end + + def test_pages_iterator_can_work_without_an_initial_cursor + iterator = make_iterator(initial_cursor: nil).pages + + assert_equal 7, iterator.to_a.length + assert_equal 7, @times_called + end + + def test_pages_iterator_iterates_lazily + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + iterator.first + + assert_equal 1, @times_called + + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + assert_equal 2, iterator.first(2).length + assert_equal 2, @times_called + end + + def test_pages_iterator_knows_whether_another_page_is_upcoming + iterator = make_iterator(initial_cursor: 0).pages + + iterator.each_with_index do |_page, index| + assert_equal index + 1, @times_called + assert_equal index < 6, iterator.next? + end + end + + def test_pages_iterator_can_be_advanced_manually + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + + lengths = [] + expected_times_called = 0 + while (page = iterator.next_page) + expected_times_called += 1 + + assert_equal expected_times_called, @times_called + lengths.push(page.cards.length) + end + + assert_equal 7, @times_called + assert_equal [10, 10, 10, 10, 10, 10, 5], lengths + end + + def test_pages_iterator_implements_enumerable + iterator = make_iterator(initial_cursor: 0).pages + + assert_equal 0, @times_called + lengths = iterator.map { |page| page.cards.length } + + assert_equal 7, @times_called + assert_equal [10, 10, 10, 10, 10, 10, 5], lengths + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_offset_item_iterator.rb new file mode 100644 index 000000000000..92576b820128 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "stringio" +require "json" +require "test_helper" + +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) +TestIteratorConfig = Struct.new( + :step, + :has_next_field, + :total_item_count, + :per_page, + :initial_page +) do + def first_item_returned + if step + (initial_page || 0) + 1 + else + (((initial_page || 1) - 1) * per_page) + 1 + end + end +end + +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) +ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| + [:has_next, nil].map do |has_next_field| + [0, 5, 10, 60, 63].map do |total_item_count| + [5, 10].map do |per_page| + initial_pages = [nil, 3, 100] + initial_pages << (step ? 0 : 1) + + initial_pages.map do |initial_page| + TestIteratorConfig.new( + step: step, + has_next_field: has_next_field, + total_item_count: total_item_count, + per_page: per_page, + initial_page: initial_page + ) + end + end + end + end +end.flatten + +class OffsetItemIteratorTest < Minitest::Test + def make_iterator(config) + @times_called = 0 + + items = (1..config.total_item_count).to_a + + Seed::Internal::OffsetItemIterator.new( + initial_page: config.initial_page, + item_field: :items, + has_next_field: config.has_next_field, + step: config.step + ) do |page| + @times_called += 1 + + slice_start = config.step ? page : (page - 1) * config.per_page + slice_end = slice_start + config.per_page + + output = { + items: items[slice_start...slice_end] + } + output[config.has_next_field] = slice_end < items.length if config.has_next_field + + OffsetPageResponse.new(**output) + end + end + + def test_item_iterator_can_iterate_to_exhaustion + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config) + + assert_equal (config.first_item_returned..config.total_item_count).to_a, iterator.to_a + end + end + + def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config) + items = [] + + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") + items.push(item) + end + + assert_equal (config.first_item_returned..config.total_item_count).to_a, items + end + end + + def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next + ALL_TEST_ITERATOR_CONFIGS.each do |config| + iterator = make_iterator(config).pages + pages = [] + + loop do + has_next_output = iterator.next? + page = iterator.next_page + + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") + break if page.nil? + + pages.push(page) + end + + assert_equal pages, make_iterator(config).pages.to_a + end + end + + def test_items_iterator_iterates_lazily + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + assert_equal 1, iterator.first + assert_equal 1, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + assert_equal (1..15).to_a, iterator.first(15) + assert_equal 2, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG) + + assert_equal 0, @times_called + iterator.each do |card| + break if card >= 15 + end + + assert_equal 2, @times_called + end + + def test_pages_iterator_iterates_lazily + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG).pages + + assert_equal 0, @times_called + iterator.first + + assert_equal 1, @times_called + + iterator = make_iterator(LAZY_TEST_ITERATOR_CONFIG).pages + + assert_equal 0, @times_called + assert_equal 3, iterator.first(3).length + assert_equal 3, @times_called + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_array.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_array.rb new file mode 100644 index 000000000000..e7e6571f03ee --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_array.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Array do + module TestArray + StringArray = Seed::Internal::Types::Array[String] + end + + describe "#initialize" do + it "sets the type" do + assert_equal String, TestArray::StringArray.type + end + end + + describe "#coerce" do + it "does not perform coercion if not an array" do + assert_equal 1, TestArray::StringArray.coerce(1) + end + + it "raises an error if not an array and strictness is on" do + assert_raises Seed::Internal::Errors::TypeError do + TestArray::StringArray.coerce(1, strict: true) + end + end + + it "coerces the elements" do + assert_equal %w[foobar 1 true], TestArray::StringArray.coerce(["foobar", 1, true]) + end + + it "raises an error if element of array is not coercable and strictness is on" do + assert_raises Seed::Internal::Errors::TypeError do + TestArray::StringArray.coerce([Object.new], strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_boolean.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_boolean.rb new file mode 100644 index 000000000000..cba18e48765b --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_boolean.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Boolean do + describe ".coerce" do + it "coerces true/false" do + assert Seed::Internal::Types::Boolean.coerce(true) + refute Seed::Internal::Types::Boolean.coerce(false) + end + + it "coerces an Integer" do + assert Seed::Internal::Types::Boolean.coerce(1) + refute Seed::Internal::Types::Boolean.coerce(0) + end + + it "coerces a String" do + assert Seed::Internal::Types::Boolean.coerce("1") + assert Seed::Internal::Types::Boolean.coerce("true") + refute Seed::Internal::Types::Boolean.coerce("0") + end + + it "passes through other values with strictness off" do + obj = Object.new + + assert_equal obj, Seed::Internal::Types::Boolean.coerce(obj) + end + + it "raises an error with other values with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + Seed::Internal::Types::Boolean.coerce(Object.new, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_enum.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_enum.rb new file mode 100644 index 000000000000..e8d89bce467f --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_enum.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Enum do + module EnumTest + module ExampleEnum + extend Seed::Internal::Types::Enum + + FOO = :foo + BAR = :bar + + finalize! + end + end + + describe "#values" do + it "defines values" do + assert_equal %i[foo bar].sort, EnumTest::ExampleEnum.values.sort + end + end + + describe "#coerce" do + it "coerces an existing member" do + assert_equal :foo, EnumTest::ExampleEnum.coerce(:foo) + end + + it "coerces a string version of a member" do + assert_equal :foo, EnumTest::ExampleEnum.coerce("foo") + end + + it "returns the value if not a member with strictness off" do + assert_equal 1, EnumTest::ExampleEnum.coerce(1) + end + + it "raises an error if value is not a member with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + EnumTest::ExampleEnum.coerce(1, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_hash.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_hash.rb new file mode 100644 index 000000000000..6c5e58a6a946 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_hash.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Hash do + module TestHash + SymbolStringHash = Seed::Internal::Types::Hash[Symbol, String] + end + + describe ".[]" do + it "defines the key and value type" do + assert_equal Symbol, TestHash::SymbolStringHash.key_type + assert_equal String, TestHash::SymbolStringHash.value_type + end + end + + describe "#coerce" do + it "coerces the keys" do + assert_equal %i[foo bar], TestHash::SymbolStringHash.coerce({ "foo" => "1", :bar => "2" }).keys + end + + it "coerces the values" do + assert_equal %w[foo 1], TestHash::SymbolStringHash.coerce({ foo: :foo, bar: 1 }).values + end + + it "passes through other values with strictness off" do + obj = Object.new + + assert_equal obj, TestHash::SymbolStringHash.coerce(obj) + end + + it "raises an error with other values with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce(Object.new, strict: true) + end + end + + it "raises an error with non-coercable key types with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce({ Object.new => 1 }, strict: true) + end + end + + it "raises an error with non-coercable value types with strictness on" do + assert_raises Seed::Internal::Errors::TypeError do + TestHash::SymbolStringHash.coerce({ "foobar" => Object.new }, strict: true) + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_model.rb new file mode 100644 index 000000000000..3d87b9f5a8c7 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_model.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Model do + module StringInteger + extend Seed::Internal::Types::Union + + member String + member Integer + end + + class ExampleModel < Seed::Internal::Types::Model + field :name, String + field :rating, StringInteger, optional: true + field :year, Integer, optional: true, nullable: true, api_name: "yearOfRelease" + end + + class ExampleModelInheritance < ExampleModel + field :director, String + end + + class ExampleWithDefaults < ExampleModel + field :type, String, default: "example" + end + + class ExampleChild < Seed::Internal::Types::Model + field :value, String + end + + class ExampleParent < Seed::Internal::Types::Model + field :child, ExampleChild + end + + describe ".field" do + before do + @example = ExampleModel.new(name: "Inception", rating: 4) + end + + it "defines fields on model" do + assert_equal %i[name rating year], ExampleModel.fields.keys + end + + it "defines fields from parent models" do + assert_equal %i[name rating year director], ExampleModelInheritance.fields.keys + end + + it "sets the field's type" do + assert_equal String, ExampleModel.fields[:name].type + assert_equal StringInteger, ExampleModel.fields[:rating].type + end + + it "sets the `default` option" do + assert_equal "example", ExampleWithDefaults.fields[:type].default + end + + it "defines getters" do + assert_respond_to @example, :name + assert_respond_to @example, :rating + + assert_equal "Inception", @example.name + assert_equal 4, @example.rating + end + + it "defines setters" do + assert_respond_to @example, :name= + assert_respond_to @example, :rating= + + @example.name = "Inception 2" + @example.rating = 5 + + assert_equal "Inception 2", @example.name + assert_equal 5, @example.rating + end + end + + describe "#initialize" do + it "sets the data" do + example = ExampleModel.new(name: "Inception", rating: 4) + + assert_equal "Inception", example.name + assert_equal 4, example.rating + end + + it "allows extra fields to be set" do + example = ExampleModel.new(name: "Inception", rating: 4, director: "Christopher Nolan") + + assert_equal "Christopher Nolan", example.director + end + + it "sets the defaults where applicable" do + example_using_defaults = ExampleWithDefaults.new + + assert_equal "example", example_using_defaults.type + + example_without_defaults = ExampleWithDefaults.new(type: "not example") + + assert_equal "not example", example_without_defaults.type + end + + it "coerces child models" do + parent = ExampleParent.new(child: { value: "foobar" }) + + assert_kind_of ExampleChild, parent.child + end + + it "uses the api_name to pull the value" do + example = ExampleModel.new({ name: "Inception", yearOfRelease: 2014 }) + + assert_equal 2014, example.year + refute_respond_to example, :yearOfRelease + end + end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_union.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_union.rb new file mode 100644 index 000000000000..2b08e7f91d8f --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_union.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Union do + class Rectangle < Seed::Internal::Types::Model + literal :type, "square" + + field :area, Float + end + + class Circle < Seed::Internal::Types::Model + literal :type, "circle" + + field :area, Float + end + + class Pineapple < Seed::Internal::Types::Model + literal :type, "pineapple" + + field :area, Float + end + + module Shape + extend Seed::Internal::Types::Union + + discriminant :type + + member -> { Rectangle }, key: "rect" + member -> { Circle }, key: "circle" + end + + module StringOrInteger + extend Seed::Internal::Types::Union + + member String + member Integer + end + + describe "#coerce" do + it "coerces hashes into member models with discriminated unions" do + circle = Shape.coerce({ type: "circle", area: 4.0 }) + + assert_instance_of Circle, circle + end + end + + describe "#member" do + it "defines Model members" do + assert Shape.member?(Rectangle) + assert Shape.member?(Circle) + refute Shape.member?(Pineapple) + end + + it "defines other members" do + assert StringOrInteger.member?(String) + assert StringOrInteger.member?(Integer) + refute StringOrInteger.member?(Float) + refute StringOrInteger.member?(Pineapple) + end + end +end diff --git a/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_utils.rb b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_utils.rb new file mode 100644 index 000000000000..29d14621a229 --- /dev/null +++ b/seed/ruby-sdk-v2/pagination-custom/test/unit/internal/types/test_utils.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +require "test_helper" + +describe Seed::Internal::Types::Utils do + Utils = Seed::Internal::Types::Utils + + module TestUtils + class M < Seed::Internal::Types::Model + field :value, String + end + + class UnionMemberA < Seed::Internal::Types::Model + literal :type, "A" + field :only_on_a, String + end + + class UnionMemberB < Seed::Internal::Types::Model + literal :type, "B" + field :only_on_b, String + end + + module U + extend Seed::Internal::Types::Union + + discriminant :type + + member -> { UnionMemberA }, key: "A" + member -> { UnionMemberB }, key: "B" + end + + SymbolStringHash = Seed::Internal::Types::Hash[Symbol, String] + SymbolModelHash = -> { Seed::Internal::Types::Hash[Symbol, TestUtils::M] } + end + + describe ".coerce" do + describe "NilClass" do + it "always returns nil" do + assert_nil Utils.coerce(NilClass, "foobar") + assert_nil Utils.coerce(NilClass, 1) + assert_nil Utils.coerce(NilClass, Object.new) + end + end + + describe "String" do + it "coerces from String, Symbol, Numeric, or Boolean" do + assert_equal "foobar", Utils.coerce(String, "foobar") + assert_equal "foobar", Utils.coerce(String, :foobar) + assert_equal "1", Utils.coerce(String, 1) + assert_equal "1.0", Utils.coerce(String, 1.0) + assert_equal "true", Utils.coerce(String, true) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(String, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(String, Object.new, strict: true) + end + end + end + + describe "Symbol" do + it "coerces from Symbol, String" do + assert_equal :foobar, Utils.coerce(Symbol, :foobar) + assert_equal :foobar, Utils.coerce(Symbol, "foobar") + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Symbol, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Symbol, Object.new, strict: true) + end + end + end + + describe "Integer" do + it "coerces from Numeric, String, Time" do + assert_equal 1, Utils.coerce(Integer, 1) + assert_equal 1, Utils.coerce(Integer, 1.0) + assert_equal 1, Utils.coerce(Integer, Complex.rect(1)) + assert_equal 1, Utils.coerce(Integer, Rational(1)) + assert_equal 1, Utils.coerce(Integer, "1") + assert_equal 1_713_916_800, Utils.coerce(Integer, Time.utc(2024, 4, 24)) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Integer, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Integer, Object.new, strict: true) + end + end + end + + describe "Float" do + it "coerces from Numeric, Time" do + assert_in_delta(1.0, Utils.coerce(Float, 1.0)) + assert_in_delta(1.0, Utils.coerce(Float, 1)) + assert_in_delta(1.0, Utils.coerce(Float, Complex.rect(1))) + assert_in_delta(1.0, Utils.coerce(Float, Rational(1))) + assert_in_delta(1_713_916_800.0, Utils.coerce(Integer, Time.utc(2024, 4, 24))) + end + + it "passes through value if it cannot be coerced and not strict" do + obj = Object.new + + assert_equal obj, Utils.coerce(Float, obj) + end + + it "raises an error if value cannot be coerced and strict" do + assert_raises Seed::Internal::Errors::TypeError do + Utils.coerce(Float, Object.new, strict: true) + end + end + end + + describe "Model" do + it "coerces a hash" do + result = Utils.coerce(TestUtils::M, { value: "foobar" }) + + assert_kind_of TestUtils::M, result + assert_equal "foobar", result.value + end + + it "coerces a hash when the target is a type function" do + result = Utils.coerce(-> { TestUtils::M }, { value: "foobar" }) + + assert_kind_of TestUtils::M, result + assert_equal "foobar", result.value + end + + it "will not coerce non-hashes" do + assert_equal "foobar", Utils.coerce(TestUtils::M, "foobar") + end + end + + describe "Enum" do + module ExampleEnum + extend Seed::Internal::Types::Enum + + FOO = :FOO + BAR = :BAR + + finalize! + end + + it "coerces into a Symbol version of the member value" do + assert_equal :FOO, Utils.coerce(ExampleEnum, "FOO") + end + + it "returns given value if not a member" do + assert_equal "NOPE", Utils.coerce(ExampleEnum, "NOPE") + end + end + + describe "Array" do + StringArray = Seed::Internal::Types::Array[String] + ModelArray = -> { Seed::Internal::Types::Array[TestUtils::M] } + UnionArray = -> { Seed::Internal::Types::Array[TestUtils::U] } + + it "coerces an array of literals" do + assert_equal %w[a b c], Utils.coerce(StringArray, %w[a b c]) + assert_equal ["1", "2.0", "true"], Utils.coerce(StringArray, [1, 2.0, true]) + assert_equal ["1", "2.0", "true"], Utils.coerce(StringArray, Set.new([1, 2.0, true])) + end + + it "coerces an array of Models" do + assert_equal [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")], + Utils.coerce(ModelArray, [{ value: "foobar" }, { value: "bizbaz" }]) + + assert_equal [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")], + Utils.coerce(ModelArray, [TestUtils::M.new(value: "foobar"), TestUtils::M.new(value: "bizbaz")]) + end + + it "coerces an array of model unions" do + assert_equal [TestUtils::UnionMemberA.new(type: "A", only_on_a: "A"), TestUtils::UnionMemberB.new(type: "B", only_on_b: "B")], + Utils.coerce(UnionArray, [{ type: "A", only_on_a: "A" }, { type: "B", only_on_b: "B" }]) + end + + it "returns given value if not an array" do + assert_equal 1, Utils.coerce(StringArray, 1) + end + end + + describe "Hash" do + it "coerces the keys and values" do + ssh_res = Utils.coerce(TestUtils::SymbolStringHash, { "foo" => "bar", "biz" => "2" }) + + assert_equal "bar", ssh_res[:foo] + assert_equal "2", ssh_res[:biz] + + smh_res = Utils.coerce(TestUtils::SymbolModelHash, { "foo" => { "value" => "foo" } }) + + assert_equal TestUtils::M.new(value: "foo"), smh_res[:foo] + end + end + end +end diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example0/snippet.rb index 1a219df6f2e9..2b105070c91d 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example0/snippet.rb @@ -10,5 +10,10 @@ pagination: { per_page: 1, starting_after: 'starting_after' + }, + query: { + field: 'field', + operator: '=', + value: 'value' } ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example1/snippet.rb index 643a686bc510..a2c1067aad13 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example1/snippet.rb @@ -8,5 +8,6 @@ client.inline_users.inline_users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example13/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example13/snippet.rb index 66f6e8722659..3d0779f4948e 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example13/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example13/snippet.rb @@ -8,5 +8,6 @@ client.users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example16/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example16/snippet.rb index 66f6e8722659..3d0779f4948e 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example16/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example16/snippet.rb @@ -8,5 +8,6 @@ client.users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example17/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example17/snippet.rb index df28d489a539..055d077afcda 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example17/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example17/snippet.rb @@ -8,5 +8,6 @@ client.users.list_with_cursor_pagination( page: 1.1, per_page: 1.1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example19/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example19/snippet.rb index 2d5e16f355d3..cc55833ffd7c 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example19/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example19/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.users.list_with_cursor_pagination(page: 1); +client.users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example20/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example20/snippet.rb index 2d5e16f355d3..cc55833ffd7c 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example20/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example20/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.users.list_with_cursor_pagination(page: 1); +client.users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example4/snippet.rb index 643a686bc510..a2c1067aad13 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example4/snippet.rb @@ -8,5 +8,6 @@ client.inline_users.inline_users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example5/snippet.rb index f531f7ca9e89..50cfd12e6356 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example5/snippet.rb @@ -8,5 +8,6 @@ client.inline_users.inline_users.list_with_cursor_pagination( page: 1.1, per_page: 1.1, + order: 'asc', starting_after: 'starting_after' ); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example7/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example7/snippet.rb index aa1f42d077eb..ff5befcfec98 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example7/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example7/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.inline_users.inline_users.list_with_cursor_pagination(page: 1); +client.inline_users.inline_users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); diff --git a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example8/snippet.rb b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example8/snippet.rb index aa1f42d077eb..ff5befcfec98 100644 --- a/seed/ruby-sdk-v2/pagination/dynamic-snippets/example8/snippet.rb +++ b/seed/ruby-sdk-v2/pagination/dynamic-snippets/example8/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.inline_users.inline_users.list_with_cursor_pagination(page: 1); +client.inline_users.inline_users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); diff --git a/seed/ruby-sdk-v2/pagination/lib/seed/inline_users/inline_users/client.rb b/seed/ruby-sdk-v2/pagination/lib/seed/inline_users/inline_users/client.rb index 84fbadc13599..751f2567be96 100644 --- a/seed/ruby-sdk-v2/pagination/lib/seed/inline_users/inline_users/client.rb +++ b/seed/ruby-sdk-v2/pagination/lib/seed/inline_users/inline_users/client.rb @@ -44,7 +44,8 @@ def list_with_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -88,7 +89,8 @@ def list_with_mixed_type_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -128,7 +130,8 @@ def list_with_body_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/inline-users", - body: Seed::InlineUsers::InlineUsers::Types::ListUsersBodyCursorPaginationRequest.new(body_bag).to_h + body: Seed::InlineUsers::InlineUsers::Types::ListUsersBodyCursorPaginationRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -179,7 +182,8 @@ def list_with_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -230,7 +234,8 @@ def list_with_double_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -271,7 +276,8 @@ def list_with_body_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/inline-users", - body: Seed::InlineUsers::InlineUsers::Types::ListUsersBodyOffsetPaginationRequest.new(body_bag).to_h + body: Seed::InlineUsers::InlineUsers::Types::ListUsersBodyOffsetPaginationRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -320,7 +326,8 @@ def list_with_offset_step_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -369,7 +376,8 @@ def list_with_offset_pagination_has_next_page(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -413,7 +421,8 @@ def list_with_extended_results(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -457,7 +466,8 @@ def list_with_extended_results_and_optional_data(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -501,7 +511,8 @@ def list_usernames(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -546,7 +557,8 @@ def list_with_global_config(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/inline-users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/pagination/lib/seed/users/client.rb b/seed/ruby-sdk-v2/pagination/lib/seed/users/client.rb index 223b7505826f..0824ff7c2705 100644 --- a/seed/ruby-sdk-v2/pagination/lib/seed/users/client.rb +++ b/seed/ruby-sdk-v2/pagination/lib/seed/users/client.rb @@ -43,7 +43,8 @@ def list_with_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -87,7 +88,8 @@ def list_with_mixed_type_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -127,7 +129,8 @@ def list_with_body_cursor_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/users", - body: Seed::Users::Types::ListUsersBodyCursorPaginationRequest.new(body_bag).to_h + body: Seed::Users::Types::ListUsersBodyCursorPaginationRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -178,7 +181,8 @@ def list_with_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -229,7 +233,8 @@ def list_with_double_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -270,7 +275,8 @@ def list_with_body_offset_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/users", - body: Seed::Users::Types::ListUsersBodyOffsetPaginationRequest.new(body_bag).to_h + body: Seed::Users::Types::ListUsersBodyOffsetPaginationRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -319,7 +325,8 @@ def list_with_offset_step_pagination(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -368,7 +375,8 @@ def list_with_offset_pagination_has_next_page(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -412,7 +420,8 @@ def list_with_extended_results(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -456,7 +465,8 @@ def list_with_extended_results_and_optional_data(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -500,7 +510,8 @@ def list_usernames(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -544,7 +555,8 @@ def list_usernames_with_optional_response(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -587,7 +599,8 @@ def list_with_global_config(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/users", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/pagination/reference.md b/seed/ruby-sdk-v2/pagination/reference.md index cd20e96069e3..0cccf224f4ab 100644 --- a/seed/ruby-sdk-v2/pagination/reference.md +++ b/seed/ruby-sdk-v2/pagination/reference.md @@ -18,6 +18,11 @@ client.complex.search( pagination: { per_page: 1, starting_after: 'starting_after' + }, + query: { + field: 'field', + operator: '=', + value: 'value' } ); ``` @@ -71,6 +76,7 @@ client.complex.search( client.inline_users.inline_users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -225,6 +231,7 @@ in order to fetch the next page of results. client.inline_users.inline_users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -296,6 +303,7 @@ the next page of results. client.inline_users.inline_users.list_with_cursor_pagination( page: 1.1, per_page: 1.1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -407,7 +415,10 @@ in order to fetch the next page of results.
```ruby -client.inline_users.inline_users.list_with_cursor_pagination(page: 1); +client.inline_users.inline_users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); ```
@@ -467,7 +478,10 @@ paginated endpoint.
```ruby -client.inline_users.inline_users.list_with_cursor_pagination(page: 1); +client.inline_users.inline_users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); ```
@@ -694,6 +708,7 @@ client.inline_users.inline_users.list_with_cursor_pagination(); client.users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -848,6 +863,7 @@ in order to fetch the next page of results. client.users.list_with_cursor_pagination( page: 1, per_page: 1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -919,6 +935,7 @@ the next page of results. client.users.list_with_cursor_pagination( page: 1.1, per_page: 1.1, + order: 'asc', starting_after: 'starting_after' ); ``` @@ -1030,7 +1047,10 @@ in order to fetch the next page of results.
```ruby -client.users.list_with_cursor_pagination(page: 1); +client.users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); ```
@@ -1090,7 +1110,10 @@ paginated endpoint.
```ruby -client.users.list_with_cursor_pagination(page: 1); +client.users.list_with_cursor_pagination( + page: 1, + order: 'asc' +); ```
diff --git a/seed/ruby-sdk-v2/pagination/seed.gemspec b/seed/ruby-sdk-v2/pagination/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/pagination/seed.gemspec +++ b/seed/ruby-sdk-v2/pagination/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/path-parameters/.rubocop.yml b/seed/ruby-sdk-v2/path-parameters/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/path-parameters/.rubocop.yml +++ b/seed/ruby-sdk-v2/path-parameters/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/path-parameters/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/path-parameters/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/path-parameters/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/path-parameters/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/path-parameters/lib/seed/organizations/client.rb b/seed/ruby-sdk-v2/path-parameters/lib/seed/organizations/client.rb index 29c8a069779d..44e60064936c 100644 --- a/seed/ruby-sdk-v2/path-parameters/lib/seed/organizations/client.rb +++ b/seed/ruby-sdk-v2/path-parameters/lib/seed/organizations/client.rb @@ -25,7 +25,8 @@ def get_organization(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/#{params[:tenant_id]}/organizations/#{params[:organization_id]}/" + path: "/#{params[:tenant_id]}/organizations/#{params[:organization_id]}/", + request_options: request_options ) begin response = @client.send(request) @@ -57,7 +58,8 @@ def get_organization_user(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/#{params[:tenant_id]}/organizations/#{params[:organization_id]}/users/#{params[:user_id]}" + path: "/#{params[:tenant_id]}/organizations/#{params[:organization_id]}/users/#{params[:user_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -96,7 +98,8 @@ def search_organizations(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/#{params[:tenant_id]}/organizations/#{params[:organization_id]}/search", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/path-parameters/lib/seed/user/client.rb b/seed/ruby-sdk-v2/path-parameters/lib/seed/user/client.rb index 2c25b99905ec..942849016bcb 100644 --- a/seed/ruby-sdk-v2/path-parameters/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/path-parameters/lib/seed/user/client.rb @@ -25,7 +25,8 @@ def get_user(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/#{params[:tenant_id]}/user/#{params[:user_id]}" + path: "/#{params[:tenant_id]}/user/#{params[:user_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -56,7 +57,8 @@ def create_user(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/#{params[:tenant_id]}/user/", - body: Seed::User::Types::User.new(params).to_h + body: Seed::User::Types::User.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -91,7 +93,8 @@ def update_user(request_options: {}, **params) base_url: request_options[:base_url], method: "PATCH", path: "/#{params[:tenant_id]}/user/#{params[:user_id]}", - body: Seed::User::Types::User.new(body_params).to_h + body: Seed::User::Types::User.new(body_params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -130,7 +133,8 @@ def search_users(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/#{params[:tenant_id]}/user/#{params[:user_id]}/search", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -162,7 +166,8 @@ def get_user_metadata(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/#{params[:tenant_id]}/user/#{params[:user_id]}/metadata/v#{params[:version]}" + path: "/#{params[:tenant_id]}/user/#{params[:user_id]}/metadata/v#{params[:version]}", + request_options: request_options ) begin response = @client.send(request) @@ -197,7 +202,8 @@ def get_user_specifics(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/#{params[:tenant_id]}/user/#{params[:user_id]}/specifics/#{params[:version]}/#{params[:thought]}" + path: "/#{params[:tenant_id]}/user/#{params[:user_id]}/specifics/#{params[:version]}/#{params[:thought]}", + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/path-parameters/seed.gemspec b/seed/ruby-sdk-v2/path-parameters/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/path-parameters/seed.gemspec +++ b/seed/ruby-sdk-v2/path-parameters/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/path-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/plain-text/.rubocop.yml b/seed/ruby-sdk-v2/plain-text/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/plain-text/.rubocop.yml +++ b/seed/ruby-sdk-v2/plain-text/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/plain-text/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/plain-text/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/plain-text/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/plain-text/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/plain-text/seed.gemspec b/seed/ruby-sdk-v2/plain-text/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/plain-text/seed.gemspec +++ b/seed/ruby-sdk-v2/plain-text/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/plain-text/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/property-access/.rubocop.yml b/seed/ruby-sdk-v2/property-access/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/property-access/.rubocop.yml +++ b/seed/ruby-sdk-v2/property-access/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/property-access/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/property-access/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/property-access/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/property-access/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/property-access/seed.gemspec b/seed/ruby-sdk-v2/property-access/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/property-access/seed.gemspec +++ b/seed/ruby-sdk-v2/property-access/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/property-access/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/public-object/.rubocop.yml b/seed/ruby-sdk-v2/public-object/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/public-object/.rubocop.yml +++ b/seed/ruby-sdk-v2/public-object/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/public-object/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/public-object/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/public-object/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/public-object/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/public-object/seed.gemspec b/seed/ruby-sdk-v2/public-object/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/public-object/seed.gemspec +++ b/seed/ruby-sdk-v2/public-object/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/public-object/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/.rubocop.yml b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/.rubocop.yml +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/dynamic-snippets/example0/snippet.rb index 5c93e3c5e108..3f0d2dd95c1c 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/dynamic-snippets/example0/snippet.rb @@ -27,5 +27,13 @@ optional_user: { name: 'name', tags: ['tags', 'tags'] + }, + neighbor: { + name: 'name', + tags: ['tags', 'tags'] + }, + neighbor_required: { + name: 'name', + tags: ['tags', 'tags'] } ); diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/reference.md b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/reference.md index 5267ddbcf9ab..0e9b13d3e46a 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/reference.md +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/reference.md @@ -37,6 +37,14 @@ client.search( optional_user: { name: 'name', tags: ['tags', 'tags'] + }, + neighbor: { + name: 'name', + tags: ['tags', 'tags'] + }, + neighbor_required: { + name: 'name', + tags: ['tags', 'tags'] } ); ``` diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/seed.gemspec b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/seed.gemspec +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi-as-objects/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/.rubocop.yml b/seed/ruby-sdk-v2/query-parameters-openapi/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/.rubocop.yml +++ b/seed/ruby-sdk-v2/query-parameters-openapi/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/query-parameters-openapi/dynamic-snippets/example0/snippet.rb index 5c93e3c5e108..3f0d2dd95c1c 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi/dynamic-snippets/example0/snippet.rb @@ -27,5 +27,13 @@ optional_user: { name: 'name', tags: ['tags', 'tags'] + }, + neighbor: { + name: 'name', + tags: ['tags', 'tags'] + }, + neighbor_required: { + name: 'name', + tags: ['tags', 'tags'] } ); diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/query-parameters-openapi/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/reference.md b/seed/ruby-sdk-v2/query-parameters-openapi/reference.md index 5267ddbcf9ab..0e9b13d3e46a 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/reference.md +++ b/seed/ruby-sdk-v2/query-parameters-openapi/reference.md @@ -37,6 +37,14 @@ client.search( optional_user: { name: 'name', tags: ['tags', 'tags'] + }, + neighbor: { + name: 'name', + tags: ['tags', 'tags'] + }, + neighbor_required: { + name: 'name', + tags: ['tags', 'tags'] } ); ``` diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/seed.gemspec b/seed/ruby-sdk-v2/query-parameters-openapi/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/seed.gemspec +++ b/seed/ruby-sdk-v2/query-parameters-openapi/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters-openapi/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/query-parameters/.rubocop.yml b/seed/ruby-sdk-v2/query-parameters/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/query-parameters/.rubocop.yml +++ b/seed/ruby-sdk-v2/query-parameters/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/query-parameters/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/query-parameters/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/query-parameters/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/query-parameters/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/query-parameters/lib/seed/user/client.rb b/seed/ruby-sdk-v2/query-parameters/lib/seed/user/client.rb index 10a88a4d8ae3..b9c9025a1235 100644 --- a/seed/ruby-sdk-v2/query-parameters/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/query-parameters/lib/seed/user/client.rb @@ -35,8 +35,7 @@ def initialize(client:) # @return [Seed::User::Types::User] def get_username(request_options: {}, **params) params = Seed::Internal::Types::Utils.symbolize_keys(params) - query_param_names = %i[limit id date deadline bytes user user_list optional_deadline key_value optional_string - nested_user optional_user exclude_user filter] + query_param_names = %i[limit id date deadline bytes user user_list optional_deadline key_value optional_string nested_user optional_user exclude_user filter] query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["id"] = params[:id] if params.key?(:id) @@ -58,7 +57,8 @@ def get_username(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/user", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/query-parameters/lib/seed/user/types/get_users_request.rb b/seed/ruby-sdk-v2/query-parameters/lib/seed/user/types/get_users_request.rb index 2967b24136f0..c71c6bf741c0 100644 --- a/seed/ruby-sdk-v2/query-parameters/lib/seed/user/types/get_users_request.rb +++ b/seed/ruby-sdk-v2/query-parameters/lib/seed/user/types/get_users_request.rb @@ -10,17 +10,11 @@ class GetUsersRequest < Internal::Types::Model field :deadline, -> { String }, optional: false, nullable: false field :bytes, -> { String }, optional: false, nullable: false field :user, -> { Seed::User::Types::User }, optional: false, nullable: false - field :user_list, -> { - Internal::Types::Array[Seed::User::Types::User] - }, optional: false, nullable: false, api_name: "userList" + field :user_list, -> { Internal::Types::Array[Seed::User::Types::User] }, optional: false, nullable: false, api_name: "userList" field :optional_deadline, -> { String }, optional: true, nullable: false, api_name: "optionalDeadline" - field :key_value, -> { - Internal::Types::Hash[String, String] - }, optional: false, nullable: false, api_name: "keyValue" + field :key_value, -> { Internal::Types::Hash[String, String] }, optional: false, nullable: false, api_name: "keyValue" field :optional_string, -> { String }, optional: true, nullable: false, api_name: "optionalString" - field :nested_user, -> { - Seed::User::Types::NestedUser - }, optional: false, nullable: false, api_name: "nestedUser" + field :nested_user, -> { Seed::User::Types::NestedUser }, optional: false, nullable: false, api_name: "nestedUser" field :optional_user, -> { Seed::User::Types::User }, optional: true, nullable: false, api_name: "optionalUser" field :exclude_user, -> { Seed::User::Types::User }, optional: false, nullable: false, api_name: "excludeUser" field :filter, -> { String }, optional: false, nullable: false diff --git a/seed/ruby-sdk-v2/query-parameters/seed.gemspec b/seed/ruby-sdk-v2/query-parameters/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/query-parameters/seed.gemspec +++ b/seed/ruby-sdk-v2/query-parameters/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/query-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/request-parameters/.rubocop.yml b/seed/ruby-sdk-v2/request-parameters/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/request-parameters/.rubocop.yml +++ b/seed/ruby-sdk-v2/request-parameters/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example2/snippet.rb index bb175eb20fb5..1da67616a270 100644 --- a/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example2/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.user.create_username_optional(); +client.user.create_username_optional(request: {}); diff --git a/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example3/snippet.rb index bb175eb20fb5..1f3d8d469efd 100644 --- a/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/request-parameters/dynamic-snippets/example3/snippet.rb @@ -2,4 +2,8 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.user.create_username_optional(); +client.user.create_username_optional(request: { + username: 'username', + password: 'password', + name: 'test' +}); diff --git a/seed/ruby-sdk-v2/request-parameters/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/request-parameters/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/request-parameters/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/request-parameters/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/request-parameters/lib/seed/user/client.rb b/seed/ruby-sdk-v2/request-parameters/lib/seed/user/client.rb index bf1f556f7eb8..711a556a6402 100644 --- a/seed/ruby-sdk-v2/request-parameters/lib/seed/user/client.rb +++ b/seed/ruby-sdk-v2/request-parameters/lib/seed/user/client.rb @@ -35,7 +35,8 @@ def create_username(request_options: {}, **params) method: "POST", path: "/user/username", query: query_params, - body: Seed::User::Types::CreateUsernameRequest.new(body_bag).to_h + body: Seed::User::Types::CreateUsernameRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -71,7 +72,8 @@ def create_username_with_referenced_type(request_options: {}, **params) method: "POST", path: "/user/username-referenced", query: query_params, - body: Seed::User::Types::CreateUsernameBody.new(params).to_h + body: Seed::User::Types::CreateUsernameBody.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -99,7 +101,8 @@ def create_username_optional(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/user/username-optional", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) @@ -140,8 +143,7 @@ def create_username_optional(request_options: {}, **params) # @return [Seed::User::Types::User] def get_username(request_options: {}, **params) params = Seed::Internal::Types::Utils.symbolize_keys(params) - query_param_names = %i[limit id date deadline bytes user user_list optional_deadline key_value optional_string - nested_user optional_user exclude_user filter long_param big_int_param] + query_param_names = %i[limit id date deadline bytes user user_list optional_deadline key_value optional_string nested_user optional_user exclude_user filter long_param big_int_param] query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["id"] = params[:id] if params.key?(:id) @@ -165,7 +167,8 @@ def get_username(request_options: {}, **params) base_url: request_options[:base_url], method: "GET", path: "/user", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/request-parameters/lib/seed/user/types/get_users_request.rb b/seed/ruby-sdk-v2/request-parameters/lib/seed/user/types/get_users_request.rb index c0a5dcf0ce70..e415fb2a3ad9 100644 --- a/seed/ruby-sdk-v2/request-parameters/lib/seed/user/types/get_users_request.rb +++ b/seed/ruby-sdk-v2/request-parameters/lib/seed/user/types/get_users_request.rb @@ -10,17 +10,11 @@ class GetUsersRequest < Internal::Types::Model field :deadline, -> { String }, optional: false, nullable: false field :bytes, -> { String }, optional: false, nullable: false field :user, -> { Seed::User::Types::User }, optional: false, nullable: false - field :user_list, -> { - Internal::Types::Array[Seed::User::Types::User] - }, optional: false, nullable: false, api_name: "userList" + field :user_list, -> { Internal::Types::Array[Seed::User::Types::User] }, optional: false, nullable: false, api_name: "userList" field :optional_deadline, -> { String }, optional: true, nullable: false, api_name: "optionalDeadline" - field :key_value, -> { - Internal::Types::Hash[String, String] - }, optional: false, nullable: false, api_name: "keyValue" + field :key_value, -> { Internal::Types::Hash[String, String] }, optional: false, nullable: false, api_name: "keyValue" field :optional_string, -> { String }, optional: true, nullable: false, api_name: "optionalString" - field :nested_user, -> { - Seed::User::Types::NestedUser - }, optional: false, nullable: false, api_name: "nestedUser" + field :nested_user, -> { Seed::User::Types::NestedUser }, optional: false, nullable: false, api_name: "nestedUser" field :optional_user, -> { Seed::User::Types::User }, optional: true, nullable: false, api_name: "optionalUser" field :exclude_user, -> { Seed::User::Types::User }, optional: false, nullable: false, api_name: "excludeUser" field :filter, -> { String }, optional: false, nullable: false diff --git a/seed/ruby-sdk-v2/request-parameters/reference.md b/seed/ruby-sdk-v2/request-parameters/reference.md index 9a21bc3d1280..173155592861 100644 --- a/seed/ruby-sdk-v2/request-parameters/reference.md +++ b/seed/ruby-sdk-v2/request-parameters/reference.md @@ -130,7 +130,7 @@ client.user.create_username_with_referenced_type(tags: ['tags', 'tags']);
```ruby -client.user.create_username_optional(); +client.user.create_username_optional(request: {}); ```
diff --git a/seed/ruby-sdk-v2/request-parameters/seed.gemspec b/seed/ruby-sdk-v2/request-parameters/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/request-parameters/seed.gemspec +++ b/seed/ruby-sdk-v2/request-parameters/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/request-parameters/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/required-nullable/.rubocop.yml b/seed/ruby-sdk-v2/required-nullable/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/required-nullable/.rubocop.yml +++ b/seed/ruby-sdk-v2/required-nullable/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/required-nullable/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/required-nullable/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/required-nullable/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/required-nullable/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/required-nullable/seed.gemspec b/seed/ruby-sdk-v2/required-nullable/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/required-nullable/seed.gemspec +++ b/seed/ruby-sdk-v2/required-nullable/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/required-nullable/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/reserved-keywords/.rubocop.yml b/seed/ruby-sdk-v2/reserved-keywords/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/.rubocop.yml +++ b/seed/ruby-sdk-v2/reserved-keywords/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/reserved-keywords/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/reserved-keywords/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/reserved-keywords/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/reserved-keywords/lib/seed/package/client.rb b/seed/ruby-sdk-v2/reserved-keywords/lib/seed/package/client.rb index 302295a76488..f6960f1ed788 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/lib/seed/package/client.rb +++ b/seed/ruby-sdk-v2/reserved-keywords/lib/seed/package/client.rb @@ -31,7 +31,8 @@ def test(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/reserved-keywords/seed.gemspec b/seed/ruby-sdk-v2/reserved-keywords/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/seed.gemspec +++ b/seed/ruby-sdk-v2/reserved-keywords/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/reserved-keywords/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/response-property/.rubocop.yml b/seed/ruby-sdk-v2/response-property/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/response-property/.rubocop.yml +++ b/seed/ruby-sdk-v2/response-property/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example0/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example0/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example1/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example1/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example2/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example2/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example3/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example3/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example4/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example4/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example5/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example5/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example6/snippet.rb index 56b6b066fbd6..09c03e4f276c 100644 --- a/seed/ruby-sdk-v2/response-property/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/response-property/dynamic-snippets/example6/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); diff --git a/seed/ruby-sdk-v2/response-property/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/response-property/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/response-property/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/response-property/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/response-property/reference.md b/seed/ruby-sdk-v2/response-property/reference.md index 1a053c637c77..516b9a1eee8c 100644 --- a/seed/ruby-sdk-v2/response-property/reference.md +++ b/seed/ruby-sdk-v2/response-property/reference.md @@ -13,7 +13,7 @@
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -53,7 +53,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -93,7 +93,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -133,7 +133,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -173,7 +173,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -213,7 +213,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
@@ -253,7 +253,7 @@ client.service.get_optional_movie_docs();
```ruby -client.service.get_optional_movie_docs(); +client.service.get_movie(request: 'string'); ```
diff --git a/seed/ruby-sdk-v2/response-property/seed.gemspec b/seed/ruby-sdk-v2/response-property/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/response-property/seed.gemspec +++ b/seed/ruby-sdk-v2/response-property/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/response-property/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/.rubocop.yml b/seed/ruby-sdk-v2/ruby-reserved-word-properties/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/.rubocop.yml +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/service/types/foo.rb b/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/service/types/foo.rb index 5074a73ad3c5..df6657173104 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/service/types/foo.rb +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/lib/seed/service/types/foo.rb @@ -22,16 +22,10 @@ class Foo < Internal::Types::Model field :extend_, -> { String }, optional: false, nullable: false, api_name: "extend" field :singleton_class_, -> { String }, optional: false, nullable: false, api_name: "singleton_class" field :instance_variables_, -> { String }, optional: false, nullable: false, api_name: "instance_variables" - field :instance_variable_get_, -> { - String - }, optional: false, nullable: false, api_name: "instance_variable_get" - field :instance_variable_set_, -> { - String - }, optional: false, nullable: false, api_name: "instance_variable_set" + field :instance_variable_get_, -> { String }, optional: false, nullable: false, api_name: "instance_variable_get" + field :instance_variable_set_, -> { String }, optional: false, nullable: false, api_name: "instance_variable_set" field :instance_variable_defined, -> { String }, optional: false, nullable: false - field :remove_instance_variable_, -> { - String - }, optional: false, nullable: false, api_name: "remove_instance_variable" + field :remove_instance_variable_, -> { String }, optional: false, nullable: false, api_name: "remove_instance_variable" field :public_methods_, -> { String }, optional: false, nullable: false, api_name: "public_methods" field :private_methods_, -> { String }, optional: false, nullable: false, api_name: "private_methods" field :protected_methods_, -> { String }, optional: false, nullable: false, api_name: "protected_methods" diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/seed.gemspec b/seed/ruby-sdk-v2/ruby-reserved-word-properties/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/seed.gemspec +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/ruby-reserved-word-properties/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/.rubocop.yml b/seed/ruby-sdk-v2/server-sent-event-examples/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/.rubocop.yml +++ b/seed/ruby-sdk-v2/server-sent-event-examples/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/completions/client.rb b/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/completions/client.rb index b80b4356b68f..9b52ca8e3e9d 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/completions/client.rb +++ b/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/completions/client.rb @@ -27,7 +27,8 @@ def stream(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "stream", - body: Seed::Completions::Types::StreamCompletionRequest.new(body_bag).to_h + body: Seed::Completions::Types::StreamCompletionRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/server-sent-event-examples/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/seed.gemspec b/seed/ruby-sdk-v2/server-sent-event-examples/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/seed.gemspec +++ b/seed/ruby-sdk-v2/server-sent-event-examples/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/server-sent-event-examples/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/server-sent-events/.rubocop.yml b/seed/ruby-sdk-v2/server-sent-events/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/server-sent-events/.rubocop.yml +++ b/seed/ruby-sdk-v2/server-sent-events/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/server-sent-events/lib/seed/completions/client.rb b/seed/ruby-sdk-v2/server-sent-events/lib/seed/completions/client.rb index b80b4356b68f..9b52ca8e3e9d 100644 --- a/seed/ruby-sdk-v2/server-sent-events/lib/seed/completions/client.rb +++ b/seed/ruby-sdk-v2/server-sent-events/lib/seed/completions/client.rb @@ -27,7 +27,8 @@ def stream(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "stream", - body: Seed::Completions::Types::StreamCompletionRequest.new(body_bag).to_h + body: Seed::Completions::Types::StreamCompletionRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/server-sent-events/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/server-sent-events/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/server-sent-events/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/server-sent-events/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/server-sent-events/seed.gemspec b/seed/ruby-sdk-v2/server-sent-events/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/server-sent-events/seed.gemspec +++ b/seed/ruby-sdk-v2/server-sent-events/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/server-sent-events/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/simple-api/.rubocop.yml b/seed/ruby-sdk-v2/simple-api/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/simple-api/.rubocop.yml +++ b/seed/ruby-sdk-v2/simple-api/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/simple-api/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/simple-api/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/simple-api/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/simple-api/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/simple-api/seed.gemspec b/seed/ruby-sdk-v2/simple-api/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/simple-api/seed.gemspec +++ b/seed/ruby-sdk-v2/simple-api/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/simple-api/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/simple-fhir/.rubocop.yml b/seed/ruby-sdk-v2/simple-fhir/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/simple-fhir/.rubocop.yml +++ b/seed/ruby-sdk-v2/simple-fhir/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/simple-fhir/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/simple-fhir/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/simple-fhir/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/simple-fhir/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/simple-fhir/lib/seed/types/base_resource.rb b/seed/ruby-sdk-v2/simple-fhir/lib/seed/types/base_resource.rb index 605e1e08a71c..1b674024c147 100644 --- a/seed/ruby-sdk-v2/simple-fhir/lib/seed/types/base_resource.rb +++ b/seed/ruby-sdk-v2/simple-fhir/lib/seed/types/base_resource.rb @@ -4,9 +4,7 @@ module Seed module Types class BaseResource < Internal::Types::Model field :id, -> { String }, optional: false, nullable: false - field :related_resources, -> { - Internal::Types::Array[Seed::Types::ResourceList] - }, optional: false, nullable: false + field :related_resources, -> { Internal::Types::Array[Seed::Types::ResourceList] }, optional: false, nullable: false field :memo, -> { Seed::Types::Memo }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/simple-fhir/seed.gemspec b/seed/ruby-sdk-v2/simple-fhir/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/simple-fhir/seed.gemspec +++ b/seed/ruby-sdk-v2/simple-fhir/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/simple-fhir/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/http/raw_client.rb index b79f4d9125ef..3370a92b608b 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/http/raw_client.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/http/raw_client.rb @@ -45,7 +45,8 @@ def send(request) # @return [URI::Generic] The URL. def build_url(request) path = request.path.start_with?("/") ? request.path[1..] : request.path - url = "#{@base_url.chomp("/")}/#{path}" + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" url = "#{url}?#{encode_query(request.query)}" if request.query&.any? URI.parse(url) end @@ -94,6 +95,11 @@ def connect(url) http.max_retries = @max_retries http end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_item_iterator.rb index 8189180b2041..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -11,6 +11,7 @@ class CursorItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_item_iterator.rb index c5f46f8033a9..f8840246686d 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_item_iterator.rb @@ -13,6 +13,7 @@ class OffsetItemIterator < ItemIterator # # @return [Seed::Internal::OffsetItemIterator] def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/json/request.rb index 93db7f188cf2..15773d44c641 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/json/request.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/json/request.rb @@ -22,10 +22,11 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => "application/json", "Accept" => "application/json" - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/multipart/multipart_request.rb index d87eea059db1..915dada8c56e 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/multipart/multipart_request.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/multipart/multipart_request.rb @@ -22,9 +22,10 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => @body.content_type - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/enum.rb index af56cf76b98c..72e45e4c1f27 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/enum.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/enum.rb @@ -39,6 +39,14 @@ def coerce(value, strict: strict?) value end + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + def inspect "#{name}[#{values.join(", ")}]" end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model.rb index 515b63fbaa25..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) @@ -187,7 +187,9 @@ def ==(other) # @return [String] def inspect attrs = @data.map do |name, value| - "#{name}=#{value.inspect}" + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" end "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model/field.rb index 5294b2710a0d..6ce0186f6a5d 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model/field.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/model/field.rb @@ -6,6 +6,11 @@ module Types class Model # Definition of a field on a model class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) @@ -21,6 +26,11 @@ def initialize(name:, type:, optional: false, nullable: false, api_name: nil, va def literal? !value.nil? end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/union.rb index 868ab392ebb9..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/union.rb @@ -100,6 +100,14 @@ def coerce(value, strict: strict?) Utils.coerce(type, value, strict: strict) end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_offset_item_iterator.rb index a94fde9e1c15..92576b820128 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -66,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -83,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -98,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/types/test_model.rb index 7412306821a6..3d87b9f5a8c7 100644 --- a/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/types/test_model.rb +++ b/seed/ruby-sdk-v2/single-url-environment-default/test/unit/internal/types/test_model.rb @@ -111,4 +111,44 @@ class ExampleParent < Seed::Internal::Types::Model refute_respond_to example, :yearOfRelease end end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/http/raw_client.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/http/raw_client.rb index b79f4d9125ef..3370a92b608b 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/http/raw_client.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/http/raw_client.rb @@ -45,7 +45,8 @@ def send(request) # @return [URI::Generic] The URL. def build_url(request) path = request.path.start_with?("/") ? request.path[1..] : request.path - url = "#{@base_url.chomp("/")}/#{path}" + base = request.base_url || @base_url + url = "#{base.chomp("/")}/#{path}" url = "#{url}?#{encode_query(request.query)}" if request.query&.any? URI.parse(url) end @@ -94,6 +95,11 @@ def connect(url) http.max_retries = @max_retries http end + + # @return [String] + def inspect + "#<#{self.class.name}:0x#{object_id.to_s(16)} @base_url=#{@base_url.inspect}>" + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb index 8189180b2041..ab627ffc7025 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_item_iterator.rb @@ -11,6 +11,7 @@ class CursorItemIterator < ItemIterator # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Seed::Internal::CursorItemIterator] def initialize(initial_cursor:, cursor_field:, item_field:, &) + super() @item_field = item_field @page_iterator = CursorPageIterator.new(initial_cursor:, cursor_field:, &) @page = nil diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb index 8cbfb77a936a..f479a749fef9 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/cursor_page_iterator.rb @@ -23,7 +23,7 @@ def initialize(initial_cursor:, cursor_field:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -31,20 +31,20 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? @need_initial_load || !@cursor.nil? end # Retrieves the next page from the API. # # @return [Boolean] - def get_next + def next_page return if !@need_initial_load && @cursor.nil? @need_initial_load = false - next_page = @get_next_page.call(@cursor) - @cursor = next_page.send(@cursor_field) - next_page + fetched_page = @get_next_page.call(@cursor) + @cursor = fetched_page.send(@cursor_field) + fetched_page end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb index c6974bc0f3a2..1284fb0fd367 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/item_iterator.rb @@ -10,7 +10,7 @@ class ItemIterator # @param block [Proc] The block which each retrieved item is yielded to. # @return [NilClass] def each(&block) - while (item = get_next) + while (item = next_element) block.call(item) end end @@ -18,18 +18,18 @@ def each(&block) # Whether another item will be available from the API. # # @return [Boolean] - def has_next? + def next? load_next_page if @page.nil? return false if @page.nil? - return true if any_items_in_cached_page + return true if any_items_in_cached_page? load_next_page - any_items_in_cached_page + any_items_in_cached_page? end # Retrieves the next item from the API. - def get_next + def next_element item = next_item_from_cached_page return item if item @@ -45,14 +45,14 @@ def next_item_from_cached_page @page.send(@item_field).shift end - def any_items_in_cached_page + def any_items_in_cached_page? return false unless @page !@page.send(@item_field).empty? end def load_next_page - @page = @page_iterator.get_next + @page = @page_iterator.next_page end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb index c5f46f8033a9..f8840246686d 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_item_iterator.rb @@ -13,6 +13,7 @@ class OffsetItemIterator < ItemIterator # # @return [Seed::Internal::OffsetItemIterator] def initialize(initial_page:, item_field:, has_next_field:, step:, &) + super() @item_field = item_field @page_iterator = OffsetPageIterator.new(initial_page:, item_field:, has_next_field:, step:, &) @page = nil diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb index 8e676725b538..051b65c5774c 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/iterators/offset_page_iterator.rb @@ -31,7 +31,7 @@ def initialize(initial_page:, item_field:, has_next_field:, step:, &block) # @param block [Proc] The block which each retrieved page is yielded to. # @return [NilClass] def each(&block) - while (page = get_next) + while (page = next_page) block.call(page) end end @@ -39,22 +39,22 @@ def each(&block) # Whether another page will be available from the API. # # @return [Boolean] - def has_next? + def next? return @has_next_page unless @has_next_page.nil? return true if @next_page - next_page = @get_next_page.call(@page_number) - next_page_items = next_page&.send(@item_field) - if next_page_items.nil? || next_page_items.empty? + fetched_page = @get_next_page.call(@page_number) + fetched_page_items = fetched_page&.send(@item_field) + if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else - @next_page = next_page + @next_page = fetched_page true end end # Returns the next page from the API. - def get_next + def next_page return nil if @page_number.nil? if @next_page diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/json/request.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/json/request.rb index 93db7f188cf2..15773d44c641 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/json/request.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/json/request.rb @@ -22,10 +22,11 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => "application/json", "Accept" => "application/json" - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb index d87eea059db1..915dada8c56e 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/multipart/multipart_request.rb @@ -22,9 +22,10 @@ def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, req # @return [Hash] The encoded HTTP request headers. def encode_headers + additional_headers = @request_options&.dig(:additional_headers) || @request_options&.dig("additional_headers") || {} { "Content-Type" => @body.content_type - }.merge(@headers) + }.merge(@headers).merge(additional_headers) end # @return [String, nil] The encoded HTTP request body. diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/enum.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/enum.rb index af56cf76b98c..72e45e4c1f27 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/enum.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/enum.rb @@ -39,6 +39,14 @@ def coerce(value, strict: strict?) value end + # Parse JSON string and coerce to the enum value + # + # @param str [String] JSON string to parse + # @return [String] The enum value + def load(str) + coerce(::JSON.parse(str)) + end + def inspect "#{name}[#{values.join(", ")}]" end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model.rb index 515b63fbaa25..9b1480c7333a 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model.rb @@ -112,7 +112,7 @@ def add_extra_field_definition(name:, type:) end end - def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) + def coerce(value, strict: (respond_to?(:strict?) ? strict? : false)) # rubocop:disable Lint/UnusedMethodArgument return value if value.is_a?(self) return value unless value.is_a?(::Hash) @@ -187,7 +187,9 @@ def ==(other) # @return [String] def inspect attrs = @data.map do |name, value| - "#{name}=#{value.inspect}" + field = self.class.fields[name] || self.class.extra_fields[name] + display_value = field&.sensitive? ? "[REDACTED]" : value.inspect + "#{name}=#{display_value}" end "#<#{self.class.name}:0x#{object_id&.to_s(16)} #{attrs.join(" ")}>" diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model/field.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model/field.rb index 5294b2710a0d..6ce0186f6a5d 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model/field.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/model/field.rb @@ -6,6 +6,11 @@ module Types class Model # Definition of a field on a model class Field + SENSITIVE_FIELD_NAMES = %i[ + password secret token api_key apikey access_token refresh_token + client_secret client_id credential bearer authorization + ].freeze + attr_reader :name, :type, :optional, :nullable, :api_name, :value, :default def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) @@ -21,6 +26,11 @@ def initialize(name:, type:, optional: false, nullable: false, api_name: nil, va def literal? !value.nil? end + + def sensitive? + SENSITIVE_FIELD_NAMES.include?(@name) || + SENSITIVE_FIELD_NAMES.any? { |sensitive| @name.to_s.include?(sensitive.to_s) } + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/union.rb index 868ab392ebb9..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/union.rb @@ -100,6 +100,14 @@ def coerce(value, strict: strict?) Utils.coerce(type, value, strict: strict) end + + # Parse JSON string and coerce to the correct union member type + # + # @param str [String] JSON string to parse + # @return [Object] Coerced value matching a union member + def load(str) + coerce(::JSON.parse(str, symbolize_names: true)) + end end end end diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/utils.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/utils.rb index 917edbd73d76..4685ec234596 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/utils.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/lib/seed/internal/types/utils.rb @@ -75,9 +75,10 @@ def self.coerce(target, value, strict: false) end in Module case type - in ->(t) { t.singleton_class.included_modules.include?(Enum) } - return type.coerce(value, strict: strict) - in ->(t) { t.singleton_class.included_modules.include?(Union) } + in ->(t) { + t.singleton_class.included_modules.include?(Enum) || + t.singleton_class.included_modules.include?(Union) + } return type.coerce(value, strict: strict) else value diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0a5a88f5bab0..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) @@ -85,11 +85,11 @@ def test_items_iterator_can_be_advanced_manually items = [] expected_times_called = 0 - while (item = iterator.get_next) + while (item = iterator.next_element) expected_times_called += 1 if (item % 10) == 1 assert_equal expected_times_called, @times_called - assert_equal item != NUMBERS.last, iterator.has_next?, "#{item} #{iterator}" + assert_equal item != NUMBERS.last, iterator.next?, "#{item} #{iterator}" items.push(item) end @@ -155,7 +155,7 @@ def test_pages_iterator_knows_whether_another_page_is_upcoming iterator.each_with_index do |_page, index| assert_equal index + 1, @times_called - assert_equal index < 6, iterator.has_next? + assert_equal index < 6, iterator.next? end end @@ -166,7 +166,7 @@ def test_pages_iterator_can_be_advanced_manually lengths = [] expected_times_called = 0 - while (page = iterator.get_next) + while (page = iterator.next_page) expected_times_called += 1 assert_equal expected_times_called, @times_called diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb index a94fde9e1c15..92576b820128 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -66,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end @@ -83,8 +83,8 @@ def test_items_iterator_can_be_advanced_manually_and_has_accurate_has_next iterator = make_iterator(config) items = [] - while (item = iterator.get_next) - assert_equal(item != config.total_item_count, iterator.has_next?, "#{item} #{iterator}") + while (item = iterator.next_element) + assert_equal(item != config.total_item_count, iterator.next?, "#{item} #{iterator}") items.push(item) end @@ -98,10 +98,10 @@ def test_pages_iterator_can_be_advanced_manually_and_has_accurate_has_next pages = [] loop do - has_next_output = iterator.has_next? - page = iterator.get_next + has_next_output = iterator.next? + page = iterator.next_page - assert_equal(has_next_output, !page.nil?, "has_next was inaccurate: #{config} #{iterator.inspect}") + assert_equal(has_next_output, !page.nil?, "next? was inaccurate: #{config} #{iterator.inspect}") break if page.nil? pages.push(page) diff --git a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/types/test_model.rb b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/types/test_model.rb index 7412306821a6..3d87b9f5a8c7 100644 --- a/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/types/test_model.rb +++ b/seed/ruby-sdk-v2/single-url-environment-no-default/test/unit/internal/types/test_model.rb @@ -111,4 +111,44 @@ class ExampleParent < Seed::Internal::Types::Model refute_respond_to example, :yearOfRelease end end + + describe "#inspect" do + class SensitiveModel < Seed::Internal::Types::Model + field :username, String + field :password, String + field :client_secret, String + field :access_token, String + field :api_key, String + end + + it "redacts sensitive fields" do + model = SensitiveModel.new( + username: "user123", + password: "secret123", + client_secret: "cs_abc", + access_token: "token_xyz", + api_key: "key_123" + ) + + inspect_output = model.inspect + + assert_includes inspect_output, "username=\"user123\"" + assert_includes inspect_output, "password=[REDACTED]" + assert_includes inspect_output, "client_secret=[REDACTED]" + assert_includes inspect_output, "access_token=[REDACTED]" + assert_includes inspect_output, "api_key=[REDACTED]" + refute_includes inspect_output, "secret123" + refute_includes inspect_output, "cs_abc" + refute_includes inspect_output, "token_xyz" + refute_includes inspect_output, "key_123" + end + + it "does not redact non-sensitive fields" do + example = ExampleModel.new(name: "Inception", rating: 4) + inspect_output = example.inspect + + assert_includes inspect_output, "name=\"Inception\"" + assert_includes inspect_output, "rating=4" + end + end end diff --git a/seed/ruby-sdk-v2/streaming-parameter/.rubocop.yml b/seed/ruby-sdk-v2/streaming-parameter/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/.rubocop.yml +++ b/seed/ruby-sdk-v2/streaming-parameter/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/streaming-parameter/lib/seed/dummy/client.rb b/seed/ruby-sdk-v2/streaming-parameter/lib/seed/dummy/client.rb index 4ab3d853a453..38d2170c8b5c 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/lib/seed/dummy/client.rb +++ b/seed/ruby-sdk-v2/streaming-parameter/lib/seed/dummy/client.rb @@ -27,7 +27,8 @@ def generate(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "generate", - body: Seed::Dummy::Types::GenerateRequest.new(body_bag).to_h + body: Seed::Dummy::Types::GenerateRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/streaming-parameter/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/streaming-parameter/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/streaming-parameter/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/streaming-parameter/seed.gemspec b/seed/ruby-sdk-v2/streaming-parameter/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/seed.gemspec +++ b/seed/ruby-sdk-v2/streaming-parameter/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/streaming-parameter/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/streaming/.rubocop.yml b/seed/ruby-sdk-v2/streaming/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/streaming/.rubocop.yml +++ b/seed/ruby-sdk-v2/streaming/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/streaming/lib/seed/dummy/client.rb b/seed/ruby-sdk-v2/streaming/lib/seed/dummy/client.rb index eb2f70532373..6e74b35bfe37 100644 --- a/seed/ruby-sdk-v2/streaming/lib/seed/dummy/client.rb +++ b/seed/ruby-sdk-v2/streaming/lib/seed/dummy/client.rb @@ -27,7 +27,8 @@ def generate_stream(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "generate-stream", - body: Seed::Dummy::Types::GenerateStreamRequest.new(body_bag).to_h + body: Seed::Dummy::Types::GenerateStreamRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -58,7 +59,8 @@ def generate(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "generate", - body: Seed::Dummy::Types::Generateequest.new(body_bag).to_h + body: Seed::Dummy::Types::Generateequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/streaming/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/streaming/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/streaming/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/streaming/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/streaming/seed.gemspec b/seed/ruby-sdk-v2/streaming/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/streaming/seed.gemspec +++ b/seed/ruby-sdk-v2/streaming/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/streaming/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/trace/.rubocop.yml b/seed/ruby-sdk-v2/trace/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/trace/.rubocop.yml +++ b/seed/ruby-sdk-v2/trace/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example1/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example1/snippet.rb index 4148dec18207..cef40b048b31 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example1/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example1/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.admin.update_test_submission_status(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.update_test_submission_status( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: {} +); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example10/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example10/snippet.rb index 3b5df2983338..a43e0cf244e0 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example10/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example10/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.homepage.set_homepage_problems(); +client.homepage.set_homepage_problems(request: ['string', 'string']); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example17/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example17/snippet.rb index 8db4eb492c9a..84235e8a5042 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example17/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example17/snippet.rb @@ -7,5 +7,9 @@ client.playlist.update_playlist( service_param: 1, - playlist_id: 'playlistId' + playlist_id: 'playlistId', + request: { + name: 'name', + problems: ['problems', 'problems'] + } ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example18/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example18/snippet.rb index 8db4eb492c9a..84235e8a5042 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example18/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example18/snippet.rb @@ -7,5 +7,9 @@ client.playlist.update_playlist( service_param: 1, - playlist_id: 'playlistId' + playlist_id: 'playlistId', + request: { + name: 'name', + problems: ['problems', 'problems'] + } ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example2/snippet.rb index 84cc01010317..e376e6089ef8 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example2/snippet.rb @@ -7,5 +7,6 @@ client.admin.send_test_submission_update( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - update_time: '2024-01-15T09:30:00Z' + update_time: '2024-01-15T09:30:00Z', + update_info: {} ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example20/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example20/snippet.rb index 25b5348a67ff..6b07f1d6b278 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example20/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example20/snippet.rb @@ -8,24 +8,43 @@ client.problem.create_problem( problem_name: 'problemName', problem_description: { - boards: [] + boards: [{}, {}] + }, + files: { + JAVA: { + solution_file: { + filename: 'filename', + contents: 'contents' + }, + read_only_files: [{ + filename: 'filename', + contents: 'contents' + }, { + filename: 'filename', + contents: 'contents' + }] + } }, - files: {}, input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, testcases: [{ test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }, { test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }], method_name: 'methodName' ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example21/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example21/snippet.rb index e85bd1042c9d..b71c3fd72baa 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example21/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example21/snippet.rb @@ -9,24 +9,43 @@ problem_id: 'problemId', problem_name: 'problemName', problem_description: { - boards: [] + boards: [{}, {}] + }, + files: { + JAVA: { + solution_file: { + filename: 'filename', + contents: 'contents' + }, + read_only_files: [{ + filename: 'filename', + contents: 'contents' + }, { + filename: 'filename', + contents: 'contents' + }] + } }, - files: {}, input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, testcases: [{ test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }, { test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }], method_name: 'methodName' ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example23/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example23/snippet.rb index f728f8696a67..57451772bffb 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example23/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example23/snippet.rb @@ -7,9 +7,12 @@ client.problem.get_default_starter_files( input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, method_name: 'methodName' ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example24/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example24/snippet.rb index 86059a8e73c1..606d7edd0d9a 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example24/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example24/snippet.rb @@ -5,4 +5,4 @@ base_url: 'https://api.fern.com' ); -client.submission.create_execution_session(); +client.submission.create_execution_session(language: 'JAVA'); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example28/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example28/snippet.rb index e0a521ea25de..7a2565c19273 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example28/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example28/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.sysprop.set_num_warm_instances(num_warm_instances: 1); +client.sysprop.set_num_warm_instances( + language: 'JAVA', + num_warm_instances: 1 +); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example3/snippet.rb index 3758c816a4b3..2c49224b83b8 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example3/snippet.rb @@ -5,4 +5,7 @@ base_url: 'https://api.fern.com' ); -client.admin.update_workspace_submission_status(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.update_workspace_submission_status( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: {} +); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example4/snippet.rb index 97c3d1189b08..b45799f9266b 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example4/snippet.rb @@ -7,5 +7,6 @@ client.admin.send_workspace_submission_update( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - update_time: '2024-01-15T09:30:00Z' + update_time: '2024-01-15T09:30:00Z', + update_info: {} ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example5/snippet.rb index dacf385b3576..7145385d9605 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example5/snippet.rb @@ -10,6 +10,10 @@ test_case_id: 'testCaseId', result: { result: { + expected_result: {}, + actual_result: { + value: {} + }, passed: true }, stdout: 'stdout' @@ -17,6 +21,7 @@ trace_responses: [{ submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -27,9 +32,13 @@ method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -37,6 +46,7 @@ }, { submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -47,9 +57,13 @@ method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example6/snippet.rb index 966b7eb0b8a4..5f2dbb63f27f 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example6/snippet.rb @@ -7,5 +7,64 @@ client.admin.store_traced_test_case_v_2( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - test_case_id: 'testCaseId' + test_case_id: 'testCaseId', + request: [{ + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }, { + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }] ); diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example7/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example7/snippet.rb index 7f83cd16f8b2..d5d51d596ab8 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example7/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example7/snippet.rb @@ -18,6 +18,7 @@ trace_responses: [{ submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -28,9 +29,13 @@ method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -38,6 +43,7 @@ }, { submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -48,9 +54,13 @@ method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, diff --git a/seed/ruby-sdk-v2/trace/dynamic-snippets/example8/snippet.rb b/seed/ruby-sdk-v2/trace/dynamic-snippets/example8/snippet.rb index 71d59cbaabe8..22171c2ec5ac 100644 --- a/seed/ruby-sdk-v2/trace/dynamic-snippets/example8/snippet.rb +++ b/seed/ruby-sdk-v2/trace/dynamic-snippets/example8/snippet.rb @@ -5,4 +5,65 @@ base_url: 'https://api.fern.com' ); -client.admin.store_traced_workspace_v_2(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.store_traced_workspace_v_2( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: [{ + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }, { + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }] +); diff --git a/seed/ruby-sdk-v2/trace/lib/seed/admin/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/admin/client.rb index 756adaa67c12..1980a6d55590 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/admin/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/admin/client.rb @@ -22,10 +22,11 @@ def initialize(client:) # @return [untyped] def update_test_submission_status(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-test-submission-status/#{params[:submission_id]}", - body: Seed::Submission::Types::TestSubmissionStatus.new(params).to_h + body: Seed::Submission::Types::TestSubmissionStatus.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -51,10 +52,11 @@ def update_test_submission_status(request_options: {}, **params) # @return [untyped] def send_test_submission_update(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-test-submission-status-v2/#{params[:submission_id]}", - body: Seed::Submission::Types::TestSubmissionUpdate.new(params).to_h + body: Seed::Submission::Types::TestSubmissionUpdate.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -80,10 +82,11 @@ def send_test_submission_update(request_options: {}, **params) # @return [untyped] def update_workspace_submission_status(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-workspace-submission-status/#{params[:submission_id]}", - body: Seed::Submission::Types::WorkspaceSubmissionStatus.new(params).to_h + body: Seed::Submission::Types::WorkspaceSubmissionStatus.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -109,10 +112,11 @@ def update_workspace_submission_status(request_options: {}, **params) # @return [untyped] def send_workspace_submission_update(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-workspace-submission-status-v2/#{params[:submission_id]}", - body: Seed::Submission::Types::WorkspaceSubmissionUpdate.new(params).to_h + body: Seed::Submission::Types::WorkspaceSubmissionUpdate.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -144,10 +148,11 @@ def store_traced_test_case(request_options: {}, **params) body_bag = body_params.slice(*body_prop_names) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-test-trace/submission/#{params[:submission_id]}/testCase/#{params[:test_case_id]}", - body: Seed::Admin::Types::StoreTracedTestCaseRequest.new(body_bag).to_h + body: Seed::Admin::Types::StoreTracedTestCaseRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -174,10 +179,11 @@ def store_traced_test_case(request_options: {}, **params) # @return [untyped] def store_traced_test_case_v_2(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-test-trace-v2/submission/#{params[:submission_id]}/testCase/#{params[:test_case_id]}", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) @@ -208,10 +214,11 @@ def store_traced_workspace(request_options: {}, **params) body_bag = body_params.slice(*body_prop_names) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-workspace-trace/submission/#{params[:submission_id]}", - body: Seed::Admin::Types::StoreTracedWorkspaceRequest.new(body_bag).to_h + body: Seed::Admin::Types::StoreTracedWorkspaceRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -237,10 +244,11 @@ def store_traced_workspace(request_options: {}, **params) # @return [untyped] def store_traced_workspace_v_2(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/admin/store-workspace-trace-v2/submission/#{params[:submission_id]}", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_test_case_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_test_case_request.rb index 80fcfe72e6a7..da590b59d77e 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_test_case_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_test_case_request.rb @@ -7,9 +7,7 @@ class StoreTracedTestCaseRequest < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :test_case_id, -> { String }, optional: false, nullable: false, api_name: "testCaseId" field :result, -> { Seed::Submission::Types::TestCaseResultWithStdout }, optional: false, nullable: false - field :trace_responses, -> { - Internal::Types::Array[Seed::Submission::Types::TraceResponse] - }, optional: false, nullable: false, api_name: "traceResponses" + field :trace_responses, -> { Internal::Types::Array[Seed::Submission::Types::TraceResponse] }, optional: false, nullable: false, api_name: "traceResponses" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_workspace_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_workspace_request.rb index 33b815501e61..1df792b992be 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_workspace_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/admin/types/store_traced_workspace_request.rb @@ -5,12 +5,8 @@ module Admin module Types class StoreTracedWorkspaceRequest < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" - field :workspace_run_details, -> { - Seed::Submission::Types::WorkspaceRunDetails - }, optional: false, nullable: false, api_name: "workspaceRunDetails" - field :trace_responses, -> { - Internal::Types::Array[Seed::Submission::Types::TraceResponse] - }, optional: false, nullable: false, api_name: "traceResponses" + field :workspace_run_details, -> { Seed::Submission::Types::WorkspaceRunDetails }, optional: false, nullable: false, api_name: "workspaceRunDetails" + field :trace_responses, -> { Internal::Types::Array[Seed::Submission::Types::TraceResponse] }, optional: false, nullable: false, api_name: "traceResponses" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/client.rb index 1cfacd517a2e..62974bf4ceca 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/client.rb @@ -8,7 +8,7 @@ class Client # @return [void] def initialize(base_url:, token:) @raw_client = Seed::Internal::Http::RawClient.new( - base_url: base_url, + base_url: base_url || Seed::Environment::PROD, headers: { "User-Agent" => "fern_trace/0.0.1", "X-Fern-Language" => "Ruby", diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_node_and_tree_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_node_and_tree_value.rb index ebaef41cd879..1e38121616b6 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_node_and_tree_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_node_and_tree_value.rb @@ -5,9 +5,7 @@ module Commons module Types class BinaryTreeNodeAndTreeValue < Internal::Types::Model field :node_id, -> { String }, optional: false, nullable: false, api_name: "nodeId" - field :full_tree, -> { - Seed::Commons::Types::BinaryTreeValue - }, optional: false, nullable: false, api_name: "fullTree" + field :full_tree, -> { Seed::Commons::Types::BinaryTreeValue }, optional: false, nullable: false, api_name: "fullTree" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_value.rb index d4360e44a0fd..5b667b96f1c4 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/binary_tree_value.rb @@ -5,9 +5,7 @@ module Commons module Types class BinaryTreeValue < Internal::Types::Model field :root, -> { String }, optional: true, nullable: false - field :nodes, -> { - Internal::Types::Hash[String, Seed::Commons::Types::BinaryTreeNodeValue] - }, optional: false, nullable: false + field :nodes, -> { Internal::Types::Hash[String, Seed::Commons::Types::BinaryTreeNodeValue] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/debug_map_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/debug_map_value.rb index f901f43d485b..98c173e3b0d0 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/debug_map_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/debug_map_value.rb @@ -4,9 +4,7 @@ module Seed module Commons module Types class DebugMapValue < Internal::Types::Model - field :key_value_pairs, -> { - Internal::Types::Array[Seed::Commons::Types::DebugKeyValuePairs] - }, optional: false, nullable: false, api_name: "keyValuePairs" + field :key_value_pairs, -> { Internal::Types::Array[Seed::Commons::Types::DebugKeyValuePairs] }, optional: false, nullable: false, api_name: "keyValuePairs" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_node_and_list_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_node_and_list_value.rb index 7234a561ada6..2e849281e6f0 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_node_and_list_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_node_and_list_value.rb @@ -5,9 +5,7 @@ module Commons module Types class DoublyLinkedListNodeAndListValue < Internal::Types::Model field :node_id, -> { String }, optional: false, nullable: false, api_name: "nodeId" - field :full_list, -> { - Seed::Commons::Types::DoublyLinkedListValue - }, optional: false, nullable: false, api_name: "fullList" + field :full_list, -> { Seed::Commons::Types::DoublyLinkedListValue }, optional: false, nullable: false, api_name: "fullList" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_value.rb index 98b8e6c543e4..fdb3c639a7ea 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/doubly_linked_list_value.rb @@ -5,9 +5,7 @@ module Commons module Types class DoublyLinkedListValue < Internal::Types::Model field :head, -> { String }, optional: true, nullable: false - field :nodes, -> { - Internal::Types::Hash[String, Seed::Commons::Types::DoublyLinkedListNodeValue] - }, optional: false, nullable: false + field :nodes, -> { Internal::Types::Hash[String, Seed::Commons::Types::DoublyLinkedListNodeValue] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/list_type.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/list_type.rb index dd6794bb33b1..39685736c7c9 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/list_type.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/list_type.rb @@ -4,12 +4,8 @@ module Seed module Commons module Types class ListType < Internal::Types::Model - field :value_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "valueType" - field :is_fixed_length, -> { - Internal::Types::Boolean - }, optional: true, nullable: false, api_name: "isFixedLength" + field :value_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "valueType" + field :is_fixed_length, -> { Internal::Types::Boolean }, optional: true, nullable: false, api_name: "isFixedLength" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_type.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_type.rb index e2b014ae1c1b..e2d9c5770d34 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_type.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_type.rb @@ -4,12 +4,8 @@ module Seed module Commons module Types class MapType < Internal::Types::Model - field :key_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "keyType" - field :value_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "valueType" + field :key_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "keyType" + field :value_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "valueType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_value.rb index 9340d1549fb4..5e57f6b6f140 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/map_value.rb @@ -4,9 +4,7 @@ module Seed module Commons module Types class MapValue < Internal::Types::Model - field :key_value_pairs, -> { - Internal::Types::Array[Seed::Commons::Types::KeyValuePair] - }, optional: false, nullable: false, api_name: "keyValuePairs" + field :key_value_pairs, -> { Internal::Types::Array[Seed::Commons::Types::KeyValuePair] }, optional: false, nullable: false, api_name: "keyValuePairs" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_node_and_list_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_node_and_list_value.rb index d3768ce9f700..ea83e0960944 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_node_and_list_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_node_and_list_value.rb @@ -5,9 +5,7 @@ module Commons module Types class SinglyLinkedListNodeAndListValue < Internal::Types::Model field :node_id, -> { String }, optional: false, nullable: false, api_name: "nodeId" - field :full_list, -> { - Seed::Commons::Types::SinglyLinkedListValue - }, optional: false, nullable: false, api_name: "fullList" + field :full_list, -> { Seed::Commons::Types::SinglyLinkedListValue }, optional: false, nullable: false, api_name: "fullList" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_value.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_value.rb index e432022970df..c5317d4eff74 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_value.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/singly_linked_list_value.rb @@ -5,9 +5,7 @@ module Commons module Types class SinglyLinkedListValue < Internal::Types::Model field :head, -> { String }, optional: true, nullable: false - field :nodes, -> { - Internal::Types::Hash[String, Seed::Commons::Types::SinglyLinkedListNodeValue] - }, optional: false, nullable: false + field :nodes, -> { Internal::Types::Hash[String, Seed::Commons::Types::SinglyLinkedListNodeValue] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case.rb index 2a108b8a62a5..5441ebf63d92 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case.rb @@ -5,9 +5,7 @@ module Commons module Types class TestCase < Internal::Types::Model field :id, -> { String }, optional: false, nullable: false - field :params, -> { - Internal::Types::Array[Seed::Commons::Types::VariableValue] - }, optional: false, nullable: false + field :params, -> { Internal::Types::Array[Seed::Commons::Types::VariableValue] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case_with_expected_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case_with_expected_result.rb index 74ebcbe9bf40..afc124acf072 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case_with_expected_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/commons/types/test_case_with_expected_result.rb @@ -5,9 +5,7 @@ module Commons module Types class TestCaseWithExpectedResult < Internal::Types::Model field :test_case, -> { Seed::Commons::Types::TestCase }, optional: false, nullable: false, api_name: "testCase" - field :expected_result, -> { - Seed::Commons::Types::VariableValue - }, optional: false, nullable: false, api_name: "expectedResult" + field :expected_result, -> { Seed::Commons::Types::VariableValue }, optional: false, nullable: false, api_name: "expectedResult" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/homepage/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/homepage/client.rb index 56642e916222..063c894e18fb 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/homepage/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/homepage/client.rb @@ -21,7 +21,7 @@ def initialize(client:) # @return [Array[String]] def get_homepage_problems(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/homepage-problems", request_options: request_options @@ -49,7 +49,7 @@ def get_homepage_problems(request_options: {}, **_params) # @return [untyped] def set_homepage_problems(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/homepage-problems", body: params, diff --git a/seed/ruby-sdk-v2/trace/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/trace/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/trace/lib/seed/migration/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/migration/client.rb index 2b6c815b6469..635276d0c106 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/migration/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/migration/client.rb @@ -22,7 +22,7 @@ def initialize(client:) # @return [Array[Seed::Migration::Types::Migration]] def get_attempted_migrations(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/migration-info/all", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/playlist/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/playlist/client.rb index 7d0b6beb085d..70aa2fca06ff 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/playlist/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/playlist/client.rb @@ -36,11 +36,12 @@ def create_playlist(request_options: {}, **params) params = params.except(*query_param_names) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/v2/playlist/#{params[:service_param]}/create", query: query_params, - body: Seed::Playlist::Types::PlaylistCreateRequest.new(body_params).to_h + body: Seed::Playlist::Types::PlaylistCreateRequest.new(body_params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -80,18 +81,16 @@ def get_playlists(request_options: {}, **params) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["otherField"] = params[:other_field] if params.key?(:other_field) query_params["multiLineDocs"] = params[:multi_line_docs] if params.key?(:multi_line_docs) - if params.key?(:optional_multiple_field) - query_params["optionalMultipleField"] = - params[:optional_multiple_field] - end + query_params["optionalMultipleField"] = params[:optional_multiple_field] if params.key?(:optional_multiple_field) query_params["multipleField"] = params[:multiple_field] if params.key?(:multiple_field) params = params.except(*query_param_names) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/v2/playlist/#{params[:service_param]}/all", - query: query_params + query: query_params, + request_options: request_options ) begin response = @client.send(request) @@ -120,9 +119,10 @@ def get_playlists(request_options: {}, **params) # @return [Seed::Playlist::Types::Playlist] def get_playlist(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", - path: "/v2/playlist/#{params[:service_param]}/#{params[:playlist_id]}" + path: "/v2/playlist/#{params[:service_param]}/#{params[:playlist_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -153,10 +153,11 @@ def get_playlist(request_options: {}, **params) # @return [Seed::Playlist::Types::Playlist, nil] def update_playlist(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "PUT", path: "/v2/playlist/#{params[:service_param]}/#{params[:playlist_id]}", - body: params + body: params, + request_options: request_options ) begin response = @client.send(request) @@ -185,9 +186,10 @@ def update_playlist(request_options: {}, **params) # @return [untyped] def delete_playlist(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "DELETE", - path: "/v2/playlist/#{params[:service_param]}/#{params[:playlist_id]}" + path: "/v2/playlist/#{params[:service_param]}/#{params[:playlist_id]}", + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/trace/lib/seed/playlist/types/get_playlists_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/playlist/types/get_playlists_request.rb index 2530535d9e52..a9eaa9261e34 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/playlist/types/get_playlists_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/playlist/types/get_playlists_request.rb @@ -8,9 +8,7 @@ class GetPlaylistsRequest < Internal::Types::Model field :limit, -> { Integer }, optional: true, nullable: false field :other_field, -> { String }, optional: false, nullable: false, api_name: "otherField" field :multi_line_docs, -> { String }, optional: false, nullable: false, api_name: "multiLineDocs" - field :optional_multiple_field, -> { - String - }, optional: true, nullable: false, api_name: "optionalMultipleField" + field :optional_multiple_field, -> { String }, optional: true, nullable: false, api_name: "optionalMultipleField" field :multiple_field, -> { String }, optional: false, nullable: false, api_name: "multipleField" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/client.rb index 8cb72f3b95f1..a66c5ec095e3 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/client.rb @@ -23,10 +23,11 @@ def initialize(client:) # @return [Seed::Problem::Types::CreateProblemResponse] def create_problem(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/problem-crud/create", - body: Seed::Problem::Types::CreateProblemRequest.new(params).to_h + body: Seed::Problem::Types::CreateProblemRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -56,10 +57,11 @@ def create_problem(request_options: {}, **params) # @return [Seed::Problem::Types::UpdateProblemResponse] def update_problem(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/problem-crud/update/#{params[:problem_id]}", - body: Seed::Problem::Types::CreateProblemRequest.new(params).to_h + body: Seed::Problem::Types::CreateProblemRequest.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -89,9 +91,10 @@ def update_problem(request_options: {}, **params) # @return [untyped] def delete_problem(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "DELETE", - path: "/problem-crud/delete/#{params[:problem_id]}" + path: "/problem-crud/delete/#{params[:problem_id]}", + request_options: request_options ) begin response = @client.send(request) @@ -121,10 +124,11 @@ def get_default_starter_files(request_options: {}, **params) body_bag = params.slice(*body_prop_names) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/problem-crud/default-starter-files", - body: Seed::Problem::Types::GetDefaultStarterFilesRequest.new(body_bag).to_h + body: Seed::Problem::Types::GetDefaultStarterFilesRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/create_problem_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/create_problem_request.rb index 82d440ad1090..78a6330d2973 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/create_problem_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/create_problem_request.rb @@ -5,21 +5,11 @@ module Problem module Types class CreateProblemRequest < Internal::Types::Model field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" - field :files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] - }, optional: false, nullable: false - field :input_params, -> { - Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] - }, optional: false, nullable: false, api_name: "inputParams" - field :output_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "outputType" - field :testcases, -> { - Internal::Types::Array[Seed::Commons::Types::TestCaseWithExpectedResult] - }, optional: false, nullable: false + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" + field :files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] }, optional: false, nullable: false + field :input_params, -> { Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] }, optional: false, nullable: false, api_name: "inputParams" + field :output_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "outputType" + field :testcases, -> { Internal::Types::Array[Seed::Commons::Types::TestCaseWithExpectedResult] }, optional: false, nullable: false field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_request.rb index d0f7fbac9664..b1b729260206 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_request.rb @@ -4,12 +4,8 @@ module Seed module Problem module Types class GetDefaultStarterFilesRequest < Internal::Types::Model - field :input_params, -> { - Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] - }, optional: false, nullable: false, api_name: "inputParams" - field :output_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "outputType" + field :input_params, -> { Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] }, optional: false, nullable: false, api_name: "inputParams" + field :output_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "outputType" field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_response.rb index dfa18e8db729..ceb09b5dfaaa 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/get_default_starter_files_response.rb @@ -4,9 +4,7 @@ module Seed module Problem module Types class GetDefaultStarterFilesResponse < Internal::Types::Model - field :files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] - }, optional: false, nullable: false + field :files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_description.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_description.rb index 43e52e6c1166..292aedf7d24f 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_description.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_description.rb @@ -4,9 +4,7 @@ module Seed module Problem module Types class ProblemDescription < Internal::Types::Model - field :boards, -> { - Internal::Types::Array[Seed::Problem::Types::ProblemDescriptionBoard] - }, optional: false, nullable: false + field :boards, -> { Internal::Types::Array[Seed::Problem::Types::ProblemDescriptionBoard] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_files.rb index a6a470c0e493..41d281e4d43f 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_files.rb @@ -4,12 +4,8 @@ module Seed module Problem module Types class ProblemFiles < Internal::Types::Model - field :solution_file, -> { - Seed::Commons::Types::FileInfo - }, optional: false, nullable: false, api_name: "solutionFile" - field :read_only_files, -> { - Internal::Types::Array[Seed::Commons::Types::FileInfo] - }, optional: false, nullable: false, api_name: "readOnlyFiles" + field :solution_file, -> { Seed::Commons::Types::FileInfo }, optional: false, nullable: false, api_name: "solutionFile" + field :read_only_files, -> { Internal::Types::Array[Seed::Commons::Types::FileInfo] }, optional: false, nullable: false, api_name: "readOnlyFiles" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_info.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_info.rb index e954fa657f60..86b2feb77d76 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_info.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/problem_info.rb @@ -5,27 +5,15 @@ module Problem module Types class ProblemInfo < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] - }, optional: false, nullable: false - field :input_params, -> { - Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] - }, optional: false, nullable: false, api_name: "inputParams" - field :output_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "outputType" - field :testcases, -> { - Internal::Types::Array[Seed::Commons::Types::TestCaseWithExpectedResult] - }, optional: false, nullable: false + field :files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Problem::Types::ProblemFiles] }, optional: false, nullable: false + field :input_params, -> { Internal::Types::Array[Seed::Problem::Types::VariableTypeAndName] }, optional: false, nullable: false, api_name: "inputParams" + field :output_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "outputType" + field :testcases, -> { Internal::Types::Array[Seed::Commons::Types::TestCaseWithExpectedResult] }, optional: false, nullable: false field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" - field :supports_custom_test_cases, -> { - Internal::Types::Boolean - }, optional: false, nullable: false, api_name: "supportsCustomTestCases" + field :supports_custom_test_cases, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "supportsCustomTestCases" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/variable_type_and_name.rb b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/variable_type_and_name.rb index da4c91177ad5..c8058d194c72 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/problem/types/variable_type_and_name.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/problem/types/variable_type_and_name.rb @@ -4,9 +4,7 @@ module Seed module Problem module Types class VariableTypeAndName < Internal::Types::Model - field :variable_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "variableType" + field :variable_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "variableType" field :name, -> { String }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/client.rb index b67719a1371c..4e2d97e032f7 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/client.rb @@ -24,7 +24,7 @@ def initialize(client:) # @return [Seed::Submission::Types::ExecutionSessionResponse] def create_execution_session(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "POST", path: "/sessions/create-session/#{params[:language]}", request_options: request_options @@ -57,7 +57,7 @@ def create_execution_session(request_options: {}, **params) # @return [Seed::Submission::Types::ExecutionSessionResponse, nil] def get_execution_session(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/sessions/#{params[:session_id]}", request_options: request_options @@ -88,7 +88,7 @@ def get_execution_session(request_options: {}, **params) # @return [untyped] def stop_execution_session(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "DELETE", path: "/sessions/stop/#{params[:session_id]}", request_options: request_options @@ -116,7 +116,7 @@ def stop_execution_session(request_options: {}, **params) # @return [Seed::Submission::Types::GetExecutionSessionStateResponse] def get_execution_sessions_state(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/sessions/execution-sessions-state", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/errored_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/errored_response.rb index 6b6d3146360c..25fb50b9cf8a 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/errored_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/errored_response.rb @@ -5,9 +5,7 @@ module Submission module Types class ErroredResponse < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" - field :error_info, -> { - Seed::Submission::Types::ErrorInfo - }, optional: false, nullable: false, api_name: "errorInfo" + field :error_info, -> { Seed::Submission::Types::ErrorInfo }, optional: false, nullable: false, api_name: "errorInfo" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/execution_session_state.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/execution_session_state.rb index 5fddf29990bc..670844ad64d9 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/execution_session_state.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/execution_session_state.rb @@ -6,9 +6,7 @@ module Types class ExecutionSessionState < Internal::Types::Model field :last_time_contacted, -> { String }, optional: true, nullable: false, api_name: "lastTimeContacted" field :session_id, -> { String }, optional: false, nullable: false, api_name: "sessionId" - field :is_warm_instance, -> { - Internal::Types::Boolean - }, optional: false, nullable: false, api_name: "isWarmInstance" + field :is_warm_instance, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "isWarmInstance" field :aws_task_id, -> { String }, optional: true, nullable: false, api_name: "awsTaskId" field :language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false field :status, -> { Seed::Submission::Types::ExecutionSessionStatus }, optional: false, nullable: false diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_execution_session_state_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_execution_session_state_response.rb index 67dae9a58210..100c6e64fc53 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_execution_session_state_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_execution_session_state_response.rb @@ -4,13 +4,9 @@ module Seed module Submission module Types class GetExecutionSessionStateResponse < Internal::Types::Model - field :states, -> { - Internal::Types::Hash[String, Seed::Submission::Types::ExecutionSessionState] - }, optional: false, nullable: false + field :states, -> { Internal::Types::Hash[String, Seed::Submission::Types::ExecutionSessionState] }, optional: false, nullable: false field :num_warming_instances, -> { Integer }, optional: true, nullable: false, api_name: "numWarmingInstances" - field :warming_session_ids, -> { - Internal::Types::Array[String] - }, optional: false, nullable: false, api_name: "warmingSessionIds" + field :warming_session_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false, api_name: "warmingSessionIds" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_submission_state_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_submission_state_response.rb index d55a2b96b2a5..c29120056d2f 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_submission_state_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/get_submission_state_response.rb @@ -7,9 +7,7 @@ class GetSubmissionStateResponse < Internal::Types::Model field :time_submitted, -> { String }, optional: true, nullable: false, api_name: "timeSubmitted" field :submission, -> { String }, optional: false, nullable: false field :language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false - field :submission_type_state, -> { - Seed::Submission::Types::SubmissionTypeState - }, optional: false, nullable: false, api_name: "submissionTypeState" + field :submission_type_state, -> { Seed::Submission::Types::SubmissionTypeState }, optional: false, nullable: false, api_name: "submissionTypeState" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response.rb index 23e9fb9c0417..c587e2af2260 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response.rb @@ -5,9 +5,7 @@ module Submission module Types class GradedResponse < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" - field :test_cases, -> { - Internal::Types::Hash[String, Seed::Submission::Types::TestCaseResultWithStdout] - }, optional: false, nullable: false, api_name: "testCases" + field :test_cases, -> { Internal::Types::Hash[String, Seed::Submission::Types::TestCaseResultWithStdout] }, optional: false, nullable: false, api_name: "testCases" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response_v_2.rb index c79789a89119..7807bb048c87 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/graded_response_v_2.rb @@ -5,9 +5,7 @@ module Submission module Types class GradedResponseV2 < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" - field :test_cases, -> { - Internal::Types::Hash[String, Seed::Submission::Types::TestCaseGrade] - }, optional: false, nullable: false, api_name: "testCases" + field :test_cases, -> { Internal::Types::Hash[String, Seed::Submission::Types::TestCaseGrade] }, optional: false, nullable: false, api_name: "testCases" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/internal_error.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/internal_error.rb index b54951f62600..284e8e87c3fd 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/internal_error.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/internal_error.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class InternalError < Internal::Types::Model - field :exception_info, -> { - Seed::Submission::Types::ExceptionInfo - }, optional: false, nullable: false, api_name: "exceptionInfo" + field :exception_info, -> { Seed::Submission::Types::ExceptionInfo }, optional: false, nullable: false, api_name: "exceptionInfo" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/lightweight_stackframe_information.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/lightweight_stackframe_information.rb index 926e1e53ac3f..0796228e168a 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/lightweight_stackframe_information.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/lightweight_stackframe_information.rb @@ -5,9 +5,7 @@ module Submission module Types class LightweightStackframeInformation < Internal::Types::Model field :num_stack_frames, -> { Integer }, optional: false, nullable: false, api_name: "numStackFrames" - field :top_stack_frame_method_name, -> { - String - }, optional: false, nullable: false, api_name: "topStackFrameMethodName" + field :top_stack_frame_method_name, -> { String }, optional: false, nullable: false, api_name: "topStackFrameMethodName" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/recording_response_notification.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/recording_response_notification.rb index 24e138bb955c..799f4a81cecc 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/recording_response_notification.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/recording_response_notification.rb @@ -7,12 +7,8 @@ class RecordingResponseNotification < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :test_case_id, -> { String }, optional: true, nullable: false, api_name: "testCaseId" field :line_number, -> { Integer }, optional: false, nullable: false, api_name: "lineNumber" - field :lightweight_stack_info, -> { - Seed::Submission::Types::LightweightStackframeInformation - }, optional: false, nullable: false, api_name: "lightweightStackInfo" - field :traced_file, -> { - Seed::Submission::Types::TracedFile - }, optional: true, nullable: false, api_name: "tracedFile" + field :lightweight_stack_info, -> { Seed::Submission::Types::LightweightStackframeInformation }, optional: false, nullable: false, api_name: "lightweightStackInfo" + field :traced_file, -> { Seed::Submission::Types::TracedFile }, optional: true, nullable: false, api_name: "tracedFile" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/scope.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/scope.rb index e9939d0d5247..25a876f79fdf 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/scope.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/scope.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class Scope < Internal::Types::Model - field :variables, -> { - Internal::Types::Hash[String, Seed::Commons::Types::DebugVariableValue] - }, optional: false, nullable: false + field :variables, -> { Internal::Types::Hash[String, Seed::Commons::Types::DebugVariableValue] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/stack_information.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/stack_information.rb index a056abacb53a..9aa291446229 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/stack_information.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/stack_information.rb @@ -5,9 +5,7 @@ module Submission module Types class StackInformation < Internal::Types::Model field :num_stack_frames, -> { Integer }, optional: false, nullable: false, api_name: "numStackFrames" - field :top_stack_frame, -> { - Seed::Submission::Types::StackFrame - }, optional: true, nullable: false, api_name: "topStackFrame" + field :top_stack_frame, -> { Seed::Submission::Types::StackFrame }, optional: true, nullable: false, api_name: "topStackFrame" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/submit_request_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/submit_request_v_2.rb index 747358e54bd7..0d27bb33fd59 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/submit_request_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/submit_request_v_2.rb @@ -6,9 +6,7 @@ module Types class SubmitRequestV2 < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false - field :submission_files, -> { - Internal::Types::Array[Seed::Submission::Types::SubmissionFileInfo] - }, optional: false, nullable: false, api_name: "submissionFiles" + field :submission_files, -> { Internal::Types::Array[Seed::Submission::Types::SubmissionFileInfo] }, optional: false, nullable: false, api_name: "submissionFiles" field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" field :problem_version, -> { Integer }, optional: true, nullable: false, api_name: "problemVersion" field :user_id, -> { String }, optional: true, nullable: false, api_name: "userId" diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_non_hidden_grade.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_non_hidden_grade.rb index d56e02ca67ae..02b9930a5360 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_non_hidden_grade.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_non_hidden_grade.rb @@ -5,9 +5,7 @@ module Submission module Types class TestCaseNonHiddenGrade < Internal::Types::Model field :passed, -> { Internal::Types::Boolean }, optional: false, nullable: false - field :actual_result, -> { - Seed::Commons::Types::VariableValue - }, optional: true, nullable: false, api_name: "actualResult" + field :actual_result, -> { Seed::Commons::Types::VariableValue }, optional: true, nullable: false, api_name: "actualResult" field :exception, -> { Seed::Submission::Types::ExceptionV2 }, optional: true, nullable: false field :stdout, -> { String }, optional: false, nullable: false end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_result.rb index 82bfff96c620..2169f4e3ece4 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_case_result.rb @@ -4,12 +4,8 @@ module Seed module Submission module Types class TestCaseResult < Internal::Types::Model - field :expected_result, -> { - Seed::Commons::Types::VariableValue - }, optional: false, nullable: false, api_name: "expectedResult" - field :actual_result, -> { - Seed::Submission::Types::ActualResult - }, optional: false, nullable: false, api_name: "actualResult" + field :expected_result, -> { Seed::Commons::Types::VariableValue }, optional: false, nullable: false, api_name: "expectedResult" + field :actual_result, -> { Seed::Submission::Types::ActualResult }, optional: false, nullable: false, api_name: "actualResult" field :passed, -> { Internal::Types::Boolean }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_state.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_state.rb index 17acedb42441..f9f7bfbbd04b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_state.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_state.rb @@ -5,12 +5,8 @@ module Submission module Types class TestSubmissionState < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" - field :default_test_cases, -> { - Internal::Types::Array[Seed::Commons::Types::TestCase] - }, optional: false, nullable: false, api_name: "defaultTestCases" - field :custom_test_cases, -> { - Internal::Types::Array[Seed::Commons::Types::TestCase] - }, optional: false, nullable: false, api_name: "customTestCases" + field :default_test_cases, -> { Internal::Types::Array[Seed::Commons::Types::TestCase] }, optional: false, nullable: false, api_name: "defaultTestCases" + field :custom_test_cases, -> { Internal::Types::Array[Seed::Commons::Types::TestCase] }, optional: false, nullable: false, api_name: "customTestCases" field :status, -> { Seed::Submission::Types::TestSubmissionStatus }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status.rb index 4c3ecb2b640a..0907ee7306ec 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status.rb @@ -11,9 +11,7 @@ class TestSubmissionStatus < Internal::Types::Model member -> { Object }, key: "STOPPED" member -> { Seed::Submission::Types::ErrorInfo }, key: "ERRORED" member -> { Seed::Submission::Types::RunningSubmissionState }, key: "RUNNING" - member -> { - Internal::Types::Hash[String, Seed::Submission::Types::SubmissionStatusForTestCase] - }, key: "TEST_CASE_ID_TO_STATE" + member -> { Internal::Types::Hash[String, Seed::Submission::Types::SubmissionStatusForTestCase] }, key: "TEST_CASE_ID_TO_STATE" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status_v_2.rb index 912365f1bf74..9d61ffd0c944 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_status_v_2.rb @@ -4,14 +4,10 @@ module Seed module Submission module Types class TestSubmissionStatusV2 < Internal::Types::Model - field :updates, -> { - Internal::Types::Array[Seed::Submission::Types::TestSubmissionUpdate] - }, optional: false, nullable: false + field :updates, -> { Internal::Types::Array[Seed::Submission::Types::TestSubmissionUpdate] }, optional: false, nullable: false field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :problem_info, -> { - Seed::V2::Problem::Types::ProblemInfoV2 - }, optional: false, nullable: false, api_name: "problemInfo" + field :problem_info, -> { Seed::V2::Problem::Types::ProblemInfoV2 }, optional: false, nullable: false, api_name: "problemInfo" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_update.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_update.rb index f21b7125234c..f9e1c51c7282 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_update.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/test_submission_update.rb @@ -5,9 +5,7 @@ module Submission module Types class TestSubmissionUpdate < Internal::Types::Model field :update_time, -> { String }, optional: false, nullable: false, api_name: "updateTime" - field :update_info, -> { - Seed::Submission::Types::TestSubmissionUpdateInfo - }, optional: false, nullable: false, api_name: "updateInfo" + field :update_info, -> { Seed::Submission::Types::TestSubmissionUpdateInfo }, optional: false, nullable: false, api_name: "updateInfo" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response.rb index 1e7654a22df4..bc8ee232be48 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response.rb @@ -6,12 +6,8 @@ module Types class TraceResponse < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :line_number, -> { Integer }, optional: false, nullable: false, api_name: "lineNumber" - field :return_value, -> { - Seed::Commons::Types::DebugVariableValue - }, optional: true, nullable: false, api_name: "returnValue" - field :expression_location, -> { - Seed::Submission::Types::ExpressionLocation - }, optional: true, nullable: false, api_name: "expressionLocation" + field :return_value, -> { Seed::Commons::Types::DebugVariableValue }, optional: true, nullable: false, api_name: "returnValue" + field :expression_location, -> { Seed::Submission::Types::ExpressionLocation }, optional: true, nullable: false, api_name: "expressionLocation" field :stack, -> { Seed::Submission::Types::StackInformation }, optional: false, nullable: false field :stdout, -> { String }, optional: true, nullable: false end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response_v_2.rb index b862ff99fb63..0224ad8e0c26 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_response_v_2.rb @@ -7,12 +7,8 @@ class TraceResponseV2 < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :line_number, -> { Integer }, optional: false, nullable: false, api_name: "lineNumber" field :file, -> { Seed::Submission::Types::TracedFile }, optional: false, nullable: false - field :return_value, -> { - Seed::Commons::Types::DebugVariableValue - }, optional: true, nullable: false, api_name: "returnValue" - field :expression_location, -> { - Seed::Submission::Types::ExpressionLocation - }, optional: true, nullable: false, api_name: "expressionLocation" + field :return_value, -> { Seed::Commons::Types::DebugVariableValue }, optional: true, nullable: false, api_name: "returnValue" + field :expression_location, -> { Seed::Submission::Types::ExpressionLocation }, optional: true, nullable: false, api_name: "expressionLocation" field :stack, -> { Seed::Submission::Types::StackInformation }, optional: false, nullable: false field :stdout, -> { String }, optional: true, nullable: false end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page.rb index 71e177458016..e91c4dbee070 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page.rb @@ -5,9 +5,7 @@ module Submission module Types class TraceResponsesPage < Internal::Types::Model field :offset, -> { Integer }, optional: true, nullable: false - field :trace_responses, -> { - Internal::Types::Array[Seed::Submission::Types::TraceResponse] - }, optional: false, nullable: false, api_name: "traceResponses" + field :trace_responses, -> { Internal::Types::Array[Seed::Submission::Types::TraceResponse] }, optional: false, nullable: false, api_name: "traceResponses" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page_v_2.rb index 167fa73e15af..1887338b029a 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/trace_responses_page_v_2.rb @@ -5,9 +5,7 @@ module Submission module Types class TraceResponsesPageV2 < Internal::Types::Model field :offset, -> { Integer }, optional: true, nullable: false - field :trace_responses, -> { - Internal::Types::Array[Seed::Submission::Types::TraceResponseV2] - }, optional: false, nullable: false, api_name: "traceResponses" + field :trace_responses, -> { Internal::Types::Array[Seed::Submission::Types::TraceResponseV2] }, optional: false, nullable: false, api_name: "traceResponses" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/unexpected_language_error.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/unexpected_language_error.rb index b01ade56128c..5136f484a7e7 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/unexpected_language_error.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/unexpected_language_error.rb @@ -4,12 +4,8 @@ module Seed module Submission module Types class UnexpectedLanguageError < Internal::Types::Model - field :expected_language, -> { - Seed::Commons::Types::Language - }, optional: false, nullable: false, api_name: "expectedLanguage" - field :actual_language, -> { - Seed::Commons::Types::Language - }, optional: false, nullable: false, api_name: "actualLanguage" + field :expected_language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false, api_name: "expectedLanguage" + field :actual_language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false, api_name: "actualLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_files.rb index c25642bf458a..2bce77b9b8fa 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_files.rb @@ -5,9 +5,7 @@ module Submission module Types class WorkspaceFiles < Internal::Types::Model field :main_file, -> { Seed::Commons::Types::FileInfo }, optional: false, nullable: false, api_name: "mainFile" - field :read_only_files, -> { - Internal::Types::Array[Seed::Commons::Types::FileInfo] - }, optional: false, nullable: false, api_name: "readOnlyFiles" + field :read_only_files, -> { Internal::Types::Array[Seed::Commons::Types::FileInfo] }, optional: false, nullable: false, api_name: "readOnlyFiles" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_ran_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_ran_response.rb index f12538efb282..6ea0f1efe330 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_ran_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_ran_response.rb @@ -5,9 +5,7 @@ module Submission module Types class WorkspaceRanResponse < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" - field :run_details, -> { - Seed::Submission::Types::WorkspaceRunDetails - }, optional: false, nullable: false, api_name: "runDetails" + field :run_details, -> { Seed::Submission::Types::WorkspaceRunDetails }, optional: false, nullable: false, api_name: "runDetails" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_run_details.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_run_details.rb index 5e6bf262b50e..4fdfee9b4551 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_run_details.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_run_details.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class WorkspaceRunDetails < Internal::Types::Model - field :exception_v_2, -> { - Seed::Submission::Types::ExceptionV2 - }, optional: true, nullable: false, api_name: "exceptionV2" + field :exception_v_2, -> { Seed::Submission::Types::ExceptionV2 }, optional: true, nullable: false, api_name: "exceptionV2" field :exception, -> { Seed::Submission::Types::ExceptionInfo }, optional: true, nullable: false field :stdout, -> { String }, optional: false, nullable: false end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response.rb index a1d1cd60aa67..7cebeae20833 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class WorkspaceStarterFilesResponse < Internal::Types::Model - field :files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Submission::Types::WorkspaceFiles] - }, optional: false, nullable: false + field :files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::Submission::Types::WorkspaceFiles] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response_v_2.rb index 883bc4cf7f03..9ca47e0ff866 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_starter_files_response_v_2.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class WorkspaceStarterFilesResponseV2 < Internal::Types::Model - field :files_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "filesByLanguage" + field :files_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, optional: false, nullable: false, api_name: "filesByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_status_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_status_v_2.rb index 4f556fca7bb0..cdacd87703f8 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_status_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_status_v_2.rb @@ -4,9 +4,7 @@ module Seed module Submission module Types class WorkspaceSubmissionStatusV2 < Internal::Types::Model - field :updates, -> { - Internal::Types::Array[Seed::Submission::Types::WorkspaceSubmissionUpdate] - }, optional: false, nullable: false + field :updates, -> { Internal::Types::Array[Seed::Submission::Types::WorkspaceSubmissionUpdate] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_update.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_update.rb index 288db6136352..a59044fe008e 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_update.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submission_update.rb @@ -5,9 +5,7 @@ module Submission module Types class WorkspaceSubmissionUpdate < Internal::Types::Model field :update_time, -> { String }, optional: false, nullable: false, api_name: "updateTime" - field :update_info, -> { - Seed::Submission::Types::WorkspaceSubmissionUpdateInfo - }, optional: false, nullable: false, api_name: "updateInfo" + field :update_info, -> { Seed::Submission::Types::WorkspaceSubmissionUpdateInfo }, optional: false, nullable: false, api_name: "updateInfo" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submit_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submit_request.rb index 5522c36cde4a..a5818a491beb 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submit_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/submission/types/workspace_submit_request.rb @@ -6,9 +6,7 @@ module Types class WorkspaceSubmitRequest < Internal::Types::Model field :submission_id, -> { String }, optional: false, nullable: false, api_name: "submissionId" field :language, -> { Seed::Commons::Types::Language }, optional: false, nullable: false - field :submission_files, -> { - Internal::Types::Array[Seed::Submission::Types::SubmissionFileInfo] - }, optional: false, nullable: false, api_name: "submissionFiles" + field :submission_files, -> { Internal::Types::Array[Seed::Submission::Types::SubmissionFileInfo] }, optional: false, nullable: false, api_name: "submissionFiles" field :user_id, -> { String }, optional: true, nullable: false, api_name: "userId" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/sysprop/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/sysprop/client.rb index d0777b75513f..11f145cb3e3e 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/sysprop/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/sysprop/client.rb @@ -23,7 +23,7 @@ def initialize(client:) # @return [untyped] def set_num_warm_instances(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "PUT", path: "/sysprop/num-warm-instances/#{params[:language]}/#{params[:num_warm_instances]}", request_options: request_options @@ -51,7 +51,7 @@ def set_num_warm_instances(request_options: {}, **params) # @return [Hash[Seed::Commons::Types::Language, Integer]] def get_num_warm_instances(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/sysprop/num-warm-instances", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/client.rb index 7fd51814077e..bbb81aef067c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/client.rb @@ -21,7 +21,7 @@ def initialize(client:) # @return [untyped] def test(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/client.rb index 95b78c98ff36..c7194cc989c6 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/client.rb @@ -24,7 +24,7 @@ def initialize(client:) # @return [Array[Seed::V2::Problem::Types::LightweightProblemInfoV2]] def get_lightweight_problems(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/lightweight-problem-info", request_options: request_options @@ -54,7 +54,7 @@ def get_lightweight_problems(request_options: {}, **_params) # @return [Array[Seed::V2::Problem::Types::ProblemInfoV2]] def get_problems(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info", request_options: request_options @@ -85,7 +85,7 @@ def get_problems(request_options: {}, **_params) # @return [Seed::V2::Problem::Types::ProblemInfoV2] def get_latest_problem(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info/#{params[:problem_id]}", request_options: request_options @@ -119,7 +119,7 @@ def get_latest_problem(request_options: {}, **params) # @return [Seed::V2::Problem::Types::ProblemInfoV2] def get_problem_version(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info/#{params[:problem_id]}/version/#{params[:problem_version]}", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_custom_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_custom_files.rb index 6f9b76b8a129..c62ee492e8f4 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_custom_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_custom_files.rb @@ -7,12 +7,8 @@ module Types class BasicCustomFiles < Internal::Types::Model field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" field :signature, -> { Seed::V2::Problem::Types::NonVoidFunctionSignature }, optional: false, nullable: false - field :additional_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "additionalFiles" - field :basic_test_case_template, -> { - Seed::V2::Problem::Types::BasicTestCaseTemplate - }, optional: false, nullable: false, api_name: "basicTestCaseTemplate" + field :additional_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, optional: false, nullable: false, api_name: "additionalFiles" + field :basic_test_case_template, -> { Seed::V2::Problem::Types::BasicTestCaseTemplate }, optional: false, nullable: false, api_name: "basicTestCaseTemplate" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_test_case_template.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_test_case_template.rb index f9a87ebeb712..4797263dd419 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_test_case_template.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/basic_test_case_template.rb @@ -7,12 +7,8 @@ module Types class BasicTestCaseTemplate < Internal::Types::Model field :template_id, -> { String }, optional: false, nullable: false, api_name: "templateId" field :name, -> { String }, optional: false, nullable: false - field :description, -> { - Seed::V2::Problem::Types::TestCaseImplementationDescription - }, optional: false, nullable: false - field :expected_value_parameter_id, -> { - String - }, optional: false, nullable: false, api_name: "expectedValueParameterId" + field :description, -> { Seed::V2::Problem::Types::TestCaseImplementationDescription }, optional: false, nullable: false + field :expected_value_parameter_id, -> { String }, optional: false, nullable: false, api_name: "expectedValueParameterId" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/create_problem_request_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/create_problem_request_v_2.rb index 9de8f2a15bd0..d6bb2a1310d3 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/create_problem_request_v_2.rb @@ -6,21 +6,11 @@ module Problem module Types class CreateProblemRequestV2 < Internal::Types::Model field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" - field :custom_files, -> { - Seed::V2::Problem::Types::CustomFiles - }, optional: false, nullable: false, api_name: "customFiles" - field :custom_test_case_templates, -> { - Internal::Types::Array[Seed::V2::Problem::Types::TestCaseTemplate] - }, optional: false, nullable: false, api_name: "customTestCaseTemplates" - field :testcases, -> { - Internal::Types::Array[Seed::V2::Problem::Types::TestCaseV2] - }, optional: false, nullable: false - field :supported_languages, -> { - Internal::Types::Array[Seed::Commons::Types::Language] - }, optional: false, nullable: false, api_name: "supportedLanguages" + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" + field :custom_files, -> { Seed::V2::Problem::Types::CustomFiles }, optional: false, nullable: false, api_name: "customFiles" + field :custom_test_case_templates, -> { Internal::Types::Array[Seed::V2::Problem::Types::TestCaseTemplate] }, optional: false, nullable: false, api_name: "customTestCaseTemplates" + field :testcases, -> { Internal::Types::Array[Seed::V2::Problem::Types::TestCaseV2] }, optional: false, nullable: false + field :supported_languages, -> { Internal::Types::Array[Seed::Commons::Types::Language] }, optional: false, nullable: false, api_name: "supportedLanguages" field :is_public, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "isPublic" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/custom_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/custom_files.rb index 2fba201ce856..e1a0e864f6ff 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/custom_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/custom_files.rb @@ -10,9 +10,7 @@ class CustomFiles < Internal::Types::Model discriminant :type member -> { Seed::V2::Problem::Types::BasicCustomFiles }, key: "BASIC" - member -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, key: "CUSTOM" + member -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, key: "CUSTOM" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/deep_equality_correctness_check.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/deep_equality_correctness_check.rb index 86c016037fec..a507083484c2 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/deep_equality_correctness_check.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/deep_equality_correctness_check.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class DeepEqualityCorrectnessCheck < Internal::Types::Model - field :expected_value_parameter_id, -> { - String - }, optional: false, nullable: false, api_name: "expectedValueParameterId" + field :expected_value_parameter_id, -> { String }, optional: false, nullable: false, api_name: "expectedValueParameterId" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/default_provided_file.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/default_provided_file.rb index 858cc1a166ab..498664d50426 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/default_provided_file.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/default_provided_file.rb @@ -6,9 +6,7 @@ module Problem module Types class DefaultProvidedFile < Internal::Types::Model field :file, -> { Seed::V2::Problem::Types::FileInfoV2 }, optional: false, nullable: false - field :related_types, -> { - Internal::Types::Array[Seed::Commons::Types::VariableType] - }, optional: false, nullable: false, api_name: "relatedTypes" + field :related_types, -> { Internal::Types::Array[Seed::Commons::Types::VariableType] }, optional: false, nullable: false, api_name: "relatedTypes" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/files.rb index 9eadb1738f53..ef7a7b3310fa 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/files.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class Files < Internal::Types::Model - field :files, -> { - Internal::Types::Array[Seed::V2::Problem::Types::FileInfoV2] - }, optional: false, nullable: false + field :files, -> { Internal::Types::Array[Seed::V2::Problem::Types::FileInfoV2] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_implementation_for_multiple_languages.rb index c6b15b39be37..52b823879aed 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_implementation_for_multiple_languages.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class FunctionImplementationForMultipleLanguages < Internal::Types::Model - field :code_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::FunctionImplementation] - }, optional: false, nullable: false, api_name: "codeByLanguage" + field :code_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::FunctionImplementation] }, optional: false, nullable: false, api_name: "codeByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_signature.rb index 663bda78b59c..ce4e3106e9f8 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/function_signature.rb @@ -11,9 +11,7 @@ class FunctionSignature < Internal::Types::Model member -> { Seed::V2::Problem::Types::VoidFunctionSignature }, key: "VOID" member -> { Seed::V2::Problem::Types::NonVoidFunctionSignature }, key: "NON_VOID" - member -> { - Seed::V2::Problem::Types::VoidFunctionSignatureThatTakesActualResult - }, key: "VOID_THAT_TAKES_ACTUAL_RESULT" + member -> { Seed::V2::Problem::Types::VoidFunctionSignatureThatTakesActualResult }, key: "VOID_THAT_TAKES_ACTUAL_RESULT" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/generated_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/generated_files.rb index 47edd283585c..1c952111f272 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/generated_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/generated_files.rb @@ -5,15 +5,9 @@ module V2 module Problem module Types class GeneratedFiles < Internal::Types::Model - field :generated_test_case_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "generatedTestCaseFiles" - field :generated_template_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "generatedTemplateFiles" - field :other, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] - }, optional: false, nullable: false + field :generated_test_case_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, optional: false, nullable: false, api_name: "generatedTestCaseFiles" + field :generated_template_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, optional: false, nullable: false, api_name: "generatedTemplateFiles" + field :other, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::Files] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_basic_solution_file_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_basic_solution_file_response.rb index 8fd4ba294818..53d0a1aaa73b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_basic_solution_file_response.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class GetBasicSolutionFileResponse < Internal::Types::Model - field :solution_file_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::FileInfoV2] - }, optional: false, nullable: false, api_name: "solutionFileByLanguage" + field :solution_file_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::Problem::Types::FileInfoV2] }, optional: false, nullable: false, api_name: "solutionFileByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_request.rb index 94a06f789fe4..41c0e60efd13 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_request.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class GetFunctionSignatureRequest < Internal::Types::Model - field :function_signature, -> { - Seed::V2::Problem::Types::FunctionSignature - }, optional: false, nullable: false, api_name: "functionSignature" + field :function_signature, -> { Seed::V2::Problem::Types::FunctionSignature }, optional: false, nullable: false, api_name: "functionSignature" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_response.rb index 1966fb31edde..774f7e5ab1a7 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_function_signature_response.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class GetFunctionSignatureResponse < Internal::Types::Model - field :function_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, String] - }, optional: false, nullable: false, api_name: "functionByLanguage" + field :function_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, String] }, optional: false, nullable: false, api_name: "functionByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_generated_test_case_file_request.rb index 250128435f89..1f8dd9df12ac 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/get_generated_test_case_file_request.rb @@ -6,9 +6,7 @@ module Problem module Types class GetGeneratedTestCaseFileRequest < Internal::Types::Model field :template, -> { Seed::V2::Problem::Types::TestCaseTemplate }, optional: true, nullable: false - field :test_case, -> { - Seed::V2::Problem::Types::TestCaseV2 - }, optional: false, nullable: false, api_name: "testCase" + field :test_case, -> { Seed::V2::Problem::Types::TestCaseV2 }, optional: false, nullable: false, api_name: "testCase" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/lightweight_problem_info_v_2.rb index 60ccd34af670..81962c5401b9 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/lightweight_problem_info_v_2.rb @@ -8,9 +8,7 @@ class LightweightProblemInfoV2 < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :variable_types, -> { - Internal::Types::Array[Seed::Commons::Types::VariableType] - }, optional: false, nullable: false, api_name: "variableTypes" + field :variable_types, -> { Internal::Types::Array[Seed::Commons::Types::VariableType] }, optional: false, nullable: false, api_name: "variableTypes" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_definition.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_definition.rb index 9f94ee98007f..90fbe339ef36 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_definition.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_definition.rb @@ -6,9 +6,7 @@ module Problem module Types class NonVoidFunctionDefinition < Internal::Types::Model field :signature, -> { Seed::V2::Problem::Types::NonVoidFunctionSignature }, optional: false, nullable: false - field :code, -> { - Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :code, -> { Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_signature.rb index e5808e3801f1..15a1f24d1441 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/non_void_function_signature.rb @@ -5,12 +5,8 @@ module V2 module Problem module Types class NonVoidFunctionSignature < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::Problem::Types::Parameter] - }, optional: false, nullable: false - field :return_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "returnType" + field :parameters, -> { Internal::Types::Array[Seed::V2::Problem::Types::Parameter] }, optional: false, nullable: false + field :return_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "returnType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/parameter.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/parameter.rb index fe506b5cc3a9..a6c9bf4e1f39 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/parameter.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/parameter.rb @@ -7,9 +7,7 @@ module Types class Parameter < Internal::Types::Model field :parameter_id, -> { String }, optional: false, nullable: false, api_name: "parameterId" field :name, -> { String }, optional: false, nullable: false - field :variable_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "variableType" + field :variable_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "variableType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/problem_info_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/problem_info_v_2.rb index 21933a8a187a..f56108e2c30f 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/problem_info_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/problem_info_v_2.rb @@ -6,26 +6,14 @@ module Problem module Types class ProblemInfoV2 < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :supported_languages, -> { - Internal::Types::Array[Seed::Commons::Types::Language] - }, optional: false, nullable: false, api_name: "supportedLanguages" - field :custom_files, -> { - Seed::V2::Problem::Types::CustomFiles - }, optional: false, nullable: false, api_name: "customFiles" - field :generated_files, -> { - Seed::V2::Problem::Types::GeneratedFiles - }, optional: false, nullable: false, api_name: "generatedFiles" - field :custom_test_case_templates, -> { - Internal::Types::Array[Seed::V2::Problem::Types::TestCaseTemplate] - }, optional: false, nullable: false, api_name: "customTestCaseTemplates" - field :testcases, -> { - Internal::Types::Array[Seed::V2::Problem::Types::TestCaseV2] - }, optional: false, nullable: false + field :supported_languages, -> { Internal::Types::Array[Seed::Commons::Types::Language] }, optional: false, nullable: false, api_name: "supportedLanguages" + field :custom_files, -> { Seed::V2::Problem::Types::CustomFiles }, optional: false, nullable: false, api_name: "customFiles" + field :generated_files, -> { Seed::V2::Problem::Types::GeneratedFiles }, optional: false, nullable: false, api_name: "generatedFiles" + field :custom_test_case_templates, -> { Internal::Types::Array[Seed::V2::Problem::Types::TestCaseTemplate] }, optional: false, nullable: false, api_name: "customTestCaseTemplates" + field :testcases, -> { Internal::Types::Array[Seed::V2::Problem::Types::TestCaseV2] }, optional: false, nullable: false field :is_public, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "isPublic" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation.rb index 61fd16c8fd0b..82cda0b3a483 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class TestCaseImplementation < Internal::Types::Model - field :description, -> { - Seed::V2::Problem::Types::TestCaseImplementationDescription - }, optional: false, nullable: false + field :description, -> { Seed::V2::Problem::Types::TestCaseImplementationDescription }, optional: false, nullable: false field :function, -> { Seed::V2::Problem::Types::TestCaseFunction }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation_description.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation_description.rb index 7cd6fd073873..d4401bf3d9ca 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_implementation_description.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class TestCaseImplementationDescription < Internal::Types::Model - field :boards, -> { - Internal::Types::Array[Seed::V2::Problem::Types::TestCaseImplementationDescriptionBoard] - }, optional: false, nullable: false + field :boards, -> { Internal::Types::Array[Seed::V2::Problem::Types::TestCaseImplementationDescriptionBoard] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_template.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_template.rb index c4877d92a49e..0750cbef2de7 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_template.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_template.rb @@ -7,9 +7,7 @@ module Types class TestCaseTemplate < Internal::Types::Model field :template_id, -> { String }, optional: false, nullable: false, api_name: "templateId" field :name, -> { String }, optional: false, nullable: false - field :implementation, -> { - Seed::V2::Problem::Types::TestCaseImplementation - }, optional: false, nullable: false + field :implementation, -> { Seed::V2::Problem::Types::TestCaseImplementation }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_v_2.rb index 1762f51e05b9..88d26509ea3c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_v_2.rb @@ -6,12 +6,8 @@ module Problem module Types class TestCaseV2 < Internal::Types::Model field :metadata, -> { Seed::V2::Problem::Types::TestCaseMetadata }, optional: false, nullable: false - field :implementation, -> { - Seed::V2::Problem::Types::TestCaseImplementationReference - }, optional: false, nullable: false - field :arguments, -> { - Internal::Types::Hash[String, Seed::Commons::Types::VariableValue] - }, optional: false, nullable: false + field :implementation, -> { Seed::V2::Problem::Types::TestCaseImplementationReference }, optional: false, nullable: false + field :arguments, -> { Internal::Types::Hash[String, Seed::Commons::Types::VariableValue] }, optional: false, nullable: false field :expects, -> { Seed::V2::Problem::Types::TestCaseExpects }, optional: true, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_with_actual_result_implementation.rb index 0f395dbee3ad..92fd63ace775 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/test_case_with_actual_result_implementation.rb @@ -5,12 +5,8 @@ module V2 module Problem module Types class TestCaseWithActualResultImplementation < Internal::Types::Model - field :get_actual_result, -> { - Seed::V2::Problem::Types::NonVoidFunctionDefinition - }, optional: false, nullable: false, api_name: "getActualResult" - field :assert_correctness_check, -> { - Seed::V2::Problem::Types::AssertCorrectnessCheck - }, optional: false, nullable: false, api_name: "assertCorrectnessCheck" + field :get_actual_result, -> { Seed::V2::Problem::Types::NonVoidFunctionDefinition }, optional: false, nullable: false, api_name: "getActualResult" + field :assert_correctness_check, -> { Seed::V2::Problem::Types::AssertCorrectnessCheck }, optional: false, nullable: false, api_name: "assertCorrectnessCheck" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition.rb index cd96915e36f5..606bfe683bec 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition.rb @@ -5,12 +5,8 @@ module V2 module Problem module Types class VoidFunctionDefinition < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::Problem::Types::Parameter] - }, optional: false, nullable: false - field :code, -> { - Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :parameters, -> { Internal::Types::Array[Seed::V2::Problem::Types::Parameter] }, optional: false, nullable: false + field :code, -> { Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition_that_takes_actual_result.rb index 44adb2d7a789..b85006fbfd78 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_definition_that_takes_actual_result.rb @@ -6,12 +6,8 @@ module Problem module Types # The generated signature will include an additional param, actualResult class VoidFunctionDefinitionThatTakesActualResult < Internal::Types::Model - field :additional_parameters, -> { - Internal::Types::Array[Seed::V2::Problem::Types::Parameter] - }, optional: false, nullable: false, api_name: "additionalParameters" - field :code, -> { - Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :additional_parameters, -> { Internal::Types::Array[Seed::V2::Problem::Types::Parameter] }, optional: false, nullable: false, api_name: "additionalParameters" + field :code, -> { Seed::V2::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature.rb index c009b05a9212..9b8ffe37538b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature.rb @@ -5,9 +5,7 @@ module V2 module Problem module Types class VoidFunctionSignature < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::Problem::Types::Parameter] - }, optional: false, nullable: false + field :parameters, -> { Internal::Types::Array[Seed::V2::Problem::Types::Parameter] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature_that_takes_actual_result.rb index 13b4ef9a6b05..0b235b0442cc 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/problem/types/void_function_signature_that_takes_actual_result.rb @@ -5,12 +5,8 @@ module V2 module Problem module Types class VoidFunctionSignatureThatTakesActualResult < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::Problem::Types::Parameter] - }, optional: false, nullable: false - field :actual_result_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "actualResultType" + field :parameters, -> { Internal::Types::Array[Seed::V2::Problem::Types::Parameter] }, optional: false, nullable: false + field :actual_result_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "actualResultType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/client.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/client.rb index 77ab12a0e43a..7e8dc719c880 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/client.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/client.rb @@ -25,7 +25,7 @@ def initialize(client:) # @return [Array[Seed::V2::V3::Problem::Types::LightweightProblemInfoV2]] def get_lightweight_problems(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/lightweight-problem-info", request_options: request_options @@ -55,7 +55,7 @@ def get_lightweight_problems(request_options: {}, **_params) # @return [Array[Seed::V2::V3::Problem::Types::ProblemInfoV2]] def get_problems(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info", request_options: request_options @@ -86,7 +86,7 @@ def get_problems(request_options: {}, **_params) # @return [Seed::V2::V3::Problem::Types::ProblemInfoV2] def get_latest_problem(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info/#{params[:problem_id]}", request_options: request_options @@ -120,7 +120,7 @@ def get_latest_problem(request_options: {}, **params) # @return [Seed::V2::V3::Problem::Types::ProblemInfoV2] def get_problem_version(request_options: {}, **params) request = Seed::Internal::JSON::Request.new( - base_url: request_options[:base_url] || Seed::Environment::PROD, + base_url: request_options[:base_url], method: "GET", path: "/problems-v2/problem-info/#{params[:problem_id]}/version/#{params[:problem_version]}", request_options: request_options diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_custom_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_custom_files.rb index e8d9dae162df..4596ec54307a 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_custom_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_custom_files.rb @@ -7,15 +7,9 @@ module Problem module Types class BasicCustomFiles < Internal::Types::Model field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" - field :signature, -> { - Seed::V2::V3::Problem::Types::NonVoidFunctionSignature - }, optional: false, nullable: false - field :additional_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "additionalFiles" - field :basic_test_case_template, -> { - Seed::V2::V3::Problem::Types::BasicTestCaseTemplate - }, optional: false, nullable: false, api_name: "basicTestCaseTemplate" + field :signature, -> { Seed::V2::V3::Problem::Types::NonVoidFunctionSignature }, optional: false, nullable: false + field :additional_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] }, optional: false, nullable: false, api_name: "additionalFiles" + field :basic_test_case_template, -> { Seed::V2::V3::Problem::Types::BasicTestCaseTemplate }, optional: false, nullable: false, api_name: "basicTestCaseTemplate" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_test_case_template.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_test_case_template.rb index b15c6a3ee4fb..9bc70f067fed 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_test_case_template.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/basic_test_case_template.rb @@ -8,12 +8,8 @@ module Types class BasicTestCaseTemplate < Internal::Types::Model field :template_id, -> { String }, optional: false, nullable: false, api_name: "templateId" field :name, -> { String }, optional: false, nullable: false - field :description, -> { - Seed::V2::V3::Problem::Types::TestCaseImplementationDescription - }, optional: false, nullable: false - field :expected_value_parameter_id, -> { - String - }, optional: false, nullable: false, api_name: "expectedValueParameterId" + field :description, -> { Seed::V2::V3::Problem::Types::TestCaseImplementationDescription }, optional: false, nullable: false + field :expected_value_parameter_id, -> { String }, optional: false, nullable: false, api_name: "expectedValueParameterId" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/create_problem_request_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/create_problem_request_v_2.rb index 00a52f0757b4..c43a4006ca0b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/create_problem_request_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/create_problem_request_v_2.rb @@ -7,21 +7,11 @@ module Problem module Types class CreateProblemRequestV2 < Internal::Types::Model field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" - field :custom_files, -> { - Seed::V2::V3::Problem::Types::CustomFiles - }, optional: false, nullable: false, api_name: "customFiles" - field :custom_test_case_templates, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseTemplate] - }, optional: false, nullable: false, api_name: "customTestCaseTemplates" - field :testcases, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseV2] - }, optional: false, nullable: false - field :supported_languages, -> { - Internal::Types::Array[Seed::Commons::Types::Language] - }, optional: false, nullable: false, api_name: "supportedLanguages" + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" + field :custom_files, -> { Seed::V2::V3::Problem::Types::CustomFiles }, optional: false, nullable: false, api_name: "customFiles" + field :custom_test_case_templates, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseTemplate] }, optional: false, nullable: false, api_name: "customTestCaseTemplates" + field :testcases, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseV2] }, optional: false, nullable: false + field :supported_languages, -> { Internal::Types::Array[Seed::Commons::Types::Language] }, optional: false, nullable: false, api_name: "supportedLanguages" field :is_public, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "isPublic" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/custom_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/custom_files.rb index fa518bdfe86f..17b8eadd7775 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/custom_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/custom_files.rb @@ -11,9 +11,7 @@ class CustomFiles < Internal::Types::Model discriminant :type member -> { Seed::V2::V3::Problem::Types::BasicCustomFiles }, key: "BASIC" - member -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] - }, key: "CUSTOM" + member -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] }, key: "CUSTOM" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/deep_equality_correctness_check.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/deep_equality_correctness_check.rb index 059a69e0089d..f2a5813a187b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/deep_equality_correctness_check.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/deep_equality_correctness_check.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class DeepEqualityCorrectnessCheck < Internal::Types::Model - field :expected_value_parameter_id, -> { - String - }, optional: false, nullable: false, api_name: "expectedValueParameterId" + field :expected_value_parameter_id, -> { String }, optional: false, nullable: false, api_name: "expectedValueParameterId" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/default_provided_file.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/default_provided_file.rb index 5414fee41e6b..8ac08fb831f7 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/default_provided_file.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/default_provided_file.rb @@ -7,9 +7,7 @@ module Problem module Types class DefaultProvidedFile < Internal::Types::Model field :file, -> { Seed::V2::V3::Problem::Types::FileInfoV2 }, optional: false, nullable: false - field :related_types, -> { - Internal::Types::Array[Seed::Commons::Types::VariableType] - }, optional: false, nullable: false, api_name: "relatedTypes" + field :related_types, -> { Internal::Types::Array[Seed::Commons::Types::VariableType] }, optional: false, nullable: false, api_name: "relatedTypes" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/files.rb index 00ebc5f6106e..b4cdce73e23c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/files.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class Files < Internal::Types::Model - field :files, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::FileInfoV2] - }, optional: false, nullable: false + field :files, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::FileInfoV2] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb index 663178d41181..22dc199e0e19 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_implementation_for_multiple_languages.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class FunctionImplementationForMultipleLanguages < Internal::Types::Model - field :code_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::FunctionImplementation] - }, optional: false, nullable: false, api_name: "codeByLanguage" + field :code_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::FunctionImplementation] }, optional: false, nullable: false, api_name: "codeByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_signature.rb index 22eab47cc125..2306323d9029 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/function_signature.rb @@ -12,9 +12,7 @@ class FunctionSignature < Internal::Types::Model member -> { Seed::V2::V3::Problem::Types::VoidFunctionSignature }, key: "VOID" member -> { Seed::V2::V3::Problem::Types::NonVoidFunctionSignature }, key: "NON_VOID" - member -> { - Seed::V2::V3::Problem::Types::VoidFunctionSignatureThatTakesActualResult - }, key: "VOID_THAT_TAKES_ACTUAL_RESULT" + member -> { Seed::V2::V3::Problem::Types::VoidFunctionSignatureThatTakesActualResult }, key: "VOID_THAT_TAKES_ACTUAL_RESULT" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/generated_files.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/generated_files.rb index e3e3c35cf241..e66e56e21bfd 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/generated_files.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/generated_files.rb @@ -6,15 +6,9 @@ module V3 module Problem module Types class GeneratedFiles < Internal::Types::Model - field :generated_test_case_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "generatedTestCaseFiles" - field :generated_template_files, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] - }, optional: false, nullable: false, api_name: "generatedTemplateFiles" - field :other, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] - }, optional: false, nullable: false + field :generated_test_case_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] }, optional: false, nullable: false, api_name: "generatedTestCaseFiles" + field :generated_template_files, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] }, optional: false, nullable: false, api_name: "generatedTemplateFiles" + field :other, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::Files] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_request.rb index 9972688765c9..cdad834cd4a0 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_request.rb @@ -7,9 +7,7 @@ module Problem module Types class GetBasicSolutionFileRequest < Internal::Types::Model field :method_name, -> { String }, optional: false, nullable: false, api_name: "methodName" - field :signature, -> { - Seed::V2::V3::Problem::Types::NonVoidFunctionSignature - }, optional: false, nullable: false + field :signature, -> { Seed::V2::V3::Problem::Types::NonVoidFunctionSignature }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_response.rb index ecfe68774df9..496432639ad0 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_basic_solution_file_response.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class GetBasicSolutionFileResponse < Internal::Types::Model - field :solution_file_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::FileInfoV2] - }, optional: false, nullable: false, api_name: "solutionFileByLanguage" + field :solution_file_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, Seed::V2::V3::Problem::Types::FileInfoV2] }, optional: false, nullable: false, api_name: "solutionFileByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_request.rb index 4686f0882bfa..9774cd249c06 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_request.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class GetFunctionSignatureRequest < Internal::Types::Model - field :function_signature, -> { - Seed::V2::V3::Problem::Types::FunctionSignature - }, optional: false, nullable: false, api_name: "functionSignature" + field :function_signature, -> { Seed::V2::V3::Problem::Types::FunctionSignature }, optional: false, nullable: false, api_name: "functionSignature" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_response.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_response.rb index fd463decdbb5..850f7ad7fa7c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_response.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_function_signature_response.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class GetFunctionSignatureResponse < Internal::Types::Model - field :function_by_language, -> { - Internal::Types::Hash[Seed::Commons::Types::Language, String] - }, optional: false, nullable: false, api_name: "functionByLanguage" + field :function_by_language, -> { Internal::Types::Hash[Seed::Commons::Types::Language, String] }, optional: false, nullable: false, api_name: "functionByLanguage" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_generated_test_case_file_request.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_generated_test_case_file_request.rb index 450136bb2183..4c5480457109 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_generated_test_case_file_request.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/get_generated_test_case_file_request.rb @@ -7,9 +7,7 @@ module Problem module Types class GetGeneratedTestCaseFileRequest < Internal::Types::Model field :template, -> { Seed::V2::V3::Problem::Types::TestCaseTemplate }, optional: true, nullable: false - field :test_case, -> { - Seed::V2::V3::Problem::Types::TestCaseV2 - }, optional: false, nullable: false, api_name: "testCase" + field :test_case, -> { Seed::V2::V3::Problem::Types::TestCaseV2 }, optional: false, nullable: false, api_name: "testCase" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb index d8a2d6d57587..047e6f601ea3 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/lightweight_problem_info_v_2.rb @@ -9,9 +9,7 @@ class LightweightProblemInfoV2 < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :variable_types, -> { - Internal::Types::Array[Seed::Commons::Types::VariableType] - }, optional: false, nullable: false, api_name: "variableTypes" + field :variable_types, -> { Internal::Types::Array[Seed::Commons::Types::VariableType] }, optional: false, nullable: false, api_name: "variableTypes" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_definition.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_definition.rb index 632596d176ab..03b8befba181 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_definition.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_definition.rb @@ -6,12 +6,8 @@ module V3 module Problem module Types class NonVoidFunctionDefinition < Internal::Types::Model - field :signature, -> { - Seed::V2::V3::Problem::Types::NonVoidFunctionSignature - }, optional: false, nullable: false - field :code, -> { - Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :signature, -> { Seed::V2::V3::Problem::Types::NonVoidFunctionSignature }, optional: false, nullable: false + field :code, -> { Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_signature.rb index be9f6825c433..b83e8bd4526f 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/non_void_function_signature.rb @@ -6,12 +6,8 @@ module V3 module Problem module Types class NonVoidFunctionSignature < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] - }, optional: false, nullable: false - field :return_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "returnType" + field :parameters, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] }, optional: false, nullable: false + field :return_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "returnType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/parameter.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/parameter.rb index 6cf985ae6462..82b6842389cd 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/parameter.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/parameter.rb @@ -8,9 +8,7 @@ module Types class Parameter < Internal::Types::Model field :parameter_id, -> { String }, optional: false, nullable: false, api_name: "parameterId" field :name, -> { String }, optional: false, nullable: false - field :variable_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "variableType" + field :variable_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "variableType" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/problem_info_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/problem_info_v_2.rb index 33e5fdf53486..5fb37908124b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/problem_info_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/problem_info_v_2.rb @@ -7,26 +7,14 @@ module Problem module Types class ProblemInfoV2 < Internal::Types::Model field :problem_id, -> { String }, optional: false, nullable: false, api_name: "problemId" - field :problem_description, -> { - Seed::Problem::Types::ProblemDescription - }, optional: false, nullable: false, api_name: "problemDescription" + field :problem_description, -> { Seed::Problem::Types::ProblemDescription }, optional: false, nullable: false, api_name: "problemDescription" field :problem_name, -> { String }, optional: false, nullable: false, api_name: "problemName" field :problem_version, -> { Integer }, optional: false, nullable: false, api_name: "problemVersion" - field :supported_languages, -> { - Internal::Types::Array[Seed::Commons::Types::Language] - }, optional: false, nullable: false, api_name: "supportedLanguages" - field :custom_files, -> { - Seed::V2::V3::Problem::Types::CustomFiles - }, optional: false, nullable: false, api_name: "customFiles" - field :generated_files, -> { - Seed::V2::V3::Problem::Types::GeneratedFiles - }, optional: false, nullable: false, api_name: "generatedFiles" - field :custom_test_case_templates, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseTemplate] - }, optional: false, nullable: false, api_name: "customTestCaseTemplates" - field :testcases, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseV2] - }, optional: false, nullable: false + field :supported_languages, -> { Internal::Types::Array[Seed::Commons::Types::Language] }, optional: false, nullable: false, api_name: "supportedLanguages" + field :custom_files, -> { Seed::V2::V3::Problem::Types::CustomFiles }, optional: false, nullable: false, api_name: "customFiles" + field :generated_files, -> { Seed::V2::V3::Problem::Types::GeneratedFiles }, optional: false, nullable: false, api_name: "generatedFiles" + field :custom_test_case_templates, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseTemplate] }, optional: false, nullable: false, api_name: "customTestCaseTemplates" + field :testcases, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseV2] }, optional: false, nullable: false field :is_public, -> { Internal::Types::Boolean }, optional: false, nullable: false, api_name: "isPublic" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_function.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_function.rb index e9c95274fa5a..ece00d1b049b 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_function.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_function.rb @@ -10,9 +10,7 @@ class TestCaseFunction < Internal::Types::Model discriminant :type - member -> { - Seed::V2::V3::Problem::Types::TestCaseWithActualResultImplementation - }, key: "WITH_ACTUAL_RESULT" + member -> { Seed::V2::V3::Problem::Types::TestCaseWithActualResultImplementation }, key: "WITH_ACTUAL_RESULT" member -> { Seed::V2::V3::Problem::Types::VoidFunctionDefinition }, key: "CUSTOM" end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation.rb index ac987bbf6598..67b349a532ef 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class TestCaseImplementation < Internal::Types::Model - field :description, -> { - Seed::V2::V3::Problem::Types::TestCaseImplementationDescription - }, optional: false, nullable: false + field :description, -> { Seed::V2::V3::Problem::Types::TestCaseImplementationDescription }, optional: false, nullable: false field :function, -> { Seed::V2::V3::Problem::Types::TestCaseFunction }, optional: false, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation_description.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation_description.rb index 2f979d375a01..39d516aff6c1 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation_description.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_implementation_description.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class TestCaseImplementationDescription < Internal::Types::Model - field :boards, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseImplementationDescriptionBoard] - }, optional: false, nullable: false + field :boards, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::TestCaseImplementationDescriptionBoard] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_template.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_template.rb index 2b8371bca239..c2dbbc1d366e 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_template.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_template.rb @@ -8,9 +8,7 @@ module Types class TestCaseTemplate < Internal::Types::Model field :template_id, -> { String }, optional: false, nullable: false, api_name: "templateId" field :name, -> { String }, optional: false, nullable: false - field :implementation, -> { - Seed::V2::V3::Problem::Types::TestCaseImplementation - }, optional: false, nullable: false + field :implementation, -> { Seed::V2::V3::Problem::Types::TestCaseImplementation }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_v_2.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_v_2.rb index 400814040f8d..8cbc34d03478 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_v_2.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_v_2.rb @@ -7,12 +7,8 @@ module Problem module Types class TestCaseV2 < Internal::Types::Model field :metadata, -> { Seed::V2::V3::Problem::Types::TestCaseMetadata }, optional: false, nullable: false - field :implementation, -> { - Seed::V2::V3::Problem::Types::TestCaseImplementationReference - }, optional: false, nullable: false - field :arguments, -> { - Internal::Types::Hash[String, Seed::Commons::Types::VariableValue] - }, optional: false, nullable: false + field :implementation, -> { Seed::V2::V3::Problem::Types::TestCaseImplementationReference }, optional: false, nullable: false + field :arguments, -> { Internal::Types::Hash[String, Seed::Commons::Types::VariableValue] }, optional: false, nullable: false field :expects, -> { Seed::V2::V3::Problem::Types::TestCaseExpects }, optional: true, nullable: false end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb index ddf95d2d6627..ba1a5b42a747 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/test_case_with_actual_result_implementation.rb @@ -6,12 +6,8 @@ module V3 module Problem module Types class TestCaseWithActualResultImplementation < Internal::Types::Model - field :get_actual_result, -> { - Seed::V2::V3::Problem::Types::NonVoidFunctionDefinition - }, optional: false, nullable: false, api_name: "getActualResult" - field :assert_correctness_check, -> { - Seed::V2::V3::Problem::Types::AssertCorrectnessCheck - }, optional: false, nullable: false, api_name: "assertCorrectnessCheck" + field :get_actual_result, -> { Seed::V2::V3::Problem::Types::NonVoidFunctionDefinition }, optional: false, nullable: false, api_name: "getActualResult" + field :assert_correctness_check, -> { Seed::V2::V3::Problem::Types::AssertCorrectnessCheck }, optional: false, nullable: false, api_name: "assertCorrectnessCheck" end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition.rb index fe08e1eb800e..74b91f155b0c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition.rb @@ -6,12 +6,8 @@ module V3 module Problem module Types class VoidFunctionDefinition < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] - }, optional: false, nullable: false - field :code, -> { - Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :parameters, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] }, optional: false, nullable: false + field :code, -> { Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb index 5e14dc16482b..65f0127dbf27 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_definition_that_takes_actual_result.rb @@ -7,12 +7,8 @@ module Problem module Types # The generated signature will include an additional param, actualResult class VoidFunctionDefinitionThatTakesActualResult < Internal::Types::Model - field :additional_parameters, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] - }, optional: false, nullable: false, api_name: "additionalParameters" - field :code, -> { - Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages - }, optional: false, nullable: false + field :additional_parameters, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] }, optional: false, nullable: false, api_name: "additionalParameters" + field :code, -> { Seed::V2::V3::Problem::Types::FunctionImplementationForMultipleLanguages }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature.rb index 1557c8800cd2..c2c8eb71bb06 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature.rb @@ -6,9 +6,7 @@ module V3 module Problem module Types class VoidFunctionSignature < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] - }, optional: false, nullable: false + field :parameters, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb index 50044e97aead..ba858a3eb88c 100644 --- a/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb +++ b/seed/ruby-sdk-v2/trace/lib/seed/v_2/v_3/problem/types/void_function_signature_that_takes_actual_result.rb @@ -6,12 +6,8 @@ module V3 module Problem module Types class VoidFunctionSignatureThatTakesActualResult < Internal::Types::Model - field :parameters, -> { - Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] - }, optional: false, nullable: false - field :actual_result_type, -> { - Seed::Commons::Types::VariableType - }, optional: false, nullable: false, api_name: "actualResultType" + field :parameters, -> { Internal::Types::Array[Seed::V2::V3::Problem::Types::Parameter] }, optional: false, nullable: false + field :actual_result_type, -> { Seed::Commons::Types::VariableType }, optional: false, nullable: false, api_name: "actualResultType" end end end diff --git a/seed/ruby-sdk-v2/trace/reference.md b/seed/ruby-sdk-v2/trace/reference.md index 9eee8652594e..3f3263f06468 100644 --- a/seed/ruby-sdk-v2/trace/reference.md +++ b/seed/ruby-sdk-v2/trace/reference.md @@ -39,7 +39,10 @@ client.v_2.test();
```ruby -client.admin.update_test_submission_status(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.update_test_submission_status( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: {} +); ```
@@ -89,7 +92,8 @@ client.admin.update_test_submission_status(submission_id: 'd5e9c84f-c2b2-4bf4-b4 ```ruby client.admin.send_test_submission_update( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - update_time: '2024-01-15T09:30:00Z' + update_time: '2024-01-15T09:30:00Z', + update_info: {} ); ``` @@ -138,7 +142,10 @@ client.admin.send_test_submission_update(
```ruby -client.admin.update_workspace_submission_status(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.update_workspace_submission_status( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: {} +); ```
@@ -188,7 +195,8 @@ client.admin.update_workspace_submission_status(submission_id: 'd5e9c84f-c2b2-4b ```ruby client.admin.send_workspace_submission_update( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - update_time: '2024-01-15T09:30:00Z' + update_time: '2024-01-15T09:30:00Z', + update_info: {} ); ``` @@ -242,6 +250,10 @@ client.admin.store_traced_test_case( test_case_id: 'testCaseId', result: { result: { + expected_result: {}, + actual_result: { + value: {} + }, passed: true }, stdout: 'stdout' @@ -249,6 +261,7 @@ client.admin.store_traced_test_case( trace_responses: [{ submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -259,9 +272,13 @@ client.admin.store_traced_test_case( method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -269,6 +286,7 @@ client.admin.store_traced_test_case( }, { submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -279,9 +297,13 @@ client.admin.store_traced_test_case( method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -353,7 +375,66 @@ client.admin.store_traced_test_case( ```ruby client.admin.store_traced_test_case_v_2( submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', - test_case_id: 'testCaseId' + test_case_id: 'testCaseId', + request: [{ + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }, { + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }] ); ``` @@ -423,6 +504,7 @@ client.admin.store_traced_workspace( trace_responses: [{ submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -433,9 +515,13 @@ client.admin.store_traced_workspace( method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -443,6 +529,7 @@ client.admin.store_traced_workspace( }, { submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', line_number: 1, + return_value: {}, expression_location: { start: 1, offset: 1 @@ -453,9 +540,13 @@ client.admin.store_traced_workspace( method_name: 'methodName', line_number: 1, scopes: [{ - variables: {} + variables: { + variables: {} + } }, { - variables: {} + variables: { + variables: {} + } }] } }, @@ -517,7 +608,68 @@ client.admin.store_traced_workspace(
```ruby -client.admin.store_traced_workspace_v_2(submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32'); +client.admin.store_traced_workspace_v_2( + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + request: [{ + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }, { + submission_id: 'd5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32', + line_number: 1, + file: { + filename: 'filename', + directory: 'directory' + }, + return_value: {}, + expression_location: { + start: 1, + offset: 1 + }, + stack: { + num_stack_frames: 1, + top_stack_frame: { + method_name: 'methodName', + line_number: 1, + scopes: [{ + variables: { + variables: {} + } + }, { + variables: { + variables: {} + } + }] + } + }, + stdout: 'stdout' + }] +); ```
@@ -591,7 +743,7 @@ client.homepage.get_homepage_problems();
```ruby -client.homepage.set_homepage_problems(); +client.homepage.set_homepage_problems(request: ['string', 'string']); ```
@@ -938,7 +1090,11 @@ Updates a playlist ```ruby client.playlist.update_playlist( service_param: 1, - playlist_id: 'playlistId' + playlist_id: 'playlistId', + request: { + name: 'name', + problems: ['problems', 'problems'] + } ); ``` @@ -1078,24 +1234,43 @@ Creates a problem client.problem.create_problem( problem_name: 'problemName', problem_description: { - boards: [] + boards: [{}, {}] + }, + files: { + JAVA: { + solution_file: { + filename: 'filename', + contents: 'contents' + }, + read_only_files: [{ + filename: 'filename', + contents: 'contents' + }, { + filename: 'filename', + contents: 'contents' + }] + } }, - files: {}, input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, testcases: [{ test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }, { test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }], method_name: 'methodName' ); @@ -1156,24 +1331,43 @@ client.problem.update_problem( problem_id: 'problemId', problem_name: 'problemName', problem_description: { - boards: [] + boards: [{}, {}] + }, + files: { + JAVA: { + solution_file: { + filename: 'filename', + contents: 'contents' + }, + read_only_files: [{ + filename: 'filename', + contents: 'contents' + }, { + filename: 'filename', + contents: 'contents' + }] + } }, - files: {}, input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, testcases: [{ test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }, { test_case: { id: 'id', - params: [] - } + params: [{}, {}] + }, + expected_result: {} }], method_name: 'methodName' ); @@ -1294,10 +1488,13 @@ Returns default starter files for problem ```ruby client.problem.get_default_starter_files( input_params: [{ + variable_type: {}, name: 'name' }, { + variable_type: {}, name: 'name' }], + output_type: {}, method_name: 'methodName' ); ``` @@ -1377,7 +1574,7 @@ Returns sessionId and execution server URL for session. Spins up server.
```ruby -client.submission.create_execution_session(); +client.submission.create_execution_session(language: 'JAVA'); ```
@@ -1551,7 +1748,10 @@ client.submission.get_execution_sessions_state();
```ruby -client.sysprop.set_num_warm_instances(num_warm_instances: 1); +client.sysprop.set_num_warm_instances( + language: 'JAVA', + num_warm_instances: 1 +); ```
diff --git a/seed/ruby-sdk-v2/trace/seed.gemspec b/seed/ruby-sdk-v2/trace/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/trace/seed.gemspec +++ b/seed/ruby-sdk-v2/trace/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/trace/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/.rubocop.yml b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/.rubocop.yml +++ b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/seed.gemspec b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/seed.gemspec +++ b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/undiscriminated-union-with-response-property/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/.rubocop.yml b/seed/ruby-sdk-v2/undiscriminated-unions/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/.rubocop.yml +++ b/seed/ruby-sdk-v2/undiscriminated-unions/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example0/snippet.rb index 45be905b454f..4218764937ec 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example0/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.get(); +client.union.get(request: 'string'); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example10/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example10/snippet.rb index 7b627ea27376..64e6e3cfcdc1 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example10/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example10/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.test_camel_case_properties(); +client.union.test_camel_case_properties(payment_method: { + method_: 'method', + card_number: 'cardNumber' +}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example3/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example3/snippet.rb index 5cc8074a2bf0..2bfc4e134459 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example3/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example3/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.update_metadata(); +client.union.update_metadata(request: {}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example4/snippet.rb index 5cc8074a2bf0..2bfc4e134459 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example4/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.update_metadata(); +client.union.update_metadata(request: {}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example5/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example5/snippet.rb index 29806dfbba22..3779cc7561d4 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example5/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example5/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.call(); +client.union.call(union: {}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example6/snippet.rb index 29806dfbba22..3779cc7561d4 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example6/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.call(); +client.union.call(union: {}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example7/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example7/snippet.rb index 78b48c45672a..a4215de07fdd 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example7/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example7/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.duplicate_types_union(); +client.union.duplicate_types_union(request: 'string'); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example8/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example8/snippet.rb index b5560ce29df0..86b2de30f5b3 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example8/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example8/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.nested_unions(); +client.union.nested_unions(request: 'string'); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example9/snippet.rb b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example9/snippet.rb index 7b627ea27376..5ae43eedb4aa 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example9/snippet.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/dynamic-snippets/example9/snippet.rb @@ -2,4 +2,7 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.union.test_camel_case_properties(); +client.union.test_camel_case_properties(payment_method: { + method_: 'card', + card_number: '1234567890123456' +}); diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/client.rb b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/client.rb index e576f11664e4..e48b3f65590e 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/client.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/client.rb @@ -24,7 +24,8 @@ def get(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "", - body: Seed::Union::Types::MyUnion.new(params).to_h + body: Seed::Union::Types::MyUnion.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -53,7 +54,8 @@ def get_metadata(request_options: {}, **_params) request = Seed::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "GET", - path: "/metadata" + path: "/metadata", + request_options: request_options ) begin response = @client.send(request) @@ -83,7 +85,8 @@ def update_metadata(request_options: {}, **params) base_url: request_options[:base_url], method: "PUT", path: "/metadata", - body: Seed::Union::Types::MetadataUnion.new(params).to_h + body: Seed::Union::Types::MetadataUnion.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -111,7 +114,8 @@ def call(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/call", - body: Seed::Union::Types::Request.new(params).to_h + body: Seed::Union::Types::Request.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -139,7 +143,8 @@ def duplicate_types_union(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/duplicate", - body: Seed::Union::Types::UnionWithDuplicateTypes.new(params).to_h + body: Seed::Union::Types::UnionWithDuplicateTypes.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -169,7 +174,8 @@ def nested_unions(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/nested", - body: Seed::Union::Types::NestedUnionRoot.new(params).to_h + body: Seed::Union::Types::NestedUnionRoot.new(params).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -200,7 +206,8 @@ def test_camel_case_properties(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/camel-case", - body: Seed::Union::Types::PaymentRequest.new(body_bag).to_h + body: Seed::Union::Types::PaymentRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/named_metadata.rb b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/named_metadata.rb index 2bdcfd70960a..e6f3a404e8c3 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/named_metadata.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/named_metadata.rb @@ -5,9 +5,7 @@ module Union module Types class NamedMetadata < Internal::Types::Model field :name, -> { String }, optional: false, nullable: false - field :value, -> { - Internal::Types::Hash[String, Internal::Types::Hash[String, Object]] - }, optional: false, nullable: false + field :value, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false end end end diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/payment_request.rb b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/payment_request.rb index 36879880797f..ace55e57fcf1 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/payment_request.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/lib/seed/union/types/payment_request.rb @@ -4,9 +4,7 @@ module Seed module Union module Types class PaymentRequest < Internal::Types::Model - field :payment_method, -> { - Seed::Union::Types::PaymentMethodUnion - }, optional: false, nullable: false, api_name: "paymentMethod" + field :payment_method, -> { Seed::Union::Types::PaymentMethodUnion }, optional: false, nullable: false, api_name: "paymentMethod" end end end diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/reference.md b/seed/ruby-sdk-v2/undiscriminated-unions/reference.md index c91f0514f68e..259169808577 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/reference.md +++ b/seed/ruby-sdk-v2/undiscriminated-unions/reference.md @@ -13,7 +13,7 @@
```ruby -client.union.get(); +client.union.get(request: 'string'); ```
@@ -78,7 +78,7 @@ client.union.get_metadata();
```ruby -client.union.update_metadata(); +client.union.update_metadata(request: {}); ```
@@ -118,7 +118,7 @@ client.union.update_metadata();
```ruby -client.union.call(); +client.union.call(union: {}); ```
@@ -158,7 +158,7 @@ client.union.call();
```ruby -client.union.duplicate_types_union(); +client.union.duplicate_types_union(request: 'string'); ```
@@ -198,7 +198,7 @@ client.union.duplicate_types_union();
```ruby -client.union.nested_unions(); +client.union.nested_unions(request: 'string'); ```
@@ -238,7 +238,10 @@ client.union.nested_unions();
```ruby -client.union.test_camel_case_properties(); +client.union.test_camel_case_properties(payment_method: { + method_: 'card', + card_number: '1234567890123456' +}); ```
diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/seed.gemspec b/seed/ruby-sdk-v2/undiscriminated-unions/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/seed.gemspec +++ b/seed/ruby-sdk-v2/undiscriminated-unions/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/undiscriminated-unions/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/unions-with-local-date/.rubocop.yml b/seed/ruby-sdk-v2/unions-with-local-date/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/.rubocop.yml +++ b/seed/ruby-sdk-v2/unions-with-local-date/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example10/snippet.rb b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example10/snippet.rb index c17f0077bedb..0b7d5d0bffca 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example10/snippet.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example10/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.bigunion.update(); +client.union.update(); diff --git a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example2/snippet.rb index 57fd46b47bdb..5ca82753dc2f 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example2/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.bigunion.update_many(); +client.bigunion.update_many(request: []); diff --git a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example6/snippet.rb b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example6/snippet.rb index fd09cdbf9f00..98572eca78e5 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example6/snippet.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example6/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.types.update(); +client.types.update(request: {}); diff --git a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example7/snippet.rb b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example7/snippet.rb index fd09cdbf9f00..98572eca78e5 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example7/snippet.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example7/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.types.update(); +client.types.update(request: {}); diff --git a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example8/snippet.rb b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example8/snippet.rb index fd09cdbf9f00..12f85d7b6d4e 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example8/snippet.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/dynamic-snippets/example8/snippet.rb @@ -2,4 +2,6 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.types.update(); +client.types.update(request: { + value: 1 +}); diff --git a/seed/ruby-sdk-v2/unions-with-local-date/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/unions-with-local-date/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/unions-with-local-date/reference.md b/seed/ruby-sdk-v2/unions-with-local-date/reference.md index 0b179f574d3e..ad99a2fe9b24 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/reference.md +++ b/seed/ruby-sdk-v2/unions-with-local-date/reference.md @@ -93,7 +93,7 @@ client.bigunion.update();
```ruby -client.bigunion.update_many(); +client.bigunion.update_many(request: []); ```
@@ -174,7 +174,7 @@ client.types.get(id: 'date-example');
```ruby -client.types.update(); +client.types.update(request: {}); ```
@@ -255,7 +255,7 @@ client.bigunion.get(id: 'id');
```ruby -client.bigunion.update(); +client.union.update(); ```
diff --git a/seed/ruby-sdk-v2/unions-with-local-date/seed.gemspec b/seed/ruby-sdk-v2/unions-with-local-date/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/seed.gemspec +++ b/seed/ruby-sdk-v2/unions-with-local-date/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/unions-with-local-date/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/unions/.rubocop.yml b/seed/ruby-sdk-v2/unions/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/unions/.rubocop.yml +++ b/seed/ruby-sdk-v2/unions/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/unions/dynamic-snippets/example2/snippet.rb b/seed/ruby-sdk-v2/unions/dynamic-snippets/example2/snippet.rb index 57fd46b47bdb..5ca82753dc2f 100644 --- a/seed/ruby-sdk-v2/unions/dynamic-snippets/example2/snippet.rb +++ b/seed/ruby-sdk-v2/unions/dynamic-snippets/example2/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.bigunion.update_many(); +client.bigunion.update_many(request: []); diff --git a/seed/ruby-sdk-v2/unions/dynamic-snippets/example4/snippet.rb b/seed/ruby-sdk-v2/unions/dynamic-snippets/example4/snippet.rb index c17f0077bedb..0b7d5d0bffca 100644 --- a/seed/ruby-sdk-v2/unions/dynamic-snippets/example4/snippet.rb +++ b/seed/ruby-sdk-v2/unions/dynamic-snippets/example4/snippet.rb @@ -2,4 +2,4 @@ client = Seed::Client.new(base_url: 'https://api.fern.com'); -client.bigunion.update(); +client.union.update(); diff --git a/seed/ruby-sdk-v2/unions/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/unions/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/unions/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/unions/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/unions/reference.md b/seed/ruby-sdk-v2/unions/reference.md index c8b2967f5ee8..08ed0f249410 100644 --- a/seed/ruby-sdk-v2/unions/reference.md +++ b/seed/ruby-sdk-v2/unions/reference.md @@ -93,7 +93,7 @@ client.bigunion.update();
```ruby -client.bigunion.update_many(); +client.bigunion.update_many(request: []); ```
@@ -174,7 +174,7 @@ client.bigunion.get(id: 'id');
```ruby -client.bigunion.update(); +client.union.update(); ```
diff --git a/seed/ruby-sdk-v2/unions/seed.gemspec b/seed/ruby-sdk-v2/unions/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/unions/seed.gemspec +++ b/seed/ruby-sdk-v2/unions/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/unions/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/unknown/.rubocop.yml b/seed/ruby-sdk-v2/unknown/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/unknown/.rubocop.yml +++ b/seed/ruby-sdk-v2/unknown/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/unknown/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/unknown/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/unknown/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/unknown/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/unknown/seed.gemspec b/seed/ruby-sdk-v2/unknown/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/unknown/seed.gemspec +++ b/seed/ruby-sdk-v2/unknown/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/unknown/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/url-form-encoded/.rubocop.yml b/seed/ruby-sdk-v2/url-form-encoded/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/url-form-encoded/.rubocop.yml +++ b/seed/ruby-sdk-v2/url-form-encoded/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/url-form-encoded/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/url-form-encoded/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/url-form-encoded/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/url-form-encoded/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/url-form-encoded/seed.gemspec b/seed/ruby-sdk-v2/url-form-encoded/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/url-form-encoded/seed.gemspec +++ b/seed/ruby-sdk-v2/url-form-encoded/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/url-form-encoded/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/validation/.rubocop.yml b/seed/ruby-sdk-v2/validation/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/validation/.rubocop.yml +++ b/seed/ruby-sdk-v2/validation/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/validation/dynamic-snippets/example0/snippet.rb b/seed/ruby-sdk-v2/validation/dynamic-snippets/example0/snippet.rb index 836152e1378b..11c13b1cd122 100644 --- a/seed/ruby-sdk-v2/validation/dynamic-snippets/example0/snippet.rb +++ b/seed/ruby-sdk-v2/validation/dynamic-snippets/example0/snippet.rb @@ -5,5 +5,6 @@ client.create( decimal: 2.2, even: 100, - name: 'fern' + name: 'fern', + shape: 'SQUARE' ); diff --git a/seed/ruby-sdk-v2/validation/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/validation/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/validation/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/validation/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/validation/reference.md b/seed/ruby-sdk-v2/validation/reference.md index 26eef3402cc1..db4d510c8db5 100644 --- a/seed/ruby-sdk-v2/validation/reference.md +++ b/seed/ruby-sdk-v2/validation/reference.md @@ -15,7 +15,8 @@ client.create( decimal: 2.2, even: 100, - name: 'fern' + name: 'fern', + shape: 'SQUARE' ); ``` diff --git a/seed/ruby-sdk-v2/validation/seed.gemspec b/seed/ruby-sdk-v2/validation/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/validation/seed.gemspec +++ b/seed/ruby-sdk-v2/validation/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/validation/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/variables/.rubocop.yml b/seed/ruby-sdk-v2/variables/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/variables/.rubocop.yml +++ b/seed/ruby-sdk-v2/variables/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/variables/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/variables/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/variables/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/variables/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/variables/seed.gemspec b/seed/ruby-sdk-v2/variables/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/variables/seed.gemspec +++ b/seed/ruby-sdk-v2/variables/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/variables/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/version-no-default/.rubocop.yml b/seed/ruby-sdk-v2/version-no-default/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/version-no-default/.rubocop.yml +++ b/seed/ruby-sdk-v2/version-no-default/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/version-no-default/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/version-no-default/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/version-no-default/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/version-no-default/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/version-no-default/seed.gemspec b/seed/ruby-sdk-v2/version-no-default/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/version-no-default/seed.gemspec +++ b/seed/ruby-sdk-v2/version-no-default/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/version-no-default/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/version/.rubocop.yml b/seed/ruby-sdk-v2/version/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/version/.rubocop.yml +++ b/seed/ruby-sdk-v2/version/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/version/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/version/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/version/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/version/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/version/seed.gemspec b/seed/ruby-sdk-v2/version/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/version/seed.gemspec +++ b/seed/ruby-sdk-v2/version/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/version/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/websocket-bearer-auth/.rubocop.yml b/seed/ruby-sdk-v2/websocket-bearer-auth/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/websocket-bearer-auth/.rubocop.yml +++ b/seed/ruby-sdk-v2/websocket-bearer-auth/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/websocket-bearer-auth/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/websocket-bearer-auth/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/websocket-bearer-auth/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/websocket-bearer-auth/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/websocket-bearer-auth/seed.gemspec b/seed/ruby-sdk-v2/websocket-bearer-auth/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/websocket-bearer-auth/seed.gemspec +++ b/seed/ruby-sdk-v2/websocket-bearer-auth/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket-bearer-auth/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/.rubocop.yml b/seed/ruby-sdk-v2/websocket-inferred-auth/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/.rubocop.yml +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/auth/client.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/auth/client.rb index e59bd162be52..bb6c07da0736 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/auth/client.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/auth/client.rb @@ -28,7 +28,8 @@ def get_token_with_client_credentials(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token", - body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::GetTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) @@ -62,7 +63,8 @@ def refresh_token(request_options: {}, **params) base_url: request_options[:base_url], method: "POST", path: "/token/refresh", - body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h + body: Seed::Auth::Types::RefreshTokenRequest.new(body_bag).to_h, + request_options: request_options ) begin response = @client.send(request) diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/client.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/client.rb index ac4021c9fd98..511109b1800e 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/client.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/client.rb @@ -28,8 +28,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) # Create the auth provider with the auth client and credentials @auth_provider = Seed::Internal::InferredAuthProvider.new( auth_client: auth_client, - options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, - x_api_key: x_api_key } + options: { base_url: base_url, client_id: client_id, client_secret: client_secret, scope: scope, x_api_key: x_api_key } ) @raw_client = Seed::Internal::Http::RawClient.new( @@ -37,7 +36,7 @@ def initialize(base_url:, client_id:, client_secret:, x_api_key:, scope: nil) headers: { "User-Agent" => "fern_websocket-inferred-auth/0.0.1", "X-Fern-Language" => "Ruby" - }.merge(@auth_provider.get_auth_headers) + }.merge(@auth_provider.auth_headers) ) end diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/inferred_auth_provider.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/inferred_auth_provider.rb index ac882f4886c8..b3ec8a0ea7bc 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/inferred_auth_provider.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/inferred_auth_provider.rb @@ -19,7 +19,7 @@ def initialize(auth_client:, options:) # Refreshes the token if it's nil, or if we're within the buffer period before expiration. # # @return [String] - def get_token + def token return refresh if @access_token.nil? @access_token @@ -28,10 +28,10 @@ def get_token # Returns the authentication headers to be included in requests. # # @return [Hash[String, String]] - def get_auth_headers - token = get_token + def auth_headers + access_token = token { - "Authorization" => "Bearer #{token}" + "Authorization" => "Bearer #{access_token}" } end # Refreshes the access token by calling the token endpoint. @@ -47,8 +47,7 @@ def get_auth_headers scope: @options[:scope] } - token_response = @auth_client.get_token_with_client_credentials(**request_params, -request_options: { base_url: @options[:base_url] }) + token_response = @auth_client.get_token_with_client_credentials(**request_params, request_options: { base_url: @options[:base_url] }) @access_token = token_response.access_token diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/seed.gemspec b/seed/ruby-sdk-v2/websocket-inferred-auth/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/seed.gemspec +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket-inferred-auth/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end diff --git a/seed/ruby-sdk-v2/websocket/.rubocop.yml b/seed/ruby-sdk-v2/websocket/.rubocop.yml index c03cf73d740e..2c5567ea193e 100644 --- a/seed/ruby-sdk-v2/websocket/.rubocop.yml +++ b/seed/ruby-sdk-v2/websocket/.rubocop.yml @@ -41,6 +41,12 @@ Metrics/CyclomaticComplexity: Metrics/ModuleLength: Enabled: false +Layout/LineLength: + Enabled: false + +Naming/VariableNumber: + EnforcedStyle: snake_case + Style/Documentation: Enabled: false diff --git a/seed/ruby-sdk-v2/websocket/lib/seed/internal/types/union.rb b/seed/ruby-sdk-v2/websocket/lib/seed/internal/types/union.rb index 53aeab2e7e8b..8e47f2f1a592 100644 --- a/seed/ruby-sdk-v2/websocket/lib/seed/internal/types/union.rb +++ b/seed/ruby-sdk-v2/websocket/lib/seed/internal/types/union.rb @@ -72,10 +72,7 @@ def discriminant(key) # Validate that all required (non-optional) fields are present # This ensures undiscriminated unions properly distinguish between member types member_type.fields.each do |field_name, field| - if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional - raise Errors::TypeError, - "Required field `#{field_name}` missing for union member #{member_type.name}" - end + raise Errors::TypeError, "Required field `#{field_name}` missing for union member #{member_type.name}" if candidate.instance_variable_get(:@data)[field_name].nil? && !field.optional end true diff --git a/seed/ruby-sdk-v2/websocket/seed.gemspec b/seed/ruby-sdk-v2/websocket/seed.gemspec index a5f3cc69681f..23b6a2279add 100644 --- a/seed/ruby-sdk-v2/websocket/seed.gemspec +++ b/seed/ruby-sdk-v2/websocket/seed.gemspec @@ -27,9 +27,6 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" - # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_cursor_item_iterator.rb b/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_cursor_item_iterator.rb index 0fb0fc550be6..5008f6abf69f 100644 --- a/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -4,9 +4,9 @@ require "stringio" require "json" require "test_helper" -require "ostruct" NUMBERS = (1..65).to_a +PageResponse = Struct.new(:cards, :next_cursor, keyword_init: true) class CursorItemIteratorTest < Minitest::Test def make_iterator(initial_cursor:) @@ -16,7 +16,7 @@ def make_iterator(initial_cursor:) @times_called += 1 cursor ||= 0 next_cursor = cursor + 10 - OpenStruct.new( + PageResponse.new( cards: NUMBERS[cursor...next_cursor], next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil ) diff --git a/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_offset_item_iterator.rb b/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_offset_item_iterator.rb index 311f28622209..92576b820128 100644 --- a/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_offset_item_iterator.rb +++ b/seed/ruby-sdk-v2/websocket/test/unit/internal/iterators/test_offset_item_iterator.rb @@ -4,8 +4,8 @@ require "stringio" require "json" require "test_helper" -require "ostruct" +OffsetPageResponse = Struct.new(:items, :has_next, keyword_init: true) TestIteratorConfig = Struct.new( :step, :has_next_field, @@ -22,8 +22,7 @@ def first_item_returned end end -LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, - total_item_count: 65, per_page: 10) +LAZY_TEST_ITERATOR_CONFIG = TestIteratorConfig.new(initial_page: 1, step: false, has_next_field: :has_next, total_item_count: 65, per_page: 10) ALL_TEST_ITERATOR_CONFIGS = [true, false].map do |step| [:has_next, nil].map do |has_next_field| [0, 5, 10, 60, 63].map do |total_item_count| @@ -67,7 +66,7 @@ def make_iterator(config) } output[config.has_next_field] = slice_end < items.length if config.has_next_field - OpenStruct.new(output) + OffsetPageResponse.new(**output) end end