qas_dock_gem 0.1.29 → 0.1.34

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: 4b96b1528b0ecb8e94f88543aab16c5903fd3738bed88659f867ba0736a59c83
4
- data.tar.gz: cf78c7d598dc40da5f8fe0d36487decc3157480621f24b0b31276878de002293
3
+ metadata.gz: 45312a8bfe393e9b4ac6ad03fce14826966e54cf734f1098ee97cca0c69d1468
4
+ data.tar.gz: 6570f600280fa00caee4718beb612314984b0c21eeb2fd2df21b1794a258fb36
5
5
  SHA512:
6
- metadata.gz: 9342dc51b29d1038403e48487bf7d728367af861df89c6be2b4aa8ccaa07ba23191cdb85fbeb310677612c3c81066cee63be91c9f2281932a46e71f2e8a5dd38
7
- data.tar.gz: 38afdf63c5e2ef5963043f4415529162300f1b40a93918cdc72787af9ab0d03132aa847612d04077dba2b07f969b41cb8e782bf1d06e1a4309793a898590069a
6
+ metadata.gz: 3c9d7a8e85ae9d402603f6e8b4fae6818069205fe2d6f52b6f0fd1117c91be01cc533f446af084cb98da5697a17f9d1730f712d6178fd90c9cb372be612601c9
7
+ data.tar.gz: 0c8193e46f52758518d7da1df7f887edd0ede936688a3b00dd968f8265bac31165ad5441ce79be30e85b2bca0654630aefe10cc9c962447b5ce444b54b5fc2e8
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.idea/
data/CODE_OF_CONDUCT.md CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for
6
+ everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity
7
+ and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion,
8
+ or sexual identity and orientation.
6
9
 
7
10
  We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
11
 
@@ -18,67 +21,82 @@ Examples of behavior that contributes to a positive environment for our communit
18
21
 
19
22
  Examples of unacceptable behavior include:
20
23
 
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
24
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
23
25
  * Trolling, insulting or derogatory comments, and personal or political attacks
24
26
  * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
27
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
29
29
 
30
30
  ## Enforcement Responsibilities
31
31
 
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take
33
+ appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive,
34
+ or harmful.
33
35
 
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
36
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
37
+ issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for
38
+ moderation decisions when appropriate.
35
39
 
36
40
  ## Scope
37
41
 
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
42
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing
43
+ the community in public spaces. Examples of representing our community include using an official e-mail address, posting
44
+ via an official social media account, or acting as an appointed representative at an online or offline event.
39
45
 
40
46
  ## Enforcement
41
47
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lucas.gimenes23@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
48
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible
49
+ for enforcement at lucas.gimenes23@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
50
 
44
51
  All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
52
 
46
53
  ## Enforcement Guidelines
47
54
 
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
55
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem
56
+ in violation of this Code of Conduct:
49
57
 
50
58
  ### 1. Correction
51
59
 
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
60
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the
61
+ community.
53
62
 
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
63
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation
64
+ and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
65
 
56
66
  ### 2. Warning
57
67
 
58
68
  **Community Impact**: A violation through a single incident or series of actions.
59
69
 
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
70
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including
71
+ unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding
72
+ interactions in community spaces as well as external channels like social media. Violating these terms may lead to a
73
+ temporary or permanent ban.
61
74
 
62
75
  ### 3. Temporary Ban
63
76
 
64
77
  **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
78
 
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
79
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified
80
+ period of time. No public or private interaction with the people involved, including unsolicited interaction with those
81
+ enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
82
 
68
83
  ### 4. Permanent Ban
69
84
 
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
85
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate
86
+ behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
87
 
72
88
  **Consequence**: A permanent ban from any sort of public interaction within the community.
73
89
 
74
90
  ## Attribution
75
91
 
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
92
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available
93
+ at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
94
 
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
95
+ Community Impact Guidelines were inspired
96
+ by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
97
 
81
98
  [homepage]: https://www.contributor-covenant.org
82
99
 
83
100
  For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
101
+ https://www.contributor-covenant.org/faq. Translations are available
102
+ at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in qas_dock_gem.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem 'rake', '~> 13.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qas_dock_gem (0.1.27)
4
+ qas_dock_gem (0.1.32)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -31,7 +31,7 @@ GEM
31
31
  redis (4.2.5)
32
32
 
33
33
  PLATFORMS
34
- x86_64-linux-musl
34
+ x86_64-linux
35
35
 
36
36
  DEPENDENCIES
37
37
  aws-sdk-secretsmanager
@@ -43,4 +43,4 @@ DEPENDENCIES
43
43
  redis
44
44
 
45
45
  BUNDLED WITH
46
- 2.2.17
46
+ 2.2.15
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # QasDockGem
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/qas_dock_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
4
+ into a gem. Put your Ruby code in the file `lib/qas_dock_gem`. To experiment with that code, run `bin/console` for an
5
+ interactive prompt.
4
6
 
5
7
  TODO: Delete this and the text above, and describe your gem
6
8
 
@@ -26,13 +28,18 @@ TODO: Write usage instructions here
26
28
 
27
29
  ## Development
28
30
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive
32
+ prompt that will allow you to experiment.
30
33
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
35
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
36
+ push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
37
 
33
38
  ## Contributing
34
39
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qas_dock_gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qas_dock_gem. This project is
41
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
42
+ the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
36
43
 
37
44
  ## License
38
45
 
@@ -40,4 +47,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
47
 
41
48
  ## Code of Conduct
42
49
 
43
- Everyone interacting in the QasDockGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
50
+ Everyone interacting in the QasDockGem project's codebases, issue trackers, chat rooms and mailing lists is expected to
51
+ follow the [code of conduct](https://github.com/[USERNAME]/qas_dock_gem/blob/master/CODE_OF_CONDUCT.md).
data/lib/qas_dock_gem.rb CHANGED
@@ -1,119 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "qas_dock_gem/version"
4
- require_relative "qas_dock_gem/services/aws_services"
5
- require_relative "qas_dock_gem/services/redis_services"
3
+ require_relative 'qas_dock_gem/version'
4
+ require_relative 'qas_dock_gem/services/aws_services'
5
+ require_relative 'qas_dock_gem/services/redis_services'
6
+ require_relative 'qas_dock_gem/services/requests_api_services'
6
7
 
7
8
  module QasDockGem
8
- class RequestsAPI
9
- require "httparty"
10
-
11
- def initialize
12
- require "logger"
13
- @logger = Logger.new(STDOUT)
14
- end
15
-
16
- def initialize_headers(token, headers)
17
- headers_default = {"cache-control": "no-cache", "content-type": "application/json"}
18
-
19
- #seta o campo authorization caso o token seja diferente de nulo
20
- headers_default["Authorization"] = token unless token.nil?
21
-
22
- #define os headers parametrizados como um Hash caso seja nulo
23
- headers = {} if headers.nil?
24
-
25
- #realiza o merge dos headers defaults + os headers parametrizados
26
- headers_default.merge!(headers)
27
-
28
- #remove o campo content-type caso não seja informado
29
- headers_default.delete(:"content-type") if headers_default[:"content-type"] == "" or headers_default[:"content-type"].nil?
30
-
31
- #retorna os headers
32
- JSON.parse(headers_default.to_json)
33
- end
34
-
35
- def initialize_request(params)
36
- formated_params = init_request_body(params[:token], params[:payload], params[:headers]) if params.include?(:payload)
37
- formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
38
- formated_params = init_request_basic_auth(params[:token], params[:basic_auth], params[:headers]) if params.include?(:basic_auth)
39
-
40
- #retorna os params formatados para a request
41
- formated_params
42
- end
43
-
44
- def init_request_body(token, payload, headers)
45
- final_headers = initialize_headers(token, headers)
46
- payload = {} if payload.nil?
47
- @logger.info("Payload: #{payload.to_json}")
48
- @logger.info("Headers: #{final_headers}")
49
-
50
- { :headers => final_headers, :body => payload.to_json }
51
- end
52
-
53
- def init_request_basic_auth(token, basic_auth, headers)
54
- final_headers = initialize_headers(token, headers)
55
- payload = {} if payload.nil?
56
- @logger.info("Headers: #{final_headers}")
57
- { :headers => final_headers, :basic_auth => basic_auth }
58
- end
59
-
60
- def init_request_query(token, query, headers)
61
- final_headers = initialize_headers(token, headers)
62
- query = {} if query.nil?
63
- @logger.info("Query: #{query}")
64
- @logger.info("Headers: #{final_headers}")
65
-
66
- { :headers => final_headers, :query => query }
67
- end
68
-
69
- def execute_post(params)
70
- formated_params = initialize_request(params)
71
- @logger.info("Realizando POST")
72
- @logger.info("URI: #{params[:uri]}")
73
- request = HTTParty.post(params[:uri], formated_params)
74
- @logger.info("URI Final: #{request.request.last_uri}")
75
- @logger.info("POST realizado \n")
76
- request
77
- end
78
-
79
- def execute_get(params)
80
- formated_params = initialize_request(params)
81
- @logger.info("Realizando GET")
82
- @logger.info("URI: #{params[:uri]}")
83
- request = HTTParty.get(params[:uri], formated_params)
84
- @logger.info("URI Final: #{request.request.last_uri}")
85
- @logger.info("GET realizado \n")
86
- request
87
- end
88
-
89
- def execute_patch(params)
90
- formated_params = initialize_request(params)
91
- @logger.info("Realizando PATCH")
92
- @logger.info("URI: #{params[:uri]}")
93
- request = HTTParty.patch(params[:uri], formated_params)
94
- @logger.info("URI Final: #{request.request.last_uri}")
95
- @logger.info("PATCH realizado \n")
96
- request
97
- end
98
-
99
- def execute_put(params)
100
- formated_params = initialize_request(params)
101
- @logger.info("Realizando PUT")
102
- @logger.info("URI: #{params[:uri]}")
103
- request = HTTParty.put(params[:uri], formated_params)
104
- @logger.info("URI Final: #{request.request.last_uri}")
105
- @logger.info("PUT realizado \n")
106
- request
107
- end
108
-
109
- def execute_delete(params)
110
- formated_params = initialize_request(params)
111
- @logger.info("Realizando DELETE")
112
- @logger.info("URI: #{params[:uri]}")
113
- request = HTTParty.put(params[:uri], formated_params)
114
- @logger.info("URI Final: #{request.request.last_uri}")
115
- @logger.info("DELETE realizado \n")
116
- request
117
- end
9
+ class Envs
10
+ def get_envs(env)
11
+ $env_lib = env
12
+ end
118
13
  end
119
- end
14
+ end
@@ -1,21 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QasDockGem
2
- class AwsServices
3
- def credentials_aws(access_key_id, secret_access_key_id, region)
4
- {
5
- access_key_id: access_key_id,
6
- secret_access_key: secret_access_key_id,
7
- region: region
8
- }
9
- end
10
-
11
- def init_secrets_manager(credentials)
12
- require "aws-sdk-secretsmanager"
13
- Aws::SecretsManager::Client.new(credentials)
14
- end
15
-
16
- def get_sm_secret_value(credentials, secret_name)
17
- secret = init_secrets_manager(credentials).get_secret_value(secret_id: "#{secret_name}")
18
- JSON.parse(secret.secret_string)
19
- end
20
- end
21
- end
4
+ class AwsServices
5
+ def credentials_aws(access_key_id, secret_access_key_id, region)
6
+ {
7
+ access_key_id: access_key_id,
8
+ secret_access_key: secret_access_key_id,
9
+ region: region
10
+ }
11
+ end
12
+
13
+ def init_secrets_manager(credentials)
14
+ require 'aws-sdk-secretsmanager'
15
+ Aws::SecretsManager::Client.new(credentials)
16
+ end
17
+
18
+ def get_sm_secret_value(credentials, secret_name)
19
+ secret = init_secrets_manager(credentials).get_secret_value(secret_id: secret_name.to_s)
20
+ JSON.parse(secret.secret_string)
21
+ end
22
+ end
23
+ end
@@ -1,57 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QasDockGem
2
- class RedisService
3
- def initialize
4
- require "logger"
5
- @logger = Logger.new(STDOUT)
6
- end
7
-
8
- def initialize_redis
9
- require 'redis'
10
- params_redis = {
11
- host: ENV["uri_redis"],
12
- port: 6379,
13
- connect_timeout: 0.5,
14
- read_timeout: 1.0,
15
- write_timeout: 1.0,
16
- reconnect_delay: 0.5,
17
- reconnect_delay_max: 1.5
18
- }
19
- #Realiza a tentativa de conexão com o redis com os params informados
20
- @redis = Redis.new(params_redis)
21
- begin
22
- #verifica se a conexão obteve sucesso
23
- @redis.ping
24
- #caso tenha obtido sucesso na conexão, retorna o objeto do Redis
25
- return @redis
26
- rescue StandardError => redis_exception
27
- @redis = nil
28
- @logger.error("Params Redis: #{JSON.pretty_generate(JSON.parse(params_redis.to_json))}")
29
- @logger.error("Exceção retornada do Redis: #{redis_exception.inspect}")
30
- @logger.error("Mensagem de exceção retornada do Redis: #{redis_exception.message}")
31
- end
32
- end
33
-
34
- def get_key_redis(key)
35
- @logger.info("Buscando chave #{key} no Redis")
36
- @redis = initialize_redis if @redis.nil?
37
- begin
38
- @redis.get(key)
39
- rescue => redis_excep_get
40
- @logger.error("Exceção retornada do redis ao consultar a chave: #{redis_excep_get}")
41
- return nil
42
- end
43
- end
44
-
45
- def set_key_redis(key, value, ttl)
46
- @logger.info("Cadastrando chave #{key} com valor: #{value} e tempo de duração: #{ttl}")
47
- @redis = initialize_redis if @redis.nil?
48
- begin
49
- set_redis = @redis.set(key, value, ex: ttl)
50
- @logger.info("Chave cadastrada com sucesso no redis") if set_redis == "OK"
51
- rescue => redis_excep_set
52
- @logger.error("Exceção retornada do redis ao cadastrar a chave: #{redis_excep_set}")
53
- return nil
54
- end
55
- end
4
+ class RedisService
5
+ def initialize
6
+ require 'logger'
7
+ require 'redis'
8
+ @logger = Logger.new($stdout)
9
+ end
10
+
11
+ def initialize_redis
12
+ redis_params = { host: ENV['uri_redis'], port: 6379, connect_timeout: 0.5, read_timeout: 1.0, write_timeout: 1.0 }
13
+ @redis = Redis.new(redis_params) # Realiza a tentativa de conexão com o redis com os params informados
14
+ begin
15
+ @redis.ping
16
+ @redis
17
+ rescue StandardError => e
18
+ @redis = nil
19
+ @logger.error("Params Redis: #{JSON.pretty_generate(JSON.parse(redis_params.to_json))}")
20
+ @logger.error("Exceção retornada do Redis: #{e.inspect} - Mensagem: #{e.message}")
56
21
  end
57
- end
22
+ end
23
+
24
+ def get_key_redis(key)
25
+ @logger.info("Buscando chave #{key} no Redis")
26
+ @redis = initialize_redis if @redis.nil?
27
+ begin
28
+ @redis.get(key)
29
+ rescue StandardError => e
30
+ @logger.error("Exceção retornada do redis ao consultar a chave: #{e}")
31
+ nil
32
+ end
33
+ end
34
+
35
+ def set_key_redis(key, value, ttl)
36
+ @logger.info("Cadastrando chave #{key} com valor: #{value} e tempo de duração: #{ttl}")
37
+ @redis = initialize_redis if @redis.nil?
38
+ begin
39
+ set_redis = @redis.set(key, value, ex: ttl)
40
+ @logger.info('Chave cadastrada com sucesso no redis') if set_redis == 'OK'
41
+ rescue StandardError => e
42
+ @logger.error("Exceção retornada do redis ao cadastrar a chave: #{e}")
43
+ nil
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QasDockGem
4
+ class RequestsAPI
5
+ require 'httparty'
6
+
7
+ def initialize
8
+ require 'logger'
9
+ @logger = Logger.new($stdout)
10
+ end
11
+
12
+ def initialize_headers(token, headers)
13
+ headers_default = { "cache-control": 'no-cache', "content-type": 'application/json' }
14
+
15
+ # seta o campo authorization caso o token seja diferente de nulo
16
+ headers_default['Authorization'] = token unless token.nil?
17
+
18
+ # define os headers parametrizados como um Hash caso seja nulo
19
+ headers = {} if headers.nil?
20
+
21
+ # realiza o merge dos headers defaults + os headers parametrizados
22
+ headers_default.merge!(headers)
23
+
24
+ # remove o campo content-type caso não seja informado
25
+ if (headers_default[:"content-type"] == '') || headers_default[:"content-type"].nil?
26
+ headers_default.delete(:"content-type")
27
+ end
28
+
29
+ # retorna os headers
30
+ JSON.parse(headers_default.to_json)
31
+ end
32
+
33
+ def initialize_request(params)
34
+ formated_params = nil
35
+ if params.include?(:payload)
36
+ formated_params = init_request_body(params[:token], params[:payload], params[:headers])
37
+ end
38
+
39
+ formated_params = init_request_query(params[:token], params[:query], params[:headers]) if params.include?(:query)
40
+
41
+ if params.include?(:basic_auth)
42
+ formated_params = init_request_basic_auth(params[:token], params[:basic_auth], params[:headers])
43
+ end
44
+
45
+ # retorna os params formatados para a request
46
+ formated_params
47
+ end
48
+
49
+ def init_request_body(token, payload, headers)
50
+ final_headers = initialize_headers(token, headers)
51
+ payload = {} if payload.nil?
52
+ @logger.info("Payload: #{payload.to_json}")
53
+ @logger.info("Headers: #{final_headers}")
54
+
55
+ { headers: final_headers, body: payload.to_json }
56
+ end
57
+
58
+ def init_request_basic_auth(token, basic_auth, headers)
59
+ final_headers = initialize_headers(token, headers)
60
+ @logger.info("Headers: #{final_headers}")
61
+ { headers: final_headers, basic_auth: basic_auth }
62
+ end
63
+
64
+ def init_request_query(token, query, headers)
65
+ final_headers = initialize_headers(token, headers)
66
+ query = {} if query.nil?
67
+ @logger.info("Query: #{query}")
68
+ @logger.info("Headers: #{final_headers}")
69
+
70
+ { headers: final_headers, query: query }
71
+ end
72
+
73
+ def execute_post(params)
74
+ formated_params = initialize_request(params)
75
+ @logger.info('Realizando POST')
76
+ @logger.info("URI: #{params[:uri]}")
77
+ request = HTTParty.post(params[:uri], formated_params)
78
+ @logger.info("URI Final: #{request.request.last_uri}")
79
+ @logger.info("POST realizado \n")
80
+ request
81
+ end
82
+
83
+ def execute_get(params)
84
+ formated_params = initialize_request(params)
85
+ @logger.info('Realizando GET')
86
+ @logger.info("URI: #{params[:uri]}")
87
+ request = HTTParty.get(params[:uri], formated_params)
88
+ @logger.info("URI Final: #{request.request.last_uri}")
89
+ @logger.info("GET realizado \n")
90
+ request
91
+ end
92
+
93
+ def execute_patch(params)
94
+ formated_params = initialize_request(params)
95
+ @logger.info('Realizando PATCH')
96
+ @logger.info("URI: #{params[:uri]}")
97
+ request = HTTParty.patch(params[:uri], formated_params)
98
+ @logger.info("URI Final: #{request.request.last_uri}")
99
+ @logger.info("PATCH realizado \n")
100
+ request
101
+ end
102
+
103
+ def execute_put(params)
104
+ formated_params = initialize_request(params)
105
+ @logger.info('Realizando PUT')
106
+ @logger.info("URI: #{params[:uri]}")
107
+ request = HTTParty.put(params[:uri], formated_params)
108
+ @logger.info("URI Final: #{request.request.last_uri}")
109
+ @logger.info("PUT realizado \n")
110
+ request
111
+ end
112
+
113
+ def execute_delete(params)
114
+ formated_params = initialize_request(params)
115
+ @logger.info('Realizando DELETE')
116
+ @logger.info("URI: #{params[:uri]}")
117
+ request = HTTParty.put(params[:uri], formated_params)
118
+ @logger.info("URI Final: #{request.request.last_uri}")
119
+ @logger.info("DELETE realizado \n")
120
+ request
121
+ end
122
+ end
123
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QasDockGem
4
- VERSION = "0.1.29"
4
+ VERSION = '0.1.34'
5
5
  end
data/qas_dock_gem.gemspec CHANGED
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/qas_dock_gem/version"
3
+ require_relative 'lib/qas_dock_gem/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "qas_dock_gem"
7
- spec.version = QasDockGem::VERSION
8
- spec.authors = ["LucasKoritar23"]
9
- spec.email = ["lucas.gimenes23@gmail.com"]
6
+ spec.name = 'qas_dock_gem'
7
+ spec.version = QasDockGem::VERSION
8
+ spec.authors = ['LucasKoritar23']
9
+ spec.email = ['lucas.gimenes23@gmail.com']
10
10
 
11
- spec.summary = "A hello gem to the ruby world"
12
- spec.description = "I just created this gem to say hello for the ruby gems world, okay."
13
- spec.homepage = ""
14
- spec.license = "MIT"
11
+ spec.summary = 'A hello gem to the ruby world'
12
+ spec.description = 'I just created this gem to say hello for the ruby gems world, okay.'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler"
22
- spec.add_development_dependency "httparty"
23
- spec.add_development_dependency "logger"
24
- spec.add_development_dependency "aws-sdk-secretsmanager"
25
- spec.add_development_dependency "redis"
21
+ spec.add_development_dependency 'aws-sdk-secretsmanager'
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'httparty'
24
+ spec.add_development_dependency 'logger'
25
+ spec.add_development_dependency 'redis'
26
26
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qas_dock_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - LucasKoritar23
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: aws-sdk-secretsmanager
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: httparty
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: logger
42
+ name: httparty
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: aws-sdk-secretsmanager
56
+ name: logger
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -102,13 +102,14 @@ files:
102
102
  - lib/qas_dock_gem.rb
103
103
  - lib/qas_dock_gem/services/aws_services.rb
104
104
  - lib/qas_dock_gem/services/redis_services.rb
105
+ - lib/qas_dock_gem/services/requests_api_services.rb
105
106
  - lib/qas_dock_gem/version.rb
106
107
  - qas_dock_gem.gemspec
107
108
  homepage: ''
108
109
  licenses:
109
110
  - MIT
110
111
  metadata: {}
111
- post_install_message:
112
+ post_install_message:
112
113
  rdoc_options: []
113
114
  require_paths:
114
115
  - lib
@@ -123,8 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  - !ruby/object:Gem::Version
124
125
  version: '0'
125
126
  requirements: []
126
- rubygems_version: 3.2.15
127
- signing_key:
127
+ rubygems_version: 3.1.2
128
+ signing_key:
128
129
  specification_version: 4
129
130
  summary: A hello gem to the ruby world
130
131
  test_files: []