customerx_tracking 2.0.0 → 2.1.0

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: 6f5db5d0d8185cb42c3968df3cf4cbd3c2ff2d36d395859d7f899b319d62870b
4
- data.tar.gz: dc3ef6f2ae4cbd8545381175559d1346ee75e36fb0697a12760a02523a84d8af
3
+ metadata.gz: 5d4e3d43aec5e19517ffd9483fc7baa9f7deb0139f1150b8970ee3d6ff6e9718
4
+ data.tar.gz: cda3b742f83cfbc3d604cf8a44d1082ed261edcb1359271f8b63525fca0f2d1b
5
5
  SHA512:
6
- metadata.gz: 11afbdbd44dc8b17c5c3b00f86c1ea69cf88eb0f290c563cab7e617318d2c12a52b02e401fd732081ddf87e922d75b57f5027c7e5dce2d12c99aef7a0ebec8fc
7
- data.tar.gz: c404db573b9be5e3cad8fb6c8643bea68b136c4e57ba7bc44a2e99e66dceb417c73478a08d883550cba8de8a56da9ad33c3df60df5c7f82e680b63b14de35390
6
+ metadata.gz: 031a7eef2d62b7105266374efaddaea8c5db2fcb5c0d5bfb557b62a66bfbde25db18151c675e17c35a35bfbda76aa4121c596e852906e216656c0783dc270a5d
7
+ data.tar.gz: 76a170d6eae62b6d16216d562b50a4fef4c64a9e0aad7ba4cae12da988cdf0f9930d9119725ab74c9860ce0c50964198aed5939f0e55628dca9d934255395437
@@ -5,7 +5,7 @@ module CustomerxTracking
5
5
  end
6
6
 
7
7
  def authorizations_is_not_present?
8
- ::CustomerxTracking.credential.nil? || ::CustomerxTracking.key.nil?
8
+ ::CustomerxTracking.authorization.nil? && (::CustomerxTracking.credential.nil? || ::CustomerxTracking.key.nil?)
9
9
  end
10
10
 
11
11
  private
@@ -13,12 +13,19 @@ module CustomerxTracking
13
13
  def faraday_options
14
14
  {
15
15
  headers: {
16
- accept: "application/json",
17
- credential: ::CustomerxTracking.credential,
18
- key: ::CustomerxTracking.key
19
- },
16
+ 'Content-Type' => 'application/json'
17
+ }.merge(validate_authorization),
20
18
  url: ::CustomerxTracking.base_url
21
19
  }
22
20
  end
21
+
22
+ def validate_authorization
23
+ return { authorization: ::CustomerxTracking.authorization } unless ::CustomerxTracking.authorization.nil?
24
+
25
+ {
26
+ credential: ::CustomerxTracking.credential,
27
+ key: ::CustomerxTracking.key
28
+ }
29
+ end
23
30
  end
24
- end
31
+ end
@@ -1,22 +1,23 @@
1
1
  module CustomerxTracking
2
2
  class Requestor < Base
3
3
  def initialize
4
- raise 'credential and key should be set' if authorizations_is_not_present?
4
+ super
5
+ raise 'authorization or credential and key should be set' if authorizations_is_not_present?
5
6
  end
6
7
 
7
8
  def request(meth, params = nil)
8
9
  meth = meth.downcase
9
10
 
10
11
  begin
12
+ p JSON.parse(params.to_json)
11
13
  response = connection.method(meth).call do |req|
12
- (if meth == :get then req.params = params else req.body = params end) if params
14
+ (meth == :get ? (req.params = params) : (req.body = params.to_json)) if params
13
15
  end
14
- rescue
15
- raise 'it was not possible to carry out the request'
16
+ rescue StandardError => e
17
+ raise "it was not possible to carry out the request #{e}"
16
18
  end
17
19
 
18
- p response
19
20
  { status: response.status, body: JSON.parse(response.body) }
20
21
  end
21
22
  end
22
- end
23
+ end
@@ -4,4 +4,4 @@ module CustomerxTracking
4
4
  Requestor.new.request(:post, params)
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomerxTracking
4
- VERSION = "2.0.0"
4
+ VERSION = '2.1.0'
5
5
  end
@@ -1,9 +1,5 @@
1
- # Module main of CustomerX Tracking
2
1
  module CustomerxTracking
3
- @base_url = 'https://tracking.customerx.com.br/api/v1/trackings'
4
- @credential
5
- @key
6
- @authorization
2
+ @base_url = 'https://tracker.customerx.com.br'
7
3
 
8
4
  def self.config
9
5
  yield self
@@ -50,4 +46,4 @@ require 'customerx_tracking/base'
50
46
  require 'customerx_tracking/requestor'
51
47
 
52
48
  # Tracker
53
- require 'customerx_tracking/tracker'
49
+ require 'customerx_tracking/tracker'
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerx_tracking
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Grassi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 2.0.0
19
+ version: '1.8'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.9.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 2.0.0
26
+ version: '1.8'
33
27
  description: Ruby wrapper for the REST API at https://www.customerx.cx. Documentation
34
28
  at https://www.customerx.cx/developers.
35
29
  email:
@@ -49,23 +43,23 @@ licenses:
49
43
  metadata:
50
44
  bug_tracker_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/issues
51
45
  changelog_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/blob/master/CHANGELOG.md
52
- releases_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/releases/tag/2.0.0
46
+ releases_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/releases/tag/2.1.0
53
47
  post_install_message:
54
48
  rdoc_options: []
55
49
  require_paths:
56
50
  - lib
57
51
  required_ruby_version: !ruby/object:Gem::Requirement
58
52
  requirements:
59
- - - ">="
53
+ - - '='
60
54
  - !ruby/object:Gem::Version
61
- version: '2.3'
55
+ version: 3.0.0
62
56
  required_rubygems_version: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - ">="
65
59
  - !ruby/object:Gem::Version
66
- version: 1.3.6
60
+ version: '0'
67
61
  requirements: []
68
- rubygems_version: 3.2.22
62
+ rubygems_version: 3.2.3
69
63
  signing_key:
70
64
  specification_version: 4
71
65
  summary: CustomerX Tracking REST API Client