neon_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/bin/console +17 -0
- data/bin/setup +8 -0
- data/lib/neon_api/client.rb +123 -0
- data/lib/neon_api/configuration.rb +25 -0
- data/lib/neon_api/methods/balance.rb +15 -0
- data/lib/neon_api/methods/cancel_payment.rb +16 -0
- data/lib/neon_api/methods/confirm_payment.rb +16 -0
- data/lib/neon_api/methods/create_payer.rb +26 -0
- data/lib/neon_api/methods/create_sub_account.rb +17 -0
- data/lib/neon_api/methods/generate_payment_slip_to_payer.rb +21 -0
- data/lib/neon_api/methods/get_account_types.rb +15 -0
- data/lib/neon_api/methods/get_accounts.rb +14 -0
- data/lib/neon_api/methods/get_banks.rb +15 -0
- data/lib/neon_api/methods/get_finality.rb +15 -0
- data/lib/neon_api/methods/get_payers.rb +16 -0
- data/lib/neon_api/methods/get_payment.rb +16 -0
- data/lib/neon_api/methods/get_payment_slip_by_payer.rb +16 -0
- data/lib/neon_api/methods/get_payment_slip_by_sub_account.rb +16 -0
- data/lib/neon_api/methods/get_statement.rb +1 -0
- data/lib/neon_api/methods/send_payment.rb +26 -0
- data/lib/neon_api/methods/send_transfer.rb +28 -0
- data/lib/neon_api/methods.rb +15 -0
- data/lib/neon_api/version.rb +3 -0
- data/lib/neon_api.rb +8 -0
- data/neon_api.gemspec +37 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b0db4399b55143865d40a660a84a5fd5eb91f2f
|
4
|
+
data.tar.gz: d8a4289b2ea315e6a57709d64f8095c430699ec2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 57d95a962da39fa56cea7f769f101c12e9e668d6db3045718239461bdea0a2787d75c5f0e1ee6fbf75c907d4628b0ae7faa1abab43d7b335cbd1f27dcd53b209
|
7
|
+
data.tar.gz: 07d38ab502d8ba5dd0fa0f49695b517d1df02850196af3d9402b34d9bd7af01168462d69c4797ad32e735fe26178b1fbce2bbea2dfb95ace453dfe00056da282
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ghamdan.eng@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Gabriel Hamdan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# NeonApi
|
2
|
+
|
3
|
+
Gem used to integrate any rails system to Bank NeonApi
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'neon_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install neon_api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Initialize the system on its own initializer file:
|
24
|
+
|
25
|
+
config/initializer/neon_api.rb
|
26
|
+
```ruby
|
27
|
+
NeonApi.configure do |config|
|
28
|
+
config.token = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
|
29
|
+
config.username = 'user@name.com'
|
30
|
+
config.password = 'password'
|
31
|
+
config.encrypt_pem = 'public_encrypt.pem' #your encryption pem
|
32
|
+
config.decrypt_pem = 'public_decrypt.pem' #your decryption pem
|
33
|
+
config.environment = :development #environment :development of :production
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
Use the bank methods in order to create or manage your transactions:
|
38
|
+
|
39
|
+
Get Balance:
|
40
|
+
```ruby
|
41
|
+
NeonApi::Balance.get_balance
|
42
|
+
```
|
43
|
+
|
44
|
+
Create Payer:
|
45
|
+
```ruby
|
46
|
+
NeonApi::CreatePayer.create(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
47
|
+
```
|
48
|
+
|
49
|
+
CancelPayment:
|
50
|
+
```ruby
|
51
|
+
NeonApi::CancelPayment.create(list_uniq_id)
|
52
|
+
```
|
53
|
+
|
54
|
+
ConfirmPayment
|
55
|
+
```ruby
|
56
|
+
NeonApi::ConfirmPayment.create(list_uniq_id)
|
57
|
+
```
|
58
|
+
|
59
|
+
Generate Payment Slip
|
60
|
+
```ruby
|
61
|
+
GeneratePaymentSlipToPayer.create(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
62
|
+
```
|
63
|
+
More methods (and their arguments) can be found on methods folder
|
64
|
+
|
65
|
+
## Development
|
66
|
+
|
67
|
+
I made this for myself, in a hurry. It works but it's not tested or well documented. Sorry for that.
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
BUUUUUT... You can help!!!!
|
71
|
+
Help me to test and document it. It's good for everybody. (please rspec)
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Hamdan85/neon_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
|
+
|
79
|
+
## Code of Conduct
|
80
|
+
|
81
|
+
Everyone interacting in the NeonApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/neon_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "neon_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
require "pry"
|
15
|
+
require "dotenv/load"
|
16
|
+
IRB.start(__FILE__)
|
17
|
+
#Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
module NeonApi
|
2
|
+
require "rest-client"
|
3
|
+
require "openssl"
|
4
|
+
require "aes"
|
5
|
+
require "base64"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
class Client
|
9
|
+
attr_accessor :url, :environment, :payload, :token, :last_authenticated_at, :response,
|
10
|
+
:auth_token, :aes_key, :aes_iv, :expire_time, :client_id, :bank_account, :response
|
11
|
+
def initialize(environment = :development, token, login, password, encrypt_pem, decrypt_pem)
|
12
|
+
@base_url = if production?
|
13
|
+
else
|
14
|
+
'https://servicosdev.neonhomol.com.br/servicopj/'
|
15
|
+
end
|
16
|
+
|
17
|
+
@environment = environment
|
18
|
+
@token = token
|
19
|
+
@username = login
|
20
|
+
@password = password
|
21
|
+
@encrypt_pem = encrypt_pem
|
22
|
+
@decrypt_pem = decrypt_pem
|
23
|
+
end
|
24
|
+
|
25
|
+
def authenticate
|
26
|
+
@last_authenticated_at = Time.now
|
27
|
+
|
28
|
+
request = begin
|
29
|
+
RestClient::Request.execute(method: :post, url: "#{@base_url}/V1/Client/Authentication",
|
30
|
+
payload: { "Data": encrypted_payload(authentication: true) }, headers: auth_headers)
|
31
|
+
rescue RestClient::ExceptionWithResponse => err
|
32
|
+
err.response
|
33
|
+
end
|
34
|
+
|
35
|
+
if request.code == 200
|
36
|
+
update_auth JSON.parse(decrypt_payload(payload: JSON.parse(request.body)["Data"], authentication: true))
|
37
|
+
else
|
38
|
+
raise request
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_request(object, url)
|
43
|
+
|
44
|
+
authenticate if expire_time > Time.now
|
45
|
+
|
46
|
+
request = begin
|
47
|
+
RestClient::Request.execute(method: :post, url: @base_url + url,
|
48
|
+
payload: { "Data": encrypted_payload(payload: object) }, headers: headers)
|
49
|
+
rescue RestClient::ExceptionWithResponse => err
|
50
|
+
err.response
|
51
|
+
end
|
52
|
+
|
53
|
+
if request.code != 500
|
54
|
+
@response = JSON.parse(decrypt_payload(payload: JSON.parse(request.body)['Data']))
|
55
|
+
else
|
56
|
+
@response = request
|
57
|
+
end
|
58
|
+
|
59
|
+
return @response
|
60
|
+
end
|
61
|
+
|
62
|
+
def production?
|
63
|
+
@environment == :production
|
64
|
+
end
|
65
|
+
|
66
|
+
def auth_headers
|
67
|
+
{
|
68
|
+
"Cache-Control": "no-cache",
|
69
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
70
|
+
"Token": token
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def headers
|
75
|
+
{
|
76
|
+
"Cache-Control": "no-cache",
|
77
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
78
|
+
"Token": auth_token
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_auth(auth_answer)
|
83
|
+
@auth_token = auth_answer['DataReturn']['Token']
|
84
|
+
@aes_key = auth_answer['DataReturn']['AESKey']
|
85
|
+
@aes_iv = auth_answer['DataReturn']['AESIV']
|
86
|
+
@expire_time = Time.at(auth_answer['DataReturn']['DataExpiracao'].gsub(/[^\d]/, '').to_i)
|
87
|
+
@client_id = auth_answer['DataReturn']['ClientId']
|
88
|
+
@bank_account = auth_answer['DataReturn']['BankAccountId']
|
89
|
+
end
|
90
|
+
|
91
|
+
def encrypted_payload(payload: self.payload, authentication: false)
|
92
|
+
if authentication
|
93
|
+
Base64.encode64 OpenSSL::PKey::RSA.new(File.read(@encrypt_pem)).public_encrypt(payload)
|
94
|
+
else
|
95
|
+
Base64.encode64(aes_cipher(:encrypt, payload))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def decrypt_payload(payload:, authentication: false)
|
100
|
+
if authentication
|
101
|
+
OpenSSL::PKey::RSA.new(File.read(@decrypt_pem)).private_decrypt(Base64.decode64 payload)
|
102
|
+
else
|
103
|
+
aes_cipher(:decrypt, Base64.decode64(payload))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def aes_cipher(method, payload)
|
108
|
+
cipher = OpenSSL::Cipher::AES.new(256, :CBC)
|
109
|
+
cipher.send(method)
|
110
|
+
cipher.key = aes_key.map { |u| u.chr }.join
|
111
|
+
cipher.iv = aes_iv.map { |u| u.chr }.join
|
112
|
+
(cipher.update(payload) + cipher.final).force_encoding('UTF-8')
|
113
|
+
end
|
114
|
+
|
115
|
+
def payload
|
116
|
+
{
|
117
|
+
"Username": @username,
|
118
|
+
"Password": @password,
|
119
|
+
"RequestDate": Time.now.strftime('%Y-%m-%dT%H:%M:%S')
|
120
|
+
}.to_json
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module NeonApi
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
self.configuration ||= Configuration.new
|
8
|
+
yield(configuration)
|
9
|
+
self.configuration.client_setup
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.client
|
13
|
+
self.configuration.client
|
14
|
+
end
|
15
|
+
|
16
|
+
# Configuration
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :environment, :token, :client, :username, :password, :encrypt_pem, :decrypt_pem
|
19
|
+
|
20
|
+
def client_setup
|
21
|
+
@client ||= Client.new(environment, token, username, password, encrypt_pem, decrypt_pem)
|
22
|
+
@client.authenticate
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module CancelPayment
|
3
|
+
URL = 'V1/PaymentSlip/CancelPayment'
|
4
|
+
def self.create(list_uniq_id)
|
5
|
+
NeonApi.client.send_request(payload(list_uniq_id), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(list_uniq_id)
|
9
|
+
{
|
10
|
+
"ClientID": NeonApi.client.client_id,
|
11
|
+
"ListUniqueId": list_uniq_id
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module ConfirmPayment
|
3
|
+
URL = 'V1/PaymentSlip/ConfirmPayment'
|
4
|
+
def self.create(list_uniq_id)
|
5
|
+
NeonApi.client.send_request(payload(list_uniq_id), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(list_uniq_id)
|
9
|
+
{
|
10
|
+
"ClientID": NeonApi.client.client_id,
|
11
|
+
"ListUniqueId": list_uniq_id
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module CreatePayer
|
3
|
+
URL = 'V1/Payer/CreatePayersBySubAccount'
|
4
|
+
def self.create(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
5
|
+
NeonApi.client.send_request(payload(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
9
|
+
{
|
10
|
+
"BankAccountId": bank_acc_id,
|
11
|
+
"Name": name,
|
12
|
+
"CPF": cpf,
|
13
|
+
"Email": email,
|
14
|
+
"ClientID": NeonApi.client.client_id,
|
15
|
+
"Address": address,
|
16
|
+
"Number": number,
|
17
|
+
"Complement": complement,
|
18
|
+
"PostalCode": zipcode,
|
19
|
+
"City": city,
|
20
|
+
"State": state,
|
21
|
+
"Country": country
|
22
|
+
}.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module CreateSubAccount
|
3
|
+
URL = 'V1/SubAccount/CreateSubAccount'
|
4
|
+
def self.create(name, percentage, main_percentage)
|
5
|
+
NeonApi.client.send_request(payload(name, percentage, main_percentage), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(name, percentage, main_percentage)
|
9
|
+
{
|
10
|
+
"ClientID": NeonApi.client.client_id,
|
11
|
+
"SubAccountName": name,
|
12
|
+
"PercentageRedemption": percentage,
|
13
|
+
"PercentageRedemptionMain": main_percentage
|
14
|
+
}.to_json
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module GeneratePaymentSlipToPayer
|
3
|
+
URL = 'V1/PaymentSlip/GeneratePaymentSlipToPayer'
|
4
|
+
def self.create(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
5
|
+
NeonApi.client.send_request(payload(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(bank_account, payer_id, cpf, due_date, value, instructions = [])
|
9
|
+
{
|
10
|
+
"ClientId": NeonApi.client.client_id,
|
11
|
+
"BankAccountId": bank_account,
|
12
|
+
"PayerId": payer_id,
|
13
|
+
"CPF": cpf,
|
14
|
+
"DueDate": due_date,
|
15
|
+
"Value": value,
|
16
|
+
"Instructions": instructions
|
17
|
+
}.to_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module GetPayers
|
3
|
+
URL = 'V1/Payer/GetPayersBySubAccount'
|
4
|
+
def self.create(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
5
|
+
NeonApi.client.send_request(payload(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(bank_acc_id, name, cpf, email, address, number, complement, zipcode, city, state, country)
|
9
|
+
{
|
10
|
+
"BankAccountId": bank_acc_id,
|
11
|
+
"ClientID": NeonApi.client.client_id,
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module GetPayment
|
3
|
+
URL = 'V1/PaymentSlip/GetPayment'
|
4
|
+
def self.create(uniq_id)
|
5
|
+
NeonApi.client.send_request(payload(uniq_id), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(uniq_id)
|
9
|
+
{
|
10
|
+
"ClientID": NeonApi.client.client_id,
|
11
|
+
"UniqueID": uniq_id
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module GetPaymentSlipByPayer
|
3
|
+
URL = 'V1/PaymentSlip/GetPaymentSlipByPayer'
|
4
|
+
def self.create(payer_id)
|
5
|
+
NeonApi.client.send_request(payload(payer_id), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(payer_id)
|
9
|
+
{
|
10
|
+
"PayerId": payer_id,
|
11
|
+
"ClientID": NeonApi.client.client_id,
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module GetPaymentSlipBySubAccount
|
3
|
+
URL = 'V1/PaymentSlip/GetPaymentSlipBySubAccount'
|
4
|
+
def self.create(payer_id, bank_account_id)
|
5
|
+
NeonApi.client.send_request(payload(payer_id, bank_account_id), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(payer_id, bank_account_id)
|
9
|
+
{
|
10
|
+
"PayerId": payer_id,
|
11
|
+
"BankAccountId": bank_account_id
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# TODO: 'Do Get Statement'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module SendPayment
|
3
|
+
URL = 'V1/PaymentSlip/SendPayment'
|
4
|
+
def self.create(description, bar_code, due_date, value, discount, tx)
|
5
|
+
NeonApi.client.send_request(payload(description, bar_code, due_date, value, discount, tx), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(description, bar_code, due_date, value, discount, tx)
|
9
|
+
{
|
10
|
+
"ClientId": NeonApi.client.client_id,
|
11
|
+
"Payments": [
|
12
|
+
{
|
13
|
+
"description": description,
|
14
|
+
"BarCodeNumber": bar_code,
|
15
|
+
"DueDate": due_date,
|
16
|
+
"Assignor": "Cedente",
|
17
|
+
"Value": value,
|
18
|
+
"Discount": discount,
|
19
|
+
"TaxValue": tx
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module NeonApi
|
2
|
+
module SendTransfer
|
3
|
+
URL = 'V1/Transfer/SendTransfer'
|
4
|
+
def self.create(bank_account_id, finality_id, description, credit_to_bank, account_type, branch, bank_account_number, name, document, value, scheduled_to)
|
5
|
+
NeonApi.client.send_request(payload(bank_account_id, finality_id, description, credit_to_bank, account_type, branch, bank_account_number, name, document, value, scheduled_to), URL)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.payload(bank_account_id, finality_id, description, credit_to_bank, account_type = "CC", branch = "1", bank_account_number, name, document, value, scheduled_to)
|
9
|
+
{
|
10
|
+
"BankAccountId": bank_account_id,
|
11
|
+
"FinalityId": finality_id,
|
12
|
+
"Description": description,
|
13
|
+
"CreditTo": {
|
14
|
+
"CodBank": credit_to_bank,
|
15
|
+
"AccountyType": account_type,
|
16
|
+
"Branch": branch,
|
17
|
+
"BankAccountNumber": bank_account_number,
|
18
|
+
"Name": name,
|
19
|
+
"Document": document,
|
20
|
+
"Value": value,
|
21
|
+
"SchedulingDate": scheduled_to
|
22
|
+
},
|
23
|
+
"ClientID": NeonApi.client.client_id
|
24
|
+
}.to_json
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "neon_api/methods/balance"
|
2
|
+
require "neon_api/methods/cancel_payment"
|
3
|
+
require "neon_api/methods/confirm_payment"
|
4
|
+
require "neon_api/methods/create_payer"
|
5
|
+
require "neon_api/methods/create_sub_account"
|
6
|
+
require "neon_api/methods/generate_payment_slip_to_payer"
|
7
|
+
require "neon_api/methods/get_accounts"
|
8
|
+
require "neon_api/methods/get_banks"
|
9
|
+
require "neon_api/methods/get_finality"
|
10
|
+
require "neon_api/methods/get_payers"
|
11
|
+
require "neon_api/methods/get_payment_slip_by_payer"
|
12
|
+
require "neon_api/methods/get_payment_slip_by_sub_account"
|
13
|
+
require "neon_api/methods/get_statement"
|
14
|
+
require "neon_api/methods/send_payment"
|
15
|
+
require "neon_api/methods/send_transfer"
|
data/lib/neon_api.rb
ADDED
data/neon_api.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "neon_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "neon_api"
|
8
|
+
spec.version = NeonApi::VERSION
|
9
|
+
spec.authors = ["Gabriel Hamdan"]
|
10
|
+
spec.email = ["ghamdan.eng@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gem to integrate with Bank Neon's API}
|
13
|
+
spec.description = %q{Gem to integrate with Bank Neon's API and its encrypted authentication process}
|
14
|
+
spec.homepage = "https://github.com/Hamdan85/neon_api"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "openssl", "~> 2.0"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neon_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Hamdan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: openssl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
description: Gem to integrate with Bank Neon's API and its encrypted authentication
|
70
|
+
process
|
71
|
+
email:
|
72
|
+
- ghamdan.eng@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/neon_api.rb
|
88
|
+
- lib/neon_api/client.rb
|
89
|
+
- lib/neon_api/configuration.rb
|
90
|
+
- lib/neon_api/methods.rb
|
91
|
+
- lib/neon_api/methods/balance.rb
|
92
|
+
- lib/neon_api/methods/cancel_payment.rb
|
93
|
+
- lib/neon_api/methods/confirm_payment.rb
|
94
|
+
- lib/neon_api/methods/create_payer.rb
|
95
|
+
- lib/neon_api/methods/create_sub_account.rb
|
96
|
+
- lib/neon_api/methods/generate_payment_slip_to_payer.rb
|
97
|
+
- lib/neon_api/methods/get_account_types.rb
|
98
|
+
- lib/neon_api/methods/get_accounts.rb
|
99
|
+
- lib/neon_api/methods/get_banks.rb
|
100
|
+
- lib/neon_api/methods/get_finality.rb
|
101
|
+
- lib/neon_api/methods/get_payers.rb
|
102
|
+
- lib/neon_api/methods/get_payment.rb
|
103
|
+
- lib/neon_api/methods/get_payment_slip_by_payer.rb
|
104
|
+
- lib/neon_api/methods/get_payment_slip_by_sub_account.rb
|
105
|
+
- lib/neon_api/methods/get_statement.rb
|
106
|
+
- lib/neon_api/methods/send_payment.rb
|
107
|
+
- lib/neon_api/methods/send_transfer.rb
|
108
|
+
- lib/neon_api/version.rb
|
109
|
+
- neon_api.gemspec
|
110
|
+
homepage: https://github.com/Hamdan85/neon_api
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.6.13
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Gem to integrate with Bank Neon's API
|
134
|
+
test_files: []
|