janio_api 0.1.9 → 0.1.10
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/configuration.rb +19 -0
- data/lib/janio_api/resources/base.rb +0 -1
- data/lib/janio_api/resources/order.rb +0 -7
- data/lib/janio_api/version.rb +1 -1
- data/lib/janio_api.rb +8 -28
- data/lib/zeitwerk_loader.rb +3 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f10b33efcc9231d65c281637e911d76e74d9d29a29992703b07b282a3c385d9e
|
4
|
+
data.tar.gz: 1c63294439ba647ba20cd8467ecfb164c4a3ebb16cc747bfed63cd3563325fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc0c8816a305eab6f8a2b6e23a5db4e5f38d9d134efa2ee3bb222735c019bea67cfdc650a0d75adba9c39b498aae54b3b2795d67f4d5dd2c3ab42a818471c003
|
7
|
+
data.tar.gz: bac6bb9dd74c8a5e32bb542f86ae5f8b6c389e16c604322313dbc42c11217eec4957a6cddc5e2a5c37504e8f92914c846fdfa13c020818995a0af7582d64ead9
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module JanioAPI
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_host, :api_token
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.config
|
7
|
+
@config ||= Configuration.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.config=(config)
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield config
|
16
|
+
# set the site once user configure
|
17
|
+
JanioAPI::Base.site = JanioAPI.config.api_host
|
18
|
+
end
|
19
|
+
end
|
@@ -37,8 +37,6 @@ module JanioAPI
|
|
37
37
|
validates :payment_type, inclusion: {in: VALID_PAYMENT_TYPES, message: "%{value} is not a valid payment type, valid payment types are #{VALID_PAYMENT_TYPES.join(", ")}"}
|
38
38
|
validates :cod_amount_to_collect, presence: true, if: -> { payment_type == "cod" }
|
39
39
|
validates :items, length: {minimum: 1, message: "are required. Please add at least one."}
|
40
|
-
|
41
|
-
validate :check_credentials
|
42
40
|
validate :items_validation
|
43
41
|
|
44
42
|
class << self
|
@@ -144,11 +142,6 @@ module JanioAPI
|
|
144
142
|
|
145
143
|
private
|
146
144
|
|
147
|
-
def check_credentials
|
148
|
-
errors.add(:base, "Please set the api_token in the initializer file") if JanioAPI.config&.api_token&.blank?
|
149
|
-
errors.add(:base, "Please set the api_host in the initializer file") if JanioAPI.config&.api_host&.blank?
|
150
|
-
end
|
151
|
-
|
152
145
|
def items_validation
|
153
146
|
items&.each_with_index do |item, index|
|
154
147
|
item.errors.full_messages.each { |msg| errors.add("item_#{index}".to_sym, msg) } unless item.valid?
|
data/lib/janio_api/version.rb
CHANGED
data/lib/janio_api.rb
CHANGED
@@ -1,36 +1,16 @@
|
|
1
1
|
require "janio_api/version"
|
2
2
|
require "active_resource"
|
3
3
|
require "dotenv/load"
|
4
|
-
|
5
|
-
require "zeitwerk"
|
6
|
-
|
7
|
-
loader = Zeitwerk::Loader.for_gem
|
8
|
-
loader.inflector.inflect(
|
9
|
-
"janio_api" => "JanioAPI"
|
10
|
-
)
|
11
|
-
loader.collapse("./lib/janio_api/resources")
|
12
|
-
loader.enable_reloading
|
13
|
-
loader.tag = "janio_api_gem"
|
14
|
-
# loader.log!
|
15
|
-
loader.setup
|
16
|
-
$__janio_api_loader__ = loader
|
17
|
-
if ENV["JANIO_API_GEM_ENV"] == "development"
|
18
|
-
def reload!
|
19
|
-
$__janio_api_loader__.reload
|
20
|
-
end
|
21
|
-
end
|
4
|
+
require_relative "zeitwerk_loader" if ENV["JANIO_API_GEM_ENV"] == "development"
|
22
5
|
|
23
6
|
module JanioAPI
|
24
|
-
|
25
|
-
|
7
|
+
require "janio_api/configuration"
|
8
|
+
|
9
|
+
require "janio_api/redirect_fetcher"
|
26
10
|
|
27
|
-
|
28
|
-
self.config ||= Configuration.new
|
29
|
-
yield(config)
|
30
|
-
end
|
11
|
+
require "janio_api/connection"
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
13
|
+
require "janio_api/resources/base"
|
14
|
+
require "janio_api/resources/item"
|
15
|
+
require "janio_api/resources/order"
|
36
16
|
end
|
data/lib/zeitwerk_loader.rb
CHANGED
@@ -9,10 +9,7 @@ loader.enable_reloading
|
|
9
9
|
loader.tag = "janio_api_gem"
|
10
10
|
# loader.log!
|
11
11
|
loader.setup
|
12
|
-
|
13
|
-
|
14
|
-
$__janio_api_loader__
|
15
|
-
def reload!
|
16
|
-
$__janio_api_loader__.reload
|
17
|
-
end
|
12
|
+
$__janio_api_loader__ = loader
|
13
|
+
def reload!
|
14
|
+
$__janio_api_loader__.reload
|
18
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: janio_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Chong
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- bin/setup
|
115
115
|
- janio_api.gemspec
|
116
116
|
- lib/janio_api.rb
|
117
|
+
- lib/janio_api/configuration.rb
|
117
118
|
- lib/janio_api/connection.rb
|
118
119
|
- lib/janio_api/redirect_fetcher.rb
|
119
120
|
- lib/janio_api/resources/base.rb
|