Class: EventbriteAPI::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rubybrite/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = "", query = {}) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/rubybrite/request.rb', line 8

def initialize(path = "", query = {})
  @path = path
  @query = query
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/rubybrite/request.rb', line 28

def method_missing(method, *args)
  params = args[0].is_a?(Hash) ? args[0] : {}
  route, token = path.split("?")
  id = params.delete(:id)
  route += "/#{method}/#{id}?#{token}"
  Request.new(route, params)
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/rubybrite/request.rb', line 6

def path
  @path
end

#queryObject

Returns the value of attribute query.



6
7
8
# File 'lib/rubybrite/request.rb', line 6

def query
  @query
end

Instance Method Details

#deleteObject



23
24
25
26
# File 'lib/rubybrite/request.rb', line 23

def delete
  response = self.class.delete(path, query: query).body
  Response.new(response)
end

#getObject



13
14
15
16
# File 'lib/rubybrite/request.rb', line 13

def get
  response = self.class.get(path, query: query).body
  Response.new(response)
end

#postObject



18
19
20
21
# File 'lib/rubybrite/request.rb', line 18

def post
  response = self.class.post(path, query: query).body
  Response.new(response)
end