paghiper 0.1.1 → 0.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 +10 -1
- data/lib/paghiper.rb +1 -1
- data/lib/paghiper/client.rb +19 -4
- data/lib/paghiper/transaction.rb +7 -2
- data/lib/paghiper/version.rb +1 -1
- data/lib/rails/generators/templates/paghiper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da31a11dc2e22c997d659b2b42382d96336780f4f60baf100a3d41674106e98d
|
4
|
+
data.tar.gz: fcfeabd0edbfeaa7fa1c29c3c87d99ccb802e76d75841fa897d69019e3291df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2059c9c598ecaf786e322ca4f2741598e583e86d971a9828bb13c7cf0134ffb8c8858044dcb67457bd2ef092a535195c5b37b8823ae2f5f864e181caefc6bc74
|
7
|
+
data.tar.gz: 92e0279075df87c91876d2e9e6aae08acba21a47c0f7faf314d61908e76f784128b2ef8ca286c3de1eb47ed94db1bee913ea4e2d7a6f3b9c3ffe894aca005f35
|
data/README.md
CHANGED
@@ -36,6 +36,7 @@ Configure your client settings
|
|
36
36
|
```ruby
|
37
37
|
Paghiper.configure do |config|
|
38
38
|
config.api_key = 'apk_99999999-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
39
|
+
config.token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
39
40
|
config.http_debug = true
|
40
41
|
end
|
41
42
|
```
|
@@ -48,7 +49,15 @@ end
|
|
48
49
|
Paghiper::Transaction.create(transaction_data)
|
49
50
|
```
|
50
51
|
|
51
|
-
Check [API
|
52
|
+
Check the [API documentation](https://dev.paghiper.com/reference#gerar-boleto) for more information regarding this endpoint.
|
53
|
+
|
54
|
+
### Responding to boletos webhook (Automatic status notification)
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Paghiper::Transaction.notification(notification_data)
|
58
|
+
```
|
59
|
+
|
60
|
+
Check the [API documentation](https://dev.paghiper.com/reference#qq) for the detailed notification flow.
|
52
61
|
|
53
62
|
## Development
|
54
63
|
|
data/lib/paghiper.rb
CHANGED
data/lib/paghiper/client.rb
CHANGED
@@ -2,6 +2,7 @@ require 'httparty'
|
|
2
2
|
|
3
3
|
module Paghiper
|
4
4
|
class MissingApiKeyError < StandardError; end
|
5
|
+
class MissingTokenError < StandardError; end
|
5
6
|
|
6
7
|
class Client
|
7
8
|
include HTTParty
|
@@ -11,20 +12,34 @@ module Paghiper
|
|
11
12
|
debug_output $stdout if Paghiper.configuration && Paghiper.configuration.http_debug
|
12
13
|
|
13
14
|
class << self
|
14
|
-
def create_transaction(
|
15
|
-
peform_action!(:post, '/transaction/create', body: prepare_body(
|
15
|
+
def create_transaction(data)
|
16
|
+
peform_action!(:post, '/transaction/create', body: prepare_body(data))
|
17
|
+
end
|
18
|
+
|
19
|
+
def transaction_notification(data)
|
20
|
+
raise(MissingTokenError, 'Informe o token para realizar essa operação') if missing_configuration_parameter?(:token)
|
21
|
+
|
22
|
+
peform_action!(:post, '/transaction/notification', body: data.merge(token: Paghiper.configuration.token).to_json)
|
16
23
|
end
|
17
24
|
|
18
25
|
private
|
19
26
|
|
27
|
+
def missing_configuration_parameter?(parameter)
|
28
|
+
return Paghiper.configuration.nil? || Paghiper.configuration.send(parameter).nil? || Paghiper.configuration.send(parameter).empty?
|
29
|
+
end
|
30
|
+
|
20
31
|
def prepare_body(data)
|
21
32
|
data.merge(apiKey: Paghiper.configuration.api_key).to_json
|
22
33
|
end
|
23
34
|
|
24
35
|
def peform_action!(action_name, url, options = {})
|
25
|
-
raise(
|
36
|
+
raise(MissingApiKeyError, 'Informe a api key para realizar a autenticação') if missing_configuration_parameter?(:api_key)
|
37
|
+
|
38
|
+
parse_response(send(action_name, url, options))
|
39
|
+
end
|
26
40
|
|
27
|
-
|
41
|
+
def parse_response(response)
|
42
|
+
JSON.parse(response.body).with_indifferent_access
|
28
43
|
end
|
29
44
|
end
|
30
45
|
end
|
data/lib/paghiper/transaction.rb
CHANGED
@@ -3,9 +3,14 @@ module Paghiper
|
|
3
3
|
class << self
|
4
4
|
def create(transaction)
|
5
5
|
response = Paghiper::Client.create_transaction(transaction)
|
6
|
-
hash = JSON.parse(response.body).with_indifferent_access
|
7
6
|
|
8
|
-
return
|
7
|
+
return response['create_request']
|
8
|
+
end
|
9
|
+
|
10
|
+
def notification(notification)
|
11
|
+
response = Paghiper::Client.transaction_notification(notification)
|
12
|
+
|
13
|
+
return response['status_request']
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
data/lib/paghiper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paghiper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coyô Software
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|