class Tickethub::Endpoint
Attributes
options[R]
Public Class Methods
new(url, options)
click to toggle source
# File lib/tickethub/endpoint.rb, line 11 def initialize(url, options) @url = _normalize_path url @options = options end
Public Instance Methods
[](*parts)
click to toggle source
# File lib/tickethub/endpoint.rb, line 16 def [](*parts) parts = parts.compact.map { |part| _normalize_path part.to_s } self.class.new URI.join(url, *parts).to_s, @options end
_normalize_path(str)
click to toggle source
# File lib/tickethub/endpoint.rb, line 40 def _normalize_path(str) str.match(/\/$/) ? str : "#{str}/" end
request(params, options)
click to toggle source
# File lib/tickethub/endpoint.rb, line 35 def request(params, options) raise 'this endpoint is readonly' if frozen? Tickethub::Request.new(url, options.merge(params: params)).execute end
uri()
click to toggle source
# File lib/tickethub/endpoint.rb, line 27 def uri URI.parse @url end
url(params = {})
click to toggle source
# File lib/tickethub/endpoint.rb, line 31 def url(params = {}) return params.empty?? @url : "#{@url}?#{Helpers.to_param(params)}" end