axiomus_api 0.3 → 0.4
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 +3 -3
- data/README.md +30 -1
- data/lib/axiomus_api/label.rb +8 -0
- data/lib/axiomus_api/services/region_services.rb +1 -1
- data/lib/axiomus_api/templates/labels.html.erb +1 -1
- data/lib/axiomus_api/version.rb +1 -1
- data/spec/factories.rb +4 -3
- 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: 3e07c90ada20d4d8317aca5cba92d3d3d79781f5
|
4
|
+
data.tar.gz: 1e830f91d74db9fff95e2747e7e5eb04c502aa93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b22f978c6fe2551224c279ea07b6e36682d94656dee9744e92ff5194d5d918178956fdb58b3a2f1f02ea860a20c7e3d25acc42d51e3e59a7a53d626aecfaa62
|
7
|
+
data.tar.gz: 6ff41ce49692794bbc51078b2b6552172f36628b5316b1791819fae953cbb63109c76d861155127796133e45815110ca1656cfed2f0e835e805e4f4f55ee0378
|
data/Gemfile.lock
CHANGED
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
|
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.
|
data/lib/axiomus_api/label.rb
CHANGED
@@ -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
|
@@ -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.
|
70
|
+
<span class="time"><%= label.delivery_time %></span>
|
71
71
|
</div>
|
72
72
|
<div class="d10">
|
73
73
|
<img src='<%= label.barcode_base64 %>'/>
|
data/lib/axiomus_api/version.rb
CHANGED
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 {['Мск', '
|
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.
|
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
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|