ringcentral_sdk 1.3.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile.lock +70 -33
  4. data/{LICENSE.txt → LICENSE.md} +0 -0
  5. data/README.md +40 -76
  6. data/lib/ringcentral_sdk.rb +4 -3
  7. data/lib/ringcentral_sdk/rest.rb +18 -17
  8. data/lib/ringcentral_sdk/rest/cache.rb +9 -3
  9. data/lib/ringcentral_sdk/rest/cache/extensions.rb +91 -94
  10. data/lib/ringcentral_sdk/rest/client.rb +196 -202
  11. data/lib/ringcentral_sdk/rest/configuration.rb +91 -0
  12. data/lib/ringcentral_sdk/rest/event.rb +44 -43
  13. data/lib/ringcentral_sdk/rest/extension.rb +12 -9
  14. data/lib/ringcentral_sdk/rest/extension_presence.rb +73 -78
  15. data/lib/ringcentral_sdk/rest/messages.rb +40 -31
  16. data/lib/ringcentral_sdk/rest/messages_retriever.rb +30 -33
  17. data/lib/ringcentral_sdk/rest/request.rb +10 -5
  18. data/lib/ringcentral_sdk/rest/request/base.rb +24 -19
  19. data/lib/ringcentral_sdk/rest/request/fax.rb +88 -91
  20. data/lib/ringcentral_sdk/rest/request/inflator.rb +9 -2
  21. data/lib/ringcentral_sdk/rest/request/inflator/contact_info.rb +19 -12
  22. data/lib/ringcentral_sdk/rest/request/simple.rb +24 -34
  23. data/lib/ringcentral_sdk/rest/simple_client.rb +63 -78
  24. data/lib/ringcentral_sdk/rest/subscription.rb +223 -228
  25. data/test/test_base.rb +5 -5
  26. data/test/test_client.rb +87 -88
  27. data/test/test_event.rb +28 -11
  28. data/test/test_extension_presence.rb +64 -62
  29. data/test/test_helper_fax.rb +46 -47
  30. data/test/test_helper_inflator_contact_info.rb +8 -10
  31. data/test/test_helper_request.rb +1 -1
  32. data/test/test_setup.rb +24 -21
  33. data/test/test_subscription.rb +46 -48
  34. metadata +72 -33
  35. data/lib/ringcentral_sdk/rest/config.rb +0 -102
  36. data/test/test_config.rb +0 -29
@@ -1,102 +0,0 @@
1
- require 'dotenv'
2
-
3
- module RingCentralSdk::REST
4
- class Config
5
- attr_accessor :user
6
- attr_accessor :app
7
- attr_accessor :env
8
-
9
- def initialize
10
- @app = RingCentralSdk::REST::ConfigApp.new
11
- @user = RingCentralSdk::REST::ConfigUser.new
12
- @env = RingCentralSdk::REST::ConfigEnvRc.new
13
- end
14
-
15
- def load_dotenv
16
- Dotenv.load
17
- @app.load_env()
18
- @user.load_env()
19
- @env.load_env()
20
- return self
21
- end
22
- end
23
- end
24
-
25
- module RingCentralSdk::REST
26
- class ConfigUser
27
- attr_accessor :username
28
- attr_accessor :extension
29
- attr_accessor :password
30
-
31
- def load_env
32
- @username = ENV['RC_USER_USERNAME']
33
- @extension = ENV['RC_USER_EXTENSION']
34
- @password = ENV['RC_USER_PASSWORD']
35
- end
36
-
37
- def nilify
38
- @username = ''
39
- @extension = ''
40
- @password = ''
41
- end
42
- end
43
- end
44
-
45
- module RingCentralSdk::REST
46
- class ConfigApp
47
- attr_accessor :key
48
- attr_accessor :secret
49
- attr_accessor :server_url
50
- attr_accessor :redirect_url
51
-
52
- def initialize(app_key='', app_secret='', server_url=RingCentralSdk::RC_SERVER_SANDBOX, opts={})
53
- @key = app_key
54
- @secret = app_secret
55
- @server_url = server_url
56
- if opts.key?(:redirect_url)
57
- @redirect_url = opts[:redirect_url]
58
- elsif opts.key?(:redirect_uri)
59
- @redirect_url = opts[:redirect_uri]
60
- else
61
- @redirect_url = ''
62
- end
63
- end
64
-
65
- def load_env
66
- ['RC_APP_KEY', 'RC_APP_SECRET', 'RC_APP_SERVER_URL', 'RC_APP_REDIRECT_URL'].each do |var|
67
- if !ENV.key?(var)
68
- fail "environment variable '#{var}' not found"
69
- end
70
- end
71
-
72
- @key = ENV['RC_APP_KEY']
73
- @secret = ENV['RC_APP_SECRET']
74
- @server_url = ENV['RC_APP_SERVER_URL']
75
- @redirect_url = ENV['RC_APP_REDIRECT_URL']
76
- end
77
-
78
- def to_hash
79
- {
80
- key: @key,
81
- secret: @secret,
82
- server_url: @server_url,
83
- redirect_url: @redirect_url
84
- }
85
- end
86
- end
87
- end
88
-
89
- module RingCentralSdk::REST
90
- class ConfigEnvRc
91
- attr_accessor :data
92
- def initialize
93
- @data = {}
94
- end
95
- def load_env
96
- ENV.each do |k,v|
97
- next unless k.index('RC_') == 0
98
- @data[k] = v
99
- end
100
- end
101
- end
102
- end
data/test/test_config.rb DELETED
@@ -1,29 +0,0 @@
1
- require './test/test_base.rb'
2
-
3
- require 'faraday'
4
- require 'oauth2'
5
-
6
- class RingCentralSdkRESTConfigTest < Test::Unit::TestCase
7
- def setup
8
- @config = RingCentralSdk::REST::Config.new.load_dotenv
9
- end
10
-
11
- def test_main
12
- @config = RingCentralSdk::REST::Config.new.load_dotenv
13
- assert_equal 'myAppKey', @config.app.key
14
- assert_equal 'myAppSecret', @config.app.secret
15
- assert_equal 'myRcApiServerUrl', @config.app.server_url
16
- assert_equal 'myRcApiRedirectUrl', @config.app.redirect_url
17
-
18
- assert_equal 'myUsername', @config.user.username
19
- assert_equal 'myExtension', @config.user.extension
20
- assert_equal 'myPassword', @config.user.password
21
-
22
- assert_equal 'demoFaxToPhoneNumber', @config.env.data['RC_DEMO_FAX_TO']
23
-
24
- @config.user.nilify
25
- assert_equal '', @config.user.username
26
- assert_equal '', @config.user.extension
27
- assert_equal '', @config.user.password
28
- end
29
- end