axiomus_api 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a842cb4e7a1790dad6bed6ea6a48f59758f28a1e
4
- data.tar.gz: 7ed4a445f550a6832a95c893aadcf06e5a664849
3
+ metadata.gz: 3e07c90ada20d4d8317aca5cba92d3d3d79781f5
4
+ data.tar.gz: 1e830f91d74db9fff95e2747e7e5eb04c502aa93
5
5
  SHA512:
6
- metadata.gz: 0d370daaf919fc5144e01d4951ec32b39c2768758292a94672388793936a9602bfc59b7226c95f7daa6e9107df9ba196871926c861a368cba38b012c5f43f4c9
7
- data.tar.gz: a82560e1fa501abe855e505119ee5770230cd258c718decb68fb519ce9b2acccd05e8bf3191849c6cb26eeab4d9fabdceb31333b6fc960cdacc528505de8f17b
6
+ metadata.gz: 0b22f978c6fe2551224c279ea07b6e36682d94656dee9744e92ff5194d5d918178956fdb58b3a2f1f02ea860a20c7e3d25acc42d51e3e59a7a53d626aecfaa62
7
+ data.tar.gz: 6ff41ce49692794bbc51078b2b6552172f36628b5316b1791819fae953cbb63109c76d861155127796133e45815110ca1656cfed2f0e835e805e4f4f55ee0378
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- axiomus_api (0.3)
5
- barby (~> 0.5.0)
6
- chunky_png (~> 1.3.0)
4
+ axiomus_api (0.4)
5
+ barby (~> 0.5)
6
+ chunky_png (~> 1.3)
7
7
  nokogiri (~> 1.6)
8
8
 
9
9
  GEM
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  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").
12
12
 
13
- All methods exposed by the API by 2014-04-04 are implemented.
13
+ All methods exposed by the API v. 2.13 are implemented.
14
14
 
15
15
  ## Installation
16
16
 
@@ -112,6 +112,35 @@ Most orders use `AxiomusApi::Item` as their item type, but some don't. To safely
112
112
  @status = @session.status(@okey)
113
113
  ```
114
114
 
115
+ ### Rendering labels locally
116
+ You can render Axiomus labels in your own layout. The labels are rendered in HTML format.
117
+ ```ruby
118
+ label = AxiomusApi::Label.new
119
+ label.dispatch_number = '213123123123'
120
+ label.order_id = '12345'
121
+ label.client_name = 'John Doe'
122
+ label.weight = 0.3
123
+ label.date =
124
+ label.b_time = 10
125
+ label.e_time = 14
126
+ label.place = 1
127
+ label.places = 3
128
+ label.address = '344000 Ростов-на-Дону, ул. Б. Садовая 23'
129
+ label.type = 'P'
130
+ label.city = 'ПР'
131
+ html = AxiomusApi::Label.render(label)
132
+ ```
133
+
134
+ You can also render several labels on one page:
135
+ ```ruby
136
+ html = AxiomusApi::Label.render([label1, label2, label3])
137
+ ```
138
+
139
+ There's a built-in ERB template for rendering labels, but you can also provide your own:
140
+ ```ruby
141
+ html = AxiomusApi::Label.render(label, my_erb_string)
142
+ ```
143
+
115
144
  ### Error handling
116
145
 
117
146
  Before sending a request, the library will validate your order object to check for missing fields or wrong type of parameters. If there are errors, it will raise an `AxiomusApi::Errors::ValidationError` exception. List of errors can be accessed via the order's `#validation_errors` method. Please note that passing validation doesn't necessarily mean the order will be accepted by Axiomus.
@@ -22,6 +22,14 @@ class AxiomusApi::Label
22
22
  dispatch_number.to_s.gsub(/(....)$/, '`\1')
23
23
  end
24
24
 
25
+ def delivery_time
26
+ if b_time.nil? || e_time.nil?
27
+ nil
28
+ else
29
+ "#{b_time}-#{e_time}"
30
+ end
31
+ end
32
+
25
33
  def barcode_raw(height = 70)
26
34
  barcode = Barby::Code39.new("#{dispatch_number}+#{place}")
27
35
  barcode.wide_width = 3
@@ -2,6 +2,6 @@ require_relative '../base'
2
2
 
3
3
  class AxiomusApi::RegionServices < AxiomusApi::Base
4
4
 
5
- xml_attribute :cheque, :not_open, :extrapack, :big, optional: true
5
+ xml_attribute :cheque, :not_open, :extrapack, :big, :part_return, optional: true
6
6
 
7
7
  end
@@ -67,7 +67,7 @@
67
67
  <div class="d2">
68
68
  <b><%= label.date.strftime('%d.%m.%y') %></b>
69
69
  <br/>
70
- <span class="time"><%= label.b_time %>-<%= label.e_time %></span>
70
+ <span class="time"><%= label.delivery_time %></span>
71
71
  </div>
72
72
  <div class="d10">
73
73
  <img src='<%= label.barcode_base64 %>'/>
@@ -1,3 +1,3 @@
1
1
  module AxiomusApi
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
3
3
  end
data/spec/factories.rb CHANGED
@@ -78,6 +78,7 @@ FactoryGirl.define do
78
78
  not_open {generate :boolean}
79
79
  extrapack {generate :boolean}
80
80
  big {generate :boolean}
81
+ part_return {generate :boolean}
81
82
  end
82
83
 
83
84
  factory :base_order, class: AxiomusApi::BaseOrder do
@@ -244,13 +245,13 @@ FactoryGirl.define do
244
245
  client_name {Faker::Company.name}
245
246
  weight {rand(0.1..10.0)}
246
247
  date {(Time.now + rand(1..10)*24*60*60)}
247
- b_time {rand(10..17)}
248
- e_time {b_time + 1}
248
+ b_time {rand(0..1) == 0 ? rand(10..17) : nil}
249
+ e_time {b_time.nil? ? nil : b_time + 1}
249
250
  places {rand(1..3)}
250
251
  place {rand(1..places)}
251
252
  address {"#{Faker::Address.postcode} #{Faker::Address.city}, #{Faker::Address.street_address}"}
252
253
  type {['Д', 'C', 'Р'][rand(0..2)]}
253
- city {['Мск', 'Спб'][rand(0..1)]}
254
+ city {['Мск', 'СПб'][rand(0..1)]}
254
255
  end
255
256
 
256
257
  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.3'
4
+ version: '0.4'
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-18 00:00:00.000000000 Z
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri