Completed
Push — master ( b7118a...c3970f )
by John
01:10
created

MessagesSMS   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %
Metric Value
dl 0
loc 20
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 1
A initialize() 0 3 1
1
module RingCentralSdk::REST
2
  class Messages
3
4
    attr_reader :sms
5
    attr_reader :fax
6
7
    def initialize(client)
8
      @client = client
9
      @sms = RingCentralSdk::REST::MessagesSMS.new(client)
10
      @fax = RingCentralSdk::REST::MessagesFax.new(client)
11
    end
12
13
  end
14
end
15
16
module RingCentralSdk::REST
17
  class MessagesSMS
18
19
    def initialize(client)
20
      @client = client
21
    end
22
23
    def create(opts)
24
      response = @client.http.post do |req|
25
        req.url 'account/~/extension/~/sms'
26
        req.headers['Content-Type'] = 'application/json'
27
        req.body = {
28
          :from =>   { :phoneNumber => opts[:from].to_s },
29
          :to   => [ { :phoneNumber => opts[:to].to_s } ],
30
          :text => opts[:text].to_s
31
        }
32
      end
33
      return response
34
    end
35
36
  end
37
end
38
39
module RingCentralSdk::REST
40
  class MessagesFax
41
42
    def initialize(client)
43
      @client = client
44
    end
45
46
    def create(opts)
47
      fax = RingCentralSdk::REST::Request::Fax.new(opts)
48
      return @client.send_request(fax)
49
    end
50
51
  end
52
end