Class: MotionOcean::API::Client

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

Defined Under Namespace

Classes: APIResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, &block) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/motion_ocean/api/client.rb', line 6

def initialize(base_url, &block)
  base_url += '/' unless base_url.end_with? '/'
  @base_url = NSURL.URLWithString(base_url)
  @headers = {}

  # yield(self) if block_given?
  if block_given?
    case block.arity
    when 0
      instance_eval(&block)
    when 1
      block.call(self)
    end
  end
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

Instance Method Details

#authorization(options = {}) ⇒ Object



33
34
35
# File 'lib/motion_ocean/api/client.rb', line 33

def authorization(options = {})
  header "Authorization", MotionOcean::API::Authorization.build(options)
end

#header(name, value) ⇒ Object



29
30
31
# File 'lib/motion_ocean/api/client.rb', line 29

def header(name, value)
  @headers[name] = value
end