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)


10
11
12
13
14
# File 'lib/mms/client.rb', line 10

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.



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

def apikey
  @apikey
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/mms/client.rb', line 3

def username
  @username
end

Instance Method Details

#delete(path) ⇒ Hash

Parameters:

  • path (String)

Returns:

  • (Hash)


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

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

#get(path) ⇒ Hash

Parameters:

  • path (String)

Returns:

  • (Hash)


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

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

#patch(path, data) ⇒ Hash

Parameters:

  • path (String)
  • data (Hash)

Returns:

  • (Hash)


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

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

#post(path, data) ⇒ Hash

Parameters:

  • path (String)
  • data (Hash)

Returns:

  • (Hash)


25
26
27
# File 'lib/mms/client.rb', line 25

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

#put(path, data) ⇒ Hash

Parameters:

  • path (String)
  • data (Hash)

Returns:

  • (Hash)


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

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