Class List Method List File List

# Class: VertxAuthOauth2::OAuth2Response

Inherits:
  Object
  - Object
  - VertxAuthOauth2::OAuth2Response
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb

## Overview

A response from a fetch request. This class represents a secure response from a Oauth2 fetch call. A fetch is a simplified HTTP response from a protected resource.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (::Vertx::Buffer) body
  The HTTP response body as a buffer.
- - (String) get_header(name = nil)
  Looks up a HTTP response header by name, in case where the response is a list of headers, the first one is returned.
- - (::Vertx::MultiMap) headers
  The HTTP response headers from the HTTP layer.
- - (true, false) is?(contentType = nil)
  Helper to analize the response body.
- - (Array<String,Object>) json_array
  The HTTP response body as a JsonArray.
- - (Hash{String => Object}) json_object
  The HTTP response body as a JsonObject.
- - (Fixnum) status_code
  the returned status code from the HTTP layer.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    23
    24
    25
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 23

    def @@j_api_type.accept?(obj)
      obj.class == OAuth2Response
    end

### + (`Object`) j_api_type

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 32

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    35
    36
    37
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 35

    def self.j_class
      Java::IoVertxExtAuthOauth2::OAuth2Response.java_class
    end

### + (`Object`) unwrap(obj)

    29
    30
    31
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 29

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 26

    def @@j_api_type.wrap(obj)
      OAuth2Response.new(obj)
    end

## Instance Method Details

### - (`::Vertx::Buffer`) body

The HTTP response body as a buffer

Returns:

- (`::Vertx::Buffer`) —
  a buffer with the HTTP response body

Raises:

- (`ArgumentError`)

    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 66

    def body
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:body, []).call(),::Vertx::Buffer)
      end
      raise ArgumentError, "Invalid arguments when calling body()"
    end

### - (`String`) get_header(name = nil)

Looks up a HTTP response header by name, in case where the response is a list of headers, the first one is returned.

Parameters:

- name (`String`) (defaults to: `nil`) —
  of the header to look up

Returns:

- (`String`) —
  the single value for the header.

Raises:

- (`ArgumentError`)

    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 58

    def get_header(name=nil)
      if name.class == String && !block_given?
        return @j_del.java_method(:getHeader, [Java::java.lang.String.java_class]).call(name)
      end
      raise ArgumentError, "Invalid arguments when calling get_header(#{name})"
    end

### - (`::Vertx::MultiMap`) headers

The HTTP response headers from the HTTP layer.

Returns:

- (`::Vertx::MultiMap`) —
  the HTTP headers

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 48

    def headers
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headers, []).call(),::Vertx::MultiMap)
      end
      raise ArgumentError, "Invalid arguments when calling headers()"
    end

### - (`true`, `false`) is?(contentType = nil)

Helper to analize the response body. The test is performed against the header Content-Type, the content of the body is not analyzed.

Parameters:

- contentType (`String`) (defaults to: `nil`) —
  a content type to test, e.g.: application/json

Returns:

- (`true`, `false`) —
  true if the header matches

Raises:

- (`ArgumentError`)

    92
    93
    94
    95
    96
    97
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 92

    def is?(contentType=nil)
      if contentType.class == String && !block_given?
        return @j_del.java_method(:is, [Java::java.lang.String.java_class]).call(contentType)
      end
      raise ArgumentError, "Invalid arguments when calling is?(#{contentType})"
    end

### - (`Array<String,Object>`) json_array

The HTTP response body as a JsonArray

Returns:

- (`Array<String,Object>`) —
  a JsonArray from the HTTP response body

Raises:

- (`ArgumentError`)

    82
    83
    84
    85
    86
    87
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 82

    def json_array
      if !block_given?
        return @j_del.java_method(:jsonArray, []).call() != nil ? JSON.parse(@j_del.java_method(:jsonArray, []).call().encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling json_array()"
    end

### - (`Hash{String => Object}`) json_object

The HTTP response body as a JsonObject

Returns:

- (`Hash{String => Object}`) —
  a JsonObject from the HTTP response body

Raises:

- (`ArgumentError`)

    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 74

    def json_object
      if !block_given?
        return @j_del.java_method(:jsonObject, []).call() != nil ? JSON.parse(@j_del.java_method(:jsonObject, []).call().encode) : nil
      end
      raise ArgumentError, "Invalid arguments when calling json_object()"
    end

### - (`Fixnum`) status_code

the returned status code from the HTTP layer.

Returns:

- (`Fixnum`) —
  HTTP status code

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-oauth2/o_auth2_response.rb', line 40

    def status_code
      if !block_given?
        return @j_del.java_method(:statusCode, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling status_code()"
    end