Sha256: 4feeb861be2def893913b45909aa2fd7a78afb13f8069c51983b532c7d8e3dd3

Contents?: true

Size: 696 Bytes

Versions: 3

Compression:

Stored size: 696 Bytes

Contents

require 'json'

module WialonApi
  module Api
    def self.call(service_name, args = {}, sid = nil)
      parameters = { svc: service_name, params: args.to_json, ssid: sid }
      connection(url: WialonApi.wialon_host).send(WialonApi.http_verb, nil, 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

3 entries across 3 versions & 1 rubygems

Version Path
wialon_api-0.0.5 lib/wialon_api/api.rb
wialon_api-0.0.4 lib/wialon_api/api.rb
wialon_api-0.0.3 lib/wialon_api/api.rb