clx_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +55 -0
  7. data/Rakefile +7 -0
  8. data/clx_api.gemspec +26 -0
  9. data/doc/CLX.html +305 -0
  10. data/doc/CLX/API.html +1491 -0
  11. data/doc/CLX/CLXAPIException.html +411 -0
  12. data/doc/CLX/CLXException.html +134 -0
  13. data/doc/CLX/HTTPAdapter.html +1294 -0
  14. data/doc/CLX/HTTPClient.html +1058 -0
  15. data/doc/ClxApi.html +141 -0
  16. data/doc/_index.html +161 -0
  17. data/doc/class_list.html +58 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +57 -0
  20. data/doc/css/style.css +339 -0
  21. data/doc/file.README.html +112 -0
  22. data/doc/file_list.html +60 -0
  23. data/doc/frames.html +26 -0
  24. data/doc/index.html +112 -0
  25. data/doc/js/app.js +219 -0
  26. data/doc/js/full_list.js +181 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +279 -0
  29. data/doc/top-level-namespace.html +112 -0
  30. data/examples/get_gateway_by_id.rb +16 -0
  31. data/examples/get_gateways.rb +18 -0
  32. data/examples/get_operator_by_id.rb +21 -0
  33. data/examples/get_operators.rb +23 -0
  34. data/examples/get_price_entries_by_gateway_id.rb +19 -0
  35. data/examples/get_price_entries_by_gateway_id_and_operator_id.rb +17 -0
  36. data/examples/get_price_entries_by_gateway_id_and_operator_id_and_date.rb +18 -0
  37. data/examples/readme.md +167 -0
  38. data/lib/clx_api.rb +35 -0
  39. data/lib/clx_api/api.rb +132 -0
  40. data/lib/clx_api/exceptions/clx_api_exception.rb +25 -0
  41. data/lib/clx_api/exceptions/clx_exception.rb +8 -0
  42. data/lib/clx_api/http_adapter.rb +129 -0
  43. data/lib/clx_api/http_client.rb +163 -0
  44. data/lib/clx_api/version.rb +4 -0
  45. data/test/adapter/test_adapter.rb +67 -0
  46. data/test/api_test.rb +306 -0
  47. data/test/http_adapter_test.rb +211 -0
  48. data/test/http_client_test.rb +173 -0
  49. data/test/test_helper.rb +7 -0
  50. metadata +168 -0
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!top-level-namespace.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+
36
+
37
+ <span class="title">Top Level Namespace</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Top Level Namespace
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Defined Under Namespace</h2>
85
+ <p class="children">
86
+
87
+
88
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="CLX.html" title="CLX (module)">CLX</a></span>
89
+
90
+
91
+
92
+
93
+ </p>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ </div>
104
+
105
+ <div id="footer">
106
+ Generated on Mon May 25 12:34:49 2015 by
107
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
+ 0.8.7.6 (ruby-2.1.5).
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,16 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ gateway = clx.get_gateway_by_id(6)
4
+
5
+ puts gateway.id
6
+ puts gateway.name
7
+ puts gateway.type
8
+
9
+ rescue CLX::CLXAPIException => e
10
+ puts e.clx_error_message
11
+ puts e.clx_error_code
12
+ rescue CLX::CLXException => e
13
+ puts e.message
14
+ rescue
15
+ puts 'other error'
16
+ end
@@ -0,0 +1,18 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ gateways = clx.get_gateways
4
+
5
+ gateways.each do |gateway|
6
+ puts gateway.id
7
+ puts gateway.name
8
+ puts gateway.type
9
+ end
10
+
11
+ rescue CLX::CLXAPIException => e
12
+ puts e.clx_error_message
13
+ puts e.clx_error_code
14
+ rescue CLX::CLXException => e
15
+ puts e.message
16
+ rescue
17
+ puts 'other error'
18
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ operator = clx.get_operator_by_id(6)
4
+
5
+ puts operator.id
6
+ puts operator.name
7
+ puts operator.network
8
+ puts operator.uniqueName
9
+ puts operator.isoCountryCode
10
+ puts operator.operationalState
11
+ puts operator.operationalStatDate
12
+ puts operator.numberOfSubscribers
13
+
14
+ rescue CLX::CLXAPIException => e
15
+ puts e.clx_error_message
16
+ puts e.clx_error_code
17
+ rescue CLX::CLXException => e
18
+ puts e.message
19
+ rescue
20
+ puts 'other error'
21
+ end
@@ -0,0 +1,23 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ operators = clx.get_operators
4
+
5
+ operators.each do |operator|
6
+ puts operator.id
7
+ puts operator.name
8
+ puts operator.network
9
+ puts operator.uniqueName
10
+ puts operator.isoCountryCode
11
+ puts operator.operationalState
12
+ puts operator.operationalStatDate
13
+ puts operator.numberOfSubscribers
14
+ end
15
+
16
+ rescue CLX::CLXAPIException => e
17
+ puts e.clx_error_message
18
+ puts e.clx_error_code
19
+ rescue CLX::CLXException => e
20
+ puts e.message
21
+ rescue
22
+ puts 'other error'
23
+ end
@@ -0,0 +1,19 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ prices = clx.get_price_entires_by_gateway_id(6)
4
+
5
+ prices.each do |price|
6
+ puts price.price
7
+ puts price.gateway
8
+ puts price.operator
9
+ puts price.expireDate
10
+ end
11
+
12
+ rescue CLX::CLXAPIException => e
13
+ puts e.clx_error_message
14
+ puts e.clx_error_code
15
+ rescue CLX::CLXException => e
16
+ puts e.message
17
+ rescue
18
+ puts 'other error'
19
+ end
@@ -0,0 +1,17 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ price = clx.get_price_entries_by_gateway_id_and_operator_id(6, 1)
4
+
5
+ puts price.price
6
+ puts price.gateway
7
+ puts price.operator
8
+ puts price.expireDate
9
+
10
+ rescue CLX::CLXAPIException => e
11
+ puts e.clx_error_message
12
+ puts e.clx_error_code
13
+ rescue CLX::CLXException => e
14
+ puts e.message
15
+ rescue
16
+ puts 'other error'
17
+ end
@@ -0,0 +1,18 @@
1
+ begin
2
+ clx = CLX::API.new('username', 'password')
3
+ date = DateTime.new(2015, 5, 25)
4
+ price = clx.get_price_entries_by_gateway_id_and_operator_id_and_date(6, 1, date)
5
+
6
+ puts price.price
7
+ puts price.gateway
8
+ puts price.operator
9
+ puts price.expireDate
10
+
11
+ rescue CLX::CLXAPIException => e
12
+ puts e.clx_error_message
13
+ puts e.clx_error_code
14
+ rescue CLX::CLXException => e
15
+ puts e.message
16
+ rescue
17
+ puts 'other error'
18
+ end
@@ -0,0 +1,167 @@
1
+ #Examples
2
+
3
+ ## Get operators
4
+ ```ruby
5
+ begin
6
+ clx = CLX::API.new('username', 'password')
7
+ operators = clx.get_operators
8
+
9
+ operators.each do |operator|
10
+ puts operator.id
11
+ puts operator.name
12
+ puts operator.network
13
+ puts operator.uniqueName
14
+ puts operator.isoCountryCode
15
+ puts operator.operationalState
16
+ puts operator.operationalStatDate
17
+ puts operator.numberOfSubscribers
18
+ end
19
+
20
+ rescue CLX::CLXAPIException => e
21
+ puts e.clx_error_message
22
+ puts e.clx_error_code
23
+ rescue CLX::CLXException => e
24
+ puts e.message
25
+ rescue
26
+ puts 'other error'
27
+ end
28
+ ```
29
+
30
+
31
+ ## Get operator by id
32
+ ```ruby
33
+ begin
34
+ clx = CLX::API.new('username', 'password')
35
+ operator = clx.get_operator_by_id(6)
36
+
37
+ puts operator.id
38
+ puts operator.name
39
+ puts operator.network
40
+ puts operator.uniqueName
41
+ puts operator.isoCountryCode
42
+ puts operator.operationalState
43
+ puts operator.operationalStatDate
44
+ puts operator.numberOfSubscribers
45
+
46
+ rescue CLX::CLXAPIException => e
47
+ puts e.clx_error_message
48
+ puts e.clx_error_code
49
+ rescue CLX::CLXException => e
50
+ puts e.message
51
+ rescue
52
+ puts 'other error'
53
+ end
54
+ ```
55
+
56
+
57
+ ## Get gateways
58
+ ```ruby
59
+ begin
60
+ clx = CLX::API.new('username', 'password')
61
+ gateways = clx.get_gateways
62
+
63
+ gateways.each do |gateway|
64
+ puts gateway.id
65
+ puts gateway.name
66
+ puts gateway.type
67
+ end
68
+
69
+ rescue CLX::CLXAPIException => e
70
+ puts e.clx_error_message
71
+ puts e.clx_error_code
72
+ rescue CLX::CLXException => e
73
+ puts e.message
74
+ rescue
75
+ puts 'other error'
76
+ end
77
+ ```
78
+
79
+
80
+ ## Get gateway by id
81
+ ```ruby
82
+ begin
83
+ clx = CLX::API.new('username', 'password')
84
+ gateway = clx.get_gateway_by_id(6)
85
+
86
+ puts gateway.id
87
+ puts gateway.name
88
+ puts gateway.type
89
+
90
+ rescue CLX::CLXAPIException => e
91
+ puts e.clx_error_message
92
+ puts e.clx_error_code
93
+ rescue CLX::CLXException => e
94
+ puts e.message
95
+ rescue
96
+ puts 'other error'
97
+ end
98
+ ```
99
+
100
+
101
+ ## Get price entires by gateway id
102
+ ```ruby
103
+ begin
104
+ clx = CLX::API.new('username', 'password')
105
+ prices = clx.get_price_entires_by_gateway_id(6)
106
+
107
+ prices.each do |price|
108
+ puts price.price
109
+ puts price.gateway
110
+ puts price.operator
111
+ puts price.expireDate
112
+ end
113
+
114
+ rescue CLX::CLXAPIException => e
115
+ puts e.clx_error_message
116
+ puts e.clx_error_code
117
+ rescue CLX::CLXException => e
118
+ puts e.message
119
+ rescue
120
+ puts 'other error'
121
+ end
122
+ ```
123
+
124
+
125
+ ## Get price entry by gateway id and operator id
126
+ ```ruby
127
+ begin
128
+ clx = CLX::API.new('username', 'password')
129
+ price = clx.get_price_entries_by_gateway_id_and_operator_id(6, 1)
130
+
131
+ puts price.price
132
+ puts price.gateway
133
+ puts price.operator
134
+ puts price.expireDate
135
+
136
+ rescue CLX::CLXAPIException => e
137
+ puts e.clx_error_message
138
+ puts e.clx_error_code
139
+ rescue CLX::CLXException => e
140
+ puts e.message
141
+ rescue
142
+ puts 'other error'
143
+ end
144
+ ```
145
+
146
+
147
+ ## Get price entry by gateway id, operator id and date
148
+ ```ruby
149
+ begin
150
+ clx = CLX::API.new('username', 'password')
151
+ date = DateTime.new(2015, 5, 25)
152
+ price = clx.get_price_entries_by_gateway_id_and_operator_id_and_date(6, 1, date)
153
+
154
+ puts price.price
155
+ puts price.gateway
156
+ puts price.operator
157
+ puts price.expireDate
158
+
159
+ rescue CLX::CLXAPIException => e
160
+ puts e.clx_error_message
161
+ puts e.clx_error_code
162
+ rescue CLX::CLXException => e
163
+ puts e.message
164
+ rescue
165
+ puts 'other error'
166
+ end
167
+ ```
data/lib/clx_api.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'clx_api/version'
2
+ require 'clx_api/api'
3
+ require 'clx_api/exceptions/clx_exception'
4
+ require 'clx_api/exceptions/clx_api_exception'
5
+ require 'clx_api/http_client'
6
+ require 'clx_api/http_adapter'
7
+
8
+ # Main namespace
9
+ module CLX
10
+
11
+ # Module instance
12
+ class << self
13
+
14
+ # @!attribute [r]
15
+ attr_reader :base_url
16
+
17
+ # @!attribute [r]
18
+ attr_reader :paths
19
+
20
+ # REST server
21
+ def base_url
22
+ @base_url ||= 'https://clx-aws.clxnetworks.com/api'
23
+ end
24
+
25
+ # API paths hash
26
+ def paths
27
+ @paths ||= {
28
+ operator: '/operator',
29
+ gateway: '/gateway'
30
+ }
31
+ end
32
+
33
+ end
34
+
35
+ end