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


88
89
90
# File 'lib/manabu/client.rb', line 88

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


46
47
48
# File 'lib/manabu/client.rb', line 46

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


74
75
76
# File 'lib/manabu/client.rb', line 74

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


60
61
62
# File 'lib/manabu/client.rb', line 60

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