aga-money 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: adb2de788b6d5aaff7c6b9f816aa85f061352a6a90c771b193c72be96a7b1811
4
- data.tar.gz: f06107519ddf0d7a37e094ad05303df0694c1935d655a734ccde8c4753b90dd6
3
+ metadata.gz: fb930bdcaebb946f5c5f841103ca4ce0ee1748872ba8ea89793cfe41099fdb17
4
+ data.tar.gz: ff712f49838f5fd642c7e5d6148f1b0af121df9ab2bd22f3a2b2be2a95afd762
5
5
  SHA512:
6
- metadata.gz: ba0590138088e6ffb0af19aee7eb08f340f94a6f9f35eea0f3ebfc6d15d98a454467d857e4a2d15a059d293f55feab38279e9ebd8fef358502a3a920618dad15
7
- data.tar.gz: b12b563691cb0e01e0a1d6975f9aa8e4b04b45c03af8ac7962001b2861a9b942d1b5800c19e9cae49843dba4c0c9ce6ef8b411da09b56efff116aebb351a09b9
6
+ metadata.gz: 01606bcb91ba2f5f17fef8a33dbd0ac71e7a0e839504a440798f6579aed744f4dfba3ce3405b856678e82a031d90ae8fc6b12652943d9f861f01aadb7d8bba5a
7
+ data.tar.gz: 0d1cd32b61a213d202198afeb721fd411a85dc516ceb77ba677b552bff22dbca02ffbb4ec7d339f5f1ad78d5ea04c5d0941e1b4bccb8ac1deb253abc746d3dc7
data/lib/money/base.rb CHANGED
@@ -3,9 +3,10 @@
3
3
  module Money
4
4
  class Base
5
5
  class << self
6
- attr_accessor :app_info
6
+ attr_accessor :app_info, :path_prefix
7
7
  end
8
8
 
9
9
  self.app_info = ::ENV['APP_INFO'] || "#{::Money::NAME} V#{::Money.version}"
10
+ self.path_prefix = 'http://localhost:3000/api/v1/'
10
11
  end
11
12
  end
@@ -36,7 +36,9 @@ module Money
36
36
 
37
37
  liquidity = validator(pairs).liquidity
38
38
 
39
- validator(liquidity).gain
39
+ gain = validator(liquidity).gain
40
+
41
+ validator(gain).exist
40
42
  end
41
43
 
42
44
  def response(data)
@@ -10,6 +10,8 @@ module Money
10
10
  MIN_NUMBER = 0.0000000001
11
11
  MAX_PERC = 0.1
12
12
 
13
+ SET_PERC = 1.0
14
+
13
15
  def initialize(pairs)
14
16
  @pairs = pairs
15
17
  end
@@ -26,6 +28,8 @@ module Money
26
28
  price = detection.dig(:payload, :price)
27
29
  return {} if price.nil?
28
30
 
31
+ return {} if percentage(detection).round(3) < SET_PERC
32
+
29
33
  percentage(detection).round(3) >= computation_percentage(price).round(3)
30
34
  end
31
35
 
@@ -42,6 +42,18 @@ module Money
42
42
  end
43
43
  end
44
44
 
45
+ def exist
46
+ cryptos = []
47
+ @data&.map do |item|
48
+ request = Money::Helpers::RequestApp.new.operation_exist(item)
49
+ next if request[:response]['exist'] == true
50
+
51
+ cryptos << item
52
+ end&.compact
53
+
54
+ cryptos
55
+ end
56
+
45
57
  def pairs
46
58
  @data&.map do |item|
47
59
  filtered = item[:exchanges].select { |cmc_item| EXCHANGES.include?(cmc_item[:exchange]) }
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'json'
5
+ require 'net/http'
6
+
7
+ module Money
8
+ module Helpers
9
+ class RequestApp
10
+ def operation_exist(payload)
11
+ url = build_url('operations/exist')
12
+ builder_request(url: url, payload: payload)
13
+ end
14
+
15
+ private
16
+
17
+ def build_url(path, params = {})
18
+ URI.parse("#{Money::Base.path_prefix}#{path}")
19
+ end
20
+
21
+ def builder_request(url:, payload:)
22
+ http = Net::HTTP.new(url.host, url.port)
23
+ request = Net::HTTP::Get.new(url)
24
+ request['Authorization'] = 'Bearer 5c16c565fbd9f128063019f2828be964'
25
+ request['Content-Type'] = 'application/json'
26
+ request.body = JSON.dump(payload)
27
+
28
+ response = http.request(request)
29
+ { response: JSON.parse(response.body), status: response.code.to_i == 200 }
30
+ end
31
+
32
+ end
33
+ end
34
+ end
data/lib/money/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Money
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/money.rb CHANGED
@@ -21,6 +21,10 @@ module Money
21
21
  TZInfo::Timezone.get(value)
22
22
  end
23
23
 
24
+ def path_prefix=(value)
25
+ ::Money::Base.path_prefix = value
26
+ end
27
+
24
28
  def ping
25
29
  { status: 200 }
26
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aga-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Baldazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-09 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -237,6 +237,7 @@ files:
237
237
  - lib/money/resources/helpers/controls/validator.rb
238
238
  - lib/money/resources/helpers/format.rb
239
239
  - lib/money/resources/helpers/http_request.rb
240
+ - lib/money/resources/helpers/request_app.rb
240
241
  - lib/money/resources/new.rb
241
242
  - lib/money/resources/top.rb
242
243
  - lib/money/version.rb
@@ -262,5 +263,5 @@ requirements: []
262
263
  rubygems_version: 3.3.24
263
264
  signing_key:
264
265
  specification_version: 4
265
- summary: aga-money0.0.2
266
+ summary: aga-money0.0.3
266
267
  test_files: []