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.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#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.
-
#template_type ⇒ Object
Returns the value of attribute template_type.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .exact(value) ⇒ Object
- .file(file_path, content_type: nil, template_type: nil) ⇒ 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, file_path: nil, template_type: nil) ⇒ Body
constructor
A new instance of Body.
- #to_h ⇒ Object
- #with_template_type(template_type) ⇒ Object
Constructor Details
#initialize(type: nil, string: nil, json: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil, file_path: nil, template_type: nil) ⇒ Body
Returns a new instance of Body.
368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/mockserver/models.rb', line 368 def initialize(type: nil, string: nil, json: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil, file_path: nil, template_type: nil) @type = type @string = string @json = json @base64_bytes = base64_bytes @not_body = not_body @content_type = content_type @charset = charset @file_path = file_path @template_type = template_type end |
Instance Attribute Details
#base64_bytes ⇒ Object
Returns the value of attribute base64_bytes.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def base64_bytes @base64_bytes end |
#charset ⇒ Object
Returns the value of attribute charset.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def charset @charset end |
#content_type ⇒ Object
Returns the value of attribute content_type.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def content_type @content_type end |
#file_path ⇒ Object
Returns the value of attribute file_path.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def file_path @file_path end |
#json ⇒ Object
Returns the value of attribute json.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def json @json end |
#not_body ⇒ Object
Returns the value of attribute not_body.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def not_body @not_body end |
#string ⇒ Object
Returns the value of attribute string.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def string @string end |
#template_type ⇒ Object
Returns the value of attribute template_type.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def template_type @template_type end |
#type ⇒ Object
Returns the value of attribute type.
365 366 367 |
# File 'lib/mockserver/models.rb', line 365 def type @type end |
Class Method Details
.exact(value) ⇒ Object
423 424 425 |
# File 'lib/mockserver/models.rb', line 423 def self.exact(value) new(type: 'STRING', string: value) end |
.file(file_path, content_type: nil, template_type: nil) ⇒ Object
431 432 433 |
# File 'lib/mockserver/models.rb', line 431 def self.file(file_path, content_type: nil, template_type: nil) new(type: 'FILE', file_path: file_path, content_type: content_type, template_type: template_type) end |
.from_hash(data) ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/mockserver/models.rb', line 395 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'], file_path: data['filePath'], template_type: data['templateType'] ) end |
.graphql(query, operation_name: nil, variables_schema: nil) ⇒ Object
439 440 441 |
# File 'lib/mockserver/models.rb', line 439 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
415 416 417 |
# File 'lib/mockserver/models.rb', line 415 def self.json(value) new(type: 'JSON', json: value) end |
.json_rpc(method_name, params_schema: nil) ⇒ Object
435 436 437 |
# File 'lib/mockserver/models.rb', line 435 def self.json_rpc(method_name, params_schema: nil) JsonRpcBody.new(method_name: method_name, params_schema: params_schema) end |
.regex(value) ⇒ Object
419 420 421 |
# File 'lib/mockserver/models.rb', line 419 def self.regex(value) new(type: 'REGEX', string: value) end |
.string(value) ⇒ Object
411 412 413 |
# File 'lib/mockserver/models.rb', line 411 def self.string(value) new(type: 'STRING', string: value) end |
.xml(value) ⇒ Object
427 428 429 |
# File 'lib/mockserver/models.rb', line 427 def self.xml(value) new(type: 'XML', string: value) end |
Instance Method Details
#to_h ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/mockserver/models.rb', line 381 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['filePath'] = @file_path unless @file_path.nil? result['templateType'] = @template_type unless @template_type.nil? result end |
#with_template_type(template_type) ⇒ Object
443 444 445 446 |
# File 'lib/mockserver/models.rb', line 443 def with_template_type(template_type) @template_type = template_type self end |