xdelivery 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 355fb7f6c6cbc86ac8471c2b70f05dfefc87353cded96521b0b44bc5c538ee28
4
- data.tar.gz: c001a8e1e7c561f4782420dca6c5de9c0b8d4db15012d5472751fb735ba83bde
3
+ metadata.gz: f5b44f938f1f48e3d3bf8003ea9bd3d316d2ccf5008ef1c07b1cd111fdabae5a
4
+ data.tar.gz: ea978fb994e963bfbb5b2d03f4fe17a9ddbae651aea43619dc9412f3bb746b65
5
5
  SHA512:
6
- metadata.gz: 8070cce10383f1579f90b859fc9471ec1ae371def5a42b225a558783bd83b6ef568a4f9642f0c0460aefe7cd77d4de03b1653cd759b84b00a99e3cc1d2bfb0d4
7
- data.tar.gz: 7bfe8c7d89ff4e0c20be5af13249e88837c5e405df8475ef7a40fefab4ef11b54a25fc29cc70ec308b695269a20278306bd42feb5da42f5831b16a25b9279aac
6
+ metadata.gz: 91bb5cc8117bdae52cd7165df6a273a87dd5d0ee929aa39fab77f73195c01dec30a91a4cdac5106e6a7e6351aea9c825ceca37f0aabb5dacbed1678c8c1930cc
7
+ data.tar.gz: ed1f71dc8d7ff3525404ea7ae4ba7e6b9c3fcb58cf385c9ff1fce229ee134054cf5277affefd499eb411c45210842dee7467058d8738d9fb7feb193a7c0631d2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xdelivery (1.0.1)
4
+ xdelivery (2.0.0)
5
5
  rest-client
6
6
 
7
7
  GEM
@@ -41,7 +41,7 @@ PLATFORMS
41
41
  ruby
42
42
 
43
43
  DEPENDENCIES
44
- bundler (~> 1.16)
44
+ bundler (~> 2.3.14)
45
45
  minitest (~> 5.0)
46
46
  minitest-stub-const
47
47
  rake (~> 10.0)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  xdelivery!
51
51
 
52
52
  BUNDLED WITH
53
- 1.17.3
53
+ 2.3.14
@@ -6,13 +6,22 @@ module Xdelivery
6
6
  class Base
7
7
  attr_accessor :merchant_no, :access_key
8
8
 
9
- BASE_URL = 'https://api.xdelivery.io'
9
+ PRODUCTION_BASE_URL = 'https://api.xdelivery.io'
10
+ TEST_BASE_URL = 'https://api.staging.xdelivery.io'
10
11
 
11
12
  def initialize(merchant_no='', access_key='')
12
13
  self.merchant_no = merchant_no
13
14
  self.access_key = access_key
14
15
  end
15
16
 
17
+ def base_url
18
+ @base_url = if ::Xdelivery.production?
19
+ PRODUCTION_BASE_URL
20
+ else
21
+ TEST_BASE_URL
22
+ end
23
+ end
24
+
16
25
  protected
17
26
 
18
27
  def patch(path)
@@ -59,7 +68,7 @@ module Xdelivery
59
68
  private
60
69
 
61
70
  def uri(path)
62
- uri = URI.parse("#{BASE_URL}#{path}").tap { |u| u.query = query_auth_params }
71
+ uri = URI.parse("#{base_url}#{path}").tap { |u| u.query = query_auth_params }
63
72
  end
64
73
 
65
74
  def query_auth_params
@@ -1,3 +1,3 @@
1
1
  module Xdelivery
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/xdelivery.rb CHANGED
@@ -22,6 +22,8 @@ module Xdelivery
22
22
  @@open_timeout = 5
23
23
  @@read_timeout = 5
24
24
 
25
+ @@env = :production
26
+
25
27
  def self.open_timeout
26
28
  @@open_timeout
27
29
  end
@@ -46,7 +48,11 @@ module Xdelivery
46
48
  yield(self)
47
49
  end
48
50
 
49
- def url
50
- API::Base::BASE_URL
51
+ def self.production?
52
+ @@env.to_s == "production"
53
+ end
54
+
55
+ def self.test?
56
+ @@env.to_s == "test"
51
57
  end
52
58
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "bundler", "~> 2.3.14"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
29
  spec.add_development_dependency "minitest-stub-const"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdelivery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eddie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-04 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.3.14
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.3.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.0.3.1
135
+ rubygems_version: 3.1.6
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: 火箭快遞 API 串接