janio_api 0.1.9 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 266f4d725740685539116682121d4093e94cbb7ef5d2e57ef8ced2fd6f9bf1f4
4
- data.tar.gz: b5ddc90faec178dfefc3d19925b42a05b8b3f4a89317c497162954bd839a90b5
3
+ metadata.gz: f10b33efcc9231d65c281637e911d76e74d9d29a29992703b07b282a3c385d9e
4
+ data.tar.gz: 1c63294439ba647ba20cd8467ecfb164c4a3ebb16cc747bfed63cd3563325fad
5
5
  SHA512:
6
- metadata.gz: a92ba2ca0a2fe294ce5386cf04f54461ec69cf43ab9b8f7d7998bafbd128ae9ecee4bbdd91352186e16ec69a58ef565b2ca61505a75ec58e22ea86be7b386c38
7
- data.tar.gz: dfa6627c0774ebcf1b15726c01ecfe158481f0cc4298709e8d64d569bbd530d59050028bb5f20640cb0ecdb57e45b1d950b49e1c5bcb6ea38414bf331fa90b24
6
+ metadata.gz: dc0c8816a305eab6f8a2b6e23a5db4e5f38d9d134efa2ee3bb222735c019bea67cfdc650a0d75adba9c39b498aae54b3b2795d67f4d5dd2c3ab42a818471c003
7
+ data.tar.gz: bac6bb9dd74c8a5e32bb542f86ae5f8b6c389e16c604322313dbc42c11217eec4957a6cddc5e2a5c37504e8f92914c846fdfa13c020818995a0af7582d64ead9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- janio_api (0.1.9)
4
+ janio_api (0.1.10)
5
5
  activeresource
6
6
  zeitwerk
7
7
 
@@ -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
@@ -3,6 +3,5 @@ module JanioAPI
3
3
  self.include_root_in_json = false
4
4
  self.include_format_in_path = false
5
5
  self.connection_class = JanioAPI::Connection
6
- self.site = JanioAPI.config&.api_host
7
6
  end
8
7
  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?
@@ -1,3 +1,3 @@
1
1
  module JanioAPI
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
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
- # require_relative "zeitwerk_loader"
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
- class << self
25
- attr_accessor :config
7
+ require "janio_api/configuration"
8
+
9
+ require "janio_api/redirect_fetcher"
26
10
 
27
- def configure
28
- self.config ||= Configuration.new
29
- yield(config)
30
- end
11
+ require "janio_api/connection"
31
12
 
32
- class Configuration
33
- attr_accessor :api_host, :api_token
34
- end
35
- end
13
+ require "janio_api/resources/base"
14
+ require "janio_api/resources/item"
15
+ require "janio_api/resources/order"
36
16
  end
@@ -9,10 +9,7 @@ loader.enable_reloading
9
9
  loader.tag = "janio_api_gem"
10
10
  # loader.log!
11
11
  loader.setup
12
-
13
- if ENV["JANIO_API_GEM_ENV"] == "development"
14
- $__janio_api_loader__ = 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.9
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