Module: Luno::OtherData
- Included in:
- Client
- Defined in:
- lib/luno/other_data.rb
Constant Summary collapse
- COUNTRY_ENDPOINT =
'https://www.luno.com/en/countries'
- DOCUMENTATION_ENDPOINT =
'https://www.luno.com/en/developers/api'
Instance Method Summary collapse
- #changelog ⇒ Object
-
#countries ⇒ Object
TODO.
-
#currencies ⇒ Object
From API Documentation [WIP].
-
#permissions ⇒ Object
TODO.
- #ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/', 'https://api.luno.com/api/1']) ⇒ Object
Instance Method Details
#changelog ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/luno/other_data.rb', line 64 def changelog lines = [] response = call_api_documentation parse_html(response['body']) .at('div#tag\/Changelog') .search('li') .map(&:text) .map { |text| text.split.join(" ") } .map { |text| if (text[10] != ':' || unable_to_parse_time(text[0,10])) # ':' is at character 10 lines[-1] = "#{lines[-1]}\n#{text}" else lines << text end } output = {} lines.each do |line| tuple = line.split(':') text = tuple[1, lines.size].join(':') key = tuple[0] output.merge!(key => text) end { 'body' => output, 'headers' => response['headers'], 'metadata' => response['metadata'] } end |
#countries ⇒ Object
TODO
35 36 37 |
# File 'lib/luno/other_data.rb', line 35 def countries response = call_countries end |
#currencies ⇒ Object
From API Documentation
- WIP
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/luno/other_data.rb', line 41 def currencies lines = [] response = call_api_documentation output = parse_html(response['body']) .at('div#tag\/Currency') .search('li') .map(&:text) .map { |text| text.split.join(" ") } { 'body' => output, 'headers' => response['headers'], 'metadata' => response['metadata'] } end |
#permissions ⇒ Object
TODO
60 61 62 |
# File 'lib/luno/other_data.rb', line 60 def response = call_api_documentation end |
#ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/', 'https://api.luno.com/api/1']) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/luno/other_data.rb', line 9 def ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/', 'https://api.luno.com/api/1']) endpoint_metrics = paths.map do |path| responses = [] limit.times do responses << (http_method: :get, path: path) end avg_time = responses .map { |r| r.dig('metadata')&.dig('total_time') } .reduce(&:+) / limit { 'path' => path, 'average_time' => avg_time } end { 'metadata' => { 'endpoint_metrics' => endpoint_metrics } } end |