versacommerce_api 1.0.7 → 1.0.8
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 +8 -8
- data/CHANGELOG +1 -0
- data/lib/versacommerce_api/resources/carrier.rb +19 -0
- data/lib/versacommerce_api/resources/product.rb +23 -9
- data/lib/versacommerce_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzE3Y2JjOWVkYjc3NjA0MTAzZjg1OTRmNWI0MjEyNDc4MzFkYjkxMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjczNWFjY2U0OWMzMjAxNTkxZGNhYzk1ZTQ4NmJjNDZmZGU2MzMzZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWNjMWUxMmRjY2E0MzUwNDA3ZjBlZTc4MTM2ZTM4YmU5MDFkNzJjYzllYzhl
|
10
|
+
ZmU2ZWE4NWUxZjI5YTZiOGVjYjE5YzRlNzViMDY2MmY2NjliZDI0YzU3ODM2
|
11
|
+
MjA5ZTczZDM5M2E1YTQ3MWJmNjk2MmI5YTk2NjRlZjAwZTAzZTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzViMzg5ZDM3MTBjNWRmMjEzNmY0ZTc3NmRkMzM2ZmU2ZTYxYWE5MDcyNTRk
|
14
|
+
NzZlYWNjZmMzNzJkY2EyMzcwNmQyYjUxNjk1M2Q1NDA2NTI5YjgxY2JhYzNl
|
15
|
+
M2VjNWJlZDZhZTEwNTUxNTg0YzgwOWVlYmUyN2Q0Zjk1ZjhmMDY=
|
data/CHANGELOG
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module VersacommerceAPI
|
3
|
+
|
4
|
+
class Carrier < Base
|
5
|
+
def topup_fee_for_country(country)
|
6
|
+
#delivery_countries[country] rescue 0.00
|
7
|
+
delivery_countries[country]
|
8
|
+
end
|
9
|
+
|
10
|
+
def price_for_country(country)
|
11
|
+
[price, topup_fee_for_country(country)].compact.sum
|
12
|
+
end
|
13
|
+
|
14
|
+
def delivery_countries
|
15
|
+
attributes[:delivery_countries].attributes
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -3,7 +3,17 @@ module VersacommerceAPI
|
|
3
3
|
|
4
4
|
class Product < Base
|
5
5
|
include Associatable
|
6
|
-
|
6
|
+
|
7
|
+
def initialize(attributes, persisted = false)
|
8
|
+
super
|
9
|
+
|
10
|
+
if respond_to?(:shipping_types) && self.shipping_types.present?
|
11
|
+
self.shipping_types.map! do |shipping_type|
|
12
|
+
Carrier.new(shipping_type.attributes)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
# compute the price range
|
8
18
|
def price_range
|
9
19
|
prices = variants.collect(&:price)
|
@@ -14,7 +24,7 @@ module VersacommerceAPI
|
|
14
24
|
format % prices.min
|
15
25
|
end
|
16
26
|
end
|
17
|
-
|
27
|
+
|
18
28
|
def available
|
19
29
|
amount_available(0) && active
|
20
30
|
end
|
@@ -26,31 +36,35 @@ module VersacommerceAPI
|
|
26
36
|
true
|
27
37
|
end
|
28
38
|
end
|
29
|
-
|
39
|
+
|
30
40
|
def is_variant
|
31
41
|
!product_id.nil?
|
32
42
|
end
|
33
|
-
|
43
|
+
|
34
44
|
def properties
|
35
45
|
associated_resource "property"
|
36
46
|
end
|
37
|
-
|
47
|
+
|
38
48
|
def product_images
|
39
49
|
associated_resource "product_image"
|
40
50
|
end
|
41
|
-
|
51
|
+
|
42
52
|
def variants
|
43
53
|
associated_resource "variant"
|
44
54
|
end
|
45
|
-
|
55
|
+
|
56
|
+
def carriers
|
57
|
+
associated_resource "carrier"
|
58
|
+
end
|
59
|
+
|
46
60
|
def tags
|
47
61
|
return [] if self.respond_to?("tag_list") && self.send("tag_list").blank?
|
48
62
|
tag_list.split(",").map(&:strip)
|
49
63
|
end
|
50
|
-
|
64
|
+
|
51
65
|
def featured_image
|
52
66
|
ProductImage.new(:src => featured_image_url)
|
53
67
|
end
|
54
68
|
end
|
55
|
-
|
69
|
+
|
56
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versacommerce_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VersaCommerce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/versacommerce_api/resources/account.rb
|
171
171
|
- lib/versacommerce_api/resources/base.rb
|
172
172
|
- lib/versacommerce_api/resources/billing_addres.rb
|
173
|
+
- lib/versacommerce_api/resources/carrier.rb
|
173
174
|
- lib/versacommerce_api/resources/collection.rb
|
174
175
|
- lib/versacommerce_api/resources/customer.rb
|
175
176
|
- lib/versacommerce_api/resources/item.rb
|