rs.ge 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rs/models/waybill.rb +10 -6
- data/lib/rs/requests/waybill.rb +58 -3
- data/lib/rs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cbef5c1a418b73e5e5ad907d96f8df8f7baf14e
|
4
|
+
data.tar.gz: 24e83d6a07bf96835bf75ef1eb768f4c880f9347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b963482f324fda9ec7159cafdcf6292fe99a894da6871d1794a67aab186ec72878666776f4e24cc3b7ca01ccf48164f01053cd1cacaa61995f9466d01527610c
|
7
|
+
data.tar.gz: 8d11ea84b08172274404c2c35580140aa6e4764f6e6e0f5b8611b3dffb2283f4bdbfaf532290d0227358b26167c43bc4ec676dc34637388f0a9b39a51edc1fb8
|
data/lib/rs/models/waybill.rb
CHANGED
@@ -246,13 +246,15 @@ class RS::Waybill < RS::Validable
|
|
246
246
|
|
247
247
|
# Initialize this waybill from given hash.
|
248
248
|
def init_from_hash(hash)
|
249
|
-
items_hash = hash[:goods_list][:goods]
|
250
|
-
items_hash = [items_hash] if items_hash.instance_of? Hash
|
251
249
|
self.items = []
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
250
|
+
if hash[:goods_list].present?
|
251
|
+
items_hash = hash[:goods_list][:goods]
|
252
|
+
items_hash = [items_hash] if items_hash.instance_of? Hash
|
253
|
+
items_hash.each do |item_hash|
|
254
|
+
item = RS::WaybillItem.new
|
255
|
+
item.init_from_hash(item_hash)
|
256
|
+
self.items << item
|
257
|
+
end
|
256
258
|
end
|
257
259
|
self.id = hash[:id].to_i
|
258
260
|
self.type = hash[:type].to_i
|
@@ -271,6 +273,8 @@ class RS::Waybill < RS::Validable
|
|
271
273
|
self.delivery_date = hash[:delivery_date] # delivery date
|
272
274
|
self.status = hash[:status].to_i
|
273
275
|
self.seller_id = hash[:seler_un_id].to_i
|
276
|
+
self.seller_tin = hash[:seller_tin]
|
277
|
+
self.seller_name = hash[:seller_name]
|
274
278
|
self.activate_date = hash[:activate_date]
|
275
279
|
self.parent_id = hash[:par_id] ? hash[:par_id].to_i : nil
|
276
280
|
self.total = hash[:full_amount].to_f
|
data/lib/rs/requests/waybill.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'singleton'
|
3
3
|
|
4
4
|
module RS
|
5
|
-
|
6
5
|
class WaybillRequest < BaseRequest
|
7
6
|
include Singleton
|
8
7
|
|
@@ -43,6 +42,64 @@ module RS
|
|
43
42
|
wb.init_from_hash(response.to_hash[:get_waybill_response][:get_waybill_result][:waybill])
|
44
43
|
end
|
45
44
|
|
45
|
+
# Get waybills (seller's point of view).
|
46
|
+
def get_waybills(opts = {})
|
47
|
+
validate_presence_of(opts, :su, :sp)
|
48
|
+
message = { 'su' => opts[:su], 'sp' => opts[:sp] }
|
49
|
+
waybill_search_params(opts, message)
|
50
|
+
response = waybill_client.request 'get_waybills' do
|
51
|
+
soap.body = message
|
52
|
+
end
|
53
|
+
waybill_data = response.to_hash[:get_waybills_response][:get_waybills_result][:waybill_list][:waybill]
|
54
|
+
extract_waybills(waybill_data)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get waybills (buyer's point of view).
|
58
|
+
def get_buyer_waybills(opts = {})
|
59
|
+
validate_presence_of(opts, :su, :sp)
|
60
|
+
message = { 'su' => opts[:su], 'sp' => opts[:sp] }
|
61
|
+
waybill_search_params(opts, message)
|
62
|
+
response = waybill_client.request 'get_buyer_waybills' do
|
63
|
+
soap.body = message
|
64
|
+
end
|
65
|
+
waybill_data = response.to_hash[:get_buyer_waybills_response][:get_buyer_waybills_result][:waybill_list][:waybill]
|
66
|
+
extract_waybills(waybill_data)
|
67
|
+
end
|
68
|
+
|
69
|
+
def extract_waybills(waybill_data)
|
70
|
+
waybills = []
|
71
|
+
if waybill_data.is_a?(Array)
|
72
|
+
waybill_data.each do |data|
|
73
|
+
wb = RS::Waybill.new
|
74
|
+
wb.init_from_hash(data)
|
75
|
+
waybills << wb
|
76
|
+
end
|
77
|
+
elsif waybill_data.is_a?(Hash)
|
78
|
+
wb = RS::Waybill.new
|
79
|
+
wb.init_from_hash(waybill_data)
|
80
|
+
waybills << wb
|
81
|
+
end
|
82
|
+
waybills
|
83
|
+
end
|
84
|
+
|
85
|
+
def waybill_search_params(opts, message)
|
86
|
+
message['itypes'] = opts[:types].join(',') if opts[:types].present?
|
87
|
+
message['buyer_tin'] = opts[:buyer_tin] if opts[:buyer_tin].present?
|
88
|
+
message['statuses'] = opts[:statuses].join(',') if opts[:statuses].present?
|
89
|
+
message['car_number'] = opts[:vehicle] if opts[:vehicle].present?
|
90
|
+
message['begin_date_s'] = opts[:begin_date_1] if opts[:begin_date_1].present?
|
91
|
+
message['begin_date_e'] = opts[:begin_date_2] if opts[:begin_date_2].present?
|
92
|
+
message['create_date_s'] = opts[:create_date_1] if opts[:create_date_1].present?
|
93
|
+
message['create_date_e'] = opts[:create_date_2] if opts[:create_date_2].present?
|
94
|
+
message['driver_tin'] = opts[:driver_tin] if opts[:driver_tin].present?
|
95
|
+
message['delivery_date_s'] = opts[:delivery_date_1] if opts[:delivery_date_1].present?
|
96
|
+
message['delivery_date_e'] = opts[:delivery_date_2] if opts[:delivery_date_2].present?
|
97
|
+
message['full_amount'] = opts[:amount] if opts[:amount].present?
|
98
|
+
message['waybill_number'] = opts[:number] if opts[:number].present?
|
99
|
+
message['close_date_s'] = opts[:close_date_1] if opts[:close_date_1]
|
100
|
+
message['close_date_e'] = opts[:close_date_2] if opts[:close_date_2]
|
101
|
+
end
|
102
|
+
|
46
103
|
# Activate waybill.
|
47
104
|
def activate_waybill(opts)
|
48
105
|
validate_presence_of(opts, :id, :su, :sp)
|
@@ -110,7 +167,6 @@ module RS
|
|
110
167
|
nil
|
111
168
|
end
|
112
169
|
end
|
113
|
-
|
114
170
|
end
|
115
171
|
|
116
172
|
class << self
|
@@ -122,5 +178,4 @@ module RS
|
|
122
178
|
RS::WaybillRequest.instance
|
123
179
|
end
|
124
180
|
end
|
125
|
-
|
126
181
|
end
|
data/lib/rs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs.ge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Kurashvili
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|