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.



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

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

Instance Attribute Details

#api_keyObject (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

#emailObject (readonly)

Returns the value of attribute email.



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

def email
  @email
end

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#master_keyObject (readonly)

Returns the value of attribute master_key.



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

def master_key
  @master_key
end

#org_idObject (readonly)

Returns the value of attribute org_id.



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

def org_id
  @org_id
end

#password_hashObject (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_restObject

Build a megam api client

Parameters

api

The Megam::API client



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

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