Class: MMS::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username = nil, apikey = nil, url = nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • username (String) (defaults to: nil)
  • apikey (String) (defaults to: nil)
  • url (String) (defaults to: nil)


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

def initialize(username = nil, apikey = nil, url = nil)
  @username = username
  @apikey = apikey
  @url = url.nil? ? 'https://mms.mongodb.com:443/api/public/v1.0' : url
end

Instance Attribute Details

#apikeyObject

Returns the value of attribute apikey.



6
7
8
# File 'lib/mms/client.rb', line 6

def apikey
  @apikey
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/mms/client.rb', line 7

def url
  @url
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/mms/client.rb', line 5

def username
  @username
end

Instance Method Details

#get(path) ⇒ Hash

Parameters:

  • path (String)

Returns:

  • (Hash)


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

def get(path)
  _request(Net::HTTP::Get, @url + path, @username, @apikey, nil)
end

#post(path, data) ⇒ Hash

Parameters:

  • path (String)
  • data (Hash)

Returns:

  • (Hash)


27
28
29
# File 'lib/mms/client.rb', line 27

def post(path, data)
  _request(Net::HTTP::Post, @url + path, @username, @apikey, data)
end