Class: Gupshup::REST::Domain
- Inherits:
-
Object
- Object
- Gupshup::REST::Domain
- Defined in:
- lib/gupshup-rb/framework/rest/domain.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #absolute_url(uri) ⇒ Object
-
#initialize(client) ⇒ Domain
constructor
A new instance of Domain.
- #request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ Domain
Returns a new instance of Domain.
8 9 10 11 12 13 |
# File 'lib/gupshup-rb/framework/rest/domain.rb', line 8 def initialize(client) @client = client @host = nil @base_url = nil @port = nil end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/gupshup-rb/framework/rest/domain.rb', line 6 def client @client end |
Instance Method Details
#absolute_url(uri) ⇒ Object
15 16 17 |
# File 'lib/gupshup-rb/framework/rest/domain.rb', line 15 def absolute_url(uri) "#{@base_url.chomp('/')}/#{uri.chomp('/').gsub(/^\//, '')}" end |
#request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gupshup-rb/framework/rest/domain.rb', line 19 def request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) url = uri.match(/^http/) ? uri : absolute_url(uri) @client.request( @base_url, @port, method, url, params, data, headers, auth, timeout ) end |