Class: Megam::ServerAPI

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

Overview

Basic HTTP client, with support for adding features via middleware

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email = nil, api_key = nil, host = nil) ⇒ ServerAPI

Create a Megam REST object. The supplied email and api_key is used as the base for all subsequent requests. For example, when initialized with an email, api_key url api.megam.io, a call to get with ‘accounts’ will make an HTTP GET request to api.megam.io/accounts using the email, api_key



31
32
33
34
35
# File 'lib/megam/core/server_api.rb', line 31

def initialize(email=nil, api_key=nil, host=nil)
  @email = email
  @api_key = api_key
  @host = host
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



23
24
25
# File 'lib/megam/core/server_api.rb', line 23

def api_key
  @api_key
end

#emailObject (readonly)

Returns the value of attribute email.



22
23
24
# File 'lib/megam/core/server_api.rb', line 22

def email
  @email
end

#hostObject (readonly)

Returns the value of attribute host.



24
25
26
# File 'lib/megam/core/server_api.rb', line 24

def host
  @host
end

Instance Method Details

#megam_restObject

Build a megam api client

Parameters

api

The Megam::API client



41
42
43
44
# File 'lib/megam/core/server_api.rb', line 41

def megam_rest
  options = { :email =>email || Megam::Config[:email], :api_key => api_key || Megam::Config[:api_key], :host => host || Megam::Config[:host]}
  Megam::API.new(options)
end