rs.ge 0.1.2 → 0.1.3

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: 4e92c7c10de982d301960f308210ebf122876c6a
4
+ data.tar.gz: ad404d37bf1bdba378d2f4f3442b6930db093772
5
+ SHA512:
6
+ metadata.gz: 7f35c252ebb182108cdb8c9dba4d3da12e0d9e98643098aa0d7ba932d7e24c3a6391e03def4a4fc8aa0a3f479ecd60190cfa5f1b74252aa744c00e2a8813110c
7
+ data.tar.gz: 1cc21bb7c6f1028703e8cf4e2879ea9eefdde93a8b213d19258c315c515b72309390ed5bea01e472836f4829b30e5cf5470a0a3b02395043ae99da9c4a449307
@@ -2,6 +2,12 @@
2
2
  require 'singleton'
3
3
 
4
4
  module RS
5
+ class User
6
+ include RS::Initializable
7
+ attr_accessor :id, :username, :ip, :name, :payer_id
8
+ def self.extract(data); RS::User.new(id: data[:id].to_i, username: data[:user_name], ip: data[:ip], name: data[:name], payer_id: data[:un_id].to_i) end
9
+ end
10
+
5
11
  # System administration related methods.
6
12
  class SysRequest < BaseRequest
7
13
  include Singleton
@@ -12,20 +18,36 @@ module RS
12
18
  response.to_hash[:what_is_my_ip_response][:what_is_my_ip_result].strip
13
19
  end
14
20
 
15
- # Create service user.
16
- #
17
- # * `username` -- login for the main user
18
- # * `password` -- password for the main user
19
- # * `ip` -- your IP address
20
- # * `name` -- some name for this user/ip configuration
21
- # * `su` -- new user login
22
- # * `sp` -- new user password
23
- def create_user(opts)
24
- validate_presence_of(opts, :username, :password, :ip, :name, :su, :sp)
25
- response = waybill_client.request 'create_service_user' do
26
- soap.body = {'user_name' => opts[:username], 'user_password' => opts[:password], 'ip' => opts[:ip], 'name' => opts[:name], 'su' => opts[:su], 'sp' => opts[:sp]}
21
+ # # Create service user.
22
+ # #
23
+ # # * `username` -- login for the main user
24
+ # # * `password` -- password for the main user
25
+ # # * `ip` -- your IP address
26
+ # # * `name` -- some name for this user/ip configuration
27
+ # # * `su` -- new user login
28
+ # # * `sp` -- new user password
29
+ # def create_user(opts)
30
+ # validate_presence_of(opts, :username, :password, :ip, :name, :su, :sp)
31
+ # response = waybill_client.request 'create_service_user' do
32
+ # soap.body = {'user_name' => opts[:username], 'user_password' => opts[:password], 'ip' => opts[:ip], 'name' => opts[:name], 'su' => opts[:su], 'sp' => opts[:sp]}
33
+ # end
34
+ # response.to_hash[:create_service_user_response][:create_service_user_result]
35
+ # end
36
+
37
+ def get_users(opts)
38
+ validate_presence_of(opts, :username, :password)
39
+ response = (waybill_client.request 'get_service_users' do
40
+ soap.body = { 'user_name' => opts[:username], 'user_password' => opts[:password] }
41
+ end).to_hash
42
+ if response[:get_service_users_response][:get_service_users_result][:service_users].blank?
43
+ raise 'illegal username/password'
44
+ else
45
+ users = []
46
+ response[:get_service_users_response][:get_service_users_result][:service_users][:service_user].each do |data|
47
+ users << RS::User.extract(data)
48
+ end
49
+ users
27
50
  end
28
- response.to_hash[:create_service_user_response][:create_service_user_result]
29
51
  end
30
52
 
31
53
  # Update service user.
@@ -37,11 +59,11 @@ module RS
37
59
  # * `su` -- user login
38
60
  # * `sp` -- user's passwrod
39
61
  def update_user(opts)
40
- validate_presence_of(opts, :username, :password, :ip, :name, :su, :sp)
41
- response = waybill_client.request 'update_service_user' do
42
- soap.body = {'user_name' => opts[:username], 'user_password' => opts[:password], 'ip' => opts[:ip], 'name' => opts[:name], 'su' => opts[:su], 'sp' => opts[:sp]}
43
- end
44
- response.to_hash[:update_service_user_response][:update_service_user_result]
62
+ # validate_presence_of(opts, :username, :password, :ip, :name, :su, :sp)
63
+ # response = waybill_client.request 'update_service_user' do
64
+ # soap.body = {'user_name' => opts[:username], 'user_password' => opts[:password], 'ip' => opts[:ip], 'name' => opts[:name], 'su' => opts[:su], 'sp' => opts[:sp]}
65
+ # end
66
+ # response.to_hash[:update_service_user_response][:update_service_user_result]
45
67
  end
46
68
 
47
69
  # Check service user. Also used for getting user's ID and payer's ID.
data/lib/rs/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RS
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
@@ -14,7 +14,7 @@ describe 'create factura with items' do
14
14
  subject { @factura }
15
15
  its(:id) { should_not be_nil }
16
16
  its(:id) { should > 0 }
17
- its(:index) { should == 'ეა-36'}
17
+ its(:index) { should == 'ეა-70'}
18
18
  its(:number) { should be_nil }
19
19
  its(:operation_date) { should_not be_nil }
20
20
  its(:registration_date) { should_not be_nil }
@@ -98,7 +98,7 @@ describe 'get factura' do
98
98
  subject { @factura }
99
99
  its(:id) { should_not be_nil }
100
100
  its(:id) { should > 0 }
101
- its(:index) { should == 'ეა-36'}
101
+ its(:index) { should == 'ეა-70'}
102
102
  its(:number) { should be_nil }
103
103
  its(:operation_date) { should_not be_nil }
104
104
  its(:registration_date) { should_not be_nil }
@@ -119,12 +119,13 @@ describe 'get factura' do
119
119
  it { should_not be_nil }
120
120
  its(:id) { should == @id }
121
121
  its(:index) { should == 'ეა-36'}
122
- #its(:number) { should == 269554 }
123
- its(:number) { should be_nil }
122
+ its(:number) { should == 491549 }
123
+ #its(:number) { should be_nil }
124
124
  its(:operation_date) { should_not be_nil }
125
125
  its(:registration_date) { should_not be_nil }
126
126
  its(:seller_id) { should == 731937 }
127
- its(:status) { should == RS::Factura::STATUS_START }
127
+ #its(:status) { should == RS::Factura::STATUS_START }
128
+ its(:status) { should == RS::Factura::STATUS_SENT }
128
129
  its(:correction_of) { should be_nil }
129
130
  end
130
131
  context do
@@ -11,40 +11,40 @@ describe 'getting own IP address' do
11
11
  it { should match /([0-9]{1,3}\.){3}[0-9]{1,3}/ }
12
12
  end
13
13
 
14
- describe 'working with service user' do
15
- before(:all) do
16
- @username = "user_#{Time.now.to_i}_#{rand(100)}"
17
- @password = '123456'
18
- @new_password = 'new_password_123456'
19
- @ip = RS.sys.what_is_my_ip
20
- @resp = RS.sys.create_user(USER01.merge(ip: @ip, name: 'test', su: @username, sp: @password))
21
- end
22
- subject { @resp }
23
- it { should == true }
24
- describe 'update service user' do
25
- before(:all) do
26
- @resp = RS.sys.update_user(USER01.merge(ip: @ip, name: 'test', su: @username, sp: @new_password))
27
- end
28
- subject { @resp }
29
- it { should == true }
30
- end
31
- describe 'check service user: illegal user/password' do
32
- before(:all) do
33
- @resp = RS.sys.check_user(su: @username, sp: @password)
34
- end
35
- subject { @resp }
36
- it { should be_nil }
37
- end
38
- describe 'check service user: legal user/password' do
39
- before(:all) do
40
- @resp = RS.sys.check_user(su: @username, sp: @new_password)
41
- end
42
- subject { @resp }
43
- it { should_not be_nil }
44
- specify { subject[:payer].should_not be_nil }
45
- specify { subject[:user].should_not be_nil }
46
- end
47
- end
14
+ # describe 'working with service user' do
15
+ # before(:all) do
16
+ # @username = "user_#{Time.now.to_i}_#{rand(100)}"
17
+ # @password = '123456'
18
+ # @new_password = 'new_password_123456'
19
+ # @ip = RS.sys.what_is_my_ip
20
+ # @resp = RS.sys.create_user(USER01.merge(ip: @ip, name: 'test', su: @username, sp: @password))
21
+ # end
22
+ # subject { @resp }
23
+ # it { should == true }
24
+ # describe 'update service user' do
25
+ # before(:all) do
26
+ # @resp = RS.sys.update_user(USER01.merge(ip: @ip, name: 'test', su: @username, sp: @new_password))
27
+ # end
28
+ # subject { @resp }
29
+ # it { should == true }
30
+ # end
31
+ # describe 'check service user: illegal user/password' do
32
+ # before(:all) do
33
+ # @resp = RS.sys.check_user(su: @username, sp: @password)
34
+ # end
35
+ # subject { @resp }
36
+ # it { should be_nil }
37
+ # end
38
+ # describe 'check service user: legal user/password' do
39
+ # before(:all) do
40
+ # @resp = RS.sys.check_user(su: @username, sp: @new_password)
41
+ # end
42
+ # subject { @resp }
43
+ # it { should_not be_nil }
44
+ # specify { subject[:payer].should_not be_nil }
45
+ # specify { subject[:user].should_not be_nil }
46
+ # end
47
+ # end
48
48
 
49
49
  describe 'get error codes' do
50
50
  before(:all) do
@@ -58,3 +58,12 @@ describe 'get error codes' do
58
58
  it { should == 'პროდუქტის დასახელება დიდია' }
59
59
  end
60
60
  end
61
+
62
+ describe 'get service users list' do
63
+ before(:all) do
64
+ @users = RS.sys.get_users(username: 'tbilisi', password: '123456')
65
+ end
66
+ subject { @users }
67
+ it { should_not be_empty }
68
+ its(:size) { should == 190 }
69
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rs.ge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dimitri Kurashvili
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
11
+ date: 2013-10-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
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: :development
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: savon
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: :runtime
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,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: prawn
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
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
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: c12-commons
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: activesupport
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -126,27 +115,26 @@ files:
126
115
  - spec/spec_helper.rb
127
116
  homepage: http://c12.ge
128
117
  licenses: []
118
+ metadata: {}
129
119
  post_install_message:
130
120
  rdoc_options: []
131
121
  require_paths:
132
122
  - lib
133
123
  required_ruby_version: !ruby/object:Gem::Requirement
134
- none: false
135
124
  requirements:
136
- - - ! '>='
125
+ - - '>='
137
126
  - !ruby/object:Gem::Version
138
127
  version: '0'
139
128
  required_rubygems_version: !ruby/object:Gem::Requirement
140
- none: false
141
129
  requirements:
142
- - - ! '>='
130
+ - - '>='
143
131
  - !ruby/object:Gem::Version
144
132
  version: '0'
145
133
  requirements: []
146
134
  rubyforge_project: rs
147
- rubygems_version: 1.8.24
135
+ rubygems_version: 2.0.3
148
136
  signing_key:
149
- specification_version: 3
137
+ specification_version: 4
150
138
  summary: rs.ge web services
151
139
  test_files:
152
140
  - spec/helpers.rb