Skip to content

Commit

Permalink
Changes according to API v.2.14. New attributes in DPD services and p…
Browse files Browse the repository at this point in the history
…ost services.
  • Loading branch information
Nu-hin committed May 19, 2014
1 parent 3d4f836 commit 7ae8523
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 59 deletions.
32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
PATH
remote: .
specs:
axiomus_api (0.4)
axiomus_api (0.5)
barby (~> 0.5)
chunky_png (~> 1.3)
nokogiri (~> 1.6)

GEM
remote: https://rubygems.org/
specs:
activesupport (4.0.4)
activesupport (4.1.1)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
atomic (1.1.16)
tzinfo (~> 1.1)
barby (0.5.1)
chunky_png (1.3.0)
chunky_png (1.3.1)
coveralls (0.7.0)
multi_json (~> 1.3)
rest-client
Expand All @@ -31,12 +30,13 @@ GEM
faker (1.3.0)
i18n (~> 0.5)
i18n (0.6.9)
json (1.8.1)
mime-types (2.2)
mini_portile (0.5.3)
minitest (4.7.5)
multi_json (1.9.2)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
mini_portile (0.6.0)
minitest (5.3.4)
multi_json (1.10.0)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.14.1)
Expand All @@ -55,10 +55,10 @@ GEM
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tins (1.0.1)
tzinfo (0.3.39)
thread_safe (0.3.3)
tins (1.3.0)
tzinfo (1.1.0)
thread_safe (~> 0.1)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This is a Ruby wrapper over [Axiomus](http://www.axiomus.ru "axiomus.ru") delivery service public [API](http://www.axiomus.ru/customers/api/ "Axiomus API").

All methods exposed by the API v. 2.13 are implemented.
All methods exposed by the API v. 2.14 are implemented.

## Installation

Expand Down
6 changes: 3 additions & 3 deletions lib/axiomus_api/order/dpd_order.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require_relative('base_order')
require_relative('../address/dpd_address')
require_relative('../services/post_services')
require_relative('../services/dpd_services')

class AxiomusApi::DpdOrder < AxiomusApi::BaseOrder

xml_attribute :d_date, :b_time, :e_time, :post_type
xml_field :services, type: AxiomusApi::PostServices
xml_attribute :b_date, :b_time, :e_time, :post_type
xml_field :services, type: AxiomusApi::DpdServices
xml_field :address, type: AxiomusApi::DpdAddress

end
4 changes: 2 additions & 2 deletions lib/axiomus_api/order/ems_order.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require_relative 'base_order'
require_relative '../address/ems_address'
require_relative '../services/post_services'
require_relative '../services/ems_services'

class AxiomusApi::EmsOrder < AxiomusApi::BaseOrder

xml_attribute :b_date
xml_attribute :incl_deliv_sum, optional: true
xml_field :address, type: AxiomusApi::EmsAddress
xml_field :services, type: AxiomusApi::PostServices
xml_field :services, type: AxiomusApi::EmsServices

end
7 changes: 7 additions & 0 deletions lib/axiomus_api/services/dpd_services.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require_relative '../base'

class AxiomusApi::DpdServices < AxiomusApi::Base

xml_attribute :valuation, :fragile, :cod, :big, :waiting, optional: true

end
7 changes: 7 additions & 0 deletions lib/axiomus_api/services/ems_services.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require_relative '../base'

class AxiomusApi::EmsServices < AxiomusApi::Base

xml_attribute :valuation, :fragile, :cod, :big, optional: true

end
2 changes: 1 addition & 1 deletion lib/axiomus_api/services/post_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class AxiomusApi::PostServices < AxiomusApi::Base

xml_attribute :valuation, :fragile, :cod, :big, optional: true
xml_attribute :valuation, :fragile, :cod, :big, :class1, :post_tarif, :not_avia, :optimize, optional: true

end
2 changes: 1 addition & 1 deletion lib/axiomus_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AxiomusApi
VERSION = '0.4'
VERSION = '0.5'
end
29 changes: 24 additions & 5 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@
fragile {generate :boolean}
cod {generate :boolean}
big {generate :boolean}
class1 {generate :boolean}
post_tarif {generate :boolean}
not_avia {generate :boolean}
optimize {generate :boolean}
end

factory :dpd_services, class: AxiomusApi::DpdServices do
valuation {generate :boolean}
fragile {generate :boolean}
cod {generate :boolean}
big {generate :boolean}
waiting {generate :boolean}
end

factory :ems_services, class: AxiomusApi::EmsServices do
valuation {generate :boolean}
fragile {generate :boolean}
cod {generate :boolean}
big {generate :boolean}
end

factory :region_services, class: AxiomusApi::RegionServices do
Expand Down Expand Up @@ -185,15 +204,15 @@

factory :self_export_order, class: AxiomusApi::SelfExportOrder, parent: :base_order do
car 'с065мк61'
d_date {Time.now + rand(1..10)*24*60*60}
d_date {(Time.now + rand(1..10)*24*60*60).strftime('%Y-%m-%d')}
b_time {rand(10..19)}
e_time {b_time + 3}
quantity {rand(1..3)}
items {build(:export_items)}
end

factory :post_order, class: AxiomusApi::PostOrder, parent: :base_order do
b_date {Time.now + rand(1..10)*24*60*60}
b_date {(Time.now + rand(1..10)*24*60*60).strftime('%Y-%m-%d')}
post_type {rand(1..2)}
address {build(:post_address)}
services {build(:post_services)}
Expand All @@ -207,7 +226,7 @@
factory :ems_order, class: AxiomusApi::EmsOrder, parent: :base_order do
b_date {Time.now + rand(1..10)*24*60*60}
address {build(:ems_address)}
services {build(:post_services)}
services {build(:ems_services)}
contacts {generate(:sms)}
end

Expand All @@ -228,9 +247,9 @@

factory :dpd_order, class: AxiomusApi::DpdOrder, parent: :base_order do
post_type {rand(1..2)}
services {build(:post_services)}
services {build(:dpd_services)}
address {build(:dpd_address)}
d_date {(Time.now + rand(5..15)*24*60*60).strftime('%Y-%m-%d')}
b_date {(Time.now + rand(5..15)*24*60*60).strftime('%Y-%m-%d')}
b_time {rand(10..17)}
e_time {b_time + 1}

Expand Down
58 changes: 30 additions & 28 deletions spec/integration/lib/axiomus_api/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@
end
end

# describe '#status_list' do
# it 'should handle multiple okeys' do
# order = build(:order)
# z1 = @session.new(order)
# order = build(:order)
# z2 = @session.new(order)
# r = @session.status_list([z1.okey, z2.okey])
# puts r
# end
# end
describe '#status_list' do
it 'should handle multiple okeys' do
expect do
order = build(:order)
z1 = @session.new(order)
order = build(:order)
z2 = @session.new(order)
r = @session.status_list([z1.okey, z2.okey])
end.not_to raise_error
end
end

# describe '#get_version' do
# it 'should return version' do
# version = @session.get_version
# puts version
# end
# end
describe '#get_version' do
it 'should return version' do
expect do
version = @session.get_version
end.not_to raise_error
end
end

describe '#new, #update' do
it 'should create new order and update it' do
Expand Down Expand Up @@ -131,18 +133,18 @@
end
end

describe '#new_ems, #update_ems' do
it 'should create new order and update it' do
ems_order = build(:ems_order)
z = @session.new_ems(ems_order)
expect(z.code).to eq 0
okey = z.okey
ems_order.okey = okey
z = @session.update_ems(ems_order)
expect(z.code).to eq 0
z = @session.status(okey)
end
end
# describe '#new_ems, #update_ems' do
# it 'should create new order and update it' do
# ems_order = build(:ems_order)
# z = @session.new_ems(ems_order)
# expect(z.code).to eq 0
# okey = z.okey
# ems_order.okey = okey
# z = @session.update_ems(ems_order)
# expect(z.code).to eq 0
# z = @session.status(okey)
# end
# end

describe '#new_region_courier, #update_region_courier' do
it 'should create new order and update it' do
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/axiomus_api/order/base_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

{
AxiomusApi::Order => AxiomusApi::Services,
AxiomusApi::EmsOrder => AxiomusApi::PostServices,
AxiomusApi::EmsOrder => AxiomusApi::EmsServices,
AxiomusApi::ExportOrder => AxiomusApi::ExportServices,
AxiomusApi::CarryOrder => AxiomusApi::Services,
AxiomusApi::PostOrder => AxiomusApi::PostServices,
AxiomusApi::RegionCourierOrder => AxiomusApi::RegionServices,
AxiomusApi::RegionPickupOrder => AxiomusApi::RegionServices,
AxiomusApi::DpdOrder => AxiomusApi::PostServices
AxiomusApi::DpdOrder => AxiomusApi::DpdServices
}.each do |c, a|
describe c.name do
it 'should have correct services type' do
Expand Down

0 comments on commit 7ae8523

Please sign in to comment.