reg.api2 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
- notifications:
2
- recipients:
3
- - akzhan.abdulin@gmail.com
1
+ language: ruby
4
2
  rvm:
3
+ # - jruby-19mode
4
+ - rbx-19mode
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0.0
data/.yardopts CHANGED
@@ -5,4 +5,5 @@
5
5
  --plugin redcarpet-ext
6
6
  -
7
7
  README.md
8
+ CHANGES.md
8
9
  LICENSE
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changes
2
+
3
+ ## Version 0.0.10
4
+
5
+ * Methods of `bill` category now returns array of bills directly instead of `{ 'bills' => [ ... ] }`.
6
+ * Documentation updated.
7
+
data/lib/reg_api2/bill.rb CHANGED
@@ -12,23 +12,24 @@ module RegApi2
12
12
  # @option opts [String] :bill_id Invoice number in case of a single-invoice request.
13
13
  # @option opts [Array] :bills A list if invoice numbers.
14
14
  # For testing purposes.
15
- # @return [NilClass or Hash(bills)] nil or bills.
15
+ # @return [NilClass or Array<Hash>] nil or bills.
16
+ # @note Accessibility: clients
16
17
  # @note Support of invoice lists: yes
17
18
  # @example Get single bill
18
19
  # RegApi2.bill.nop bill_id: 12345
19
20
  # @example Get bills
20
21
  # RegApi2.bill.nop bills: ["12345","12346"]
21
- define :nop
22
+ define :nop, field: :bills
22
23
 
23
24
  # @!method get_not_payed(opts = {})
24
25
  # Use this function to obtain a list of unpaid invoices.
25
26
  # @param [Hash] opts
26
27
  # @option opts [Fixnum] :limit Defines the number of invoices to be included in the output at a time. Default value: 100. Maximum value: 1024.
27
28
  # @option opts [Fixnum] :offset The offset from the starting point, if the number of invoices exceeds the defined limit.
28
- # @return [Hash(bills)] Bills.
29
+ # @return [Array<Hash>] Bills.
29
30
  # @note Accessibility: clients
30
31
  # @note Support of invoice lists: yes
31
- define :get_not_payed
32
+ define :get_not_payed, field: :bills
32
33
 
33
34
  # @!method get_for_period(opts = {})
34
35
  # Use this function to obtain a list of invoices for the defined period.
@@ -39,25 +40,30 @@ module RegApi2
39
40
  # @option opts [Fixnum] :limit Defines the number of invoices to be included in the output at a time. Default value: 100. Maximum value: 1024.
40
41
  # @option opts [Fixnum] :offset The offset from the starting point, if the number of invoices exceeds the defined limit.
41
42
  # @option opts [Boolean] :all Show inactive invoices, i.e. invoices for outdated services and invoices cancelled due to impossibility of order execution.
42
- # @return [Hash(bills)] Bills.
43
+ # @return [Array<Hash>] Bills.
43
44
  # @note Accessibility: partners
44
45
  # @note Support of invoice lists: yes
45
- define :get_for_period, required: { start_date: { iso_date: true }, end_date: { iso_date: true } }
46
+ # @example List of invoices using Date objects.
47
+ # require 'date'
48
+ # RegApi.bill.get_for_period start_date: Date.new(2012, 1, 1), end_date: Date.new(2012, 12, 1)
49
+ # @example List of invoices using date strings in ISO format.
50
+ # RegApi.bill.get_for_period start_date: '2012-01-01', end_date: '2012-12-01'
51
+ define :get_for_period, required: { start_date: { iso_date: true }, end_date: { iso_date: true } }, field: :bills
46
52
 
47
53
  # @!method change_pay_type(opts = {})
48
54
  # You can use this function to change payment methods. Some of the methods allow issue of invoices in the defined payment systems, advance payments are made immediately.
49
- # @note Accessibility: clients
50
55
  # @param [Hash] opts
51
56
  # @option opts [Fixnum] :bill_id Invoice ID (in case of single invoice request).
52
57
  # @option opts [Array(Fixnum)] :bills A list of invoice IDs.
53
58
  # @option opts [String] :pay_type New payment type. Mandatory field. Valid values: prepay — advance payment (to be made immediately); WM — WebMoney. With the WMID defined, the invoices are issued to the customer’s WM account; yamoney, ymbill — Yandex.Dengi. To issue an invoice, define ymbill and in advance allow the receipt of invoices from REG.; bank — bank transfer
54
59
  # @option opts [String] :currency Currency. Mandatory field. «Yandex.Dengi» allows RUR only, «bank» and «prepay» – RUR and USD, «WebMoney» also allows EUR and UAH.
55
60
  # @option opts [Fixnum] :wmid WebMoney ID
61
+ # @note Accessibility: clients
56
62
  # @note Support of invoice lists: yes
57
- # @return [Hash(bills)] Bills.
63
+ # @return [Array<Hash>] Bills.
58
64
  # @example Example of request
59
65
  # bill.change_pay_type(currency: :RUR, pay_type: :prepay, bills: [ 123456 ])
60
- define :change_pay_type, required: %w[ currency pay_type ]
66
+ define :change_pay_type, required: %w[ currency pay_type ], field: :bills
61
67
 
62
68
  # @!method delete(opts = {})
63
69
  # Deletion of unpaid invoices.
@@ -66,10 +72,10 @@ module RegApi2
66
72
  # @param [Hash] opts
67
73
  # @option opts [Fixnum] :bill_id Invoice ID (in case of single invoice request).
68
74
  # @option opts [Array(Fixnum)] :bills A list of invoice IDs.
69
- # @return [Hash(bills)] Bills.
75
+ # @return [Array<Hash>] Bills.
70
76
  # @example Delete three bills.
71
77
  # bill.delete(bills: [ { bill_id: 12345 }, { bill_id: 12346 }, { bill_id: 12347 } ])
72
- define :delete
78
+ define :delete, field: :bills
73
79
 
74
80
  extend self
75
81
  end
data/lib/reg_api2/impl.rb CHANGED
@@ -114,15 +114,11 @@ module RegApi2
114
114
  # @example Dump outgoing API requests to code block
115
115
  # RegApi2.dump_requests { |path, form| p path; p form }
116
116
  def dump_requests(to = nil, &code_block)
117
- if to
118
- self.dump_requests_to= to
119
- return nil
117
+ if to.nil? && block_given?
118
+ to = code_block
120
119
  end
121
- if block_given?
122
- self.dump_requests_to= code_block
123
- return nil
124
- end
125
- self.dump_requests_to= nil
120
+ self.dump_requests_to = to
121
+ nil
126
122
  end
127
123
 
128
124
  # Dumps incoming API responses to given `to` or code block.
@@ -141,15 +137,11 @@ module RegApi2
141
137
  # @example Dump incoming API responses to `$stdout`
142
138
  # RegApi2.dump_responses :stdout
143
139
  def dump_responses(to = nil, &code_block)
144
- if to
145
- self.dump_responses_to= to
146
- return nil
140
+ if to.nil? && block_given?
141
+ to = code_block
147
142
  end
148
- if block_given?
149
- self.dump_responses_to= code_block
150
- return nil
151
- end
152
- self.dump_responses_to= nil
143
+ self.dump_responses_to = to
144
+ nil
153
145
  end
154
146
 
155
147
  # Default IO encoding
@@ -114,6 +114,7 @@ module RegApi2
114
114
  # @see #opts
115
115
  def handle_answer(answer)
116
116
  answer = convert(answer)
117
+ return nil if answer.nil?
117
118
  field = opts[:field]
118
119
  if field
119
120
  answer = answer[field]
@@ -225,36 +225,53 @@ 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
229
+ # @note Accessibility: clients
230
+ # @note Support of service lists: no
228
231
  define :set_autorenew_flag
229
232
 
230
233
  # @!method suspend(opts = {})
231
234
  # Use this function to suspend services (for domains – suspend delegation).
232
235
  # @param opts Options.
236
+ # @return [NilClass] nil
237
+ # @note Accessibility: clients
238
+ # @note Support of service lists: no
233
239
  define :suspend
234
240
 
235
241
  # @!method resume(opts = {})
236
242
  # Use this function to resume services (for domains – resume domain delegation).
237
243
  # @param opts Options.
244
+ # @return [NilClass] nil
245
+ # @note Accessibility: clients
246
+ # @note Support of service lists: no
238
247
  define :resume
239
248
 
240
249
  # @!method get_depreciated_period(opts = {})
241
250
  # Use this function to calculate the number of periods till the service expiration date.
242
251
  # @param opts Options.
252
+ # @note Accessibility: clients
253
+ # @note Support of service lists: no
243
254
  define :get_depreciated_period
244
255
 
245
256
  # @!method upgrade(opts = {})
246
257
  # This function upgrades service subtypes (rate plans). It can be used for changes of rate plans for virtual hosting ("srv_hosting_ispmgr"), VPS servers("srv_vps") and Additional Disk Space for VPS ("srv_disk_space").
247
258
  # @param opts Options.
259
+ # @note Accessibility: clients
260
+ # @note Support of service lists: no
248
261
  define :upgrade
249
262
 
250
263
  # @!method partcontrol_grant(opts = {})
251
264
  # You can use this function to grant a part of service management rights to other users.
252
265
  # @param opts Options.
266
+ # @note Accessibility: clients
267
+ # @note Support of service lists: no
253
268
  define :partcontrol_grant
254
269
 
255
270
  # @!method partcontrol_revoke(opts = {})
256
271
  # Use this function to stop granting service management rights to other.
257
272
  # @param opts Options.
273
+ # @note Accessibility: clients
274
+ # @note Support of service lists: no
258
275
  define :partcontrol_revoke
259
276
 
260
277
  # @!method resend_mail(opts = {})
@@ -262,7 +279,9 @@ module RegApi2
262
279
  # @param opts Options.
263
280
  # @option opts [Array] mailtype Email type: `approver_email` — approve ssl certificate order, `certificate_email` — certificate email.
264
281
  # @return [Hash(service_id, dname)]
265
- # @example Resend mail.
282
+ # @note Accessibility: clients
283
+ # @note Support of service lists: no
284
+ # @example Resend mail.
266
285
  # RegApi2.service.resend_mail servtype: :srv_ssl_certificate
267
286
  define :resend_mail
268
287
 
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RegApi2
3
3
  # Gem version.
4
- VERSION = "0.0.9".freeze
4
+ VERSION = "0.0.10".freeze
5
5
  end
@@ -14,11 +14,11 @@ describe RegApi2::Bill do
14
14
  end
15
15
 
16
16
  it "should return bill if specified" do
17
- bill.nop(bill_id: 12345).bills.should have(1).bill
17
+ bill.nop(bill_id: 12345).should have(1).bill
18
18
  end
19
19
 
20
20
  it "should return bills if specified" do
21
- bill.nop(bills: [ 12345, 12346 ]).bills.should have(2).bills
21
+ bill.nop(bills: [ 12345, 12346 ]).should have(2).bills
22
22
  end
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ describe RegApi2::Bill do
28
28
  end
29
29
 
30
30
  it "should return something real" do
31
- bill.get_not_payed.bills.should have(1).bill
31
+ bill.get_not_payed.should have(1).bill
32
32
  end
33
33
  end
34
34
 
@@ -41,7 +41,7 @@ describe RegApi2::Bill do
41
41
  bill.get_for_period(
42
42
  start_date: Date.new(2000, 1, 1),
43
43
  end_date: Date.new(2015, 1, 1)
44
- ).bills.should have(1).bill
44
+ ).should have(1).bill
45
45
  end
46
46
  end
47
47
 
@@ -63,7 +63,7 @@ describe RegApi2::Bill do
63
63
  pay_type: :prepay,
64
64
  currency: :RUR,
65
65
  bills: [ 123456 ]
66
- ).bills.should have(1).bill
66
+ ).should have(1).bill
67
67
  end
68
68
  end
69
69
 
@@ -71,7 +71,7 @@ describe RegApi2::Bill do
71
71
  it "should remove three bills if specified" do
72
72
  ans = bill.delete(
73
73
  bills: [ { bill_id: 12345 }, { bill_id: 12346 }, { bill_id: 12347 } ]
74
- ).bills
74
+ )
75
75
  ans.map { |b| b.bill_id }.should == [ 12345, 12346, 12347 ]
76
76
  ans.each { |b| b.result.should == 'success' }
77
77
  ans.each { |b| b.status.should == 'deleted' }
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,11 @@
6
6
  #
7
7
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
8
 
9
- require 'coveralls'
10
- Coveralls.wear!
9
+ begin
10
+ require 'coveralls'
11
+ Coveralls.wear!
12
+ rescue LoadError
13
+ end
11
14
 
12
15
  require 'faker'
13
16
  require 'machinist'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reg.api2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-08 00:00:00.000000000 Z
12
+ date: 2013-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -199,6 +199,7 @@ files:
199
199
  - .rspec
200
200
  - .travis.yml
201
201
  - .yardopts
202
+ - CHANGES.md
202
203
  - Gemfile
203
204
  - LICENSE
204
205
  - README.md
@@ -252,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
253
  version: '0'
253
254
  segments:
254
255
  - 0
255
- hash: 890297353583224213
256
+ hash: 3535020143484780529
256
257
  required_rubygems_version: !ruby/object:Gem::Requirement
257
258
  none: false
258
259
  requirements:
@@ -261,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
262
  version: '0'
262
263
  segments:
263
264
  - 0
264
- hash: 890297353583224213
265
+ hash: 3535020143484780529
265
266
  requirements: []
266
267
  rubyforge_project:
267
268
  rubygems_version: 1.8.24