ninja_van_api 0.3.9 → 0.3.11

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: a8dddcd0bf81cfaa5abe0f621de95ba0a441afce7b76e25feacc26dcbbe5725c
4
- data.tar.gz: 7490e6b3e949c40d73172cc9895abae79acb6d5147de9f0aa6618c05324e457a
3
+ metadata.gz: 34724a8b8d348323fe598cb628435f25d08d6347592ad6b150dfe6b262457412
4
+ data.tar.gz: 6ada0a2a7a78ac9110b0e6c2b6179bf0553f7572bd2c3f9ce80820b4f3fe789f
5
5
  SHA512:
6
- metadata.gz: 65394c644c5d0230a5e0effab2e52e54ed46eb6f8c12ef651246cc9ed766e5e2bb8ffba49d6d7bf979568ca45f9820c25b19ba9a4894da1e3c062ab756907733
7
- data.tar.gz: 0cbf82badc994a86782dbc06bce71a0fb512749d31b358f49942baed6c677c04685cb7200382a6a94dfe10d1331a998a92f0e8e13a26090aaa96f604f18e7d9b
6
+ metadata.gz: e3560bf994b67236ed33f95a490bfbddb3d8faf65743506ec1166be3d8b095204ad16720f5ae0cef5190549a2209fdd4331c4c37f4970823774e4afdf981fe94
7
+ data.tar.gz: 0cfc55f034bdb12e98842601964029f78a6f3d1bf9018c69b7363688e1b6b2af0ee529a58bbacc4530cd871463f5063a1362931f108d364dac6a8be1380c5178
@@ -47,14 +47,8 @@ module NinjaVanApi
47
47
  private
48
48
 
49
49
  def validate_country_code
50
- if test_mode
51
- if country_code != "SG"
52
- raise NinjaVanApi::UnsupportedCountryCodeError, "#{country_code} is not supported on test mode"
53
- end
54
- else
55
- unless SUPPORTED_COUNTRY_CODES.include? country_code
56
- raise NinjaVanApi::UnsupportedCountryCodeError, "#{country_code} is not supported"
57
- end
50
+ if SUPPORTED_COUNTRY_CODES.exclude?(country_code)
51
+ raise NinjaVanApi::UnsupportedCountryCodeError, "#{country_code} is not supported"
58
52
  end
59
53
  end
60
54
 
@@ -62,6 +56,9 @@ module NinjaVanApi
62
56
  if Rails.env.development?
63
57
  Rails.logger.debug "Access token might be expired. You can refetch the token by calling NinjaVanApi::Client#refresh_access_token. Make sure update the ENV variable NINJAVAN_API_ACCESS_TOKEN"
64
58
  return ENV.fetch("NINJAVAN_API_ACCESS_TOKEN")
59
+ elsif Rails.env.test?
60
+ Rails.logger.debug "Please use webmock to stub the access token"
61
+ return "test_token"
65
62
  end
66
63
 
67
64
  fetch_access_token if token_expired?
@@ -19,5 +19,26 @@ module NinjaVanApi
19
19
  obj
20
20
  end
21
21
  end
22
+
23
+ # Convert back to hash without table key, including nested structures
24
+ def to_hash
25
+ ostruct_to_hash(self)
26
+ end
27
+
28
+ private
29
+
30
+ def ostruct_to_hash(object)
31
+ case object
32
+ when OpenStruct
33
+ hash = object.to_h.reject { |k, _| k == :table }
34
+ hash.transform_values { |value| ostruct_to_hash(value) }
35
+ when Array
36
+ object.map { |item| ostruct_to_hash(item) }
37
+ when Hash
38
+ object.transform_values { |value| ostruct_to_hash(value) }
39
+ else
40
+ object
41
+ end
42
+ end
22
43
  end
23
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NinjaVanApi
4
- VERSION = "0.3.9"
4
+ VERSION = "0.3.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ninja_van_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jane Trang Mai Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-19 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails