Module: AmemberPro

Defined in:
lib/amember_pro.rb,
lib/amember_pro/users.rb,
lib/amember_pro/access.rb,
lib/amember_pro/version.rb,
lib/amember_pro/invoices.rb,
lib/amember_pro/products.rb,
lib/amember_pro/parameters.rb,
lib/amember_pro/check_access.rb,
lib/amember_pro/billing_plans.rb,
lib/amember_pro/invoice_refunds.rb,
lib/amember_pro/invoice_payments.rb

Defined Under Namespace

Modules: Configurator, Method Classes: Access, BillingPlans, CheckAccess, InvoicePayments, InvoiceRefunds, Invoices, Parameters, Products, Users

Constant Summary collapse

END_POINT =
'api'
VERSION =
"0.2.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.access_keyObject

Returns the value of attribute access_key.



18
19
20
# File 'lib/amember_pro.rb', line 18

def access_key
  @access_key
end

.methodObject

Returns the value of attribute method.



20
21
22
# File 'lib/amember_pro.rb', line 20

def method
  @method
end

.paramsObject

Returns the value of attribute params.



19
20
21
# File 'lib/amember_pro.rb', line 19

def params
  @params
end

.urlObject

Returns the value of attribute url.



17
18
19
# File 'lib/amember_pro.rb', line 17

def url
  @url
end

Class Method Details

.connection(controller) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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) ⇒ Object



22
23
24
25
# File 'lib/amember_pro.rb', line 22

def new(url, access_key)
  self.url = url
  self.access_key = access_key
end