reg.api2 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcf919b64250ad7be856188c30ab24b11ef258b4
4
+ data.tar.gz: 9741bbc8b397d58b26cb733c299804a5ffffd6c8
5
+ SHA512:
6
+ metadata.gz: d71dce82ad3170fc6cfd2a9086b91686cc59033a9f1f3b05689f896653f6875c47dfe6251a2c35250208fea1c276808b73e6c8e021915b70f2344d6b3e3cea28
7
+ data.tar.gz: 477e265b532a2e5d93876bc9b0e1414faf9327d03160fb69d9d05d3371b466d1f44502ae55b2a88ae9c68df1712e4123faf46dc6b6a7fb5f70d50efa80980bf9
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  # - jruby-19mode
4
- - rbx-19mode
4
+ - rbx-2.1.1
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0.0
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## Version 0.0.12
4
+
5
+ * `service.refill` method.
6
+ * rr mocks was replaced with rspec ones.
7
+
3
8
  ## Version 0.0.11
4
9
 
5
10
  * New API category: `hosting`.
data/README.md CHANGED
@@ -45,7 +45,7 @@ RegApi2.service.nop(services: [
45
45
  ])
46
46
  ```
47
47
 
48
- or with including of {RegApi2} module:
48
+ or with including of [RegApi2](http://regru.github.io/reg_api2-ruby/RegApi2.html) module:
49
49
 
50
50
  ```ruby
51
51
  require "reg_api2"
@@ -81,6 +81,19 @@ before any operations over REG.API through {RegApi2} properties.
81
81
 
82
82
  Also console reads `~/.regapi2` configuration file if exists, to assign properties from. It knows about these properties in configuration file: `username`, `password`, `lang`, `pem`, `pem_password` and `ca_cert_path`. Properties should be written in `key=value` format separated by newline.
83
83
 
84
+ ## API categories map
85
+
86
+ Please follow these links to view documentation on methods of all known API categories:
87
+
88
+ * [common](http://regru.github.io/reg_api2-ruby/RegApi2/Common.html).
89
+ * [domain](http://regru.github.io/reg_api2-ruby/RegApi2/Domain.html).
90
+ * [user](http://regru.github.io/reg_api2-ruby/RegApi2/User.html).
91
+ * [service](http://regru.github.io/reg_api2-ruby/RegApi2/Service.html).
92
+ * [bill](http://regru.github.io/reg_api2-ruby/RegApi2/Bill.html).
93
+ * [folder](http://regru.github.io/reg_api2-ruby/RegApi2/Folder.html).
94
+ * [zone](http://regru.github.io/reg_api2-ruby/RegApi2/Zone.html).
95
+ * [hosting](http://regru.github.io/reg_api2-ruby/RegApi2/Hosting.html).
96
+
84
97
  ## Recommendations for effective use of REG.API
85
98
 
86
99
  This section provides information that will help you to make you work with REG.API more productive and convenient.
@@ -24,7 +24,7 @@ module RegApi2
24
24
  # Creates a folder.
25
25
  # @param [Hash] opts
26
26
  # @option opts [String] :folder_name The name of the new folder.
27
- # @return [nil] nil.
27
+ # @return [void] Nothing.
28
28
  # @note Support of service lists: no
29
29
  # @example Creation of folder
30
30
  # RegApi2.folder.create folder_name: 'test_folder_name'
@@ -35,7 +35,7 @@ module RegApi2
35
35
  # @param [Hash] opts
36
36
  # @option opts [Fixnum] :folder_id Id of folder to remove.
37
37
  # @option opts [String] :folder_name The name of folder to remove.
38
- # @return [nil] nil.
38
+ # @return [void] Nothing.
39
39
  # @note Support of service lists: no
40
40
  # @example Removing of folder by id
41
41
  # RegApi2.folder.remove folder_id: 123456
@@ -10,7 +10,7 @@ module RegApi2
10
10
  # @!method nop(opts = {})
11
11
  # @param [Hash] opts
12
12
  # This function serves for testing purposes.
13
- # @return [Hash(domains)] A list of domains. Domains that allow DNS zone management will have the “success” value in the “result” field, otherwise the “result” field will feature an error code explaining the error reason.
13
+ # @return [void] Nothing.
14
14
  # @note Accessibility: everyone
15
15
  # @example Test
16
16
  # RegApi2.hosting.nop
@@ -27,8 +27,9 @@ module RegApi2
27
27
 
28
28
  # @!method set_jelastic_refill_url(opts = {})
29
29
  # @param [Hash] opts
30
- # @option opts [String] :url Jelastic refill URL.
30
+ # @option opts [String] :url Jelastic refill URL. You can use the keywords `<service_id>` and `<email>`, which will be replaced with the identifier of service for balance refill, and the email address used for the Jelastic account registration.
31
31
  # Sets Jelastic refill URL for current reseller.
32
+ # @return [void] Nothing.
32
33
  # @note Accessibility: partners
33
34
  # @example Typical usage
34
35
  # RegApi2.set_jelastic_refill_url url: 'http://mysite.com?service_id=<service_id>&email=<email>'
@@ -113,7 +113,7 @@ module RegApi2
113
113
  # | srv_dedicated | dedicated server |
114
114
  # | srv_kvm | KVM access |
115
115
  #
116
- # @return [NilClass] nil
116
+ # @return [void] Nothing.
117
117
  # @note Accessibility: clients
118
118
  # @note Support of service lists: no
119
119
  # @example Removing of `srv_hosting_ispmgr` service.
@@ -225,7 +225,7 @@ module RegApi2
225
225
  # @!method set_autorenew_flag(opts = {})
226
226
  # Enables or disables automatic service renewal.
227
227
  # @param opts Options.
228
- # @return [NilClass] nil
228
+ # @return [void] Nothing.
229
229
  # @note Accessibility: clients
230
230
  # @note Support of service lists: no
231
231
  define :set_autorenew_flag
@@ -233,7 +233,7 @@ module RegApi2
233
233
  # @!method suspend(opts = {})
234
234
  # Use this function to suspend services (for domains – suspend delegation).
235
235
  # @param opts Options.
236
- # @return [NilClass] nil
236
+ # @return [void] Nothing.
237
237
  # @note Accessibility: clients
238
238
  # @note Support of service lists: no
239
239
  define :suspend
@@ -241,7 +241,7 @@ module RegApi2
241
241
  # @!method resume(opts = {})
242
242
  # Use this function to resume services (for domains – resume domain delegation).
243
243
  # @param opts Options.
244
- # @return [NilClass] nil
244
+ # @return [void] Nothing.
245
245
  # @note Accessibility: clients
246
246
  # @note Support of service lists: no
247
247
  define :resume
@@ -285,6 +285,17 @@ module RegApi2
285
285
  # RegApi2.service.resend_mail servtype: :srv_ssl_certificate
286
286
  define :resend_mail
287
287
 
288
+ # @!method refill(opts = {})
289
+ # You can use this function to refill balance of you service. Only Jelastic (srv_jelastic) is supported at the moment.
290
+ # @param opts Options.
291
+ # @option opts [Array] mailtype Email type: `approver_email` — approve ssl certificate order, `certificate_email` — certificate email.
292
+ # @return [Hash(service_id, bill_id etc.)]
293
+ # @note Accessibility: clients
294
+ # @note Support of service lists: no
295
+ # @example Refill by service id.
296
+ # RegApi2.service.refill service_id: 123456, amount: 10, currency: 'UAH'
297
+ define :refill
298
+
288
299
  extend self
289
300
  end
290
301
  end
data/lib/reg_api2/user.rb CHANGED
@@ -13,7 +13,7 @@ module RegApi2
13
13
  # @!method nop
14
14
  # @param None
15
15
  # Accessibility testing.
16
- # @return [NilClass] nil
16
+ # @return [void] Nothing.
17
17
  define :nop
18
18
 
19
19
  # @!method create(opts = {})
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RegApi2
3
3
  # Gem version.
4
- VERSION = "0.0.11".freeze
4
+ VERSION = "0.0.12".freeze
5
5
  end
data/reg.api2.gemspec CHANGED
@@ -22,9 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "yajl-ruby", "~> 1.0"
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec-core"
26
- spec.add_development_dependency "rspec-expectations"
27
- spec.add_development_dependency "rr"
25
+ spec.add_development_dependency "rspec", "~> 2.14"
28
26
  spec.add_development_dependency "faker"
29
27
  spec.add_development_dependency "machinist"
30
28
  spec.add_development_dependency "yard", "~> 0.8"
@@ -11,13 +11,13 @@ describe RegApi2::Hosting do
11
11
  end
12
12
 
13
13
  describe :get_jelastic_refill_url do
14
- it "should return nil" do
14
+ it "should return \"https://test1.ru\"" do
15
15
  hosting.get_jelastic_refill_url.should == "https://test1.ru"
16
16
  end
17
17
  end
18
18
 
19
19
  describe :set_jelastic_refill_url do
20
- it "should return nil" do
20
+ it "should return nil on success" do
21
21
  hosting.set_jelastic_refill_url(url: "http://ya.ru/").should be_nil
22
22
  end
23
23
  end
@@ -11,12 +11,12 @@ describe RegApi2 do
11
11
  end
12
12
 
13
13
  it "should #create_http at first call" do
14
- mock(RegApi2).create_http { 45 }.times(1)
14
+ allow(RegApi2).to receive(:create_http).once.and_return(45)
15
15
  RegApi2.http.should == 45
16
16
  end
17
17
 
18
18
  it "should not #create_http at next call" do
19
- mock(RegApi2).create_http { 45 }.times(1)
19
+ allow(RegApi2).to receive(:create_http).once.and_return(45)
20
20
  RegApi2.http.should == 45
21
21
  RegApi2.http.should == 45
22
22
  end
@@ -31,23 +31,19 @@ describe RegApi2 do
31
31
  end
32
32
 
33
33
  it "should use ca_cert_path if exists" do
34
- any_instance_of(Net::HTTP) do |instance|
35
- proxy(instance).verify_mode=(OpenSSL::SSL::VERIFY_PEER)
36
- proxy(instance).ca_file=("file")
37
- end
38
- mock(RegApi2).ca_cert_path { "file" }.any_times
34
+ allow(RegApi2).to receive(:ca_cert_path).and_return("file")
39
35
  http = RegApi2.create_http
40
36
  http.verify_mode.should == OpenSSL::SSL::VERIFY_PEER
41
37
  http.ca_file.should == "file"
42
38
  end
43
39
 
44
40
  it "should use pem with pem_password" do
45
- mock(RegApi2).pem { "pem" }.any_times
46
- mock(RegApi2).pem_password { "pem_password" }.any_times
41
+ allow(RegApi2).to receive(:pem).and_return("pem")
42
+ allow(RegApi2).to receive(:pem_password).and_return("pem_password")
47
43
  pem = Object.new
48
44
  key = Object.new
49
- mock(OpenSSL::X509::Certificate).new("pem") { pem }
50
- mock(OpenSSL::PKey::RSA).new("pem", "pem_password") { key }
45
+ allow(OpenSSL::X509::Certificate).to receive(:new).with("pem").and_return(pem)
46
+ allow(OpenSSL::PKey::RSA).to receive(:new).with("pem", "pem_password").and_return(key)
51
47
 
52
48
  http = RegApi2.create_http
53
49
  http.cert.should == pem
@@ -55,12 +51,12 @@ describe RegApi2 do
55
51
  end
56
52
 
57
53
  it "should use pem without pem_password" do
58
- mock(RegApi2).pem { "pem" }.any_times
59
- mock(RegApi2).pem_password { nil }.any_times
54
+ allow(RegApi2).to receive(:pem).and_return("pem")
55
+ allow(RegApi2).to receive(:pem_password).and_return(nil)
60
56
  pem = Object.new
61
57
  key = Object.new
62
- mock(OpenSSL::X509::Certificate).new("pem") { pem }
63
- mock(OpenSSL::PKey::RSA).new("pem") { key }
58
+ allow(OpenSSL::X509::Certificate).to receive(:new).with("pem").and_return(pem)
59
+ allow(OpenSSL::PKey::RSA).to receive(:new).with("pem").and_return(key)
64
60
 
65
61
  http = RegApi2.create_http
66
62
  http.cert.should == pem
@@ -12,7 +12,7 @@ describe RegApi2::ResultContract do
12
12
  describe :handle_result do
13
13
  it "should return handle_answer" do
14
14
  expected = 'OOLOLLO'
15
- mock(contract).handle_answer({}) { expected }
15
+ expect(contract).to receive(:handle_answer).with({}).and_return(expected)
16
16
  contract.handle_result({ "answer" => {} }).should == expected
17
17
  end
18
18
  end
@@ -57,7 +57,7 @@ describe RegApi2::Service do
57
57
 
58
58
  describe :get_dedicated_server_list do
59
59
  it "should get list of dedicated servers" do
60
- ans = RegApi2.service.get_dedicated_server_list
60
+ ans = service.get_dedicated_server_list
61
61
  ans.should be_kind_of Array
62
62
  ans.map(&:server_id).each { |id| id.should be_kind_of Fixnum }
63
63
  end
@@ -65,9 +65,19 @@ describe RegApi2::Service do
65
65
 
66
66
  describe :get_bills do
67
67
  it "should get list of services and bills" do
68
- ans = RegApi2.service.get_bills dname: "qqq.ru"
68
+ ans = service.get_bills dname: "qqq.ru"
69
69
  ans.services.should be_kind_of Array
70
70
  ans.bills.should be_nil
71
71
  end
72
72
  end
73
+
74
+ describe :refill do
75
+ it "should refill by service id" do
76
+ ans = service.refill service_id: 123456, amount: 10, currency: 'UAH'
77
+ ans.pay_notes.should include("success")
78
+ ans.pay_type.should == "prepay"
79
+ ans.service_id.should == 123456
80
+ ans.payment.should > 0
81
+ end
82
+ end
73
83
  end
@@ -47,7 +47,7 @@ describe RegApi2::SymHash do
47
47
 
48
48
  describe :include? do
49
49
  it "should be has_key?" do
50
- mock(hash).has_key?("what") { true }
50
+ allow(hash).to receive(:has_key?).with("what").and_return(true)
51
51
  hash.include?("what").should be_true
52
52
  end
53
53
  end
data/spec/spec_helper.rb CHANGED
@@ -26,7 +26,6 @@ RSpec.configure do |config|
26
26
  config.treat_symbols_as_metadata_keys_with_true_values = true
27
27
  config.run_all_when_everything_filtered = true
28
28
  config.filter_run :focus
29
- config.mock_with :rr
30
29
 
31
30
  # Run specs in random order to surface order dependencies. If you find an
32
31
  # order dependency and want to debug it, you can fix the order by providing
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reg.api2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
5
- prerelease:
4
+ version: 0.0.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Akzhan Abdulin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: yajl-ruby
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,103 +41,62 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: rspec-core
56
+ name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: rspec-expectations
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rr
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
59
+ - - ~>
100
60
  - !ruby/object:Gem::Version
101
- version: '0'
61
+ version: '2.14'
102
62
  type: :development
103
63
  prerelease: false
104
64
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
65
  requirements:
107
- - - ! '>='
66
+ - - ~>
108
67
  - !ruby/object:Gem::Version
109
- version: '0'
68
+ version: '2.14'
110
69
  - !ruby/object:Gem::Dependency
111
70
  name: faker
112
71
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
72
  requirements:
115
- - - ! '>='
73
+ - - '>='
116
74
  - !ruby/object:Gem::Version
117
75
  version: '0'
118
76
  type: :development
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
79
  requirements:
123
- - - ! '>='
80
+ - - '>='
124
81
  - !ruby/object:Gem::Version
125
82
  version: '0'
126
83
  - !ruby/object:Gem::Dependency
127
84
  name: machinist
128
85
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
86
  requirements:
131
- - - ! '>='
87
+ - - '>='
132
88
  - !ruby/object:Gem::Version
133
89
  version: '0'
134
90
  type: :development
135
91
  prerelease: false
136
92
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
93
  requirements:
139
- - - ! '>='
94
+ - - '>='
140
95
  - !ruby/object:Gem::Version
141
96
  version: '0'
142
97
  - !ruby/object:Gem::Dependency
143
98
  name: yard
144
99
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
100
  requirements:
147
101
  - - ~>
148
102
  - !ruby/object:Gem::Version
@@ -150,7 +104,6 @@ dependencies:
150
104
  type: :development
151
105
  prerelease: false
152
106
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
107
  requirements:
155
108
  - - ~>
156
109
  - !ruby/object:Gem::Version
@@ -158,7 +111,6 @@ dependencies:
158
111
  - !ruby/object:Gem::Dependency
159
112
  name: redcarpet
160
113
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
114
  requirements:
163
115
  - - ~>
164
116
  - !ruby/object:Gem::Version
@@ -166,7 +118,6 @@ dependencies:
166
118
  type: :development
167
119
  prerelease: false
168
120
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
121
  requirements:
171
122
  - - ~>
172
123
  - !ruby/object:Gem::Version
@@ -174,7 +125,6 @@ dependencies:
174
125
  - !ruby/object:Gem::Dependency
175
126
  name: yard-redcarpet-ext
176
127
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
128
  requirements:
179
129
  - - ~>
180
130
  - !ruby/object:Gem::Version
@@ -182,7 +132,6 @@ dependencies:
182
132
  type: :development
183
133
  prerelease: false
184
134
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
135
  requirements:
187
136
  - - ~>
188
137
  - !ruby/object:Gem::Version
@@ -247,33 +196,26 @@ files:
247
196
  homepage: https://regru.github.com/reg_api2-ruby
248
197
  licenses:
249
198
  - MIT
199
+ metadata: {}
250
200
  post_install_message:
251
201
  rdoc_options: []
252
202
  require_paths:
253
203
  - lib
254
204
  required_ruby_version: !ruby/object:Gem::Requirement
255
- none: false
256
205
  requirements:
257
- - - ! '>='
206
+ - - '>='
258
207
  - !ruby/object:Gem::Version
259
208
  version: '0'
260
- segments:
261
- - 0
262
- hash: -789251017170447539
263
209
  required_rubygems_version: !ruby/object:Gem::Requirement
264
- none: false
265
210
  requirements:
266
- - - ! '>='
211
+ - - '>='
267
212
  - !ruby/object:Gem::Version
268
213
  version: '0'
269
- segments:
270
- - 0
271
- hash: -789251017170447539
272
214
  requirements: []
273
215
  rubyforge_project:
274
- rubygems_version: 1.8.24
216
+ rubygems_version: 2.0.14
275
217
  signing_key:
276
- specification_version: 3
218
+ specification_version: 4
277
219
  summary: REG.API v2 Implementation
278
220
  test_files:
279
221
  - spec/blueprints/user.rb