neon_api 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c44cfef9037b9533821395ce1db80e395f6f6b4
4
- data.tar.gz: 471549846983383c4e8c23bbb39d1d56deb64bac
3
+ metadata.gz: e3ad67af734dbf0937cbd2619b09fa7f0a9b69fd
4
+ data.tar.gz: c462a501ad976b369bacbcda3d8d69adfda6c515
5
5
  SHA512:
6
- metadata.gz: e02907d429b3f63dc97bed50cb42a32a257d057b932a5343d2713e4c1a46647a12ba0697cff9cd2fa751d0d2ad7452ba770aceceb3e4de0face65729e9bb2707
7
- data.tar.gz: 464c1068a815567c258d3862353eab65da49623750608a354545f2f15e3d430575148809fc12397ff367013df8e06bf5325fa36eeea7dc225ab2afd6e5e14cf1
6
+ metadata.gz: be704db7bed792423df83b9c651d05b9aa26e9c03f0d337a7a2ae642cf0d95ad110a222d72b7bbd09c5a3147ddf47e7d00e2a4ac95329a670e2f5e1681e14333
7
+ data.tar.gz: a9d0f8c449e8f0f9523c71c3ed258bad6dc4a962c6c73b3e4d06441e3428ad14328edf0f6cc9adfe5d46ca428e44aa80731c65f3b7cfc1947d5b488997033650
@@ -9,6 +9,8 @@ module NeonApi
9
9
  attr_accessor :url, :environment, :payload, :token, :last_authenticated_at, :response,
10
10
  :auth_token, :aes_key, :aes_iv, :expire_time, :client_id, :bank_account, :response, :base_url
11
11
 
12
+ attr_reader :time_klass
13
+
12
14
  def initialize(environment, token, login, password, encrypt_pem, decrypt_pem, proxy)
13
15
  @environment = environment
14
16
  @token = token
@@ -17,12 +19,14 @@ module NeonApi
17
19
  @encrypt_pem = encrypt_pem
18
20
  @decrypt_pem = decrypt_pem
19
21
  @proxy = proxy
22
+ @time_klass = Time.respond_to?(:zone) ? Time.zone : Time
23
+ @expire_time = time_klass.now
20
24
 
21
25
  RestClient.proxy = @proxy if @proxy
22
26
  end
23
27
 
24
28
  def authenticate
25
- @last_authenticated_at = Time.now
29
+ @last_authenticated_at = time_klass.now
26
30
 
27
31
  request = begin
28
32
  RestClient::Request.execute(method: :post, url: "#{base_url}/V1/Client/Authentication",
@@ -40,7 +44,7 @@ module NeonApi
40
44
 
41
45
  def send_request(object, url)
42
46
 
43
- authenticate if expire_time > Time.now
47
+ authenticate if time_klass.now > expire_time
44
48
 
45
49
  request = begin
46
50
  RestClient::Request.execute(method: :post, url: base_url + url,
@@ -82,7 +86,7 @@ module NeonApi
82
86
  @auth_token = auth_answer['DataReturn']['Token']
83
87
  @aes_key = auth_answer['DataReturn']['AESKey']
84
88
  @aes_iv = auth_answer['DataReturn']['AESIV']
85
- @expire_time = Time.at(auth_answer['DataReturn']['DataExpiracao'].gsub(/[^\d]/, '').to_i)
89
+ @expire_time = time_klass.at(auth_answer['DataReturn']['DataExpiracao'].gsub(/[^\d]/, '').to_i)
86
90
  @client_id = auth_answer['DataReturn']['ClientId']
87
91
  @bank_account = auth_answer['DataReturn']['BankAccountId']
88
92
  end
@@ -115,7 +119,7 @@ module NeonApi
115
119
  {
116
120
  "Username": @username,
117
121
  "Password": @password,
118
- "RequestDate": Time.now.strftime('%Y-%m-%dT%H:%M:%S')
122
+ "RequestDate": time_klass.now.strftime('%Y-%m-%dT%H:%M:%S')
119
123
  }.to_json
120
124
  end
121
125
 
@@ -19,7 +19,6 @@ module NeonApi
19
19
 
20
20
  def client_setup
21
21
  @client ||= Client.new(environment, token, username, password, encrypt_pem, decrypt_pem, proxy)
22
- @client.authenticate
23
22
  end
24
23
  end
25
- end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module NeonApi
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
36
36
  spec.add_development_dependency "openssl", "~> 2.0"
37
- spec.add_development_dependency "aes", "~> 0.5.0"
37
+ spec.add_dependency "aes", "~> 0.5.0"
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neon_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Hamdan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,7 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.5.0
76
- type: :development
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements: