Class: Switchcoder::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token, host = nil, opts = nil) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/switchcoder/client.rb', line 7

def initialize(api_token, host = nil, opts = nil)
  @api_token = api_token;
  @host = host || 'api.switchcoder.com';
  @opts = (opts || {}).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



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

def api_token
  @api_token
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#optsObject (readonly)

Returns the value of attribute opts.



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

def opts
  @opts
end

Instance Method Details

#code(id, phone_number = nil, opts = nil) ⇒ Object



17
18
19
20
21
# File 'lib/switchcoder/client.rb', line 17

def code(id, phone_number = nil, opts = nil)
  script = Code.new(id, phone_number, opts)
  script.client = self
  return script
end

#phone_number(num, opts = nil) ⇒ Object



13
14
15
# File 'lib/switchcoder/client.rb', line 13

def phone_number(num,opts = nil)
  PhoneNumber.new(num, opts)
end