iformat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/iformat/client/orders.rb +13 -3
- data/lib/iformat/client/products.rb +1 -1
- data/lib/iformat/client.rb +5 -0
- data/lib/iformat/order.rb +7 -3
- data/lib/iformat/order_item.rb +5 -1
- data/lib/iformat/version.rb +1 -1
- metadata +17 -17
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'iformat/order'
|
2
|
+
require 'iformat/order_item'
|
3
|
+
|
1
4
|
module IFormat
|
2
5
|
|
3
6
|
class Client
|
@@ -8,7 +11,7 @@ module IFormat
|
|
8
11
|
attrs = session_request(:create_order, {
|
9
12
|
'orderID' => id,
|
10
13
|
'items' => {
|
11
|
-
'iFSCreateOrderReq' => items
|
14
|
+
'iFSCreateOrderReq' => items
|
12
15
|
}
|
13
16
|
})
|
14
17
|
end
|
@@ -17,10 +20,17 @@ module IFormat
|
|
17
20
|
attrs = session_request(:get_order_info, {
|
18
21
|
'orderID' => id
|
19
22
|
})
|
23
|
+
|
24
|
+
attrs[:items] = Array.wrap(attrs.delete(:items)[:i_fs_item]).map do |item_attrs|
|
25
|
+
item_attrs[:urls] = Array.wrap(item_attrs.delete(:content)[:string])
|
26
|
+
IFormat::OrderItem.new(item_attrs)
|
27
|
+
end
|
28
|
+
|
29
|
+
IFormat::Order.new(attrs)
|
20
30
|
end
|
21
31
|
|
22
|
-
def repeat_order
|
23
|
-
|
32
|
+
def repeat_order(id)
|
33
|
+
get_order_info(id)
|
24
34
|
end
|
25
35
|
|
26
36
|
def get_orders_history(start = 0, limit = 5)
|
@@ -9,7 +9,7 @@ module IFormat
|
|
9
9
|
def get_products
|
10
10
|
products_attrs = session_request(:get_products)
|
11
11
|
|
12
|
-
products_attrs[:products_n][:i_fs_product].map do |attrs|
|
12
|
+
Array.wrap(products_attrs[:products_n][:i_fs_product]).map do |attrs|
|
13
13
|
IFormat::Category.new(attrs)
|
14
14
|
end
|
15
15
|
end
|
data/lib/iformat/client.rb
CHANGED
@@ -2,6 +2,11 @@ require 'savon'
|
|
2
2
|
require 'iformat/configuration'
|
3
3
|
require 'iformat/error'
|
4
4
|
require 'iformat/error/bad_session_id'
|
5
|
+
require 'iformat/error/client_error'
|
6
|
+
require 'iformat/error/server_error'
|
7
|
+
require 'iformat/error/authorization_error'
|
8
|
+
require 'iformat/error/order_not_found'
|
9
|
+
require 'iformat/error/order_waiting_for_links'
|
5
10
|
require 'iformat/session'
|
6
11
|
|
7
12
|
module IFormat
|
data/lib/iformat/order.rb
CHANGED
@@ -3,14 +3,18 @@ require 'iformat/base'
|
|
3
3
|
module IFormat
|
4
4
|
|
5
5
|
class Order < IFormat::Base
|
6
|
-
lazy_attr_reader :order_id, :items
|
6
|
+
lazy_attr_reader :order_id, :date, :price, :items
|
7
7
|
|
8
8
|
def id
|
9
9
|
@id ||= @attrs[:order_id]
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
@
|
12
|
+
def created_at
|
13
|
+
@created_at ||= @attrs[:date]
|
14
|
+
end
|
15
|
+
|
16
|
+
def net_amount
|
17
|
+
@net_amount ||= BigDecimal.new(@attrs[:price] || '0')
|
14
18
|
end
|
15
19
|
|
16
20
|
# @param other [IFormat::Order]
|
data/lib/iformat/order_item.rb
CHANGED
@@ -3,12 +3,16 @@ require 'iformat/base'
|
|
3
3
|
module IFormat
|
4
4
|
|
5
5
|
class OrderItem < IFormat::Base
|
6
|
-
lazy_attr_reader :product_id, :issue_id, :type_id
|
6
|
+
lazy_attr_reader :product_id, :issue_id, :type_id, :price, :id, :urls
|
7
7
|
|
8
8
|
def type
|
9
9
|
@type ||= @attrs[:type_id]
|
10
10
|
end
|
11
11
|
|
12
|
+
def net_amount
|
13
|
+
@net_amount ||= BigDecimal.new(@attrs[:price] || '0')
|
14
|
+
end
|
15
|
+
|
12
16
|
# @param other [IFormat::OrderItem]
|
13
17
|
# @return [Boolean]
|
14
18
|
def ==(other)
|
data/lib/iformat/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iformat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karol Sarnacki
|
@@ -15,11 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-19 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
22
|
+
name: savon
|
23
|
+
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
25
26
|
requirements:
|
@@ -30,11 +31,11 @@ dependencies:
|
|
30
31
|
- 0
|
31
32
|
- 9
|
32
33
|
version: "0.9"
|
33
|
-
|
34
|
-
name: savon
|
34
|
+
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
37
|
+
name: minitest
|
38
|
+
prerelease: false
|
38
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
@@ -46,11 +47,11 @@ dependencies:
|
|
46
47
|
- 0
|
47
48
|
- 0
|
48
49
|
version: 2.0.0
|
49
|
-
|
50
|
-
name: minitest
|
50
|
+
type: :development
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
53
|
+
name: rake
|
54
|
+
prerelease: false
|
54
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
@@ -60,11 +61,11 @@ dependencies:
|
|
60
61
|
segments:
|
61
62
|
- 0
|
62
63
|
version: "0"
|
63
|
-
|
64
|
-
name: rake
|
64
|
+
type: :development
|
65
65
|
version_requirements: *id003
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
-
|
67
|
+
name: turn
|
68
|
+
prerelease: false
|
68
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
70
|
none: false
|
70
71
|
requirements:
|
@@ -74,8 +75,7 @@ dependencies:
|
|
74
75
|
segments:
|
75
76
|
- 0
|
76
77
|
version: "0"
|
77
|
-
|
78
|
-
name: turn
|
78
|
+
type: :development
|
79
79
|
version_requirements: *id004
|
80
80
|
description: A Ruby wrapper for the iFormat API.
|
81
81
|
email:
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
requirements: []
|
160
160
|
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 1.4.2
|
163
163
|
signing_key:
|
164
164
|
specification_version: 3
|
165
165
|
summary: iFormat API wrapper
|