Sha256: 4071bc2a25fe1232e745b249db00916d882f2c34786f1badf1033a6b6a66f721

Contents?: true

Size: 723 Bytes

Versions: 2

Compression:

Stored size: 723 Bytes

Contents

require 'json'

module WialonApi
  module Api
    def self.call(service_name, args = {}, sid = nil)
      parameters = { svc: service_name, params: args.to_json, sid: sid }
      connection(url: WialonApi.wialon_host, sid: sid).send(WialonApi.http_verb, WialonApi.wialon_host, parameters).body
    end

    def self.connection(options = {})
      url = options.delete(:url)
      Faraday.new(url, WialonApi.faraday_options) do |builder|
        builder.request :url_encoded
        builder.request :retry, WialonApi.max_retries

        builder.response :wialon_logger
        builder.response :mashify
        builder.response :oj, preserve_raw: true

        builder.adapter WialonApi.adapter
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wialon_api-0.0.2 lib/wialon_api/api.rb
wialon_api-0.0.1 lib/wialon_api/api.rb