Class: Tickethub::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/tickethub/endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Endpoint

Returns a new instance of Endpoint.



9
10
11
12
# File 'lib/tickethub/endpoint.rb', line 9

def initialize(url, options = {})
  @url     = url
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/tickethub/endpoint.rb', line 7

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/tickethub/endpoint.rb', line 7

def url
  @url
end

Instance Method Details

#[](suburl, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tickethub/endpoint.rb', line 14

def [](suburl, options = {})
  url = (if suburl.nil? then self.url
    else
      suburl = suburl.to_s
      base   = self.url
      base  += "/" unless base =~ /\/$/
      URI.join(base, suburl).to_s
    end)

  self.class.new url, Tickethub::Helpers.deep_merge(@options, options)
end

#request(options = {}) ⇒ Object



32
33
34
# File 'lib/tickethub/endpoint.rb', line 32

def request(options = {})
  Tickethub::Request.new(url, Tickethub::Helpers.deep_merge(@options, options)).execute
end