Class: MockServer::HttpRequest
- Inherits:
-
Object
- Object
- MockServer::HttpRequest
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#keep_alive ⇒ Object
Returns the value of attribute keep_alive.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
-
#query_string_parameters ⇒ Object
Returns the value of attribute query_string_parameters.
-
#respond_before_body ⇒ Object
Returns the value of attribute respond_before_body.
-
#secure ⇒ Object
Returns the value of attribute secure.
-
#socket_address ⇒ Object
Returns the value of attribute socket_address.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method: nil, path: nil, query_string_parameters: nil, headers: nil, cookies: nil, body: nil, secure: nil, keep_alive: nil, respond_before_body: nil, path_parameters: nil, socket_address: nil) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #to_h ⇒ Object
- #with_body(body) ⇒ Object
- #with_cookie(name, value) ⇒ Object
- #with_header(name, *values) ⇒ Object
- #with_keep_alive(keep_alive) ⇒ Object
- #with_method(method) ⇒ Object
- #with_path(path) ⇒ Object
- #with_query_param(name, *values) ⇒ Object
- #with_respond_before_body(respond_before_body) ⇒ Object
- #with_secure(secure) ⇒ Object
Constructor Details
#initialize(method: nil, path: nil, query_string_parameters: nil, headers: nil, cookies: nil, body: nil, secure: nil, keep_alive: nil, respond_before_body: nil, path_parameters: nil, socket_address: nil) ⇒ HttpRequest
Returns a new instance of HttpRequest.
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/mockserver/models.rb', line 603 def initialize(method: nil, path: nil, query_string_parameters: nil, headers: nil, cookies: nil, body: nil, secure: nil, keep_alive: nil, respond_before_body: nil, path_parameters: nil, socket_address: nil) @method = method @path = path @query_string_parameters = query_string_parameters @headers = headers @cookies = @body = body @secure = secure @keep_alive = keep_alive @respond_before_body = respond_before_body @path_parameters = path_parameters @socket_address = socket_address end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def body @body end |
#cookies ⇒ Object
Returns the value of attribute cookies.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def @cookies end |
#headers ⇒ Object
Returns the value of attribute headers.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def headers @headers end |
#keep_alive ⇒ Object
Returns the value of attribute keep_alive.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def keep_alive @keep_alive end |
#method ⇒ Object
Returns the value of attribute method.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def method @method end |
#path ⇒ Object
Returns the value of attribute path.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def path @path end |
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def path_parameters @path_parameters end |
#query_string_parameters ⇒ Object
Returns the value of attribute query_string_parameters.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def query_string_parameters @query_string_parameters end |
#respond_before_body ⇒ Object
Returns the value of attribute respond_before_body.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def respond_before_body @respond_before_body end |
#secure ⇒ Object
Returns the value of attribute secure.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def secure @secure end |
#socket_address ⇒ Object
Returns the value of attribute socket_address.
599 600 601 |
# File 'lib/mockserver/models.rb', line 599 def socket_address @socket_address end |
Class Method Details
.from_hash(data) ⇒ Object
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/mockserver/models.rb', line 635 def self.from_hash(data) return nil if data.nil? new( method: data['method'], path: data['path'], query_string_parameters: MockServer.deserialize_key_multi_values(data['queryStringParameters']), headers: MockServer.deserialize_key_multi_values(data['headers']), cookies: MockServer.(data['cookies']), body: MockServer.deserialize_body(data['body']), secure: data['secure'], keep_alive: data['keepAlive'], respond_before_body: data['respondBeforeBody'], path_parameters: MockServer.deserialize_key_multi_values(data['pathParameters']), socket_address: SocketAddress.from_hash(data['socketAddress']) ) end |
.request(path: nil) ⇒ Object
653 654 655 |
# File 'lib/mockserver/models.rb', line 653 def self.request(path: nil) new(path: path) end |
Instance Method Details
#to_h ⇒ Object
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/mockserver/models.rb', line 619 def to_h MockServer.strip_none({ 'method' => @method, 'path' => @path, 'queryStringParameters' => MockServer.serialize_key_multi_values(@query_string_parameters), 'headers' => MockServer.serialize_key_multi_values(@headers), 'cookies' => MockServer.(@cookies), 'body' => MockServer.serialize_body(@body), 'secure' => @secure, 'keepAlive' => @keep_alive, 'respondBeforeBody' => @respond_before_body, 'pathParameters' => MockServer.serialize_key_multi_values(@path_parameters), 'socketAddress' => @socket_address&.to_h }) end |
#with_body(body) ⇒ Object
685 686 687 688 |
# File 'lib/mockserver/models.rb', line 685 def with_body(body) @body = body self end |
#with_cookie(name, value) ⇒ Object
679 680 681 682 683 |
# File 'lib/mockserver/models.rb', line 679 def (name, value) @cookies ||= [] @cookies << KeyToMultiValue.new(name: name, values: [value]) self end |
#with_header(name, *values) ⇒ Object
667 668 669 670 671 |
# File 'lib/mockserver/models.rb', line 667 def with_header(name, *values) @headers ||= [] @headers << KeyToMultiValue.new(name: name, values: values.flatten) self end |
#with_keep_alive(keep_alive) ⇒ Object
695 696 697 698 |
# File 'lib/mockserver/models.rb', line 695 def with_keep_alive(keep_alive) @keep_alive = keep_alive self end |
#with_method(method) ⇒ Object
657 658 659 660 |
# File 'lib/mockserver/models.rb', line 657 def with_method(method) @method = method self end |
#with_path(path) ⇒ Object
662 663 664 665 |
# File 'lib/mockserver/models.rb', line 662 def with_path(path) @path = path self end |
#with_query_param(name, *values) ⇒ Object
673 674 675 676 677 |
# File 'lib/mockserver/models.rb', line 673 def with_query_param(name, *values) @query_string_parameters ||= [] @query_string_parameters << KeyToMultiValue.new(name: name, values: values.flatten) self end |
#with_respond_before_body(respond_before_body) ⇒ Object
700 701 702 703 |
# File 'lib/mockserver/models.rb', line 700 def with_respond_before_body(respond_before_body) @respond_before_body = respond_before_body self end |
#with_secure(secure) ⇒ Object
690 691 692 693 |
# File 'lib/mockserver/models.rb', line 690 def with_secure(secure) @secure = secure self end |