Class: Manabu::Client

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

Overview

General client interface which bundles together most client functionality

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, host, port = 80, **options) ⇒ Client

Initializes with login details and passes options to all linked instances.

Parameters:

username

The User Name or e-mail address

password

The password for the given user

host

The host URL

port

The host port (default 80)

options

A hash of options, such as:

  • force_secure_connection - (default true), set to false to disable HTTPS/SSL

  • transport_type - (default :msgpack), sets transport data type [:msgpack, :json]



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/manabu/client.rb', line 24

def initialize(username, password, host, port = 80, **options)
  @status = :initializing
  @auth = Manabu::Connection::Auth.new(username, password, host, port, options)
  if @auth.success?
    @transactor = @auth.transactor
    @status = :connected
  else
    @status = :failed
    raise Error::Connection::Unauthorized
  end
end

Instance Attribute Details

#authObject

Returns the value of attribute auth.



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

def auth
  @auth
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#transactorObject

Returns the value of attribute transactor.



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

def transactor
  @transactor
end

Instance Method Details

#delete(path, **args) ⇒ Object

Performs a DELETE against the API

Parameters:

path

The API endpoint path

args

An argument hash

Returns:

The returned data as an object


92
93
94
# File 'lib/manabu/client.rb', line 92

def delete(path, **args)
  @transactor.delete(path, args)
end

#get(path, **args) ⇒ Object

Performs a GET against the API

Parameters:

path

The API endpoint path

args

An argument hash

Returns:

The returned data as an object


50
51
52
# File 'lib/manabu/client.rb', line 50

def get(path, **args)
  @transactor.get(path, args)
end

#patch(path, **args) ⇒ Object

Performs a PATCH against the API

Parameters:

path

The API endpoint path

args

An argument hash

Returns:

The returned data as an object


78
79
80
# File 'lib/manabu/client.rb', line 78

def patch(path, **args)
  @transactor.patch(path, args)
end

#post(path, **args) ⇒ Object

Performs a POST against the API

Parameters:

path

The API endpoint path

args

An argument hash

Returns:

The returned data as an object


64
65
66
# File 'lib/manabu/client.rb', line 64

def post(path, **args)
  @transactor.post(path, args)
end

#simple_get(endpoint) ⇒ Object



36
37
38
# File 'lib/manabu/client.rb', line 36

def simple_get(endpoint)
  @transactor.simple_get(endpoint)
end