aga-money 0.0.2 → 0.0.4

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: 2ffcf6cd9a1fe3b6f4fe4ddbadd06dde77ea4ab32b1e3f1239dad736c4d88a60
4
+ data.tar.gz: cfb43bd3975d8899c32f02a99e8f4d5ba2fcdf638cae896304854717874ee454
5
5
  SHA512:
6
- metadata.gz: ba0590138088e6ffb0af19aee7eb08f340f94a6f9f35eea0f3ebfc6d15d98a454467d857e4a2d15a059d293f55feab38279e9ebd8fef358502a3a920618dad15
7
- data.tar.gz: b12b563691cb0e01e0a1d6975f9aa8e4b04b45c03af8ac7962001b2861a9b942d1b5800c19e9cae49843dba4c0c9ce6ef8b411da09b56efff116aebb351a09b9
6
+ metadata.gz: 492b8b649c0b69eb2e7bd504eb8ae09bc680b331a0caaf8a9f4be4fc3f962a4f59d38aa1a128f71069a75d77854185f57d617bdfe0405d1fbfc64f12876b78de
7
+ data.tar.gz: '08e44da44aaf9209ac9ea57b8d0c7caa296b9685a4c8ce8d6b3002d4bea762e0749a7cf54dcdcb41e3a9ae84fc79eaccb4058b90e901d57d2dc080fa91affa7d'
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,7 +28,10 @@ module Money
26
28
  price = detection.dig(:payload, :price)
27
29
  return {} if price.nil?
28
30
 
29
- percentage(detection).round(3) >= computation_percentage(price).round(3)
31
+ percentage = percentage(detection).round(3)
32
+ return {} if percentage < SET_PERC
33
+
34
+ percentage >= computation_percentage(price).round(3)
30
35
  end
31
36
 
32
37
  # rubocop: disable Lint/MissingCopEnableDirective
@@ -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.4'
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.4
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.4
266
267
  test_files: []