module AmemberPro

Constants

END_POINT
VERSION

Attributes

access_key[RW]
method[RW]
params[RW]
url[RW]

Public Class Methods

connection(controller) click to toggle source
# File lib/amember_pro.rb, line 27
def connection(controller)
  method = self.method
  params = self.params.to_hash
  api = "#{self::END_POINT}/#{controller.to_s}"

  if method == Method::PUT or method == Method::DELETE
    api += "/#{params[:id]}"
  end

  params[:_key] = self.access_key
  conn = Faraday.new(:url => self.url, :ssl => {:verify => false})

  case method
  when Method::GET
    conn.get api, params
  when Method::POST
    conn.post api, params
  when Method::PUT
    conn.put api, params
  when Method::DELETE
    conn.delete api, params
  end
end
new(url, access_key) click to toggle source
# File lib/amember_pro.rb, line 22
def new(url, access_key)
  self.url = url
  self.access_key = access_key
end