braspag-rest 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -1
- data/lib/braspag-rest/configuration.rb +1 -3
- data/lib/braspag-rest/request.rb +1 -1
- data/lib/braspag-rest/version.rb +1 -1
- data/lib/braspag-rest.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62b25a333c0bdec698188695c3228d65232f54a8
|
4
|
+
data.tar.gz: af4d8fa509a8275d8646dcaf6d4bcb6c7ab91d9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9e14942adec9f0ede0064495f0864509013ecbc050b378f343727d4eaca6ba749b72899ea2f1fbda17056f3d5b56286ea259af255a5f8e96af50dce62829de1
|
7
|
+
data.tar.gz: a0a5ee325313e7c0b2aaca7b26a8ddfffa78f574f4595d046c137bbeaf207925fd46b56b0f3041926c36db6a7ab323fd9776be2bab6e7831ab6e692bc3fc9258
|
data/README.md
CHANGED
@@ -22,6 +22,50 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
### Configuration
|
26
|
+
|
27
|
+
The gem looks for a default `config/braspag-rest.yml` configuration file, with
|
28
|
+
environment (`RACK_ENV` or `RAILS_ENV`) settings for the Braspag API.
|
29
|
+
|
30
|
+
```yml
|
31
|
+
# config/braspag-rest.yml
|
32
|
+
development:
|
33
|
+
url: 'https://apisandbox.braspag.com.br'
|
34
|
+
query_url: 'https://apiquerysandbox.braspag.com.br'
|
35
|
+
merchant_id: 'Your MerchantId here'
|
36
|
+
merchant_key: 'Your MerchantKey here'
|
37
|
+
```
|
38
|
+
|
39
|
+
If you want to use a different file or manually set which environment should be
|
40
|
+
used, you can create an initializer file and use the `BraspagRest.config` method
|
41
|
+
to set your config.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# config/initializers/braspag-rest.rb
|
45
|
+
BraspagRest.config do |config|
|
46
|
+
config.config_file_path = 'config/path/here.yml'
|
47
|
+
config.enviroment = 'production'
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
You can use ERB blocks to interpolate values from your environment variables into
|
52
|
+
the configuration if you are using something like [dotenv](https://github.com/bkeepers/dotenv)
|
53
|
+
to handle configuration values that shouldn't be present in the source code.
|
54
|
+
|
55
|
+
```yml
|
56
|
+
# config/braspag-rest.yml
|
57
|
+
development:
|
58
|
+
url: 'https://apisandbox.braspag.com.br'
|
59
|
+
query_url: 'https://apiquerysandbox.braspag.com.br'
|
60
|
+
merchant_id: 'Your MerchantId here'
|
61
|
+
merchant_key: 'Your MerchantKey here'
|
62
|
+
production:
|
63
|
+
url: <%= ENV['BRASPAG_URL'] %>
|
64
|
+
query_url: <%= ENV['BRASPAG_QUERY_URL'] %>
|
65
|
+
merchant_id: <%= ENV['BRASPAG_MERCHANT_ID'] %>
|
66
|
+
merchant_key: <%= ENV['BRASPAG_MERCHANT_KEY'] %>
|
67
|
+
```
|
68
|
+
|
25
69
|
### Authorize an order
|
26
70
|
|
27
71
|
```rb
|
@@ -97,4 +141,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Dinda-
|
|
97
141
|
## License
|
98
142
|
|
99
143
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
100
|
-
|
@@ -3,8 +3,6 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module BraspagRest
|
5
5
|
class Configuration
|
6
|
-
include Singleton
|
7
|
-
|
8
6
|
attr_accessor :environment, :logger, :config_file_path
|
9
7
|
|
10
8
|
def config_file_path
|
@@ -38,7 +36,7 @@ module BraspagRest
|
|
38
36
|
private
|
39
37
|
|
40
38
|
def config
|
41
|
-
@config ||= YAML.load(File.read(config_file_path))[environment]
|
39
|
+
@config ||= YAML.load(ERB.new(File.read(config_file_path)).result)[environment]
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
data/lib/braspag-rest/request.rb
CHANGED
data/lib/braspag-rest/version.rb
CHANGED
data/lib/braspag-rest.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braspag-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinda Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|