Skip to content

Commit

Permalink
bill.nop
Browse files Browse the repository at this point in the history
  • Loading branch information
akzhan committed Sep 11, 2013
1 parent 49a4ca5 commit 2bb4c30
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/reg_api2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require 'reg_api2/clients'
require 'reg_api2/user'
require 'reg_api2/service'
require 'reg_api2/bill'

# REG.API v2
# @example List of services by specified identifiers
Expand Down Expand Up @@ -50,4 +51,9 @@ def user; RegApi2::User; end
def service; RegApi2::Service; end
module_function :service

# Shortcut for {RegApi2::Bill} methods.
# @return [Module] {RegApi2::Bill}
def bill; RegApi2::Bill; end
module_function :bill

end
25 changes: 25 additions & 0 deletions lib/reg_api2/bill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- encoding : utf-8 -*-
module RegApi2
# REG.API bill category
module Bill

include RegApi2::Builder

category :bill

# @!method nop(opts = {})
# @param [Hash] opts
# @option opts [String] :bill_id Invoice number in case of a single-invoice request.
# @option opts [Array] :bills A list if invoice numbers.
# For testing purposes.
# @return [NilClass or Hash(bills)] nil or bills.
# @note Support of invoice lists: yes
# @example Get single bill
# RegApi2.bill.nop bill_id: 12345
# @example Get bills
# RegApi2.bill.nop bills: ["12345","12346"]
define :nop

extend self
end
end
22 changes: 22 additions & 0 deletions spec/lib/reg_api2/bill_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- encoding : utf-8 -*-

describe RegApi2::Bill do
describe :nop do
it "should raise nothing" do
lambda { RegApi2.bill.nop }.should_not raise_error
end

it "should return nil" do
RegApi2.bill.nop.should be_nil
end

it "should return bill if specified" do
RegApi2.bill.nop(bill_id: 12345).bills.should have(1).bill
end

it "should return bills if specified" do
RegApi2.bill.nop(bills: [ 12345, 12346 ]).bills.should have(2).bills
end
end

end

0 comments on commit 2bb4c30

Please sign in to comment.