lmb-developers 1.2.0 → 1.2.4

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: 701b7288740d66b3ec871033ec0aa52558fe4487062c7f8d8164b14d57ef7a3e
4
- data.tar.gz: d5becf3c8733a03c5202a6a668b6385e01bb54e8148a20a3a1ba72f761aef5c1
3
+ metadata.gz: ce218988bcf4b7711e62904275feba9655196bf0af64897d3dfd50b88968398c
4
+ data.tar.gz: 379238f9fc28bd54d8b7cc54a5e2f20b1e489e97977eef50640c8c2258017a75
5
5
  SHA512:
6
- metadata.gz: 42b9e5cc0a39c8547e764bd856ce9b16eb58e396da4f87d2a550d51dafeb936a1c0079fcce6d6f209f8a116507a7be0cd0d5f4199e8eb4c0b1baee68bc2fefd5
7
- data.tar.gz: 49c955f03ed68f8a793a2825bd48e1821adf227a4826502f9fcde016562e774a0184efd06889f844091011c4631a5fc9cef0ba5e8d80b0bf17cc959dea215d43
6
+ metadata.gz: 0d9dabfd2b6423f86ffb15d807c0eb38140cb8eb5ea4b14e2b32baa4863b5d0b36eb8970a2ff46a7223bd713496c7e72e69aa6b24400035b2979dc8a85357c63
7
+ data.tar.gz: 64dab8cd523325f6101c7a2a1e197f1b07991b05cf06bb97f2c1500d03c68d0733e89e2dd3b62d035535d49c63435b03805424d132df20281fb9a9d7b9d4c16a
data/README.md CHANGED
@@ -26,6 +26,10 @@ Or install it yourself as:
26
26
 
27
27
  ### Configuration
28
28
 
29
+ To use the terminal use the following command:
30
+
31
+ $ irb -Ilib -rlmb/developers
32
+
29
33
  ```ruby
30
34
 
31
35
  # Pass environment and api_key to configure. Note: Use ENV variables to protect data in production environment
@@ -42,7 +46,7 @@ You will need an API KEY that can be obtained at [Leroy Merlin Brazil Developer'
42
46
  ```ruby
43
47
 
44
48
  #config/initilizers/lmb_developers.rb
45
- Lmb::Developers.configure('TEST', ENV['LMB_API_KEY'])
49
+ Lmb::Developers.configure('DEV', ENV['LMB_API_KEY'])
46
50
 
47
51
  #app/controller/login.rb
48
52
  Lmb::Developers::Auth.login("ldap_username", "ldap_password")
@@ -8,21 +8,24 @@ module Lmb
8
8
  # Initial config.
9
9
  def initialize
10
10
  @config = {
11
+ 'DEV' => {
12
+ 'url': 'https://api-dev.leroymerlin.com.br'
13
+ },
11
14
  'TEST' => {
12
15
  'url': 'https://api-test.leroymerlin.com.br'
13
16
  },
14
17
  'PROD' => {
15
- 'url' => 'https://api.leroymerlin.com.br',
18
+ 'url': 'https://api.leroymerlin.com.br'
16
19
  }
17
20
  }
18
- configure('TEST', nil)
21
+ configure('DEV', nil)
19
22
  end
20
23
  # Configure global parameters
21
24
  #
22
25
  # @param environment [String] environment to consume APIs, `TEST` or `PROD`
23
26
  # @param api_key [String] ApiKey to consume APIs.
24
27
  # @return [Lmb::Developers::Configuration]
25
- def configure(environment = 'TEST', api_key)
28
+ def configure(environment = 'DEV', api_key)
26
29
  @api_key = api_key
27
30
  @environment = environment
28
31
  @url = @config[environment][:url]
@@ -7,6 +7,7 @@ module Lmb
7
7
  VOUCHER_EXPIRED_PATH = '/v1/loyalty/voucher/expired'.freeze
8
8
  VOUCHER_PROVISIONED_PATH = '/v1/loyalty/voucher/provisioned'.freeze
9
9
  VOUCHER_ACTIVATED_PATH = '/v1/loyalty/voucher/activated'.freeze
10
+ SCORING_REDEMPTION_PATH = '/v1/loyalty/redemption'.freeze
10
11
 
11
12
  # Set Inhabitant's Expired Vouchers.
12
13
  #
@@ -81,6 +82,52 @@ module Lmb
81
82
  def self.configuration
82
83
  @configuration = Lmb::Developers.configuration
83
84
  end
85
+
86
+ def self.redemption(redemptions)
87
+ puts "-"*25
88
+ puts "entrou no metodo"
89
+ puts "-"*25
90
+ uri = URI.parse("#{configuration.url}#{SCORING_REDEMPTION_PATH}")
91
+ puts "-"*25
92
+ puts uri = URI.parse("#{configuration.url}#{SCORING_REDEMPTION_PATH}")
93
+ puts "-"*25
94
+ request = Net::HTTP::Post.new(uri)
95
+ puts "-"*25
96
+ puts request = Net::HTTP::Post.new(uri)
97
+ puts "-"*25
98
+ request['Apikey'] = configuration.api_key.to_s
99
+ puts "-"*25
100
+ puts request['Apikey'] = configuration.api_key.to_s
101
+ puts "-"*25
102
+ request['Cache-Control'] = 'no-cache'
103
+ puts "-"*25
104
+ puts request['Cache-Control'] = 'no-cache'
105
+ puts "-"*25
106
+ request.body = redemptions
107
+ puts "-"*25
108
+ puts request.body = redemptions
109
+ puts "-"*25
110
+ req_options = {
111
+ use_ssl: uri.scheme == 'https'
112
+ }
113
+ puts "-"*25
114
+ puts req_options = {
115
+ use_ssl: uri.scheme == 'https'
116
+ }
117
+ puts "-"*25
118
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
119
+ http.request(request)
120
+ end
121
+ puts "-"*25
122
+ puts response.code.to_i
123
+ puts "-"*25
124
+ response.code.to_i == 202
125
+ rescue StandardError => exception
126
+ puts "-"*25
127
+ puts "chegou no erro"
128
+ puts "-"*25
129
+ exception
130
+ end
84
131
  end
85
132
  end
86
133
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'lmb-developers'
3
- s.version = '1.2.0'
4
- s.date = '2019-04-01'
3
+ s.version = '1.2.4'
4
+ s.date = '2019-05-19'
5
5
  s.summary = "Consume APIs at Leroy Merlin Brazil Developer's Portal"
6
6
  s.description = "Gem to consume APIs available at Leroy Merlin Brazil Developer's Portal https://developers.leroymerlin.com.br"
7
7
  s.author = "PRTE - Tecnologia e Soluções"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lmb-developers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PRTE - Tecnologia e Soluções
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Gem to consume APIs available at Leroy Merlin Brazil Developer's Portal
14
14
  https://developers.leroymerlin.com.br
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 3.0.2
49
+ rubygems_version: 3.1.2
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: Consume APIs at Leroy Merlin Brazil Developer's Portal