Sha256: 08d8d000600eb52e58858191d3ff56ecf120a4b1df233e7c761abded50eb0228

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

module Fortenet
  class Client < Fortenet::Request

    def initialize(account_id = Fortenet.account_id, location_id = Fortenet.location_id, attrs = {})
      @location_id = location_id
      @account_id = account_id
    end

    def base_path
      "/organizations/org_#{@account_id}/locations/loc_#{@location_id}/"
    end

    def find(relative_path, data = nil)
      self.get(base_path+relative_path, query: data)
    end

    def create(relative_path, data = nil)
      self.post(base_path+relative_path, body: data_to_json(data))
    end

    def update(relative_path, data = nil)
      self.put(base_path+relative_path, body: data_to_json(data))
    end

    def destroy(relative_path)
      self.delete(base_path+relative_path)
    end

    private

    def data_to_json(data)
      data.is_a?(Hash) ? data.to_json : data
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fortenet-3.0.2 lib/fortenet/client.rb
fortenet-3.0.1 lib/fortenet/client.rb