axiomus_api 0.1.2 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -4
- data/lib/axiomus_api/base.rb +8 -2
- data/lib/axiomus_api/below.rb +5 -0
- data/lib/axiomus_api/delivset.rb +13 -0
- data/lib/axiomus_api/item/item.rb +0 -2
- data/lib/axiomus_api/items/export_items.rb +13 -0
- data/lib/axiomus_api/items/items.rb +14 -0
- data/lib/axiomus_api/order/base_order.rb +5 -12
- data/lib/axiomus_api/order/carry_order.rb +2 -0
- data/lib/axiomus_api/order/export_order.rb +2 -4
- data/lib/axiomus_api/order/order.rb +2 -1
- data/lib/axiomus_api/order/self_export_order.rb +4 -1
- data/lib/axiomus_api/serializable.rb +21 -21
- data/lib/axiomus_api/validated.rb +26 -4
- data/lib/axiomus_api/version.rb +1 -1
- data/spec/factories.rb +42 -19
- data/spec/integration/{axiomus_api → lib/axiomus_api}/session_spec.rb +23 -1
- data/spec/lib/axiomus_api/delivest_spec.rb +12 -0
- data/spec/lib/axiomus_api/{base_order_spec.rb → order/base_order_spec.rb} +5 -3
- data/spec/lib/axiomus_api/validated_spec.rb +36 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b9bba2a5f6c2a80077adee2f7618cdb3012285
|
4
|
+
data.tar.gz: f0168adfc8ec11167ecf7b9762d493884774f479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f2d713c2bbaf5c984198dcd53686ce7694842176c78e7308a7278833c1d3ea6d38b4d155abe2a68d44577840bf4c60470c4fa6bdf51d0f44c8c980fa66597f7
|
7
|
+
data.tar.gz: 76a55fe55d9b7dad0a4a9cb81c5e8036127d36523324e8694ed5a35a78079563fbadb26e985f85ea5a24ba781d4664c6ec51e7df22f274748b23642931cd9f9d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -96,13 +96,14 @@ You can also specify the Axiomus method as a symbol, using `AxiomusApi::Session#
|
|
96
96
|
@response = @session.send_order_request(:update_ems, @order)
|
97
97
|
```
|
98
98
|
|
99
|
-
Most orders use `AxiomusApi::Item` as their item type, but some don't. To safely create an item of a proper type, use `#
|
99
|
+
Most orders use `AxiomusApi::Item` as their item type, but some don't. To safely create an item of a proper type, use `#add_item` method of your order's `#items` field:
|
100
100
|
|
101
101
|
```ruby
|
102
102
|
@order = AxiomusApi::EmsOrder.new
|
103
|
-
@my_item = @order.
|
104
|
-
|
105
|
-
@
|
103
|
+
@my_item = @order.items.add_item
|
104
|
+
@my_item.name = 'My awesome product'
|
105
|
+
@my_item.weight = 0.3
|
106
|
+
# set other fields
|
106
107
|
```
|
107
108
|
|
108
109
|
### Getting order status
|
data/lib/axiomus_api/base.rb
CHANGED
@@ -13,7 +13,7 @@ class AxiomusApi::Base
|
|
13
13
|
options = extract_options(args)
|
14
14
|
|
15
15
|
options.keys.each do |k|
|
16
|
-
raise "Wrong attribute #{k}" if ![:xml_type, :xml_name, :optional, :type].include?(k)
|
16
|
+
raise "Wrong attribute #{k}" if ![:xml_type, :xml_name, :optional, :type, :array, :max_occurs].include?(k)
|
17
17
|
end
|
18
18
|
|
19
19
|
args.each do |attr_name|
|
@@ -29,6 +29,10 @@ class AxiomusApi::Base
|
|
29
29
|
xml_field(*args)
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.xml_field_array(name, options = {})
|
33
|
+
xml_field(name, options.merge({array: true}))
|
34
|
+
end
|
35
|
+
|
32
36
|
def self.attribute_meta
|
33
37
|
res = superclass.respond_to?(:attribute_meta) ? superclass.attribute_meta : {}
|
34
38
|
res.merge(@attr_info || {})
|
@@ -60,7 +64,9 @@ class AxiomusApi::Base
|
|
60
64
|
|
61
65
|
def initialize
|
62
66
|
self.class.attribute_meta.each do |k, v|
|
63
|
-
if v[:
|
67
|
+
if v[:array]
|
68
|
+
self.send("#{k}=".to_sym, [])
|
69
|
+
elsif v[:type]
|
64
70
|
self.send("#{k}=".to_sym, v[:type].new)
|
65
71
|
end
|
66
72
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'below'
|
3
|
+
|
4
|
+
class AxiomusApi::Delivset < AxiomusApi::Base
|
5
|
+
xml_attribute :return_price, :above_sum, :above_price
|
6
|
+
xml_field_array :below, type: AxiomusApi::Below, max_occurs: 3, optional: true
|
7
|
+
|
8
|
+
def add_below_element
|
9
|
+
new_below = AxiomusApi::Below.new
|
10
|
+
below << new_below
|
11
|
+
new_below
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../base'
|
2
|
+
require_relative '../item/export_item'
|
3
|
+
|
4
|
+
class AxiomusApi::ExportItems < AxiomusApi::Base
|
5
|
+
|
6
|
+
xml_field_array :item, type: AxiomusApi::ExportItem
|
7
|
+
|
8
|
+
def add_item
|
9
|
+
new_item = AxiomusApi::ExportItem.new
|
10
|
+
item << new_item
|
11
|
+
new_item
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../base'
|
2
|
+
require_relative '../item/item'
|
3
|
+
|
4
|
+
class AxiomusApi::Items < AxiomusApi::Base
|
5
|
+
|
6
|
+
xml_field_array :item, type: AxiomusApi::Item
|
7
|
+
|
8
|
+
def add_item
|
9
|
+
new_item = AxiomusApi::Item.new
|
10
|
+
item << new_item
|
11
|
+
new_item
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -1,30 +1,23 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
require_relative '../services/services'
|
3
|
+
require_relative '../items/items'
|
3
4
|
|
4
5
|
class AxiomusApi::BaseOrder < AxiomusApi::Base
|
5
6
|
xml_element :order
|
6
7
|
|
7
|
-
xml_field :contacts
|
8
|
+
xml_field :contacts
|
9
|
+
xml_field :items, type: AxiomusApi::Items
|
8
10
|
xml_field :description, optional: true
|
9
11
|
xml_attribute :inner_id, :okey, optional: true
|
10
12
|
xml_attribute :name, :places
|
11
13
|
xml_field :services, type: AxiomusApi::Services
|
12
14
|
|
13
|
-
def initialize
|
14
|
-
super
|
15
|
-
@items = []
|
16
|
-
end
|
17
|
-
|
18
15
|
def total_quantity
|
19
|
-
@items.inject(0){|sum, it| sum + it.quantity}
|
16
|
+
@items.item.inject(0){|sum, it| sum + it.quantity}
|
20
17
|
end
|
21
18
|
|
22
19
|
def checksum(uid)
|
23
|
-
Digest::MD5.hexdigest("#{uid}u#{@items.count}#{total_quantity}")
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_item
|
27
|
-
AxiomusApi::Item.new
|
20
|
+
Digest::MD5.hexdigest("#{uid}u#{@items.item.count}#{total_quantity}")
|
28
21
|
end
|
29
22
|
|
30
23
|
def self.create_by_mode(mode)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require_relative 'base_order'
|
2
|
+
require_relative '../delivset'
|
2
3
|
|
3
4
|
class AxiomusApi::CarryOrder < AxiomusApi::BaseOrder
|
4
5
|
|
5
6
|
xml_attribute :office, :incl_deliv_sum, :sms_sender, :sms, optional: true
|
6
7
|
xml_attribute :b_date, :e_date
|
8
|
+
xml_field :delivset, optional: true, type: AxiomusApi::Delivset
|
7
9
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'base_order'
|
2
|
-
require_relative '../
|
2
|
+
require_relative '../items/export_items'
|
3
3
|
require_relative '../services/export_services'
|
4
4
|
|
5
5
|
class AxiomusApi::ExportOrder < AxiomusApi::BaseOrder
|
@@ -7,8 +7,6 @@ class AxiomusApi::ExportOrder < AxiomusApi::BaseOrder
|
|
7
7
|
xml_attribute :from_mkad, :garden_ring, optional: true
|
8
8
|
xml_attribute :export_quantity, :transit, :d_date, :b_time, :e_time, :address
|
9
9
|
xml_field :services, type: AxiomusApi::ExportServices
|
10
|
+
xml_field :items, type: AxiomusApi::ExportItems
|
10
11
|
|
11
|
-
def create_item
|
12
|
-
AxiomusApi::ExportItem.new
|
13
|
-
end
|
14
12
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require_relative 'base_order'
|
2
|
+
require_relative '../delivset'
|
2
3
|
|
3
4
|
class AxiomusApi::Order < AxiomusApi::BaseOrder
|
4
5
|
|
5
6
|
xml_attribute :address, :d_date, :b_time, :e_time, :city
|
6
7
|
xml_attribute :incl_deliv_sum, :from_mkad, :garden_ring, :sms_sender, :sms, optional: true
|
7
|
-
|
8
|
+
xml_field :delivset, optional: true, type: AxiomusApi::Delivset
|
8
9
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
require_relative 'base_order'
|
2
|
+
require_relative '../items/export_items'
|
2
3
|
|
3
4
|
class AxiomusApi::SelfExportOrder < AxiomusApi::BaseOrder
|
4
5
|
|
5
6
|
xml_attribute :car, :d_date, :b_time, :e_time, :quantity
|
6
7
|
xml_field :services, optional: true
|
8
|
+
xml_field :items, type: AxiomusApi::ExportItems
|
7
9
|
|
8
10
|
def initialize
|
9
11
|
super
|
10
|
-
services = nil
|
12
|
+
@services = nil
|
11
13
|
end
|
12
14
|
|
13
15
|
def services=(val); end
|
16
|
+
|
14
17
|
end
|
15
18
|
|
@@ -3,11 +3,7 @@ require 'nokogiri'
|
|
3
3
|
module AxiomusApi::Serializable
|
4
4
|
def to_xml(xml_header = false, tag_name = nil)
|
5
5
|
serializable_fields = self.class.attribute_meta
|
6
|
-
|
7
|
-
|
8
|
-
attributes = Hash[attribute_fields.map do |k,v|
|
9
|
-
[v[:xml_name] || k, normalize_axiomus_xml(self.send(k).to_s)]
|
10
|
-
end].reject{|k,v| v.nil? || v.empty?}
|
6
|
+
attributes = extract_attributes(serializable_fields)
|
11
7
|
|
12
8
|
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
13
9
|
xml.send(tag_name || self.tag_name, attributes) {
|
@@ -16,37 +12,41 @@ module AxiomusApi::Serializable
|
|
16
12
|
xml_name = opt[:xml_name] || f
|
17
13
|
xml_type = opt[:xml_type] || :element
|
18
14
|
val = self.send(f)
|
19
|
-
|
20
15
|
next if val.nil?
|
16
|
+
elements = opt[:array] ? val : [val]
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
obj_to_xml(xml, val, xml_name)
|
25
|
-
when :text
|
26
|
-
xml.text(val)
|
18
|
+
elements.each do |el|
|
19
|
+
create_by_type(xml, el, xml_type, xml_name)
|
27
20
|
end
|
28
21
|
end
|
29
22
|
}
|
30
23
|
end
|
31
24
|
|
32
|
-
xml =
|
33
|
-
builder.to_xml
|
34
|
-
else
|
35
|
-
builder.doc.root.to_xml
|
36
|
-
end
|
37
|
-
|
25
|
+
xml = xml_header ? builder.to_xml : builder.doc.root.to_xml
|
38
26
|
normalize_axiomus_xml(xml)
|
39
27
|
end
|
40
28
|
|
41
29
|
private
|
42
30
|
|
31
|
+
def extract_attributes(serializable_fields)
|
32
|
+
attribute_fields = serializable_fields.select{|k,v| v[:xml_type] == :attribute}
|
33
|
+
Hash[attribute_fields.map do |k,v|
|
34
|
+
[v[:xml_name] || k, normalize_axiomus_xml(self.send(k).to_s)]
|
35
|
+
end].reject{|k,v| v.nil? || v.empty?}
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_by_type(xml, val, xml_type, xml_name)
|
39
|
+
case xml_type
|
40
|
+
when :element
|
41
|
+
obj_to_xml(xml, val, xml_name)
|
42
|
+
when :text
|
43
|
+
xml.text(val)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
43
47
|
def obj_to_xml(xml, obj, xml_name = nil)
|
44
48
|
if obj.kind_of?(AxiomusApi::Base)
|
45
49
|
xml << obj.to_xml(false, xml_name)
|
46
|
-
elsif obj.kind_of?(Array)
|
47
|
-
xml.send(xml_name) {
|
48
|
-
obj.each{|el| obj_to_xml(xml, el)}
|
49
|
-
}
|
50
50
|
else
|
51
51
|
xml.send(xml_name) {
|
52
52
|
xml.text(normalize_axiomus_xml(obj.to_s))
|
@@ -21,12 +21,34 @@ module AxiomusApi::Validated
|
|
21
21
|
@validation_errors << "Field #{field} is required"
|
22
22
|
end
|
23
23
|
else
|
24
|
-
if
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
if options[:array]
|
25
|
+
validate_array_field(field, value, options)
|
26
|
+
else
|
27
|
+
validate_present_field(field, value, options)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def validate_array_field(field, value, options)
|
33
|
+
if value.is_a?(Array)
|
34
|
+
if !options[:max_occurs].nil? && (value.count > options[:max_occurs])
|
35
|
+
@validation_errors << "Field #{field} can have #{options[:max_occurs]} elements maximum"
|
36
|
+
end
|
37
|
+
|
38
|
+
value.each do |el, i|
|
39
|
+
validate_present_field("#{field}[#{i}]", el, options)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
@validation_errors << "Element #{field} must be an array"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_present_field(field, value, options)
|
47
|
+
if !(options[:type].nil? || value.is_a?(options[:type]))
|
48
|
+
@validation_errors << "Field #{field} must be of type #{options[:type]}"
|
49
|
+
elsif value.respond_to?(:valid?) && !value.valid?
|
50
|
+
@validation_errors += value.validation_errors.map{|ve| "#{field} -> #{ve}"}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
32
54
|
end
|
data/lib/axiomus_api/version.rb
CHANGED
data/spec/factories.rb
CHANGED
@@ -13,6 +13,23 @@ FactoryGirl.define do
|
|
13
13
|
['yes', 'no'][rand(0..1)]
|
14
14
|
end
|
15
15
|
|
16
|
+
factory :below, class: AxiomusApi::Below do
|
17
|
+
below_sum { rand(0.0..300.0)}
|
18
|
+
price { rand(100.0..500.0)}
|
19
|
+
end
|
20
|
+
|
21
|
+
factory :delivset, class: AxiomusApi::Delivset do
|
22
|
+
return_price {rand(100.0..300.0)}
|
23
|
+
above_sum {rand(100.0..1000.0)}
|
24
|
+
above_price {rand(100.0..1000.0)}
|
25
|
+
|
26
|
+
after(:build) do |ds|
|
27
|
+
rand(1..3).times do
|
28
|
+
ds.below << build(:below)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
16
33
|
factory :item, class: AxiomusApi::Item do
|
17
34
|
name {"Product "'\"Awesome\"'" #{rand(1..1000)}"}
|
18
35
|
weight {rand(0.1..10.0)}
|
@@ -24,6 +41,18 @@ FactoryGirl.define do
|
|
24
41
|
oid {rand(10000..99999)}
|
25
42
|
end
|
26
43
|
|
44
|
+
factory :items, class: AxiomusApi::Items do
|
45
|
+
after(:build) do |items|
|
46
|
+
items.item << build(:item)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
factory :export_items, class: AxiomusApi::ExportItems do
|
51
|
+
after(:build) do |items|
|
52
|
+
items.item << build(:export_item)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
27
56
|
factory :services, class: AxiomusApi::Services do
|
28
57
|
cash {generate :boolean}
|
29
58
|
cheque {generate :boolean}
|
@@ -63,11 +92,7 @@ FactoryGirl.define do
|
|
63
92
|
places {rand(1..2)}
|
64
93
|
services {build(:services)}
|
65
94
|
|
66
|
-
|
67
|
-
rand(1..10).times do
|
68
|
-
order.items << build(:item)
|
69
|
-
end
|
70
|
-
end
|
95
|
+
items {build(:items)}
|
71
96
|
end
|
72
97
|
|
73
98
|
factory :post_address, class: AxiomusApi::PostAddress do
|
@@ -115,6 +140,7 @@ FactoryGirl.define do
|
|
115
140
|
city 0
|
116
141
|
garden_ring {generate :boolean}
|
117
142
|
from_mkad {rand(1..2) == 2 && garden_ring !='yes' && city > 0 ? rand(1..40) : nil}
|
143
|
+
delivset nil
|
118
144
|
|
119
145
|
trait :incl_deliv_sum do
|
120
146
|
incl_deliv_sum rand(100.0..200.00)
|
@@ -123,6 +149,10 @@ FactoryGirl.define do
|
|
123
149
|
trait :with_empty_address do
|
124
150
|
address ''
|
125
151
|
end
|
152
|
+
|
153
|
+
trait :with_delivset do
|
154
|
+
delivset {build(:delivset)}
|
155
|
+
end
|
126
156
|
end
|
127
157
|
|
128
158
|
factory :carry_order, class: AxiomusApi::CarryOrder, parent: :base_order do
|
@@ -130,6 +160,11 @@ FactoryGirl.define do
|
|
130
160
|
office {[0, 1, nil][rand(0..2)]}
|
131
161
|
b_date {Time.now + rand(5..10)*24*60*60}
|
132
162
|
e_date {b_date + 7*24*60*60}
|
163
|
+
delivset nil
|
164
|
+
|
165
|
+
trait :with_delivset do
|
166
|
+
delivset {build(:delivset)}
|
167
|
+
end
|
133
168
|
end
|
134
169
|
|
135
170
|
factory :export_order, class: AxiomusApi::ExportOrder, parent: :base_order do
|
@@ -142,13 +177,7 @@ FactoryGirl.define do
|
|
142
177
|
address 'Москва, Живописная, д4 корп1, кв 16'
|
143
178
|
garden_ring {generate :boolean}
|
144
179
|
from_mkad {garden_ring == 'yes' ? nil : rand(1..40)}
|
145
|
-
|
146
|
-
after(:build) do |order|
|
147
|
-
order.items = []
|
148
|
-
rand(1..10).times do
|
149
|
-
order.items << build(:export_item)
|
150
|
-
end
|
151
|
-
end
|
180
|
+
items {build(:export_items)}
|
152
181
|
end
|
153
182
|
|
154
183
|
factory :self_export_order, class: AxiomusApi::SelfExportOrder, parent: :base_order do
|
@@ -157,13 +186,7 @@ FactoryGirl.define do
|
|
157
186
|
b_time {rand(10..19)}
|
158
187
|
e_time {b_time + 3}
|
159
188
|
quantity {rand(1..3)}
|
160
|
-
|
161
|
-
after(:build) do |order|
|
162
|
-
order.items = []
|
163
|
-
rand(1..10).times do
|
164
|
-
order.items << build(:export_item)
|
165
|
-
end
|
166
|
-
end
|
189
|
+
items {build(:export_items)}
|
167
190
|
end
|
168
191
|
|
169
192
|
factory :post_order, class: AxiomusApi::PostOrder, parent: :base_order do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../spec_helper'
|
2
2
|
|
3
3
|
describe 'AxiomusApi::Sesion' do
|
4
4
|
before(:all) do
|
@@ -24,6 +24,17 @@ describe 'AxiomusApi::Sesion' do
|
|
24
24
|
expect(z.code).to eq 0
|
25
25
|
z = @session.status(okey)
|
26
26
|
end
|
27
|
+
|
28
|
+
it 'should support #delivset field' do
|
29
|
+
order = build(:order, :with_delivset)
|
30
|
+
z = @session.new(order)
|
31
|
+
expect(z.code).to eq 0
|
32
|
+
okey = z.okey
|
33
|
+
order.okey = okey
|
34
|
+
z = @session.update(order)
|
35
|
+
expect(z.code).to eq 0
|
36
|
+
z = @session.status(okey)
|
37
|
+
end
|
27
38
|
end
|
28
39
|
|
29
40
|
describe '#new_carry, #update_carry' do
|
@@ -37,6 +48,17 @@ describe 'AxiomusApi::Sesion' do
|
|
37
48
|
expect(z.code).to eq 0
|
38
49
|
z = @session.status(okey)
|
39
50
|
end
|
51
|
+
|
52
|
+
it 'should support #delivset field' do
|
53
|
+
carry_order = build(:carry_order, :with_delivset)
|
54
|
+
z = @session.new_carry(carry_order)
|
55
|
+
expect(z.code).to eq 0
|
56
|
+
okey = z.okey
|
57
|
+
carry_order.okey = okey
|
58
|
+
z = @session.update_carry(carry_order)
|
59
|
+
expect(z.code).to eq 0
|
60
|
+
z = @session.status(okey)
|
61
|
+
end
|
40
62
|
end
|
41
63
|
|
42
64
|
describe '#new_export, #update_export' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../spec_helper'
|
2
2
|
|
3
3
|
describe 'AxiomusApi::BaseOrder' do
|
4
4
|
|
@@ -11,9 +11,11 @@ describe 'AxiomusApi::BaseOrder' do
|
|
11
11
|
it 'should create item' do
|
12
12
|
ORDER_MODES.each do |mode|
|
13
13
|
order = AxiomusApi::BaseOrder.create_by_mode(mode)
|
14
|
-
item = order.
|
14
|
+
item = order.items.add_item
|
15
|
+
item.quantity = 21
|
16
|
+
expect(order.items.item.first.quantity).to eq(21)
|
15
17
|
|
16
|
-
if [:new_export, :update_export].include?(mode)
|
18
|
+
if [:new_export, :update_export, :new_self_export, :update_self_export].include?(mode)
|
17
19
|
expect(item.is_a?(AxiomusApi::ExportItem)).to be_true
|
18
20
|
else
|
19
21
|
expect(item.is_a?(AxiomusApi::Item)).to be_true
|
@@ -33,4 +33,40 @@ describe 'AxiomusApi::Validated' do
|
|
33
33
|
expect(order.validation_errors).to have(0).items
|
34
34
|
end
|
35
35
|
|
36
|
+
it 'should validate array items' do
|
37
|
+
order = build(:order)
|
38
|
+
order.delivset = AxiomusApi::Delivset.new
|
39
|
+
order.delivset.below = 'Some arbitrary string'
|
40
|
+
order.delivset.return_price = 12
|
41
|
+
order.delivset.above_sum = 12
|
42
|
+
order.delivset.above_price = 12
|
43
|
+
expect(order).not_to be_valid
|
44
|
+
expect(order.validation_errors).to have(1).items
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should validate max occurs' do
|
48
|
+
order = build(:order)
|
49
|
+
order.delivset = AxiomusApi::Delivset.new
|
50
|
+
order.delivset.return_price = 12
|
51
|
+
order.delivset.above_sum = 12
|
52
|
+
order.delivset.above_price = 12
|
53
|
+
|
54
|
+
4.times do
|
55
|
+
order.delivset.below << build(:below)
|
56
|
+
end
|
57
|
+
|
58
|
+
expect(order).not_to be_valid
|
59
|
+
expect(order.validation_errors).to have(1).items
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should validate optional arrays' do
|
63
|
+
order = build(:order)
|
64
|
+
order.delivset = AxiomusApi::Delivset.new
|
65
|
+
order.delivset.return_price = 12
|
66
|
+
order.delivset.above_sum = 12
|
67
|
+
order.delivset.above_price = 12
|
68
|
+
order.delivset.below = []
|
69
|
+
expect(order).to be_valid
|
70
|
+
end
|
71
|
+
|
36
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axiomus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinderly LTD
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -49,9 +49,13 @@ files:
|
|
49
49
|
- lib/axiomus_api/address/region_pickup_address.rb
|
50
50
|
- lib/axiomus_api/base.rb
|
51
51
|
- lib/axiomus_api/base_auth.rb
|
52
|
+
- lib/axiomus_api/below.rb
|
53
|
+
- lib/axiomus_api/delivset.rb
|
52
54
|
- lib/axiomus_api/errors.rb
|
53
55
|
- lib/axiomus_api/item/export_item.rb
|
54
56
|
- lib/axiomus_api/item/item.rb
|
57
|
+
- lib/axiomus_api/items/export_items.rb
|
58
|
+
- lib/axiomus_api/items/items.rb
|
55
59
|
- lib/axiomus_api/order/base_order.rb
|
56
60
|
- lib/axiomus_api/order/carry_order.rb
|
57
61
|
- lib/axiomus_api/order/dpd_order.rb
|
@@ -79,9 +83,10 @@ files:
|
|
79
83
|
- lib/axiomus_api/validated.rb
|
80
84
|
- lib/axiomus_api/version.rb
|
81
85
|
- spec/factories.rb
|
82
|
-
- spec/integration/axiomus_api/session_spec.rb
|
83
|
-
- spec/lib/axiomus_api/base_order_spec.rb
|
86
|
+
- spec/integration/lib/axiomus_api/session_spec.rb
|
84
87
|
- spec/lib/axiomus_api/base_spec.rb
|
88
|
+
- spec/lib/axiomus_api/delivest_spec.rb
|
89
|
+
- spec/lib/axiomus_api/order/base_order_spec.rb
|
85
90
|
- spec/lib/axiomus_api/serializable_spec.rb
|
86
91
|
- spec/lib/axiomus_api/session_spec.rb
|
87
92
|
- spec/lib/axiomus_api/validated_spec.rb
|