rs.ge 0.1.0.beta2 → 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- # WaybillUnit is a unit which is used to describe production quantities in waybill.
4
- #
5
- # The Revenue Service of Georgia provides us with standard set of units,
6
- # which can be obtained using RS.waybill_units method call.
7
- #
8
- # One special unit, is the unit which describes all units which were not included
9
- # in the Revenue Service list. Identification number for this special unit is
10
- # stored in contant RS::WaybillUnit::OTHERS.
11
- class RS::WaybillUnit
12
- # Unit ID.
13
- attr_accessor :id
14
-
15
- # Unit name,
16
- attr_accessor :name
17
-
18
- # Identification number for the unit, which were not included in
19
- # the Revenue Service list of units.
20
- OTHERS = 99
21
- end
@@ -1,44 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'singleton'
3
-
4
- module RS
5
- # Request object, used for processing waybill units.
6
- #
7
- # Use RS.unit or RS.units call to access instance of this class.
8
- class WaybillUnitRequest < BaseRequest
9
- include Singleton
10
-
11
- # Returns all units.
12
- def all(opts = {})
13
- validate_presence_of(opts, :su, :sp)
14
- response = waybill_client.request 'get_waybill_units' do
15
- soap.body = { 'su' => opts[:su], 'sp' => opts[:sp] }
16
- end
17
- extract_units_from_response(response)
18
- end
19
-
20
- private
21
-
22
- def extract_units_from_response(response)
23
- units = []
24
- units_hash = response.to_hash[:get_waybill_units_response][:get_waybill_units_result][:waybill_units][:waybill_unit]
25
- units_hash.each do |hash|
26
- unit = WaybillUnit.new
27
- unit.id = hash[:id].to_i
28
- unit.name = hash[:name]
29
- units << unit
30
- end
31
- units
32
- end
33
-
34
- end
35
-
36
- # Returns the instance of WaybillUnitRequest class.
37
- def self.units
38
- RS::WaybillUnitRequest.instance
39
- end
40
-
41
- class << self
42
- alias_method :unit, :units
43
- end
44
- end
@@ -1,24 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'getting waybill units' do
5
- before(:all) do
6
- @units = RS.units.all(SU_PARAMS)
7
- end
8
- subject { @units }
9
- it { should_not be_nil }
10
- it { should_not be_empty }
11
- context 'first unit' do
12
- subject { @units.first }
13
- it { should be_instance_of RS::WaybillUnit }
14
- its(:id) { should_not be_nil }
15
- its(:name) { should_not be_nil }
16
- end
17
- context 'last unit' do
18
- subject { @units.last }
19
- it { should be_instance_of RS::WaybillUnit }
20
- its(:id) { should_not be_nil }
21
- its(:id) { should == RS::WaybillUnit::OTHERS }
22
- its(:name) { should_not be_nil }
23
- end
24
- end