Class: MMS::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mms/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Client

Returns a new instance of Client.



22
23
24
25
26
27
28
29
30
# File 'lib/mms/client.rb', line 22

def initialize
  @username, @apikey = nil

  @api_protocol = 'https'
  @api_host = 'mms.mongodb.com'
  @api_port = '443'
  @api_path = '/api/public'
  @api_version = 'v1.0'
end

Instance Attribute Details

#api_host ⇒ Object

Returns the value of attribute api_host.



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

def api_host
  @api_host
end

#api_path ⇒ Object

Returns the value of attribute api_path.



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

def api_path
  @api_path
end

#api_port ⇒ Object

Returns the value of attribute api_port.



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

def api_port
  @api_port
end

#api_protocol ⇒ Object

Returns the value of attribute api_protocol.



16
17
18
# File 'lib/mms/client.rb', line 16

def api_protocol
  @api_protocol
end

#api_version ⇒ Object

Returns the value of attribute api_version.



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

def api_version
  @api_version
end

#apikey ⇒ Object

Returns the value of attribute apikey.



14
15
16
# File 'lib/mms/client.rb', line 14

def apikey
  @apikey
end

#username ⇒ Object

Returns the value of attribute username.



13
14
15
# File 'lib/mms/client.rb', line 13

def username
  @username
end

Instance Method Details

#auth_setup(username, apikey) ⇒ Object



32
33
34
35
# File 'lib/mms/client.rb', line 32

def auth_setup(username, apikey)
  @username = username
  @apikey = apikey
end

#get(path) ⇒ Object



41
42
43
# File 'lib/mms/client.rb', line 41

def get(path)
  _get site + path, @username, @apikey
end

#post(path, data) ⇒ Object



45
46
47
# File 'lib/mms/client.rb', line 45

def post(path, data)
  _post site + path, data, @username, @apikey
end

#site ⇒ Object



37
38
39
# File 'lib/mms/client.rb', line 37

def site
  [@api_protocol, '://', @api_host, ':', @api_port, @api_path, '/',  @api_version].join.to_s
end