class RMeetup::Client

RMeetup::Client

Essentially a simple wrapper to delegate requests to different fetcher classes who are responsible for fetching and parsing their own responses.

Constants

FETCH_TYPES
POST_TYPES

Public Class Methods

api_key() click to toggle source
# File lib/rmeetup.rb, line 39
def self.api_key; @@api_key; end
api_key=(key) click to toggle source
# File lib/rmeetup.rb, line 40
def self.api_key=(key); @@api_key = key; end
fetch(type, options = {}) click to toggle source
# File lib/rmeetup.rb, line 42
def self.fetch(type, options = {})
  check_configuration!
  
  # Merge in all the standard options
  # Keeping whatever was passed in
  options = default_options.merge(options)
  
  if FETCH_TYPES.include?(type.to_sym)
    # Get the custom fetcher used to manage options, api call to get a type of response
    fetcher = RMeetup::Fetcher.for(type)
    return fetcher.fetch(options)
  else
    raise InvalidRequestTypeError.new(type)
  end
end
post(type, options = {}) click to toggle source
# File lib/rmeetup.rb, line 58
def self.post(type, options = {})
  check_configuration!
  options = default_options.merge(options)
  
  if POST_TYPES.include?(type.to_sym)
    poster = RMeetup::Poster.for(type)
    return poster.post(options)
  else
    raise InvalidRequestTypeError.new(type)
  end
end

Protected Class Methods

check_configuration!() click to toggle source

Raise an error if RMeetup has not been provided with an api key

# File lib/rmeetup.rb, line 78
def self.check_configuration!
  raise NotConfiguredError.new unless api_key
end
default_options() click to toggle source
# File lib/rmeetup.rb, line 70
def self.default_options
  {
    :key => api_key
  }
end