janio_api 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/janio_api/resources/order.rb +17 -2
- data/lib/janio_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d85f8a1ab6814c4c4b8eb6ec69b436330384f45b788ff833387fb11d44d174
|
4
|
+
data.tar.gz: e098b9a86980679c69d5a697b9e0978cdf20c129dc00b6cc7228a9d222144523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c25cb39853f1566b4abdc8570e6f534dbd77157eeae20479de9ce62d1b77022dd5759aedd0e4c6db644ba8ed4b30a504d787ab03ba19920fd83d77eff37b7ad8
|
7
|
+
data.tar.gz: 93a94c79dd8f34efb86fc9bffed84915455028161ca06deb1401131d40e6e95212b5291b88d6e18a0731e8ee2cac90f6e890bda7320ab55d22dec67d09ff56cd
|
data/Gemfile.lock
CHANGED
@@ -17,6 +17,7 @@ module JanioAPI
|
|
17
17
|
|
18
18
|
SUPPORTED_PICKUP_COUNTRIES = SERVICES.map { |s| s[:pickup_country] }.uniq.freeze
|
19
19
|
SUPPORTED_CONSIGNEE_COUNTRIES = SERVICES.map { |s| s[:consignee_country] }.uniq.freeze
|
20
|
+
PICKUP_DATE_ACCEPTED_COUNTRIES = ["Singapore"]
|
20
21
|
|
21
22
|
POSTAL_EXCLUDED_COUNTRIES = ["Hong Kong", "Vietnam", "Brunei"].freeze
|
22
23
|
VALID_PAYMENT_TYPES = ["cod", "prepaid"].freeze
|
@@ -59,7 +60,10 @@ module JanioAPI
|
|
59
60
|
|
60
61
|
validates :service_id, :order_length, :order_width, :order_height, :order_weight,
|
61
62
|
:consignee_name, :consignee_country, :consignee_address, :consignee_state, :consignee_email,
|
62
|
-
:pickup_contact_name, :pickup_country, :pickup_address, :pickup_state,
|
63
|
+
:pickup_contact_name, :pickup_country, :pickup_address, :pickup_state, presence: true
|
64
|
+
|
65
|
+
validates :pickup_date, presence: true, if: -> { PICKUP_DATE_ACCEPTED_COUNTRIES.include?(pickup_country) }
|
66
|
+
validates :pickup_date, absence: true, if: -> { !PICKUP_DATE_ACCEPTED_COUNTRIES.include?(pickup_country) }
|
63
67
|
|
64
68
|
validates :pickup_country, inclusion: {
|
65
69
|
in: SUPPORTED_PICKUP_COUNTRIES,
|
@@ -129,11 +133,22 @@ module JanioAPI
|
|
129
133
|
end
|
130
134
|
|
131
135
|
def initialize(attributes = {}, persisted = false)
|
136
|
+
if attributes[:pickup_date].is_a?(ActiveSupport::TimeWithZone)
|
137
|
+
attributes[:pickup_date] = attributes[:pickup_date].strftime("%Y-%-m-%-d")
|
138
|
+
end
|
132
139
|
attributes = DEFAULT_ATTRS.merge(attributes)
|
133
140
|
super
|
134
141
|
set_service_id
|
135
142
|
end
|
136
143
|
|
144
|
+
def pickup_date=(date)
|
145
|
+
@attributes[:pickup_date] = if date.is_a?(ActiveSupport::TimeWithZone)
|
146
|
+
date.strftime("%Y-%-m-%-d")
|
147
|
+
else
|
148
|
+
date
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
137
152
|
def get_service_id(service_category = "pickup")
|
138
153
|
# only check with services offering pickup by default
|
139
154
|
SERVICES.find do |s|
|
@@ -234,7 +249,7 @@ module JanioAPI
|
|
234
249
|
elsif JanioAPI.config.api_token
|
235
250
|
JanioAPI.config.api_token
|
236
251
|
else
|
237
|
-
|
252
|
+
raise ArgumentError, "JanioAPI api_token is missing, please set it in the config."
|
238
253
|
end
|
239
254
|
end
|
240
255
|
|
data/lib/janio_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: janio_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Chong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|