Class: Sink::Resources::Responses

Inherits:
Object
  • Object
show all
Defined in:
lib/sink/resources/responses.rb,
lib/sink/resources/responses/union_types.rb

Defined Under Namespace

Classes: UnionTypes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Responses

Returns a new instance of Responses.

Parameters:



10
11
12
13
# File 'lib/sink/resources/responses.rb', line 10

def initialize(client:)
  @client = client
  @union_types = Sink::Resources::Responses::UnionTypes.new(client: client)
end

Instance Attribute Details

#union_typesSink::Resources::Responses::UnionTypes (readonly)



7
8
9
# File 'lib/sink/resources/responses.rb', line 7

def union_types
  @union_types
end

Instance Method Details

#additional_properties(opts = {}) ⇒ Hash

Endpoint with a top level additionalProperties response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (Hash)


20
21
22
23
24
25
26
27
# File 'lib/sink/resources/responses.rb', line 20

def additional_properties(opts = {})
  req = {
    method: :post,
    path: "/responses/additional_properties",
    model: Hash
  }
  @client.request(req, opts)
end

#additional_properties_nested_model_reference(opts = {}) ⇒ Hash

Endpoint with a top level additionalProperties response where the items type

points to an object defined as a model in the config.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (Hash)


35
36
37
38
39
40
41
42
# File 'lib/sink/resources/responses.rb', line 35

def additional_properties_nested_model_reference(opts = {})
  req = {
    method: :post,
    path: "/responses/additional_properties_nested_model_reference",
    model: Hash
  }
  @client.request(req, opts)
end

#allof_simple(opts = {}) ⇒ Sink::Models::ResponseAllofSimpleResponse

Method with a response object defined using allOf and inline schema definitions.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



49
50
51
52
53
54
55
56
# File 'lib/sink/resources/responses.rb', line 49

def allof_simple(opts = {})
  req = {
    method: :get,
    path: "/responses/allof/simple",
    model: Sink::Models::ResponseAllofSimpleResponse
  }
  @client.request(req, opts)
end

#anyof_null(opts = {}) ⇒ Sink::Models::ObjectWithAnyOfNullProperty

Method with a response object that uses anyOf to indicate nullability.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



63
64
65
66
67
68
69
70
# File 'lib/sink/resources/responses.rb', line 63

def anyof_null(opts = {})
  req = {
    method: :get,
    path: "/responses/anyof_null",
    model: Sink::Models::ObjectWithAnyOfNullProperty
  }
  @client.request(req, opts)
end

#array_object_with_union_properties(opts = {}) ⇒ Array<Sink::Models::ObjectWithUnionProperties>

Endpoint that returns an array of objects with union properties.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



77
78
79
80
81
82
83
84
# File 'lib/sink/resources/responses.rb', line 77

def array_object_with_union_properties(opts = {})
  req = {
    method: :get,
    path: "/responses/array/object_with_union_properties",
    model: Sink::ArrayOf.new(Sink::Models::ObjectWithUnionProperties)
  }
  @client.request(req, opts)
end

#array_response(opts = {}) ⇒ Array<Sink::Models::SimpleObject>

Endpoint that returns a top-level array.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



91
92
93
94
95
96
97
98
# File 'lib/sink/resources/responses.rb', line 91

def array_response(opts = {})
  req = {
    method: :get,
    path: "/responses/array",
    model: Sink::ArrayOf.new(Sink::Models::SimpleObject)
  }
  @client.request(req, opts)
end

#boolean_response(opts = {}) ⇒ Boolean

Endpoint with a top level boolean response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (Boolean)


105
106
107
108
109
110
111
112
# File 'lib/sink/resources/responses.rb', line 105

def boolean_response(opts = {})
  req = {
    method: :post,
    path: "/responses/boolean",
    model: Sink::BooleanModel
  }
  @client.request(req, opts)
end

#empty_response(opts = {}) ⇒ nil

Endpoint with an empty response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (nil)


119
120
121
122
123
124
125
126
# File 'lib/sink/resources/responses.rb', line 119

def empty_response(opts = {})
  req = {
    method: :post,
    path: "/responses/empty",
    model: NilClass
  }
  @client.request(req, opts)
end

#integer_response(opts = {}) ⇒ Integer

Endpoint with a top level integer response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (Integer)


133
134
135
136
137
138
139
140
# File 'lib/sink/resources/responses.rb', line 133

def integer_response(opts = {})
  req = {
    method: :post,
    path: "/responses/integer",
    model: Integer
  }
  @client.request(req, opts)
end

#missing_required(opts = {}) ⇒ Sink::Models::ResponseMissingRequiredResponse

Endpoint with a response schema that doesn’t set the ‘required` property.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



147
148
149
150
151
152
153
154
# File 'lib/sink/resources/responses.rb', line 147

def missing_required(opts = {})
  req = {
    method: :get,
    path: "/responses/missing_required",
    model: Sink::Models::ResponseMissingRequiredResponse
  }
  @client.request(req, opts)
end

#nested_array(opts = {}) ⇒ Sink::Models::ResponseNestedArrayResponse

Endpoint that returns a nested array.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



161
162
163
164
165
166
167
168
# File 'lib/sink/resources/responses.rb', line 161

def nested_array(opts = {})
  req = {
    method: :get,
    path: "/responses/array/nested",
    model: Sink::Models::ResponseNestedArrayResponse
  }
  @client.request(req, opts)
end

#object_all_properties(opts = {}) ⇒ Sink::Models::ResponseObjectAllPropertiesResponse

Method with a response object with a different property for each supported type.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



175
176
177
178
179
180
181
182
# File 'lib/sink/resources/responses.rb', line 175

def object_all_properties(opts = {})
  req = {
    method: :get,
    path: "/responses/object/everything",
    model: Sink::Models::ResponseObjectAllPropertiesResponse
  }
  @client.request(req, opts)
end

#object_no_properties(opts = {}) ⇒ Sink::Models::ResponseObjectNoPropertiesResponse

Endpoint with an empty response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



189
190
191
192
193
194
195
196
# File 'lib/sink/resources/responses.rb', line 189

def object_no_properties(opts = {})
  req = {
    method: :post,
    path: "/responses/object_no_properties",
    model: Sink::Models::ResponseObjectNoPropertiesResponse
  }
  @client.request(req, opts)
end

#object_with_additional_properties_prop(opts = {}) ⇒ Sink::Models::ResponseObjectWithAdditionalPropertiesPropResponse

Endpoint with an object response that contains an ‘additionalProperties`

property with a nested schema.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



204
205
206
207
208
209
210
211
# File 'lib/sink/resources/responses.rb', line 204

def object_with_additional_properties_prop(opts = {})
  req = {
    method: :post,
    path: "/responses/object_with_additional_properties_prop",
    model: Sink::Models::ResponseObjectWithAdditionalPropertiesPropResponse
  }
  @client.request(req, opts)
end

#object_with_heavily_nested_union(opts = {}) ⇒ Sink::Models::ResponseObjectWithHeavilyNestedUnionResponse

Endpoint with an object response that contains a union property with multiple

nested schemas.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



219
220
221
222
223
224
225
226
# File 'lib/sink/resources/responses.rb', line 219

def object_with_heavily_nested_union(opts = {})
  req = {
    method: :post,
    path: "/responses/object_with_heavily_nested_union",
    model: Sink::Models::ResponseObjectWithHeavilyNestedUnionResponse
  }
  @client.request(req, opts)
end

#oneof_null(opts = {}) ⇒ Sink::Models::ObjectWithOneOfNullProperty

Method with a response object that uses oneOf to indicate nullability.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



233
234
235
236
237
238
239
240
# File 'lib/sink/resources/responses.rb', line 233

def oneof_null(opts = {})
  req = {
    method: :get,
    path: "/responses/oneof_null",
    model: Sink::Models::ObjectWithOneOfNullProperty
  }
  @client.request(req, opts)
end

#only_read_only_properties(opts = {}) ⇒ Sink::Models::ResponseOnlyReadOnlyPropertiesResponse

Endpoint with a response that only has ‘readOnly` properties

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



247
248
249
250
251
252
253
254
# File 'lib/sink/resources/responses.rb', line 247

def only_read_only_properties(opts = {})
  req = {
    method: :get,
    path: "/responses/only_read_only_properties",
    model: Sink::Models::ResponseOnlyReadOnlyPropertiesResponse
  }
  @client.request(req, opts)
end

#shared_simple_object(opts = {}) ⇒ Sink::Models::SimpleObject

Endpoint that returns a $ref to SimpleObject. This is used to test shared

response models.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



262
263
264
265
266
267
268
269
# File 'lib/sink/resources/responses.rb', line 262

def shared_simple_object(opts = {})
  req = {
    method: :get,
    path: "/responses/shared_simple_object",
    model: Sink::Models::SimpleObject
  }
  @client.request(req, opts)
end

#string_response(opts = {}) ⇒ String

Endpoint with a top level string response.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (String)


276
277
278
279
280
281
282
283
# File 'lib/sink/resources/responses.rb', line 276

def string_response(opts = {})
  req = {
    method: :post,
    path: "/responses/string",
    model: String
  }
  @client.request(req, opts)
end

#unknown_object(opts = {}) ⇒ Object

Should not generate a named return type for object without defined properties;

instead, it should simply use an `unknown` type or equivalent. In Java and Go,
where we have fancier accessors for raw json stuff, we should generate a named
type, but it should basically just have untyped additional properties. See
https://linear.app/stainless/issue/STA-563/no-type-should-be-generated-for-endpoints-returning-type-object-schema.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:

  • (Object)


294
295
296
297
298
299
300
301
# File 'lib/sink/resources/responses.rb', line 294

def unknown_object(opts = {})
  req = {
    method: :post,
    path: "/responses/unknown_object",
    model: Sink::Unknown
  }
  @client.request(req, opts)
end

#with_model_in_nested_path(opts = {}) ⇒ Sink::Models::ModelWithNestedModel

Should return a ModelWithNestedModel object with a ‘properties` field that we

can rename in the Stainless config to a prettier name.

Parameters:

  • opts (Hash, Sink::RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



309
310
311
312
313
314
315
316
# File 'lib/sink/resources/responses.rb', line 309

def with_model_in_nested_path(opts = {})
  req = {
    method: :get,
    path: "/responses/with_model_in_nested_path",
    model: Sink::Models::ModelWithNestedModel
  }
  @client.request(req, opts)
end