lmb-developers 1.1.2 → 1.2.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 +4 -4
- data/README.md +18 -4
- data/lib/lmb/developers.rb +1 -0
- data/lib/lmb/developers/loyalty.rb +86 -0
- data/lmb-developers.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 701b7288740d66b3ec871033ec0aa52558fe4487062c7f8d8164b14d57ef7a3e
|
4
|
+
data.tar.gz: d5becf3c8733a03c5202a6a668b6385e01bb54e8148a20a3a1ba72f761aef5c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b9e5cc0a39c8547e764bd856ce9b16eb58e396da4f87d2a550d51dafeb936a1c0079fcce6d6f209f8a116507a7be0cd0d5f4199e8eb4c0b1baee68bc2fefd5
|
7
|
+
data.tar.gz: 49c955f03ed68f8a793a2825bd48e1821adf227a4826502f9fcde016562e774a0184efd06889f844091011c4631a5fc9cef0ba5e8d80b0bf17cc959dea215d43
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
[](http://badge.fury.io/rb/lmb-developers)
|
2
|
+
[](https://codeclimate.com/github/somosprte/lmb-developers/maintainability)
|
3
|
+
[](https://codeclimate.com/github/somosprte/lmb-developers/test_coverage)
|
2
4
|
|
3
5
|
# Lmb Developers
|
4
6
|
|
@@ -26,14 +28,26 @@ Or install it yourself as:
|
|
26
28
|
|
27
29
|
```ruby
|
28
30
|
|
29
|
-
# Pass environment and api_key to configure
|
30
|
-
Lmb::Developers.configure('environment', '
|
31
|
+
# Pass environment and api_key to configure. Note: Use ENV variables to protect data in production environment
|
32
|
+
Lmb::Developers.configure('environment', ENV['LMB_API_KEY'])
|
31
33
|
|
32
34
|
```
|
33
35
|
|
34
36
|
The environment can be 'TEST' or 'PROD'.
|
35
37
|
|
36
|
-
You will need an
|
38
|
+
You will need an API KEY that can be obtained at [Leroy Merlin Brazil Developer's Portal](https://developers.leroymerlin.com.br)
|
39
|
+
|
40
|
+
### Example
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
|
44
|
+
#config/initilizers/lmb_developers.rb
|
45
|
+
Lmb::Developers.configure('TEST', ENV['LMB_API_KEY'])
|
46
|
+
|
47
|
+
#app/controller/login.rb
|
48
|
+
Lmb::Developers::Auth.login("ldap_username", "ldap_password")
|
49
|
+
|
50
|
+
```
|
37
51
|
|
38
52
|
### Methods
|
39
53
|
|
@@ -45,7 +59,7 @@ Lmb::Developers::Auth.login("ldap_username", "ldap_password", "ldap_usertype = e
|
|
45
59
|
|
46
60
|
## Contributing
|
47
61
|
|
48
|
-
1. Fork it ( https://github.com/
|
62
|
+
1. Fork it ( https://github.com/somosprte/lmb-developers/fork )
|
49
63
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
64
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
65
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/lmb/developers.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
module Lmb
|
2
|
+
module Developers
|
3
|
+
class Loyalty
|
4
|
+
attr_reader :configuration
|
5
|
+
|
6
|
+
# Paths to methods
|
7
|
+
VOUCHER_EXPIRED_PATH = '/v1/loyalty/voucher/expired'.freeze
|
8
|
+
VOUCHER_PROVISIONED_PATH = '/v1/loyalty/voucher/provisioned'.freeze
|
9
|
+
VOUCHER_ACTIVATED_PATH = '/v1/loyalty/voucher/activated'.freeze
|
10
|
+
|
11
|
+
# Set Inhabitant's Expired Vouchers.
|
12
|
+
#
|
13
|
+
# @param expirations [Hash] the expriations object.
|
14
|
+
# @return [Boolean]
|
15
|
+
def self.voucher_expired(expirations)
|
16
|
+
uri = URI.parse("#{configuration.url}#{VOUCHER_EXPIRED_PATH}")
|
17
|
+
request = Net::HTTP::Post.new(uri)
|
18
|
+
request['Apikey'] = configuration.api_key.to_s
|
19
|
+
request['Cache-Control'] = 'no-cache'
|
20
|
+
request.body = JSON.dump(
|
21
|
+
'expirations' => expirations
|
22
|
+
)
|
23
|
+
req_options = {
|
24
|
+
use_ssl: uri.scheme == 'https'
|
25
|
+
}
|
26
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
27
|
+
http.request(request)
|
28
|
+
end
|
29
|
+
response.code.to_i == 202
|
30
|
+
rescue StandardError => exception
|
31
|
+
exception
|
32
|
+
end
|
33
|
+
|
34
|
+
# Set Inhabitant's Provisioned Vouchers.
|
35
|
+
#
|
36
|
+
# @param expirations [Hash] the provisions object.
|
37
|
+
# @return [Boolean]
|
38
|
+
def self.voucher_provisioned(provisions)
|
39
|
+
uri = URI.parse("#{configuration.url}#{VOUCHER_PROVISIONED_PATH}")
|
40
|
+
request = Net::HTTP::Post.new(uri)
|
41
|
+
request['Apikey'] = configuration.api_key.to_s
|
42
|
+
request['Cache-Control'] = 'no-cache'
|
43
|
+
request.body = JSON.dump(
|
44
|
+
'provisions' => provisions
|
45
|
+
)
|
46
|
+
req_options = {
|
47
|
+
use_ssl: uri.scheme == 'https'
|
48
|
+
}
|
49
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
50
|
+
http.request(request)
|
51
|
+
end
|
52
|
+
response.code.to_i == 202
|
53
|
+
rescue StandardError => exception
|
54
|
+
exception
|
55
|
+
end
|
56
|
+
|
57
|
+
# Set Inhabitant's Activated Vouchers.
|
58
|
+
#
|
59
|
+
# @param expirations [Hash] the activations object.
|
60
|
+
# @return [Boolean]
|
61
|
+
def self.voucher_activated(activations)
|
62
|
+
uri = URI.parse("#{configuration.url}#{VOUCHER_ACTIVATED_PATH}")
|
63
|
+
request = Net::HTTP::Post.new(uri)
|
64
|
+
request['Apikey'] = configuration.api_key.to_s
|
65
|
+
request['Cache-Control'] = 'no-cache'
|
66
|
+
request.body = JSON.dump(
|
67
|
+
'activations' => activations
|
68
|
+
)
|
69
|
+
req_options = {
|
70
|
+
use_ssl: uri.scheme == 'https'
|
71
|
+
}
|
72
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
73
|
+
http.request(request)
|
74
|
+
end
|
75
|
+
response.code.to_i == 202
|
76
|
+
rescue StandardError => exception
|
77
|
+
exception
|
78
|
+
end
|
79
|
+
|
80
|
+
# Get configuration.
|
81
|
+
def self.configuration
|
82
|
+
@configuration = Lmb::Developers.configuration
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lmb-developers.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'lmb-developers'
|
3
|
-
s.version = '1.
|
4
|
-
s.date = '2019-01
|
3
|
+
s.version = '1.2.0'
|
4
|
+
s.date = '2019-04-01'
|
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.
|
4
|
+
version: 1.2.0
|
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-01
|
11
|
+
date: 2019-04-01 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
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/lmb/developers/auth.rb
|
26
26
|
- lib/lmb/developers/configuration.rb
|
27
27
|
- lib/lmb/developers/error.rb
|
28
|
+
- lib/lmb/developers/loyalty.rb
|
28
29
|
- lmb-developers.gemspec
|
29
30
|
homepage: https://github.com/somosprte/lmb-developers
|
30
31
|
licenses:
|
@@ -45,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
46
|
- !ruby/object:Gem::Version
|
46
47
|
version: '0'
|
47
48
|
requirements: []
|
48
|
-
|
49
|
-
rubygems_version: 2.7.8
|
49
|
+
rubygems_version: 3.0.2
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Consume APIs at Leroy Merlin Brazil Developer's Portal
|