Module: ZionData::Client

Defined in:
lib/zion_data/client.rb

Overview

Class for communication with zion server

Constant Summary collapse

ZION_URL =
'http://challenge.distribusion.com/the_one/routes'.freeze
PASS_PHRASE =
'Kans4s-i$-g01ng-by3-bye'.freeze

Class Method Summary collapse

Class Method Details

.get_source(source) ⇒ Object



8
9
10
11
# File 'lib/zion_data/client.rb', line 8

def get_source(source)
  puts "=== Get #{source}"
  client.get(params: { source: source, passphrase: PASS_PHRASE }).body
end

.post_source_data(source, payload) ⇒ Object



13
14
15
16
17
18
# File 'lib/zion_data/client.rb', line 13

def post_source_data(source, payload)
  puts "=== Post #{source} data: #{payload}"
  data = client.post(payload.merge(source: source, passphrase: PASS_PHRASE)).body
  messages = eval(data)
  puts(messages.map { |k, v| "    #{k} -> #{v}" }) if messages.respond_to?(:map)
end