Class: MockServer::Body
- Inherits:
-
Object
- Object
- MockServer::Body
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#base64_bytes ⇒ Object
Returns the value of attribute base64_bytes.
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#json ⇒ Object
Returns the value of attribute json.
-
#not_body ⇒ Object
Returns the value of attribute not_body.
-
#string ⇒ Object
Returns the value of attribute string.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .exact(value) ⇒ Object
- .from_hash(data) ⇒ Object
- .graphql(query, operation_name: nil, variables_schema: nil) ⇒ Object
- .json(value) ⇒ Object
- .json_rpc(method_name, params_schema: nil) ⇒ Object
- .regex(value) ⇒ Object
- .string(value) ⇒ Object
- .xml(value) ⇒ Object
Instance Method Summary collapse
-
#initialize(type: nil, string: nil, json: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil) ⇒ Body
constructor
A new instance of Body.
- #to_h ⇒ Object
Constructor Details
#initialize(type: nil, string: nil, json: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil) ⇒ Body
Returns a new instance of Body.
344 345 346 347 348 349 350 351 352 |
# File 'lib/mockserver/models.rb', line 344 def initialize(type: nil, string: nil, json: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil) @type = type @string = string @json = json @base64_bytes = base64_bytes @not_body = not_body @content_type = content_type @charset = charset end |
Instance Attribute Details
#base64_bytes ⇒ Object
Returns the value of attribute base64_bytes.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def base64_bytes @base64_bytes end |
#charset ⇒ Object
Returns the value of attribute charset.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def charset @charset end |
#content_type ⇒ Object
Returns the value of attribute content_type.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def content_type @content_type end |
#json ⇒ Object
Returns the value of attribute json.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def json @json end |
#not_body ⇒ Object
Returns the value of attribute not_body.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def not_body @not_body end |
#string ⇒ Object
Returns the value of attribute string.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def string @string end |
#type ⇒ Object
Returns the value of attribute type.
342 343 344 |
# File 'lib/mockserver/models.rb', line 342 def type @type end |
Class Method Details
.exact(value) ⇒ Object
392 393 394 |
# File 'lib/mockserver/models.rb', line 392 def self.exact(value) new(type: 'STRING', string: value) end |
.from_hash(data) ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/mockserver/models.rb', line 366 def self.from_hash(data) return nil if data.nil? new( type: data['type'], string: data['string'], json: data['json'], base64_bytes: data['base64Bytes'], not_body: data['not'], content_type: data['contentType'], charset: data['charset'] ) end |
.graphql(query, operation_name: nil, variables_schema: nil) ⇒ Object
404 405 406 |
# File 'lib/mockserver/models.rb', line 404 def self.graphql(query, operation_name: nil, variables_schema: nil) GraphQLBody.new(query: query, operation_name: operation_name, variables_schema: variables_schema) end |
.json(value) ⇒ Object
384 385 386 |
# File 'lib/mockserver/models.rb', line 384 def self.json(value) new(type: 'JSON', json: value) end |
.json_rpc(method_name, params_schema: nil) ⇒ Object
400 401 402 |
# File 'lib/mockserver/models.rb', line 400 def self.json_rpc(method_name, params_schema: nil) JsonRpcBody.new(method_name: method_name, params_schema: params_schema) end |
.regex(value) ⇒ Object
388 389 390 |
# File 'lib/mockserver/models.rb', line 388 def self.regex(value) new(type: 'REGEX', string: value) end |
.string(value) ⇒ Object
380 381 382 |
# File 'lib/mockserver/models.rb', line 380 def self.string(value) new(type: 'STRING', string: value) end |
.xml(value) ⇒ Object
396 397 398 |
# File 'lib/mockserver/models.rb', line 396 def self.xml(value) new(type: 'XML', string: value) end |
Instance Method Details
#to_h ⇒ Object
354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/mockserver/models.rb', line 354 def to_h result = {} result['type'] = @type unless @type.nil? result['string'] = @string unless @string.nil? result['json'] = @json unless @json.nil? result['base64Bytes'] = @base64_bytes unless @base64_bytes.nil? result['not'] = @not_body unless @not_body.nil? result['contentType'] = @content_type unless @content_type.nil? result['charset'] = @charset unless @charset.nil? result end |