customerx_tracking 1.0.0 → 2.2.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: 654a0c49afb5830bdda34476e08c92694788f22f39d9cb7f0bb1754dc6a66e48
4
- data.tar.gz: c6a7534ef6f7bcf5fd69fbc58f7234eb768ef3ad9e2b7117be30c32a9c418d91
3
+ metadata.gz: f9b3ae9f0cfcbe45349c526e4a297800dc868d6ae707ad0731df6f51f579fa5e
4
+ data.tar.gz: 8b18d6856d5f4fea1ba7ba4557046ac0a273d4046e8e217b4b42d3ce8a627d66
5
5
  SHA512:
6
- metadata.gz: 0adde120a49a1bbbc386472ad14fbcffce8b6e139f6aaf1fed97ff098a0617511da07303dbe61189c25af4710309711050d9acdaab35d9b6baabbbd8c9c0ef93
7
- data.tar.gz: 5c0884b35112fc91854f9c5981bb51f66727e13520071579419ddc73effd1a97dc5ab99af84886cde22423519edb95fcb3910858cd8ce72fec3952dceabfeded
6
+ metadata.gz: 5dfc1a8a3cdee7fb6cf70f540effa5fb8c5060bbae48fb657180955680ad97e827d3e21a64030baf3132605772c1c2f9ef8b8eafb23bf674e913744d9b8d35cc
7
+ data.tar.gz: 274f9f3dcf1e1b5e35be9c1a952d4c48f22dc83733df4c4eb3869a17446d2d71b1b72500d5e2694c3c7cd443ec9f9b02614d8894be535fde4064e59a7fa31fee
@@ -0,0 +1,24 @@
1
+ module CustomerxTracking
2
+ class Base
3
+ def connection
4
+ @connection ||= Faraday.new(faraday_options)
5
+ end
6
+
7
+ def authorizations_is_not_present?
8
+ ::CustomerxTracking.credential.nil? || ::CustomerxTracking.key.nil?
9
+ end
10
+
11
+ private
12
+
13
+ def faraday_options
14
+ {
15
+ headers: {
16
+ 'Content-Type' => 'application/json',
17
+ 'credential' => CustomerxTracking.credential,
18
+ 'key'=> CustomerxTracking.key
19
+ },
20
+ url: ::CustomerxTracking.base_url
21
+ }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module CustomerxTracking
2
+ class Requestor < Base
3
+ def initialize
4
+ super
5
+ raise 'credential and key should be set' if authorizations_is_not_present?
6
+ end
7
+
8
+ def request(meth, params = nil)
9
+ meth = meth.downcase
10
+
11
+ begin
12
+ response = connection.method(meth).call do |req|
13
+ (meth == :get ? (req.params = params) : (req.body = params.to_json)) if params
14
+ end
15
+ rescue StandardError => e
16
+ raise "it was not possible to carry out the request #{e}"
17
+ end
18
+
19
+ { status: response.status, body: JSON.parse(response.body) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module CustomerxTracking
2
+ class Tracker
3
+ def self.create(params)
4
+ Requestor.new.request(:post, params)
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomerxTracking
4
- VERSION = "1.0.0"
4
+ VERSION = '2.2.0'
5
5
  end
@@ -1,7 +1,41 @@
1
- # frozen_string_literal: true
1
+ module CustomerxTracking
2
+ @base_url = 'https://tracker.customerx.com.br'
2
3
 
3
- # Module main of CustomerX Tracking
4
+ def self.config
5
+ yield self
6
+ end
4
7
 
5
- module CustomerxTracking; end
8
+ def self.base_url
9
+ @base_url
10
+ end
6
11
 
7
- require "customerx_tracking/client"
12
+ def self.base_url=(base_url)
13
+ @base_url = base_url
14
+ end
15
+
16
+ def self.credential
17
+ @credential
18
+ end
19
+
20
+ def self.credential=(credential)
21
+ @credential = credential
22
+ end
23
+
24
+ def self.key
25
+ @key
26
+ end
27
+
28
+ def self.key=(key)
29
+ @key = key
30
+ end
31
+ end
32
+
33
+ require 'faraday'
34
+ require 'json'
35
+
36
+ # Core
37
+ require 'customerx_tracking/base'
38
+ require 'customerx_tracking/requestor'
39
+
40
+ # Tracker
41
+ 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: 1.0.0
4
+ version: 2.2.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-22 00:00:00.000000000 Z
11
+ date: 2022-01-19 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:
@@ -39,16 +33,17 @@ extensions: []
39
33
  extra_rdoc_files: []
40
34
  files:
41
35
  - lib/customerx_tracking.rb
42
- - lib/customerx_tracking/client.rb
43
- - lib/customerx_tracking/configuration.rb
36
+ - lib/customerx_tracking/base.rb
37
+ - lib/customerx_tracking/requestor.rb
38
+ - lib/customerx_tracking/tracker.rb
44
39
  - lib/customerx_tracking/version.rb
45
- homepage: https://www.customerx.cx/developers/
40
+ homepage: https://github.com/CustomerX-CX/customerx_tracking_client_rb
46
41
  licenses:
47
42
  - MIT
48
43
  metadata:
49
44
  bug_tracker_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/issues
50
- changelog_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/CHANGELOG.md
51
- documentation_uri: https://rubygems.org/gems/customerx_tracking/versions/1.0.0
45
+ changelog_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/blob/master/CHANGELOG.md
46
+ releases_uri: https://github.com/CustomerX-CX/customerx_tracking_client_rb/releases/tag/2.2.0
52
47
  post_install_message:
53
48
  rdoc_options: []
54
49
  require_paths:
@@ -57,14 +52,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
52
  requirements:
58
53
  - - ">="
59
54
  - !ruby/object:Gem::Version
60
- version: '2.3'
55
+ version: '2.5'
61
56
  required_rubygems_version: !ruby/object:Gem::Requirement
62
57
  requirements:
63
58
  - - ">="
64
59
  - !ruby/object:Gem::Version
65
60
  version: 1.3.6
66
61
  requirements: []
67
- rubygems_version: 3.2.22
62
+ rubygems_version: 3.2.3
68
63
  signing_key:
69
64
  specification_version: 4
70
65
  summary: CustomerX Tracking REST API Client
@@ -1,32 +0,0 @@
1
- require "faraday"
2
-
3
- require "customerx_tracking/configuration"
4
-
5
- module CustomerxTracking
6
- class Client
7
- # @return [Configuration] Config instance
8
- attr_reader :config
9
-
10
- # Creates a new {Client} instance and yields {#config}.
11
- def initialize
12
- raise ArgumentError, "block not given" unless block_given?
13
-
14
- @config = CustomerxTracking::Configuration.new
15
- yield config
16
- end
17
-
18
- # Send tracking of API Tracking CustomerX
19
- def tracker(external_id_client:, type_tracking:, identifier:, email:, options: {})
20
- Faraday.new.post do |req|
21
- req.url "https://tracking.customerx.com.br/api/v1/trackings"
22
- req.headers = @config.options[:headers]
23
- req.body = {
24
- external_id_client: external_id_client,
25
- type_tracking: type_tracking,
26
- identifier: identifier,
27
- email: email
28
- }.merge(options)
29
- end
30
- end
31
- end
32
- end
@@ -1,23 +0,0 @@
1
- module CustomerxTracking
2
- # Holds the configuration options for the client and connection
3
- class Configuration
4
- # @return [String] The basic auth credential.
5
- attr_accessor :credential
6
-
7
- # @return [String] The basic auth key.
8
- attr_accessor :key
9
-
10
- # Sets accept and user_agent headers
11
- #
12
- # @return [Hash] Faraday-formatted hash of options.
13
- def options
14
- {
15
- headers: {
16
- accept: "application/json",
17
- credential: @credential,
18
- key: @key
19
- }
20
- }
21
- end
22
- end
23
- end