Class: Megam::RestAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/megam/core/rest_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(o) ⇒ RestAdapter

clean up this module later.



14
15
16
17
18
19
20
21
# File 'lib/megam/core/rest_adapter.rb', line 14

def initialize(o)
    @email = o[:email]
    @api_key = o[:api_key] || nil
    @host = o[:host]
    @password_hash = o[:password_hash] || nil
    @org_id = o[:org_id]
    @headers = o[:headers]
end

Instance Attribute Details

#api_key ⇒ Object (readonly)

Returns the value of attribute api_key.



4
5
6
# File 'lib/megam/core/rest_adapter.rb', line 4

def api_key
  @api_key
end

#email ⇒ Object (readonly)

Returns the value of attribute email.



3
4
5
# File 'lib/megam/core/rest_adapter.rb', line 3

def email
  @email
end

#headers ⇒ Object (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/megam/core/rest_adapter.rb', line 10

def headers
  @headers
end

#host ⇒ Object (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/megam/core/rest_adapter.rb', line 5

def host
  @host
end

#org_id ⇒ Object (readonly)

Returns the value of attribute org_id.



9
10
11
# File 'lib/megam/core/rest_adapter.rb', line 9

def org_id
  @org_id
end

#password_hash ⇒ Object (readonly)

the name :password is used as attr_accessor in accounts, hence we use gpassword



8
9
10
# File 'lib/megam/core/rest_adapter.rb', line 8

def password_hash
  @password_hash
end

Instance Method Details

#megam_rest ⇒ Object

Build a megam api client

Parameters

api

The Megam::API client



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/megam/core/rest_adapter.rb', line 27

def megam_rest
    options = {
      :email => email,
      :api_key => api_key,
      :org_id => org_id,
      :password_hash => password_hash,
      :host => host
    }
    if headers
      options[:headers] = headers
    end
    Megam::API.new(options)
end